X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FProgrammersManual.html;h=bacb0d6b81bf0946016ae4ac59c1f4ea2b4abb4d;hb=fed0b2995ecaad811a3e66c8cbe8d3920dda8b29;hp=13fe9f57fbd623b1b89bb5275fca8155044a4067;hpb=c75ff9ac19d98a42026c0b356f2a8605d05ea3df;p=oota-llvm.git diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index 13fe9f57fbd..bacb0d6b81b 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -24,6 +24,10 @@ dyn_cast<> templates
  • The DEBUG() macro & -debug option +
  • The Statistic template & -stats option + +
       + +Other useful references +
    @@ -234,7 +261,7 @@ static bool isLoopInvariant(const Value *V, const Loop *L) return true; // Otherwise, it must be an instruction... - return !L->contains(cast<Instruction>(V)->getParent()); + return !L->contains(cast<Instruction>(V)->getParent());

    Note that you should not use an isa<> test followed by a @@ -265,8 +292,8 @@ Another common example is:

       // Loop over all of the phi nodes in a basic block
    -  BasicBlock::iterator BBI = BB->begin();
    -  for (; PHINode *PN = dyn_cast<PHINode>(&*BBI); ++BBI)
    +  BasicBlock::iterator BBI = BB->begin();
    +  for (; PHINode *PN = dyn_cast<PHINode>(BBI); ++BBI)
         cerr << *PN;
     

    @@ -318,12 +345,11 @@ Naturally, because of this, you don't want to delete the debug printouts, but you don't want them to always be noisy. A standard compromise is to comment them out, allowing you to enable them if you need them in the future.

    -The "Support/Statistic.h" -file provides a macro named DEBUG() that is a much nicer solution to -this problem. Basically, you can put arbitrary code into the argument of the -DEBUG macro, and it is only executed if 'opt' is run with the -'-debug' command line argument: +The "Support/Debug.h" file +provides a macro named DEBUG() that is a much nicer solution to this +problem. Basically, you can put arbitrary code into the argument of the +DEBUG macro, and it is only executed if 'opt' (or any other +tool) is run with the '-debug' command line argument:

          ... 
    @@ -341,10 +367,69 @@ Then you can run your pass like this:

    $

    -Using the DEBUG() macro instead of a home brewed solution allows you to +Using the DEBUG() macro instead of a home-brewed solution allows you to now have to create "yet another" command line option for the debug output for -your pass. Note that DEBUG() macros are disabled for optimized -builds, so they do not cause a performance impact at all.

    +your pass. Note that DEBUG() macros are disabled for optimized builds, +so they do not cause a performance impact at all (for the same reason, they +should also not contain side-effects!).

    + +One additional nice thing about the DEBUG() macro is that you can +enable or disable it directly in gdb. Just use "set DebugFlag=0" or +"set DebugFlag=1" from the gdb if the program is running. If the +program hasn't been started yet, you can always just run it with +-debug.

    + + +


    Fine grained debug info with + DEBUG_TYPE() and the -debug-only option