[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)
commitec2bf938956257f0904500f83c9eaa4223b832de
treec1bc57614e9d21686f64e09740b8b4d663105e94
parentbeeacac0b32a94abd813148ff142152f74d0f78a
[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.]

llvm-svn: 212476
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/ppc64-byval-align.ll [new file with mode: 0644]