[cfe-commits] Alignment of return from __builtin_alloca

David Sehr sehr at google.com
Thu Jun 7 15:26:20 PDT 2012


I believe the issue Joerg is referring to is that if SuitableAlign >
stackAlign, then the function calling __builtin_alloca has to align
its own stack to SuitableAlign dynamically.  Certainly this is not a
correctness issue (I stumbled upon it before remembering to add "/ 8"
to the setAlignment call, and it was correctly handled), but it will
impact performance on all paths in that function.  I guess I don't see
it as a big issue, but I defer to the wisdom of the community in this
regard.

David

On Thu, Jun 7, 2012 at 3:20 PM, Chandler Carruth <chandlerc at google.com> wrote:
> On Thu, Jun 7, 2012 at 3:08 PM, David Sehr <sehr at google.com> wrote:
>>
>> Please disregard my last comment.  Implementing that will be a bit
>> challenging, as stackAlign is a back end value rather than a clang
>> TargetInfo value. Are there targets where stackAlign < SuitableAlign?
>
>
> I suspect so, and that's worrisome...
>
> I'm not intimately familiar with stack alignment and Joerg's concerns, but
> it seems like a *more* aligned alloca would be fine, but a less aligned
> alloca would be bad. Why is it a bad thing to increase the alignment to
> SuitableAlign?
>
>>
>>
>> David
>>
>> On Thu, Jun 7, 2012 at 2:57 PM, David Sehr <sehr at google.com> wrote:
>> > Joerg,
>> >
>> > So the interesting case is where stackAlignment < SuitableAlignment.
>> > Would it be reasonable with you to align to the minimum of those two?
>> >
>> > David
>> >
>> > On Thu, Jun 7, 2012 at 2:40 PM, Joerg Sonnenberger
>> > <joerg at britannica.bec.de> wrote:
>> >> On Thu, Jun 07, 2012 at 02:23:13PM -0700, David Sehr wrote:
>> >>> I have recently been debugging a failure with one of the tests from
>> >>> the gcc torture test suite and discovered that gcc and llvm seem to
>> >>> differ on whether __builtin_alloca is aligned more than 0mod4 (gcc
>> >>> thinks it's aligned by what clang stores inTargetInfo::SuitableAlign).
>> >>
>> >> It should ensure that the stack alignment invariance from the ABI is
>> >> honored. I don't think it should provide a stricter alignment.
>> >> Please be very careful when changing this to not violate the above.
>> >>
>> >> Joerg
>> >> _______________________________________________
>> >> cfe-commits mailing list
>> >> cfe-commits at cs.uiuc.edu
>> >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>




More information about the cfe-commits mailing list