OSDN Git Service

[PowerPC] Fix "byval align" arguments
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Mon, 7 Jul 2014 19:26:41 +0000 (19:26 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Mon, 7 Jul 2014 19:26:41 +0000 (19:26 +0000)
commitbf7bfe35498766fece1446c737d6bc90dcbd32b8
tree59e3aa7cb50c3d65e603d44f64fe820c40311f7c
parent7fcb422bb26246556a7b296cc484888b29453baa
[PowerPC] Fix "byval align" arguments

Arguments passed as "byval align" should get the specified alignment
in the parameter save area.  There was some code in PPCISelLowering.cpp
that attempted to implement this, but this didn't work correctly:
while code did update the ArgOffset value, it neglected to update
the PtrOff value (which was already computed from the old ArgOffset),
and it also neglected to update GPR_idx -- fields skipped due to
alignment in the save area must likewise be skipped in GPRs.

This patch fixes and simplifies this logic by:
- handling argument offset alignment right at the beginning
  of argument processing, using a new helper routine
  CalculateStackSlotAlignment (this avoids having to update
  PtrOff and other derived values later on)
- not tracking GPR_idx separately, but always computing the
  correct GPR_idx for each argument *from* its ArgOffset
- removing some redundant computation in LowerFormalArguments:
  MinReservedArea must equal ArgOffset after argument processing,
  so there's no use in computing it twice.

[This doesn't change the behavior of the current clang front-end,
since that never creates "byval align" arguments at the moment.
This will change with a follow-on patch, however.]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212476 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCISelLowering.cpp
test/CodeGen/PowerPC/ppc64-byval-align.ll [new file with mode: 0644]