[PATCH] D38143: Dynamic stack alignment for Thumb1
Momchil Velikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 21 10:31:29 PDT 2017
chill created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.
This patch adds dynamic stack alignment for Thumb1.
The motivating issue is micompilation of the following code, when targeting a
CPU, which implements only Thumb-1, like cortex-m0.
struct foo {
alignas(16) char buf[12];
int i;
int *ip;
foo() : ip(&i) {}
};
extern void g(foo &);
void f() {
foo myFoo;
g(myFoo);
}
When initialising the `ip` member, the address of `i` is calculated using bitwise OR:
push {r7, lr}
.pad #40
sub sp, #40
movs r1, #12
mov r0, sp
orrs r1, r0
str r1, [sp, #16]
which is obviously incorrect when the starting address of that object (resp. the
stack pointer) happens to be aligned at 8 or 4 byte boundary.
When compiling for ARM or Thumb2, the stack is realigned and the problem does
not occur.
https://reviews.llvm.org/D38143
Files:
lib/Target/ARM/ARMBaseRegisterInfo.cpp
lib/Target/ARM/Thumb1FrameLowering.cpp
test/CodeGen/ARM/thumb1_return_sequence.ll
test/CodeGen/Thumb/large-stack.ll
test/CodeGen/Thumb/long.ll
test/CodeGen/Thumb/stack-align.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38143.116214.patch
Type: text/x-patch
Size: 6503 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170921/93d8f70c/attachment.bin>
More information about the llvm-commits
mailing list