Fix a crash viewing dags that have target nodes in them
llvm-svn: 23300
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index ae0c2c8..c27523a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2263,7 +2263,8 @@
else {
if (G)
if (const TargetInstrInfo *TII = G->getTarget().getInstrInfo())
- return TII->getName(getOpcode()-ISD::BUILTIN_OP_END);
+ if (getOpcode()-ISD::BUILTIN_OP_END < TII->getNumOpcodes())
+ return TII->getName(getOpcode()-ISD::BUILTIN_OP_END);
return "<<Unknown Target Node>>";
}