<div dir="ltr"><div class="gmail_extra">Hi Manman,</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 17, 2013 at 10:42 PM, Manman Ren <span dir="ltr"><<a href="mailto:manman.ren@gmail.com" target="_blank">manman.ren@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mren<br>
Date: Sun Nov 17 12:42:37 2013<br>
New Revision: 194973<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=194973&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=194973&view=rev</a><br>
Log:<br>
Debug Info Verifier: enable public functions of Finder to update the type map.<br>
<br>
We used to depend on running processModule before the other public functions<br>
such as processDeclare, processValue and processLocation. We are now relaxing<br>
the constraint by adding a module argument to the three functions and<br>
letting the three functions to initialize the type map. This will be used in<br>
a follow-on patch that collects nodes reachable from a Function.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/DebugInfo.h<br>
    llvm/trunk/lib/IR/DebugInfo.cpp<br>
    llvm/trunk/lib/IR/Verifier.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=194973&r1=194972&r2=194973&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=194973&r1=194972&r2=194973&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo.h Sun Nov 17 12:42:37 2013<br>
@@ -766,16 +766,19 @@ public:<br>
   void processModule(const Module &M);<br>
<br>
   /// processDeclare - Process DbgDeclareInst.<br>
-  void processDeclare(const DbgDeclareInst *DDI);<br>
+  void processDeclare(const Module &M, const DbgDeclareInst *DDI);<br>
   /// Process DbgValueInst.<br>
-  void processValue(const DbgValueInst *DVI);<br>
+  void processValue(const Module &M, const DbgValueInst *DVI);<br>
   /// processLocation - Process DILocation.<br>
-  void processLocation(DILocation Loc);<br>
+  void processLocation(const Module &M, DILocation Loc);<br>
<br>
   /// Clear all lists.<br>
   void reset();<br>
<br>
 private:<br>
+  /// Initialize TypeIdentifierMap.<br>
+  void IntializeTypeMap(const Module &M);<br>
+<br>
   /// processType - Process DIType.<br>
   void processType(DIType DT);<br>
<br>
@@ -828,6 +831,8 @@ private:<br>
   SmallVector<MDNode *, 8> Scopes; // Scopes<br>
   SmallPtrSet<MDNode *, 64> NodesSeen;<br>
   DITypeIdentifierMap TypeIdentifierMap;<br>
+  /// Specify if TypeIdentifierMap is initialized.<br>
+  bool TypeMapInitialized;<br></blockquote><div><br></div><div>This wasn't initialized in the ctor, see r195003. This error was detected by MSan bootstrap bot, but unfortunately it was red already for unrelated reasons.</div>
<div>Hopefully it should be fixed now.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 };<br>
 } // end namespace llvm<br>
