diff gen/passes/GarbageCollect2Stack.cpp @ 1551:ed0feda76820

DOUT is deprecated, use DEBUG(errs()) instead
author Benjamin Kramer <benny.kra@gmail.com>
date Mon, 27 Jul 2009 11:44:01 +0200
parents a326f145a57b
children f55ca8a1598c
line wrap: on
line diff
--- a/gen/passes/GarbageCollect2Stack.cpp	Sun Jul 26 19:12:37 2009 +0200
+++ b/gen/passes/GarbageCollect2Stack.cpp	Mon Jul 27 11:44:01 2009 +0200
@@ -35,6 +35,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
 STATISTIC(NumGcToStack, "Number of calls promoted to constant-size allocas");
@@ -318,7 +319,7 @@
 /// runOnFunction - Top level algorithm.
 ///
 bool GarbageCollect2Stack::runOnFunction(Function &F) {
-    DEBUG(DOUT << "\nRunning -dgc2stack on function " << F.getName() << '\n');
+    DEBUG(errs() << "\nRunning -dgc2stack on function " << F.getName() << '\n');
     
     TargetData& TD = getAnalysis<TargetData>();
     DominatorTree& DT = getAnalysis<DominatorTree>();
@@ -364,7 +365,7 @@
                 continue;
             }
             
-            DEBUG(DOUT << "GarbageCollect2Stack inspecting: " << *Inst);
+            DEBUG(errs() << "GarbageCollect2Stack inspecting: " << *Inst);
             
             if (!info->analyze(*Context, CS, A) || !isSafeToStackAllocate(Inst, DT))
                 continue;
@@ -375,7 +376,7 @@
             IRBuilder<> Builder(BB, Inst);
             Value* newVal = info->promote(*Context, CS, Builder, A);
             
-            DEBUG(DOUT << "Promoted to: " << *newVal);
+            DEBUG(errs() << "Promoted to: " << *newVal);
             
             // Make sure the type is the same as it was before, and replace all
             // uses of the runtime call with the alloca.
@@ -418,7 +419,7 @@
 /// Returns whether Def is used by any instruction that is reachable from Alloc
 /// (without executing Def again).
 static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, DominatorTree& DT) {
-    DOUT << "### mayBeUsedAfterRealloc()\n" << *Def << *Alloc;
+    DEBUG(errs() << "### mayBeUsedAfterRealloc()\n" << *Def << *Alloc);
     
     // If the definition isn't used it obviously won't be used after the
     // allocation.
@@ -426,11 +427,11 @@
     // without going through Def again first, since the definition couldn't
     // dominate the user either.
     if (Def->use_empty() || !DT.dominates(Def, Alloc)) {
-        DOUT << "### No uses or does not dominate allocation\n";
+        DEBUG(errs() << "### No uses or does not dominate allocation\n");
         return false;
     }
     
-    DOUT << "### Def dominates Alloc\n";
+    DEBUG(errs() << "### Def dominates Alloc\n");
     
     BasicBlock* DefBlock = Def->getParent();
     BasicBlock* AllocBlock = Alloc->getParent();
@@ -441,7 +442,7 @@
     for (Instruction::use_iterator UI = Def->use_begin(), UE = Def->use_end();
          UI != UE; ++UI) {
         Instruction* User = cast<Instruction>(*UI);
-        DOUT << "USER: " << *User;
+        DEBUG(errs() << "USER: " << *User);
         BasicBlock* UserBlock = User->getParent();
         
         // This dominance check is not performed if they're in the same block
@@ -451,7 +452,7 @@
         if (AllocBlock != UserBlock && DT.dominates(AllocBlock, UserBlock)) {
             // There's definitely a path from alloc to this user that does not
             // go through Def, namely any path that ends up in that user.
-            DOUT << "### Alloc dominates user " << *User;
+            DEBUG(errs() << "### Alloc dominates user " << *User);
             return true;
         }
         
@@ -491,8 +492,8 @@
                 // This block does not contain the definition or the allocation,
                 // so any user in this block is definitely reachable without
                 // finding either the definition or the allocation.
-                DOUT << "### Block " << B->getName()
-                     << " contains a reachable user\n";
+                DEBUG(errs() << "### Block " << B->getName()
+                     << " contains a reachable user\n");
                 return true;
             }
             // We need to walk the instructions in the block to see whether we
@@ -501,7 +502,7 @@
                 if (&*BBI == Alloc || &*BBI == Def)
                     break;
                 if (Users.count(BBI)) {
-                    DOUT << "### Problematic user: " << *BBI;
+                    DEBUG(errs() << "### Problematic user: " << *BBI);
                     return true;
                 }
             }
@@ -527,7 +528,7 @@
             bool SeenDef = false;
             while (isa<PHINode>(BBI)) {
                 if (Def == cast<PHINode>(BBI)->getIncomingValueForBlock(B)) {
-                    DOUT << "### Problematic phi user: " << *BBI;
+                    DEBUG(errs() << "### Problematic phi user: " << *BBI);
                     return true;
                 }
                 SeenDef |= (Def == &*BBI);