diff gen/statements.cpp @ 622:26fce59fe80a

Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested. Commented some logging calls that could potentially write out many megabytes of type dumps.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 01 Oct 2008 18:32:31 +0200
parents 83ca663ecc20
children df196c8dea26
line wrap: on
line diff
--- a/gen/statements.cpp	Sun Sep 28 21:09:21 2008 +0200
+++ b/gen/statements.cpp	Wed Oct 01 18:32:31 2008 +0200
@@ -79,13 +79,16 @@
             DValue* e = exp->toElem(p);
             LLValue* v = e->getRVal();
             delete e;
-            Logger::cout() << "return value is '" <<*v << "'\n";
+
+            if (Logger::enabled())
+                Logger::cout() << "return value is '" <<*v << "'\n";
 
             // can happen for classes
             if (v->getType() != p->topfunc()->getReturnType())
             {
                 v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp");
-                Logger::cout() << "return value after cast: " << *v << '\n';
+                if (Logger::enabled())
+                    Logger::cout() << "return value after cast: " << *v << '\n';
             }
 
             DtoEnclosingHandlers(enclosinghandler, NULL);
@@ -165,7 +168,8 @@
     llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create("else", gIR->topfunc(), endbb) : endbb;
 
     if (cond_val->getType() != LLType::Int1Ty) {
-        Logger::cout() << "if conditional: " << *cond_val << '\n';
+        if (Logger::enabled())
+            Logger::cout() << "if conditional: " << *cond_val << '\n';
         cond_val = DtoBoolean(loc, cond_e);
     }
     LLValue* ifgoback = llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb());
@@ -677,8 +681,11 @@
 
     llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname);
 
-    Logger::cout() << *table->getType() << '\n';
-    Logger::cout() << *fn->getFunctionType()->getParamType(0) << '\n';
+    if (Logger::enabled())
+    {
+        Logger::cout() << *table->getType() << '\n';
+        Logger::cout() << *fn->getFunctionType()->getParamType(0) << '\n';
+    }
     assert(table->getType() == fn->getFunctionType()->getParamType(0));
 
     DValue* val = e->toElem(gIR);