<br>
<br>
Modified: llvm/trunk/lib/IR/DebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=194973&r1=194972&r2=194973&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=194973&r1=194972&r2=194973&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)<br>
+++ llvm/trunk/lib/IR/DebugInfo.cpp Sun Nov 17 12:42:37 2013<br>
@@ -951,12 +951,21 @@ void DebugInfoFinder::reset() {<br>
   Scopes.clear();<br>
   NodesSeen.clear();<br>
   TypeIdentifierMap.clear();<br>
+  TypeMapInitialized = false;<br>
+}<br>
+<br>
+void DebugInfoFinder::IntializeTypeMap(const Module &M) {<br>
+  if (!TypeMapInitialized)<br>
+    if (NamedMDNode *CU_Nodes = M.getNamedMetadata("<a href="http://llvm.dbg.cu" target="_blank">llvm.dbg.cu</a>")) {<br>
+      TypeIdentifierMap = generateDITypeIdentifierMap(CU_Nodes);<br>
+      TypeMapInitialized = true;<br>
+    }<br>
 }<br>
<br>
 /// processModule - Process entire module and collect debug info.<br>
 void DebugInfoFinder::processModule(const Module &M) {<br>
+  IntializeTypeMap(M);<br>
   if (NamedMDNode *CU_Nodes = M.getNamedMetadata("<a href="http://llvm.dbg.cu" target="_blank">llvm.dbg.cu</a>")) {<br>
-    TypeIdentifierMap = generateDITypeIdentifierMap(CU_Nodes);<br>
     for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {<br>
       DICompileUnit CU(CU_Nodes->getOperand(i));<br>
       addCompileUnit(CU);<br>
@@ -993,11 +1002,12 @@ void DebugInfoFinder::processModule(cons<br>
 }<br>
<br>
 /// processLocation - Process DILocation.<br>
-void DebugInfoFinder::processLocation(DILocation Loc) {<br>
+void DebugInfoFinder::processLocation(const Module &M, DILocation Loc) {<br>
   if (!Loc)<br>
     return;<br>
+  IntializeTypeMap(M);<br>
   processScope(Loc.getScope());<br>
-  processLocation(Loc.getOrigLocation());<br>
+  processLocation(M, Loc.getOrigLocation());<br>
 }<br>
<br>
 /// processType - Process DIType.<br>
@@ -1084,10 +1094,12 @@ void DebugInfoFinder::processSubprogram(<br>
 }<br>
<br>
 /// processDeclare - Process DbgDeclareInst.<br>
-void DebugInfoFinder::processDeclare(const DbgDeclareInst *DDI) {<br>
+void DebugInfoFinder::processDeclare(const Module &M,<br>
+                                     const DbgDeclareInst *DDI) {<br>
   MDNode *N = dyn_cast<MDNode>(DDI->getVariable());<br>
   if (!N)<br>
     return;<br>
+  IntializeTypeMap(M);<br>
<br>
   DIDescriptor DV(N);<br>
   if (!DV.isVariable())<br>
@@ -1099,10 +1111,11 @@ void DebugInfoFinder::processDeclare(con<br>
   processType(DIVariable(N).getType());<br>
 }<br>
<br>
-void DebugInfoFinder::processValue(const DbgValueInst *DVI) {<br>
+void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) {<br>
   MDNode *N = dyn_cast<MDNode>(DVI->getVariable());<br>
   if (!N)<br>
     return;<br>
+  IntializeTypeMap(M);<br>
<br>
   DIDescriptor DV(N);<br>
   if (!DV.isVariable())<br>
<br>
Modified: llvm/trunk/lib/IR/Verifier.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=194973&r1=194972&r2=194973&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=194973&r1=194972&r2=194973&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/IR/Verifier.cpp (original)<br>
+++ llvm/trunk/lib/IR/Verifier.cpp Sun Nov 17 12:42:37 2013<br>
@@ -2125,7 +2125,7 @@ void Verifier::visitInstruction(Instruct<br>
<br>
   if (!DisableDebugInfoVerifier) {<br>
     MD = I.getMetadata(LLVMContext::MD_dbg);<br>
-    Finder.processLocation(DILocation(MD));<br>
+    Finder.processLocation(*Mod, DILocation(MD));<br>
   }<br>
<br>
   InstsInThisBlock.insert(&I);<br>
@@ -2303,13 +2303,13 @@ void Verifier::visitIntrinsicFunctionCal<br>
     Assert1(MD->getNumOperands() == 1,<br>
                 "invalid llvm.dbg.declare intrinsic call 2", &CI);<br>
     if (!DisableDebugInfoVerifier)<br>
-      Finder.processDeclare(cast<DbgDeclareInst>(&CI));<br>
+      Finder.processDeclare(*Mod, cast<DbgDeclareInst>(&CI));<br>
   } break;<br>
   case Intrinsic::dbg_value: { //llvm.dbg.value<br>
     if (!DisableDebugInfoVerifier) {<br>
       Assert1(CI.getArgOperand(0) && isa<MDNode>(CI.getArgOperand(0)),<br>
               "invalid llvm.dbg.value intrinsic call 1", &CI);<br>
-      Finder.processValue(cast<DbgValueInst>(&CI));<br>
+      Finder.processValue(*Mod, cast<DbgValueInst>(&CI));<br>
     }<br>
     break;<br>
   }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div>
</div></div>