<div dir="ltr">MSan says that PersistentID is uninitialized sometimes:<div><div>Initial selection DAG: BB#0 'test:'</div><div>SelectionDAG has 10 nodes:</div><div>  t==15698==WARNING: MemorySanitizer: use-of-uninitialized-value</div><div>    #0 0x431a2a8 in operator<< /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/Support/raw_ostream.cpp:110:7</div><div>    #1 0x431a2a8 in llvm::raw_ostream::operator<<(long) /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/Support/raw_ostream.cpp:131</div><div>    #2 0x3f8b9b0 in operator<< /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/Support/raw_ostream.h:201:12</div><div>    #3 0x3f8b9b0 in print /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp:378</div><div>    #4 0x3f8b9b0 in operator<< /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp:386</div><div>    #5 0x3f8b9b0 in llvm::SDNode::printr(llvm::raw_ostream&, llvm::SelectionDAG const*) const /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp:619</div><div>    #6 0x3f83d7f in llvm::SDNode::print(llvm::raw_ostream&, llvm::SelectionDAG const*) const /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp:720:3</div><div>    #7 0x3f8b776 in dump /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp:393:3</div><div>    #8 0x3f8b776 in DumpNodes(llvm::SDNode const*, unsigned int, llvm::SelectionDAG const*) /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp:600</div><div>    #9 0x3f8b350 in llvm::SelectionDAG::dump() const /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp:611:7</div><div>    #10 0x3f9d6d1 in llvm::SelectionDAGISel::CodeGenAndEmitDAG() /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:693:3</div><div>    #11 0x3f9a59d in llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1317:7</div><div>    #12 0x3f910f8 in llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:466:3</div><div>    #13 0x2195e57 in (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:171:7</div><div>    #14 0x2d863ca in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/CodeGen/MachineFunctionPass.cpp:43:10</div><div>    #15 0x365933f in llvm::FPPassManager::runOnFunction(llvm::Function&) /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/IR/LegacyPassManager.cpp:1521:23</div><div>    #16 0x36599d7 in llvm::FPPassManager::runOnModule(llvm::Module&) /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/IR/LegacyPassManager.cpp:1542:16</div><div>    #17 0x365ad18 in runOnModule /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/IR/LegacyPassManager.cpp:1598:23</div><div>    #18 0x365ad18 in llvm::legacy::PassManagerImpl::run(llvm::Module&) /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/IR/LegacyPassManager.cpp:1701</div><div>    #19 0x6e328f in compileModule /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/llc/llc.cpp:381:5</div><div>    #20 0x6e328f in main /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/llc/llc.cpp:204</div><div>    #21 0x7fb2f6f2beac in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x1eeac)</div><div>    #22 0x6530dc in _start (/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/bin/llc+0x6530dc)</div><div><br></div><div>SUMMARY: MemorySanitizer: use-of-uninitialized-value /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/Support/raw_ostream.cpp:110:7 in operator<<</div></div><div><br></div><div>I think SelectionDAG::NextPersistentId is actually the one that is not being initialized, so I initialized it in r253422. We'll see if it greens the msan bootstrap bot:</div><div><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/10128">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/10128</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 18, 2015 at 10:41 AM, Matthias Braun via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: matze<br>
Date: Fri Sep 18 12:41:00 2015<br>
New Revision: 248010<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=248010&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=248010&view=rev</a><br>
Log:<br>
SelectionDAG: Introduce PersistentID to SDNode for assert builds.<br>
<br>
This gives us more human readable numbers to identify nodes in debug<br>
dumps.<br>
<br>
Before:<br>
  0x7fcbd9700160: ch = EntryToken<br>
<br>
  0x7fcbd985c7c8: i64 = Register %RAX<br>
<br>
   ...<br>
<br>
      0x7fcbd9700160: <multiple use><br>
    0x7fcbd985c578: i64,ch = MOV64rm 0x7fcbd985c6a0, 0x7fcbd985cc68, 0x7fcbd985c200, 0x7fcbd985cd90, 0x7fcbd985ceb8, 0x7fcbd9700160<Mem:LD8[@foo]> [ORD=2]<br>
<br>
  0x7fcbd985c8f0: ch,glue = CopyToReg 0x7fcbd9700160, 0x7fcbd985c7c8, 0x7fcbd985c578 [ORD=3]<br>
<br>
    0x7fcbd985c7c8: <multiple use><br>
    0x7fcbd985c8f0: <multiple use><br>
    0x7fcbd985c8f0: <multiple use><br>
  0x7fcbd985ca18: ch = RETQ 0x7fcbd985c7c8, 0x7fcbd985c8f0, 0x7fcbd985c8f0:1 [ORD=3]<br>
<br>
Now:<br>
  t0: ch = EntryToken<br>
