[llvm] [PowerPC] Add special handling for arguments that are smaller than pointer size. (PR #119003)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 12:16:51 PST 2024
================
@@ -7291,7 +7294,23 @@ SDValue PPCTargetLowering::LowerFormalArguments_AIX(
SDValue FIN = DAG.getFrameIndex(FI, PtrVT);
SDValue ArgValue =
DAG.getLoad(ValVT, dl, Chain, FIN, MachinePointerInfo());
- InVals.push_back(ArgValue);
+
+ // While the ABI specifies the the higher bits of the load should be
+ // zeroed out this is not always the case. For safety this code will zero
+ // extend the loaded value if the size of the argument type is smaller
+ // then the load.
+ if (!ArgVT.isVector() && !ValVT.isVector() && ArgVT.isInteger() &&
+ ValVT.isInteger() &&
+ ArgVT.getScalarSizeInBits() < ValVT.getScalarSizeInBits()) {
+ SDValue ArgValueTrunc = DAG.getNode(ISD::TRUNCATE, dl, ArgVT, ArgValue);
+ // DAG.getLoad(ArgVT, dl, Chain, FIN, MachinePointerInfo());
+ SDValue ArgValueExt =
+ ArgSignExt ? DAG.getSExtOrTrunc(ArgValueTrunc, dl, ValVT)
+ : DAG.getZExtOrTrunc(ArgValueTrunc, dl, ValVT);
+ InVals.push_back(ArgValueExt);
+ } else {
+ InVals.push_back(ArgValue);
+ }
----------------
RolandF77 wrote:
braces not needed here
https://github.com/llvm/llvm-project/pull/119003
More information about the llvm-commits
mailing list