[llvm] r225907 - Adjust ScheduleDAGSDNodes::RegDefIter for patchpoints

Hal Finkel hfinkel at anl.gov
Tue Jan 13 17:07:03 PST 2015

Author: hfinkel
Date: Tue Jan 13 19:07:03 2015
New Revision: 225907

URL: http://llvm.org/viewvc/llvm-project?rev=225907&view=rev
Adjust ScheduleDAGSDNodes::RegDefIter for patchpoints

PATCHPOINT is a strange pseudo-instruction. Depending on how it is used, and
whether or not the AnyReg calling convention is being used, it might or might
not define a value. However, its TableGen definition says that it defines one
value, and so when it doesn't, the code in ScheduleDAGSDNodes::RegDefIter
becomes confused and the code that uses the RegDefIter will try to get the
register class of the MVT::Other type associated with the PATCHPOINT's chain
result (under certain circumstances).

This will be covered by the PPC64 PatchPoint test cases once that support is


Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp?rev=225907&r1=225906&r2=225907&view=diff
--- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp Tue Jan 13 19:07:03 2015
@@ -551,6 +551,14 @@ void ScheduleDAGSDNodes::RegDefIter::Ini
     NodeNumDefs = 0;
+  if (POpc == TargetOpcode::PATCHPOINT &&
+      Node->getValueType(0) == MVT::Other) {
+    // PATCHPOINT is defined to have one result, but it might really have none
+    // if we're not using CallingConv::AnyReg. Don't mistake the chain for a
+    // real definition.
+    NodeNumDefs = 0;
+    return;
+  }
   unsigned NRegDefs = SchedDAG->TII->get(Node->getMachineOpcode()).getNumDefs();
   // Some instructions define regs that are not represented in the selection DAG
   // (e.g. unused flags). See tMOVi8. Make sure we don't access past NumValues.

More information about the llvm-commits mailing list