[cfe-commits] r81602 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExpr.cpp test/CodeGen/blocks-aligned-byref-variable.c
Chris Lattner
clattner at apple.com
Sun Sep 13 17:49:34 PDT 2009
On Sep 13, 2009, at 1:14 PM, Mike Stump wrote:
> On Sep 12, 2009, at 12:54 PM, Chris Lattner wrote:
>> On Sep 12, 2009, at 11:58 AM, Mike Stump wrote:
>>
>>> On Sep 11, 2009, at 7:44 PM, Anders Carlsson wrote:
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=81602&view=rev
>>>> Log:
>>>> Add support for __block variables with alignment greater than
>>>> __alignof(void *).
>>>
>>> Unfortunately, we also need a sema error for alignment larger than
>>> the
>>> minimum of the maximal stack alignmint and the alignment of malloc
>>> on
>>> the system. For darwin, I think that means 16. Also, ordinary
>>> stack
>>> decls that request larger than the maximal stack alignment the
>>> system
>>> conspires to allow need a sema error as well. In time, people might
>>> include the required alignment in the block and a flag to request
>>> more
>>> than the standard align in the blocks runtime, but until then...
>>> I've
>>> added a FIXME.
>>
>> Why?
>
> Why what? Why do we need an error for going past maximal supported
> alignment, because it won't be honored. Why warn for going past the
> alignment of malloc, because the runtime will dealign a __block
> variable to just malloc align[1] during a copy of the __block
> variable. In either case, this isn't what the user wanted. They
> actually wanted a variable that is aligned to the stated boundary.
>
>> Codegen should just set the right alignment on the alloca. The
>> LLVM backend will realign the stack as needed.
>
> You say that as if it were true:
It is true, we just don't support alignments of 512M *anywhere*. If
you want to solve the greater problem, that's fine, but this isn't
__block specific at all.
-Chris
>
> void bar(void *);
>
> void foo() {
> int i __attribute__((aligned(1024*1024*512)));
> i = 42;
> bar(&i);
> }
>
> clang -S t.c -o -
>
> _foo:
> pushq %rbp
> movq %rsp, %rbp
> subq $16, %rsp
>
> ? 16 won't cut it here. Anyway, __block variables can be allocate
> by other than the llvm stack allocator. They can be allocated when
> the runtime copies them.
>
>
> 1 - To be verified when one writes the check.
More information about the cfe-commits
mailing list