From 55b8683d246f2f563dcfa39899af27d47144379f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 20 Nov 2006 18:54:33 +0000 Subject: [PATCH] Fix PR1001, patch by Nikhil Patil! llvm-svn: 31880 --- llvm/utils/TableGen/DAGISelEmitter.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp index 1acd549b1f73..0b176088a0e2 100644 --- a/llvm/utils/TableGen/DAGISelEmitter.cpp +++ b/llvm/utils/TableGen/DAGISelEmitter.cpp @@ -3408,7 +3408,17 @@ static std::string getLegalCName(std::string OpName) { } void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) { - std::string InstNS = Target.inst_begin()->second.Namespace; + // Get the namespace to insert instructions into. Make sure not to pick up + // "TargetInstrInfo" by accidentally getting the namespace off the PHI + // instruction or something. + std::string InstNS; + for (CodeGenTarget::inst_iterator i = Target.inst_begin(), + e = Target.inst_end(); i != e; ++i) { + InstNS = i->second.Namespace; + if (InstNS != "TargetInstrInfo") + break; + } + if (!InstNS.empty()) InstNS += "::"; // Group the patterns by their top-level opcodes.