<br>
  t5: i64 = Register %RAX<br>
<br>
    ...<br>
<br>
      t0: <multiple use><br>
    t3: i64,ch = MOV64rm t10, t12, t11, t13, t14, t0<Mem:LD8[@foo]> [ORD=2]<br>
<br>
  t6: ch,glue = CopyToReg t0, t5, t3 [ORD=3]<br>
<br>
    t5: <multiple use><br>
    t6: <multiple use><br>
    t6: <multiple use><br>
  t7: ch = RETQ t5, t6, t6:1 [ORD=3]<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D12564" rel="noreferrer" target="_blank">http://reviews.llvm.org/D12564</a><br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/CodeGen/SelectionDAG.h<br>
    llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h<br>
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp<br>
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp<br>
    llvm/trunk/test/CodeGen/PowerPC/ppc64-icbt-pwr7.ll<br>
    llvm/trunk/test/DebugInfo/Generic/constant-sdnodes-have-dbg-location.ll<br>
    llvm/trunk/test/DebugInfo/Generic/constantfp-sdnodes-have-dbg-location.ll<br>
<br>
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=248010&r1=248009&r2=248010&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=248010&r1=248009&r2=248010&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original)<br>
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Fri Sep 18 12:41:00 2015<br>
@@ -215,6 +215,10 @@ class SelectionDAG {<br>
   /// Tracks dbg_value information through SDISel.<br>
   SDDbgInfo *DbgInfo;<br>
<br>
+#ifndef NDEBUG<br>
+  uint16_t NextPersistentId;<br>
+#endif<br>
+<br>
 public:<br>
   /// Clients of various APIs that cause global effects on<br>
   /// the DAG can optionally implement this interface.  This allows the clients<br>
<br>
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=248010&r1=248009&r2=248010&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=248010&r1=248009&r2=248010&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)<br>
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Fri Sep 18 12:41:00 2015<br>
@@ -431,6 +431,12 @@ private:<br>
   friend struct ilist_traits<SDNode>;<br>
<br>
 public:<br>
+#ifndef NDEBUG<br>
+  /// Unique and persistent id per SDNode in the DAG.<br>
+  /// Used for debug printing.<br>
+  uint16_t PersistentId;<br>
+#endif<br>
+<br>
   //===--------------------------------------------------------------------===//<br>
   //  Accessors<br>
   //<br>
