Skip to content

Commit 57a964c

Browse files
committed
[SelectionDAG][PPC][SystemZ] Fix GET_DYNAMIC_AREA_OFFSET chain result
The node has a chain, but it wasn't handled correctly: - DAG builder didn't update the root - DAG legalizer replaced the chain result with integer 0 - PPC and SystemZ lowerings didn't return the chain result at all SystemZ lowering is still incorrect because it now returns the source chain. Fixing it turned out to be a non-trivial task, so I left a FIXME.
1 parent 797330e commit 57a964c

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3499,7 +3499,7 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
34993499
break;
35003500
case ISD::GET_DYNAMIC_AREA_OFFSET:
35013501
Results.push_back(DAG.getConstant(0, dl, Node->getValueType(0)));
3502-
Results.push_back(Results[0].getValue(0));
3502+
Results.push_back(Node->getOperand(0));
35033503
break;
35043504
case ISD::FCOPYSIGN:
35053505
Results.push_back(ExpandFCOPYSIGN(Node));

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7401,9 +7401,9 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
74017401
if (PtrTy.getFixedSizeInBits() < ResTy.getFixedSizeInBits())
74027402
report_fatal_error("Wrong result type for @llvm.get.dynamic.area.offset"
74037403
" intrinsic!");
7404-
Res = DAG.getNode(ISD::GET_DYNAMIC_AREA_OFFSET, sdl, DAG.getVTList(ResTy),
7405-
Op);
7406-
DAG.setRoot(Op);
7404+
Res =
7405+
DAG.getNode(ISD::GET_DYNAMIC_AREA_OFFSET, sdl, {ResTy, MVT::Other}, Op);
7406+
DAG.setRoot(Res.getValue(1));
74077407
setValue(&I, Res);
74087408
return;
74097409
}

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7916,16 +7916,12 @@ PPCTargetLowering::LowerGET_DYNAMIC_AREA_OFFSET(SDValue Op,
79167916
SelectionDAG &DAG) const {
79177917
SDLoc dl(Op);
79187918

7919-
// Get the correct type for integers.
7920-
EVT IntVT = Op.getValueType();
7921-
79227919
// Get the inputs.
79237920
SDValue Chain = Op.getOperand(0);
79247921
SDValue FPSIdx = getFramePointerFrameIndex(DAG);
79257922
// Build a DYNAREAOFFSET node.
79267923
SDValue Ops[2] = {Chain, FPSIdx};
7927-
SDVTList VTs = DAG.getVTList(IntVT);
7928-
return DAG.getNode(PPCISD::DYNAREAOFFSET, dl, VTs, Ops);
7924+
return DAG.getNode(PPCISD::DYNAREAOFFSET, dl, Op->getVTList(), Ops);
79297925
}
79307926

79317927
SDValue PPCTargetLowering::LowerSTACKRESTORE(SDValue Op,

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4127,7 +4127,10 @@ SDValue SystemZTargetLowering::lowerGET_DYNAMIC_AREA_OFFSET(
41274127
SDValue Op, SelectionDAG &DAG) const {
41284128
SDLoc DL(Op);
41294129

4130-
return DAG.getNode(SystemZISD::ADJDYNALLOC, DL, MVT::i64);
4130+
// FIXME: SystemZISD::ADJDYNALLOC should be chained.
4131+
SDValue Result = DAG.getNode(SystemZISD::ADJDYNALLOC, DL, MVT::i64);
4132+
SDValue Chain = Op->getOperand(0);
4133+
return DAG.getMergeValues({Result, Chain}, DL);
41314134
}
41324135

41334136
SDValue SystemZTargetLowering::lowerSMUL_LOHI(SDValue Op,

0 commit comments

Comments
 (0)