From a9b8101333df1e690d174cc3d129996ff6937929 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Mon, 26 Mar 2007 17:44:01 +0000 Subject: [PATCH] Get better debug output by having modified instructions print both the original and new instruction. A slight performance hit with ostringstream but it is only for debug. Also, clean up an uninitialized variable warning noticed in a release build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35358 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 78446bc67fb..c545bd67f5c 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -57,6 +57,9 @@ #include "llvm/ADT/STLExtras.h" #include #include +#ifndef NDEBUG +#include +#endif using namespace llvm; using namespace llvm::PatternMatch; @@ -3134,7 +3137,7 @@ Value *InstCombiner::FoldLogicalPlusAnd(Value *LHS, Value *RHS, // Otherwise, if Mask is 0+1+0+, and if B is known to have the low 0+ // part, we don't need any explicit masks to take them out of A. If that // is all N is, ignore it. - unsigned MB, ME; + unsigned MB = 0, ME = 0; if (isRunOfOnes(Mask, MB, ME)) { // begin/end bit of run, inclusive uint32_t BitWidth = cast(RHS->getType())->getBitWidth(); APInt Mask(APInt::getAllOnesValue(BitWidth)); @@ -9445,6 +9448,10 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) { } // Now that we have an instruction, try combining it to simplify it... +#ifndef NDEBUG + std::string OrigI; +#endif + DEBUG(std::ostringstream SS; I->print(SS); OrigI = SS.str();); if (Instruction *Result = visit(*I)) { ++NumCombined; // Should we replace the old instruction with a new one? @@ -9483,7 +9490,8 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) { // Erase the old instruction. InstParent->getInstList().erase(I); } else { - DOUT << "IC: MOD = " << *I; + DOUT << "IC: Mod = " << OrigI + << " New = " << *I; // If the instruction was modified, it's possible that it is now dead. // if so, remove it.