@@ -913,36 +913,38 @@ SelectionDAGBuilder::LowerStatepoint(const GCStatepointInst &I,
913
913
// Export the result value if needed
914
914
const GCResultInst *GCResult = I.getGCResult ();
915
915
Type *RetTy = I.getActualReturnType ();
916
- if (!RetTy->isVoidTy () && GCResult) {
917
- if (GCResult->getParent () != I.getParent ()) {
918
- // Result value will be used in a different basic block so we need to
919
- // export it now. Default exporting mechanism will not work here because
920
- // statepoint call has a different type than the actual call. It means
921
- // that by default llvm will create export register of the wrong type
922
- // (always i32 in our case). So instead we need to create export register
923
- // with correct type manually.
924
- // TODO: To eliminate this problem we can remove gc.result intrinsics
925
- // completely and make statepoint call to return a tuple.
926
- unsigned Reg = FuncInfo.CreateRegs (RetTy);
927
- RegsForValue RFV (*DAG.getContext (), DAG.getTargetLoweringInfo (),
928
- DAG.getDataLayout (), Reg, RetTy,
929
- I.getCallingConv ());
930
- SDValue Chain = DAG.getEntryNode ();
931
-
932
- RFV.getCopyToRegs (ReturnValue, DAG, getCurSDLoc (), Chain, nullptr );
933
- PendingExports.push_back (Chain);
934
- FuncInfo.ValueMap [&I] = Reg;
935
- } else {
936
- // Result value will be used in a same basic block. Don't export it or
937
- // perform any explicit register copies.
938
- // We'll replace the actuall call node shortly. gc_result will grab
939
- // this value.
940
- setValue (&I, ReturnValue);
941
- }
942
- } else {
943
- // The token value is never used from here on, just generate a poison value
916
+
917
+ if (RetTy->isVoidTy () || !GCResult) {
918
+ // The return value is not needed, just generate a poison value.
944
919
setValue (&I, DAG.getIntPtrConstant (-1 , getCurSDLoc ()));
920
+ return ;
945
921
}
922
+
923
+ if (GCResult->getParent () == I.getParent ()) {
924
+ // Result value will be used in a same basic block. Don't export it or
925
+ // perform any explicit register copies. The gc_result will simply grab
926
+ // this value.
927
+ setValue (&I, ReturnValue);
928
+ return ;
929
+ }
930
+
931
+ // Result value will be used in a different basic block so we need to export
932
+ // it now. Default exporting mechanism will not work here because statepoint
933
+ // call has a different type than the actual call. It means that by default
934
+ // llvm will create export register of the wrong type (always i32 in our
935
+ // case). So instead we need to create export register with correct type
936
+ // manually.
937
+ // TODO: To eliminate this problem we can remove gc.result intrinsics
938
+ // completely and make statepoint call to return a tuple.
939
+ unsigned Reg = FuncInfo.CreateRegs (RetTy);
940
+ RegsForValue RFV (*DAG.getContext (), DAG.getTargetLoweringInfo (),
941
+ DAG.getDataLayout (), Reg, RetTy,
942
+ I.getCallingConv ());
943
+ SDValue Chain = DAG.getEntryNode ();
944
+
945
+ RFV.getCopyToRegs (ReturnValue, DAG, getCurSDLoc (), Chain, nullptr );
946
+ PendingExports.push_back (Chain);
947
+ FuncInfo.ValueMap [&I] = Reg;
946
948
}
947
949
948
950
void SelectionDAGBuilder::LowerCallSiteWithDeoptBundleImpl (
0 commit comments