[llvm-commits] patch: fix broken code generation with r125471 and newer when preferred alignment of some data type is is bigger than stack alignment
Chris Lattner
clattner at apple.com
Thu Feb 17 15:27:33 PST 2011
On Feb 14, 2011, at 11:11 AM, Heikki Kultala wrote:
> <stackalign.patch>
Hi Heikki,
This patch isn't correct. If a stack slot claims to be (e.g.) 32-byte aligned, then InferPtrAlignment can return 32 bytes. It is up to the target to provide this guarantee (by doing dynamic stack realignment) otherwise other things will fail.
You can see this at work on X86 (for example):
$ cat t.c
void foo() {
int x __attribute__((aligned(128)));
bar(&x);
}
$ clang t.c -S -o - -m32 -O3
_foo: ## @foo
## BB#0: ## %entry
pushl %ebp
movl %esp, %ebp
andl $-128, %esp
subl $256, %esp ## imm = 0x100
leal 128(%esp), %eax
movl %eax, (%esp)
calll _bar
movl %ebp, %esp
popl %ebp
ret
If your target isn't aligning things properly, then attribute(aligned) is broken.
-Chris
More information about the llvm-commits
mailing list