https://bugs.llvm.org/show_bug.cgi?id=38828
Bug ID: 38828
Summary: Incorrect assembly emitted for cmpxchg IR instruction
on thumbv7m-none-eabi target
Product: new-bugs
Version: trunk
Hardware: Other
OS: other
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedb...@nondot.org
Reporter: mvirkku...@gmail.com
CC: llvm-bugs@lists.llvm.org
Created attachment 20841
--> https://bugs.llvm.org/attachment.cgi?id=20841&action=edit
C program that reproduces the problem
When compiled with:
clang -c -target thumbv7m-none-eabi -O1 compare_exchange.c
The attached C program produces invalid assembly code that attempts to load a
value from outside the function's stack frame in the first "ldrex" instruction
of the compare exchange operation. The rest of the stack access generated by
the cmpxchg seem to be correct. More weird results can be obtained by
adding/removing "int"s before the atomic one. I've also attached the generated
assembly and IR code from my machine.
The problem seems to be on the assembly generation level and not in clang
itself (I ran into this while using Rust). The example program uses intrinsics
instead of standard C to make sure it's not a header issue, but the same
problem happens with stdatomic.h.
Compiling with "-target thumbv7-none-eabi" instead seems to produce correct
code, as well as compiling with -O0.
LLVM version: Tip of trunk from SVN, as well as 6.0.0-1ubuntu2 (my machine,
from the official Ubuntu repositories)
Godbolt link for quick verification:
https://godbolt.org/z/Ozr2xa
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs