[PATCH] D12337: [Codegen] Ensure stack is properly aligned for call argument initialization

Jeroen Ketema via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 14:37:27 PDT 2015


jketema added a comment.

Thanks for your feedback! I'll address the easy bits, and have another look at the use of `getNextStackOffset`. I might need some help with that though, as I'm not very familiar with the code generation parts of llvm (still learning).


================
Comment at: include/llvm/CodeGen/CallingConvLower.h:204
@@ -203,2 +203,3 @@
   unsigned StackOffset;
+  unsigned MinStackAlign;
   SmallVector<uint32_t, 16> UsedRegs;
----------------
rnk wrote:
> I think this is really more like `MaxStackArgAlign`. It's the maximum alignment of arguments that ended up on the stack, right?
It was meant to be the minimum stack alignment I'll eventually need. I like your suggestion though.

================
Comment at: include/llvm/CodeGen/CallingConvLower.h:274
@@ -272,2 +273,3 @@
 
-  unsigned getNextStackOffset() const { return StackOffset; }
+  unsigned getNextStackOffset() const {
+    return ((StackOffset + MinStackAlign - 1) & ~(MinStackAlign - 1));
----------------
rnk wrote:
> Are you sure this is the right place to change? Isn't this method used to figure out where variadic argument packs start also? Shouldn't we *not* align StackOffset for that use case?
> 
> I think it also gets used when we have a reserved stack frame (i.e. no dynamic alloca). As written, your code will overallocate some extra padding that isn't necessary.
I'll have another look at the use cases.


http://reviews.llvm.org/D12337





More information about the llvm-commits mailing list