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

Evan Cheng evan.cheng at apple.com
Mon Oct 10 10:49:26 PDT 2011


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