From 38dabf70b40a511a17decd36b68148a2f31c38dc Mon Sep 17 00:00:00 2001 From: Andreas Arnez Date: Fri, 29 Sep 2023 16:11:31 +0200 Subject: [PATCH] s390x regtest: Adjust op00 and op_exception tests for Clang As part of fixing Bug 465782, adjust the op00 and op_exception tests. The op00 test case doesn't compile with clang because the .hword assembler directive is not known to llvm-as. When replacing it with .short, the test case fails because clang/llvm-as generates different line number information from gcc/gas. Using gcc, Valgrind's error message locates the unrecognised instruction at 0x........: main (op00.c:3) whereas with clang, it shows: at 0x........: main (op00.c:4) The asm statement in op00.c is indeed located at line 4, so when compiling with gcc, the indicated line number is just wrong. This is because gas only updates line number information for instruction directives, not for directives like `.short' as used here. See also the discussion in https://sourceware.org/bugzilla/show_bug.cgi?id=30206 The same applies to the op_exception test case, where `.long' is used to emit illegal instructions. Make these test cases independent from this difference, by replacing the `.short' and `.long' directives by equivalent `.insn' directives. Also drop the unnecessary duplication of op00.stderr.exp. --- none/tests/s390x/Makefile.am | 2 +- none/tests/s390x/op00.c | 3 +-- .../{op00.stderr.exp1 => op00.stderr.exp} | 4 ++-- none/tests/s390x/op00.stderr.exp2 | 19 ------------------- none/tests/s390x/op_exception.c | 4 ++-- none/tests/s390x/op_exception.stderr.exp | 8 ++++---- 6 files changed, 10 insertions(+), 30 deletions(-) rename none/tests/s390x/{op00.stderr.exp1 => op00.stderr.exp} (92%) delete mode 100644 none/tests/s390x/op00.stderr.exp2 diff --git a/none/tests/s390x/Makefile.am b/none/tests/s390x/Makefile.am index 73e7b28e5d..8bbbbd1e27 100644 --- a/none/tests/s390x/Makefile.am +++ b/none/tests/s390x/Makefile.am @@ -37,7 +37,7 @@ EXTRA_DIST = \ ecag.stdout.exp-z10ec ecag.stdout.exp-z196 ecag.stdout.exp-zec12 \ ecag.stdout.exp-z13 ecag.stdout.exp-z14 ecag.stdout.exp-z15 \ ecag.stdout.exp-z16 \ - op00.stderr.exp1 op00.stderr.exp2 op00.vgtest \ + op00.stderr.exp op00.vgtest \ fixbr.vgtest fixbr.stderr.exp fixbr.stdout.exp \ fpext.vgtest fpext.stderr.exp fpext.stdout.exp \ fpext_fail.vgtest fpext_fail.stderr.exp fpext_fail.stdout.exp \ diff --git a/none/tests/s390x/op00.c b/none/tests/s390x/op00.c index ed243b0271..fd9da277b6 100644 --- a/none/tests/s390x/op00.c +++ b/none/tests/s390x/op00.c @@ -1,7 +1,6 @@ /* Test for invalid instruction 00. */ int main(int argc, char *argv[]) { - asm volatile (".hword 0\n"); + asm volatile (".insn e,0x0000"); return 0; } - diff --git a/none/tests/s390x/op00.stderr.exp1 b/none/tests/s390x/op00.stderr.exp similarity index 92% rename from none/tests/s390x/op00.stderr.exp1 rename to none/tests/s390x/op00.stderr.exp index b7552bf58a..71825f0e03 100644 --- a/none/tests/s390x/op00.stderr.exp1 +++ b/none/tests/s390x/op00.stderr.exp @@ -1,7 +1,7 @@ vex s390->IR: unknown insn: 0000 valgrind: Unrecognised instruction at address 0x......... - at 0x........: main (op00.c:3) + at 0x........: main (op00.c:4) Your program just tried to execute an instruction that Valgrind did not recognise. There are two possible reasons for this. 1. Your program has a bug and erroneously jumped to a non-code @@ -15,5 +15,5 @@ probably kill your program. Process terminating with default action of signal 4 (SIGILL) Illegal opcode at address 0x........ - at 0x........: main (op00.c:3) + at 0x........: main (op00.c:4) diff --git a/none/tests/s390x/op00.stderr.exp2 b/none/tests/s390x/op00.stderr.exp2 deleted file mode 100644 index b7552bf58a..0000000000 --- a/none/tests/s390x/op00.stderr.exp2 +++ /dev/null @@ -1,19 +0,0 @@ - -vex s390->IR: unknown insn: 0000 -valgrind: Unrecognised instruction at address 0x......... - at 0x........: main (op00.c:3) -Your program just tried to execute an instruction that Valgrind -did not recognise. There are two possible reasons for this. -1. Your program has a bug and erroneously jumped to a non-code - location. If you are running Memcheck and you just saw a - warning about a bad jump, it's probably your program's fault. -2. The instruction is legitimate but Valgrind doesn't handle it, - i.e. it's Valgrind's fault. If you think this is the case or - you are not sure, please let us know and we'll try to fix it. -Either way, Valgrind will now raise a SIGILL signal which will -probably kill your program. - -Process terminating with default action of signal 4 (SIGILL) - Illegal opcode at address 0x........ - at 0x........: main (op00.c:3) - diff --git a/none/tests/s390x/op_exception.c b/none/tests/s390x/op_exception.c index f8dcb9deb6..f4ff9b005b 100644 --- a/none/tests/s390x/op_exception.c +++ b/none/tests/s390x/op_exception.c @@ -23,14 +23,14 @@ int main() got_ill = 0; /* most architectures loop here, but on s390 this would increase the PSW by 2 and then by 2 */ - asm volatile(".long 0\n"); + asm volatile(".insn e,0x0000\n\t.insn e,0x0000"); if (got_ill) printf("0x00000000 does not loop\n"); got_ill = 0; /* most architectures loop here, but on s390 this would increase the PSW by 6 and then by 2*/ - asm volatile(".long 0xffffffff\n.long 0xffff0000\n"); + asm volatile(".insn ril,0xffffffffffff,0xf,.-2\n\t.insn e,0x0000"); if (got_ill) printf("0xffffffff does not loop\n"); return 0; diff --git a/none/tests/s390x/op_exception.stderr.exp b/none/tests/s390x/op_exception.stderr.exp index 4373ff5bb3..46dffa52c6 100644 --- a/none/tests/s390x/op_exception.stderr.exp +++ b/none/tests/s390x/op_exception.stderr.exp @@ -1,7 +1,7 @@ vex s390->IR: unknown insn: 0000 valgrind: Unrecognised instruction at address 0x......... - at 0x........: main (op_exception.c:23) + at 0x........: main (op_exception.c:26) Your program just tried to execute an instruction that Valgrind did not recognise. There are two possible reasons for this. 1. Your program has a bug and erroneously jumped to a non-code @@ -14,7 +14,7 @@ Either way, Valgrind will now raise a SIGILL signal which will probably kill your program. vex s390->IR: unknown insn: 0000 valgrind: Unrecognised instruction at address 0x......... - at 0x........: main (op_exception.c:23) + at 0x........: main (op_exception.c:26) Your program just tried to execute an instruction that Valgrind did not recognise. There are two possible reasons for this. 1. Your program has a bug and erroneously jumped to a non-code @@ -27,7 +27,7 @@ Either way, Valgrind will now raise a SIGILL signal which will probably kill your program. vex s390->IR: unknown insn: FFFF FFFF FFFF valgrind: Unrecognised instruction at address 0x......... - at 0x........: main (op_exception.c:30) + at 0x........: main (op_exception.c:33) Your program just tried to execute an instruction that Valgrind did not recognise. There are two possible reasons for this. 1. Your program has a bug and erroneously jumped to a non-code @@ -40,7 +40,7 @@ Either way, Valgrind will now raise a SIGILL signal which will probably kill your program. vex s390->IR: unknown insn: 0000 valgrind: Unrecognised instruction at address 0x......... - at 0x........: main (op_exception.c:30) + at 0x........: main (op_exception.c:33) Your program just tried to execute an instruction that Valgrind did not recognise. There are two possible reasons for this. 1. Your program has a bug and erroneously jumped to a non-code -- 2.43.5