summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2013-11-05 22:44:04 +0000
committerAndrew Trick <atrick@apple.com>2013-11-05 22:44:04 +0000
commit6664df12fb65100bd3643a56b30f63eb27c6b509 (patch)
treed2b5cf56eafcc29b13bead99f23666b94a881da8 /llvm/lib/CodeGen
parentb09ebe936ba36598f18e69f23e2d07e764ea9a4e (diff)
downloadbcm5719-llvm-6664df12fb65100bd3643a56b30f63eb27c6b509.tar.gz
bcm5719-llvm-6664df12fb65100bd3643a56b30f63eb27c6b509.zip
Slightly change the way stackmap and patchpoint intrinsics are lowered.
MorphNodeTo is not safe to call during DAG building. It eagerly deletes dependent DAG nodes which invalidates the NodeMap. We could expose a safe interface for morphing nodes, but I don't think it's worth it. Just create a new MachineNode and replaceAllUsesWith. My understaning of the SD design has been that we want to support early target opcode selection. That isn't very well supported, but generally works. It seems reasonable to rely on this feature even if it isn't widely used. llvm-svn: 194102
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index a0b965c6976..d8a2cfb64a2 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -6806,11 +6806,19 @@ void SelectionDAGBuilder::visitStackmap(const CallInst &CI) {
if (hasGlue)
Ops.push_back(*(Call->op_end()-1));
- // Replace the target specific call node with STACKMAP in-place. This way we
- // don't have to call ReplaceAllUsesWith and STACKMAP will take the call's
- // place in the chain.
SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Glue);
- DAG.SelectNodeTo(Call, TargetOpcode::STACKMAP, NodeTys, &Ops[0], Ops.size());
+
+ // Replace the target specific call node with a STACKMAP node.
+ MachineSDNode *MN = DAG.getMachineNode(TargetOpcode::STACKMAP, getCurSDLoc(),
+ NodeTys, Ops);
+
+ // StackMap generates no value, so nothing goes in the NodeMap.
+
+ // Fixup the consumers of the intrinsic. The chain and glue may be used in the
+ // call sequence.
+ DAG.ReplaceAllUsesWith(Call, MN);
+
+ DAG.DeleteNode(Call);
}
/// \brief Lower llvm.experimental.patchpoint directly to its target opcode.
@@ -6898,12 +6906,22 @@ void SelectionDAGBuilder::visitPatchpoint(const CallInst &CI) {
if (hasGlue)
Ops.push_back(*(Call->op_end()-1));
- // Replace the target specific call node with PATCHPOINT in-place. This
- // way we don't have to call ReplaceAllUsesWith and PATCHPOINT will
- // take the call's place in the chain.
SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Glue);
- DAG.SelectNodeTo(Call, TargetOpcode::PATCHPOINT, NodeTys, &Ops[0],
- Ops.size());
+
+ // Replace the target specific call node with a STACKMAP node.
+ MachineSDNode *MN = DAG.getMachineNode(TargetOpcode::PATCHPOINT,
+ getCurSDLoc(), NodeTys, Ops);
+
+ // PatchPoint generates no value, so nothing goes in the NodeMap.
+ //
+ // FIXME: with anyregcc calling convention it will need to be in the NodeMap
+ // and replace values.
+
+ // Fixup the consumers of the intrinsic. The chain and glue may be used in the
+ // call sequence.
+ DAG.ReplaceAllUsesWith(Call, MN);
+
+ DAG.DeleteNode(Call);
}
/// TargetLowering::LowerCallTo - This is the default LowerCallTo
OpenPOWER on IntegriCloud