This patch fixes calculating address of arguments larger than 32 bit on stack for variadic functions (rounding up address to alignment) on ppc32 architecture.
|3548 ↗||(On Diff #40915)|
This patch applies to more types than just double. You should probably add tests for some of the other cases, but if not, please at least make your commit message convey the intended generality.
|3549 ↗||(On Diff #40915)|
if (Align > OverflowAreaAlign)
|3559 ↗||(On Diff #40915)|
Would you mind extracting a function to do this realignment? There are 3-4 other places in this file that do exactly this. Using the existing code pattern from emitVoidPtrDirectVAArg — i.e. using an add instead of a non-inbounds GEP — seems reasonable.
I think this is a sensible prototype:
static Address emitRoundPointerUpToAlignment(CodeGenFunction &CGF, llvm::Value *Ptr, CharUnits Align, const llvm::Twine &Name);
|3562 ↗||(On Diff #40915)|
This code will be more readable if you keep Align as a CharUnits.
|241 ↗||(On Diff #41142)|
Thank you for extracting this.
First, this function deserves a doc comment now; I would suggest:
/// Dynamically round a pointer up to a multiple of the given alignment.
Also, this is now generically useful, so (1) please rename OverflowArgArea to something more generic, like Ptr, and (2) please use LLVM value names based on the name already in Ptr. That is, instead of "overflow_arg_area.align", please use
Ptr->getName () + ".aligned"
Finally, please look for the other places in this file that you could change to use this new function. There's one in emitVoidPtrDirectVAArg, and there are several other in other targets.
|3568 ↗||(On Diff #41142)|
Please sink OverflowArgArea into the if block, since you don't need it outside.