[llvm] r231889 - Fix Value dangling reference debug output

Andrew Kaylor andrew.kaylor at intel.com
Tue Mar 10 16:55:38 PDT 2015


Author: akaylor
Date: Tue Mar 10 18:55:38 2015
New Revision: 231889

URL: http://llvm.org/viewvc/llvm-project?rev=231889&view=rev
Log:
Fix Value dangling reference debug output

Modified:
    llvm/trunk/lib/IR/TypeFinder.cpp
    llvm/trunk/lib/IR/Value.cpp

Modified: llvm/trunk/lib/IR/TypeFinder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/TypeFinder.cpp?rev=231889&r1=231888&r2=231889&view=diff
==============================================================================
--- llvm/trunk/lib/IR/TypeFinder.cpp (original)
+++ llvm/trunk/lib/IR/TypeFinder.cpp Tue Mar 10 18:55:38 2015
@@ -68,7 +68,7 @@ void TypeFinder::run(const Module &M, bo
         // instructions with this loop.)
         for (User::const_op_iterator OI = I.op_begin(), OE = I.op_end();
              OI != OE; ++OI)
-          if (!isa<Instruction>(OI))
+          if (*OI && !isa<Instruction>(OI))
             incorporateValue(*OI);
 
         // Incorporate types hiding in metadata.

Modified: llvm/trunk/lib/IR/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Value.cpp?rev=231889&r1=231888&r2=231889&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Value.cpp (original)
+++ llvm/trunk/lib/IR/Value.cpp Tue Mar 10 18:55:38 2015
@@ -69,15 +69,13 @@ Value::~Value() {
 #ifndef NDEBUG      // Only in -g mode...
   // Check to make sure that there are no uses of this value that are still
   // around when the value is destroyed.  If there are, then we have a dangling
-  // reference and something is wrong.  This code is here to print out what is
-  // still being referenced.  The value in question should be printed as
-  // a <badref>
+  // reference and something is wrong.  This code is here to print out where
+  // the value is still being referenced.
   //
   if (!use_empty()) {
     dbgs() << "While deleting: " << *VTy << " %" << getName() << "\n";
-    for (use_iterator I = use_begin(), E = use_end(); I != E; ++I)
-      dbgs() << "Use still stuck around after Def is destroyed:"
-           << **I << "\n";
+    for (auto *U : users())
+      dbgs() << "Use still stuck around after Def is destroyed:" << *U << "\n";
   }
 #endif
   assert(use_empty() && "Uses remain when a value is destroyed!");





More information about the llvm-commits mailing list