[llvm] 57cf29a - [Statepoint] Remove another use of getActualReturnType [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 31 09:58:16 PST 2022
Author: Philip Reames
Date: 2022-01-31T09:57:46-08:00
New Revision: 57cf29ac1bc5d0a5e20a7262111c3d3463113c47
URL: https://github.com/llvm/llvm-project/commit/57cf29ac1bc5d0a5e20a7262111c3d3463113c47
DIFF: https://github.com/llvm/llvm-project/commit/57cf29ac1bc5d0a5e20a7262111c3d3463113c47.diff
LOG: [Statepoint] Remove another use of getActualReturnType [NFC]
For the cross block gc.result projection case, we only care about the return type if there is a cross block gc.result, and if there is one, we can take the type from the gc.result.
At the moment, this makes little difference, but for opaque pointers we need a means to get result typing without relying on pointee types.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
index 955efed83172..dfda7d8b9f81 100644
--- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -990,15 +990,21 @@ SDValue SelectionDAGBuilder::LowerAsSTATEPOINT(
return ReturnVal;
}
-static std::pair<bool, bool> getGCResultLocality(const GCStatepointInst &S) {
- std::pair<bool, bool> Res(false, false);
- for (auto *U : S.users())
- if (auto *GRI = dyn_cast<GCResultInst>(U)) {
- if (GRI->getParent() == S.getParent())
- Res.first = true;
- else
- Res.second = true;
- }
+/// Return two gc.results if present. First result is a block local
+/// gc.result, second result is a non-block local gc.result. Corresponding
+/// entry will be nullptr if not present.
+static std::pair<const GCResultInst*, const GCResultInst*>
+getGCResultLocality(const GCStatepointInst &S) {
+ std::pair<const GCResultInst *, const GCResultInst*> Res(nullptr, nullptr);
+ for (auto *U : S.users()) {
+ auto *GRI = dyn_cast<GCResultInst>(U);
+ if (!GRI)
+ continue;
+ if (GRI->getParent() == S.getParent())
+ Res.first = GRI;
+ else
+ Res.second = GRI;
+ }
return Res;
}
@@ -1087,12 +1093,11 @@ SelectionDAGBuilder::LowerStatepoint(const GCStatepointInst &I,
SDValue ReturnValue = LowerAsSTATEPOINT(SI);
// Export the result value if needed
- const std::pair<bool, bool> GCResultLocality = getGCResultLocality(I);
- Type *RetTy = I.getActualReturnType();
+ const auto GCResultLocality = getGCResultLocality(I);
- if (RetTy->isVoidTy() ||
- (!GCResultLocality.first && !GCResultLocality.second)) {
- // The return value is not needed, just generate a poison value.
+ if (!GCResultLocality.first && !GCResultLocality.second) {
+ // The return value is not needed, just generate a poison value.
+ // Note: This covers the void return case.
setValue(&I, DAG.getIntPtrConstant(-1, getCurSDLoc()));
return;
}
@@ -1114,6 +1119,7 @@ SelectionDAGBuilder::LowerStatepoint(const GCStatepointInst &I,
// manually.
// TODO: To eliminate this problem we can remove gc.result intrinsics
// completely and make statepoint call to return a tuple.
+ Type *RetTy = GCResultLocality.second->getType();
unsigned Reg = FuncInfo.CreateRegs(RetTy);
RegsForValue RFV(*DAG.getContext(), DAG.getTargetLoweringInfo(),
DAG.getDataLayout(), Reg, RetTy,
More information about the llvm-commits
mailing list