Open Quuxplusone opened 3 years ago
Attached ppc_bsjlj.c
(581 bytes, text/x-csrc): Repro
FWIW, it seems that the workaround code in the repro does not work any more
with Clang/LLVM version 12.0.1 or 13.0.0-rc1. With 12.0.1,
$ /usr/lib/llvm/12/bin/clang --target=powerpc64le-unknown-linux-musl -O3
ppc_bsjlj.c -DWORKAROUND=1
results in the hexdump'ed output
00000000 76 61 6c 75 65 20 3d 20 32 37 34 38 37 38 31 30 |value = 27487810|
00000010 37 38 35 36 0a f0 15 83 01 40 |7856.....@|
and with 13.0.0-rc1,
$ /usr/lib/llvm/13/bin/clang --target=powerpc64le-unknown-linux-musl -O3
ppc_bsjlj.c -DWORKAROUND=1
results in
00000000 76 61 6c 75 65 20 3d 20 32 37 34 38 37 38 31 30 |value = 27487810|
00000010 37 38 35 36 0a e0 15 83 01 40 |7856.....@|
I have no idea whether this is a separate issue or not. Note that this time
musl is used as a target, and so the generated executable becomes a PIE, which
I am not sure is relevant.
Attached bug50234-disasm.txt
(7559 bytes, text/plain): Disassembly of main (compiled with -O1)
It seems that __builtin_setjmp needs attribute returns_twice.
Proposed change: https://reviews.llvm.org/D109248
ppc_bsjlj.c
(581 bytes, text/x-csrc)bug50234-disasm.txt
(7559 bytes, text/plain)Created attachment 24831 Repro
The attached C program (named ppc_bsjlj.c) behaves incorrectly when compiled with optimization level -O1 or higher for PPC targets.
For 32-bit PPC
$ clang --target=powerpc-unknown-linux-gnu -O3 -c ppc_bsjlj.c
results in the output
value = 268566576 value = 268566596
where the two lines should be identical.
Similarly, for ppc64le
$ clang --target=powerpc64le-unknown-linux-gnu -O3 -c ppc_bsjlj.c
results in
value = 268566608 value = 268566648
Note that in the program the value of the local variable
n
is not changed between__builtin_setjmp
and the corresponding__builtin_longjmp
. Indeed it is const-qualified.