[llvm-commits] Natural Stack Alignment - Prevent overly aggressive alignment promotion.

Lang Hames lhames at apple.com
Mon Oct 10 11:52:51 PDT 2011


Hi All,

Bob - Exactly. Thanks for the straightforward explanation.

Evan - Patch updated with a default alignment of zero, representing "unspecified". With the default selected, no existing code should change. Let me know what you think.

Cheers,
Lang.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: NaturalStackAlignment2.patch
Type: application/octet-stream
Size: 9187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111010/6366b1a5/attachment.obj>
-------------- next part --------------

On Oct 10, 2011, at 10:49 AM, Evan Cheng wrote:

> Hi Lang,
> 
> diff --git lib/Target/TargetData.cpp lib/Target/TargetData.cpp
> index 1dfd9a8..b290207 100644
> --- lib/Target/TargetData.cpp
> +++ lib/Target/TargetData.cpp
> @@ -139,6 +139,7 @@ void TargetData::init(StringRef Desc) {
>   PointerMemSize = 8;
>   PointerABIAlign = 8;
>   PointerPrefAlign = PointerABIAlign;
> +  StackNaturalAlign = 4;
> 
> Why the default 4? I think it should be zero for "don't know". So we should add the specific entry to every TargetData string of all the targets. If you haven't already, please also make sure old bitcode files where the stack alignment is not specified continue to emit the same code as before.
> 
> Thanks,
> 
> Evan
> 
> On Oct 8, 2011, at 11:13 AM, Lang Hames wrote:
> 
>> Hi All,
>> 
>> I'm looking for feedback on the following patch, which adds a natural stack alignment field to target data. The intent is to prevent instcombine and other passes from promoting alloca alignment past the natural alignment, which would force a dynamic stack realignment (this un-breaks some cases where such alignment promotions forced dynamic stack realignment on platforms that don't support it). This patch sets the default alignment to 32 bits, which can be overridden by a new "S<size>" option in target data strings (size in bits, must be a multiple of 8).
>> 
>> Does anyone have any thoughts on this scheme? Questions and comments are very welcome. Assuming it's adopted, any Target maintainers whose platforms have a higher natural alignment should explicitly add the "S<size>" field to their target data strings so that they don't miss out on alignment promotion opportunities.
>> 
>> Cheers,
>> Lang.
>> 
>> 
>> <NaturalStackAlignment.patch>_______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 



More information about the llvm-commits mailing list