<br>
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=248010&r1=248009&r2=248010&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=248010&r1=248009&r2=248010&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Sep 18 12:41:00 2015<br>
@@ -763,6 +763,7 @@ static void VerifySDNode(SDNode *N) {<br>
 void SelectionDAG::InsertNode(SDNode *N) {<br>
   AllNodes.push_back(N);<br>
 #ifndef NDEBUG<br>
+  N->PersistentId = NextPersistentId++;<br>
   VerifySDNode(N);<br>
 #endif<br>
 }<br>
@@ -948,6 +949,9 @@ void SelectionDAG::allnodes_clear() {<br>
   AllNodes.remove(AllNodes.begin());<br>
   while (!AllNodes.empty())<br>
     DeallocateNode(AllNodes.begin());<br>
+#ifndef NDEBUG<br>
+  NextPersistentId = 0;<br>
+#endif<br>
 }<br>
<br>
 BinarySDNode *SelectionDAG::GetBinarySDNode(unsigned Opcode, SDLoc DL,<br>
<br>
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp?rev=248010&r1=248009&r2=248010&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp?rev=248010&r1=248009&r2=248010&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp Fri Sep 18 12:41:00 2015<br>
@@ -361,6 +361,27 @@ const char *SDNode::getIndexedModeName(I<br>
   }<br>
 }<br>
<br>
+namespace {<br>
+class PrintNodeId {<br>
+  const SDNode &Node;<br>
+public:<br>
+  explicit PrintNodeId(const SDNode &Node)<br>
+      : Node(Node) {}<br>
+  void print(raw_ostream &OS) const {<br>
+#ifndef NDEBUG<br>
+    OS << 't' << Node.PersistentId;<br>
+#else<br>
+    OS << (const void*)&Node;<br>
+#endif<br>
+  }<br>
+};<br>
+<br>
+static inline raw_ostream &operator<<(raw_ostream &OS, const PrintNodeId &P) {<br>
+  P.print(OS);<br>
+  return OS;<br>
+}<br>
+}<br>
+<br>
 void SDNode::dump() const { dump(nullptr); }<br>
 void SDNode::dump(const SelectionDAG *G) const {<br>
   print(dbgs(), G);<br>
@@ -368,7 +389,7 @@ void SDNode::dump(const SelectionDAG *G)<br>
 }<br>
<br>
 void SDNode::print_types(raw_ostream &OS, const SelectionDAG *G) const {<br>
-  OS << (const void*)this << ": ";<br>
+  OS << PrintNodeId(*this) << ": ";<br>
<br>
   for (unsigned i = 0, e = getNumValues(); i != e; ++i) {<br>
     if (i) OS << ",";<br>
@@ -560,7 +581,7 @@ static void DumpNodes(const SDNode *N, u<br>
       DumpNodes(Op.getNode(), indent+2, G);<br>
     else<br>
       dbgs() << "\n" << std::string(indent+2, ' ')<br>
-             << (void*)Op.getNode() << ": <multiple use>";<br>
+             << PrintNodeId(*Op.getNode()) << ": <multiple use>";<br>
<br>
   dbgs() << '\n';<br>
   dbgs().indent(indent);<br>
@@ -676,8 +697,9 @@ void SDNode::print(raw_ostream &OS, cons<br>
   print_types(OS, G);<br>
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {<br>
     if (i) OS << ", "; else OS << " ";<br>
-    OS << (void*)getOperand(i).getNode();<br>
-    if (unsigned RN = getOperand(i).getResNo())<br>
+    const SDValue Operand = getOperand(i);<br>
+    OS << PrintNodeId(*Operand.getNode());<br>
+    if (unsigned RN = Operand.getResNo())<br>
       OS << ":" << RN;<br>
   }<br>
   print_details(OS, G);<br>
<br>
Modified: llvm/trunk/test/CodeGen/PowerPC/ppc64-icbt-pwr7.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ppc64-icbt-pwr7.ll?rev=248010&r1=248009&r2=248010&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ppc64-icbt-pwr7.ll?rev=248010&r1=248009&r2=248010&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/PowerPC/ppc64-icbt-pwr7.ll (original)<br>
+++ llvm/trunk/test/CodeGen/PowerPC/ppc64-icbt-pwr7.ll Fri Sep 18 12:41:00 2015<br>
@@ -10,10 +10,10 @@ entry:<br>
   ret void<br>
<br>
 ; FIXME: Crashing is not really the correct behavior here, we really should just emit nothing<br>
-; CHECK: Cannot select: 0x{{[0-9,a-f]+}}: ch = Prefetch<br>
-; CHECK: 0x{{[0-9,a-f]+}}: i32 = Constant<0><br>
-; CHECK-NEXT: 0x{{[0-9,a-f]+}}: i32 = Constant<3><br>
-; CHECK-NEXT: 0x{{[0-9,a-f]+}}: i32 = Constant<0><br>
+; CHECK: Cannot select: {{0x[0-9,a-f]+|t[0-9]+}}: ch = Prefetch<br>
+; CHECK: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = Constant<0><br>
+; CHECK-NEXT: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = Constant<3><br>
+; CHECK-NEXT: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = Constant<0><br>
<br>
 }<br>
<br>
<br>
Modified: llvm/trunk/test/DebugInfo/Generic/constant-sdnodes-have-dbg-location.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/constant-sdnodes-have-dbg-location.ll?rev=248010&r1=248009&r2=248010&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/constant-sdnodes-have-dbg-location.ll?rev=248010&r1=248009&r2=248010&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/Generic/constant-sdnodes-have-dbg-location.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/Generic/constant-sdnodes-have-dbg-location.ll Fri Sep 18 12:41:00 2015<br>
@@ -1,7 +1,7 @@<br>
 ; RUN: llc -debug < %s 2>&1 | FileCheck %s<br>
 ; REQUIRES: asserts<br>
<br>
-; CHECK: 0x{{[0-9,a-f]+}}: i32 = Constant<-1>test.c:4:5<br>
+; CHECK: t{{[0-9]+}}: i32 = Constant<-1>test.c:4:5<br>
<br>
 define i32 @main() {<br>
 entry:<br>
<br>
Modified: llvm/trunk/test/DebugInfo/Generic/constantfp-sdnodes-have-dbg-location.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/constantfp-sdnodes-have-dbg-location.ll?rev=248010&r1=248009&r2=248010&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/constantfp-sdnodes-have-dbg-location.ll?rev=248010&r1=248009&r2=248010&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/Generic/constantfp-sdnodes-have-dbg-location.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/Generic/constantfp-sdnodes-have-dbg-location.ll Fri Sep 18 12:41:00 2015<br>
@@ -1,7 +1,7 @@<br>
 ; RUN: llc -debug < %s 2>&1 | FileCheck %s<br>
 ; REQUIRES: asserts<br>
<br>
-; CHECK: 0x{{[0-9,a-f]+}}: f64 = ConstantFP<1.500000e+00>test.c:3:5<br>
+; CHECK: t{{[0-9]+}}: f64 = ConstantFP<1.500000e+00>test.c:3:5<br>
<br>
 define double @f() {<br>
 entry:<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>