[llvm] [PowerPC] Add special handling for arguments that are smaller than pointer size. (PR #119003)
Stefan Pintilie via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 11 10:57:04 PST 2024
================
@@ -7291,7 +7294,21 @@ 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 that the higher bits of the load should be
+ // zeroed out or sign extended this is not always the case. For safety
+ // this code will zero or sign extend the loaded value if the size of
+ // the argument type is smaller than the load.
+ if (!ArgVT.isVector() && !ValVT.isVector() && ArgVT.isInteger() &&
+ ValVT.isInteger() &&
+ ArgVT.getScalarSizeInBits() < ValVT.getScalarSizeInBits()) {
+ SDValue ArgValueTrunc = DAG.getNode(ISD::TRUNCATE, dl, ArgVT, ArgValue);
+ SDValue ArgValueExt =
+ ArgSignExt ? DAG.getSExtOrTrunc(ArgValueTrunc, dl, ValVT)
+ : DAG.getZExtOrTrunc(ArgValueTrunc, dl, ValVT);
+ InVals.push_back(ArgValueExt);
+ } else
+ InVals.push_back(ArgValue);
----------------
stefanp-ibm wrote:
You mean this example here:
```
// Use braces for the `else if` and `else` block to keep it uniform with the
// `if` block.
if (isa<FunctionDecl>(D)) {
verifyFunctionDecl(D);
handleFunctionDecl(D);
} else if (isa<GlobalVarDecl>(D)) {
handleGlobalVarDecl(D);
} else {
handleOtherDecl(D);
}
```
Okay, I will change is back.
https://github.com/llvm/llvm-project/pull/119003
More information about the llvm-commits
mailing list