[PATCH] D40805: [RISCV] Support for varargs

Leslie Zhai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 19:02:53 PST 2018


xiangzhai added inline comments.


================
Comment at: lib/Target/RISCV/RISCVISelLowering.cpp:701
+    // If saving an odd-number of registers, create an extra stack slot to
+    // ensure even-numbered registers are always 2*XLEN-aligned.
+    if (Idx % 2) {
----------------
efriedma wrote:
> xiangzhai wrote:
> > efriedma wrote:
> > > Could you clarify what "ensure even-numbered registers are always 2*XLEN-aligned" means?  The varargs save area is always right next to any arguments passed on the stack, so I'm not sure what exactly you need to align.
> > Hi Eli,
> > 
> > I am reviewing [Compiler Principle](https://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools) chapter 7.2 Stack Allocation, then consider about this question, because Strict Alignment? just like GCC https://gcc.gnu.org/ml/gcc-patches/2017-05/msg00011.html Please teach me, thanks a lot!
> > 
> > Regards,
> > Leslie Zhai 
> Yes, in general, some things need to be aligned, for a variety of reasons (including the issue you noted).  I'm not questioning that part.
> 
> The question is more about the stack layout.  Why do we need to allocate an extra object here to ensure alignment?  What stack objects are we ensuring the alignment of?
Perhaps I need to review Compiler Principle's chapter 7.2.4 `VarArg in stack` and 7.3.5 Access Link more carefully :)


https://reviews.llvm.org/D40805





More information about the llvm-commits mailing list