From 9e7e60952505da18c67b575b07237445cc673691 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 23 Mar 2012 03:54:05 +0000 Subject: [PATCH] Take out the debug info probe stuff. It's making some changes to the PassManager annoying and should be reimplemented as a decorator on top of existing passes (as should the timing data). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153305 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfoProbe.h | 67 ---------- lib/Analysis/LoopPass.cpp | 23 +--- lib/VMCore/DebugInfoProbe.cpp | 225 ---------------------------------- lib/VMCore/PassManager.cpp | 23 +--- 4 files changed, 3 insertions(+), 335 deletions(-) delete mode 100644 include/llvm/DebugInfoProbe.h delete mode 100644 lib/VMCore/DebugInfoProbe.cpp diff --git a/include/llvm/DebugInfoProbe.h b/include/llvm/DebugInfoProbe.h deleted file mode 100644 index 78d00dfeedd..00000000000 --- a/include/llvm/DebugInfoProbe.h +++ /dev/null @@ -1,67 +0,0 @@ -//===-- DebugInfoProbe.h - DebugInfo Probe ----------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines a probe, DebugInfoProbe, that can be used by pass -// manager to analyze how optimizer is treating debugging information. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_DEBUGINFOPROBE_H -#define LLVM_TRANSFORMS_UTILS_DEBUGINFOPROBE_H - -#include "llvm/ADT/StringMap.h" - -namespace llvm { - class Function; - class Pass; - class DebugInfoProbeImpl; - - /// DebugInfoProbe - This class provides a interface to monitor - /// how an optimization pass is preserving debugging information. - class DebugInfoProbe { - public: - DebugInfoProbe(); - ~DebugInfoProbe(); - - /// initialize - Collect information before running an optimization pass. - void initialize(StringRef PName, Function &F); - - /// finalize - Collect information after running an optimization pass. This - /// must be used after initialization. - void finalize(Function &F); - - /// report - Report findings. This should be invoked after finalize. - void report(); - - private: - DebugInfoProbeImpl *pImpl; - }; - - /// DebugInfoProbeInfo - This class provides an interface that a pass manager - /// can use to manage debug info probes. - class DebugInfoProbeInfo { - StringMap Probes; - public: - DebugInfoProbeInfo() {} - - /// ~DebugInfoProbeInfo - Report data collected by all probes before deleting - /// them. - ~DebugInfoProbeInfo(); - - /// initialize - Collect information before running an optimization pass. - void initialize(Pass *P, Function &F); - - /// finalize - Collect information after running an optimization pass. This - /// must be used after initialization. - void finalize(Pass *P, Function &F); - }; - -} // End llvm namespace - -#endif diff --git a/lib/Analysis/LoopPass.cpp b/lib/Analysis/LoopPass.cpp index 5ba1f4045d1..aba700ac5c3 100644 --- a/lib/Analysis/LoopPass.cpp +++ b/lib/Analysis/LoopPass.cpp @@ -14,10 +14,8 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/LoopPass.h" -#include "llvm/DebugInfoProbe.h" #include "llvm/Assembly/PrintModulePass.h" #include "llvm/Support/Debug.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Timer.h" using namespace llvm; @@ -53,20 +51,6 @@ public: char PrintLoopPass::ID = 0; } -//===----------------------------------------------------------------------===// -// DebugInfoProbe - -static DebugInfoProbeInfo *TheDebugProbe; -static void createDebugInfoProbe() { - if (TheDebugProbe) return; - - // Constructed the first time this is called. This guarantees that the - // object will be constructed, if -enable-debug-info-probe is set, - // before static globals, thus it will be destroyed before them. - static ManagedStatic DIP; - TheDebugProbe = &*DIP; -} - //===----------------------------------------------------------------------===// // LPPassManager // @@ -195,7 +179,6 @@ void LPPassManager::getAnalysisUsage(AnalysisUsage &Info) const { bool LPPassManager::runOnFunction(Function &F) { LI = &getAnalysis(); bool Changed = false; - createDebugInfoProbe(); // Collect inherited analysis from Module level pass manager. populateInheritedAnalysis(TPM->activeStack); @@ -227,21 +210,19 @@ bool LPPassManager::runOnFunction(Function &F) { // Run all passes on the current Loop. for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { LoopPass *P = getContainedPass(Index); + dumpPassInfo(P, EXECUTION_MSG, ON_LOOP_MSG, CurrentLoop->getHeader()->getName()); dumpRequiredSet(P); initializeAnalysisImpl(P); - if (TheDebugProbe) - TheDebugProbe->initialize(P, F); + { PassManagerPrettyStackEntry X(P, *CurrentLoop->getHeader()); TimeRegion PassTimer(getPassTimer(P)); Changed |= P->runOnLoop(CurrentLoop, *this); } - if (TheDebugProbe) - TheDebugProbe->finalize(P, F); if (Changed) dumpPassInfo(P, MODIFICATION_MSG, ON_LOOP_MSG, diff --git a/lib/VMCore/DebugInfoProbe.cpp b/lib/VMCore/DebugInfoProbe.cpp deleted file mode 100644 index d1275ff58ca..00000000000 --- a/lib/VMCore/DebugInfoProbe.cpp +++ /dev/null @@ -1,225 +0,0 @@ -//===-- DebugInfoProbe.cpp - DebugInfo Probe ------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements DebugInfoProbe. This probe can be used by a pass -// manager to analyze how optimizer is treating debugging information. -// -//===----------------------------------------------------------------------===// - -#define DEBUG_TYPE "debuginfoprobe" -#include "llvm/DebugInfoProbe.h" -#include "llvm/Function.h" -#include "llvm/IntrinsicInst.h" -#include "llvm/Metadata.h" -#include "llvm/PassManager.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/Debug.h" -#include "llvm/Support/DebugLoc.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/ADT/StringRef.h" -#include -#include - -using namespace llvm; - -static cl::opt -EnableDebugInfoProbe("enable-debug-info-probe", cl::Hidden, - cl::desc("Enable debug info probe")); - -// CreateInfoOutputFile - Return a file stream to print our output on. -namespace llvm { extern raw_ostream *CreateInfoOutputFile(); } - -//===----------------------------------------------------------------------===// -// DebugInfoProbeImpl - This class implements a interface to monitor -// how an optimization pass is preserving debugging information. - -namespace llvm { - - class DebugInfoProbeImpl { - public: - DebugInfoProbeImpl() : NumDbgLineLost(0),NumDbgValueLost(0) {} - void initialize(StringRef PName, Function &F); - void finalize(Function &F); - void report(); - private: - unsigned NumDbgLineLost, NumDbgValueLost; - std::string PassName; - Function *TheFn; - std::set DbgVariables; - std::set MissingDebugLoc; - }; -} - -//===----------------------------------------------------------------------===// -// DebugInfoProbeImpl - -/// initialize - Collect information before running an optimization pass. -void DebugInfoProbeImpl::initialize(StringRef PName, Function &F) { - if (!EnableDebugInfoProbe) return; - PassName = PName; - - DbgVariables.clear(); - MissingDebugLoc.clear(); - TheFn = &F; - - for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) - for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); - BI != BE; ++BI) { - if (!isa(BI) && BI->getDebugLoc().isUnknown()) - MissingDebugLoc.insert(BI); - if (!isa(BI)) continue; - Value *Addr = NULL; - MDNode *Node = NULL; - if (DbgDeclareInst *DDI = dyn_cast(BI)) { - Addr = DDI->getAddress(); - Node = DDI->getVariable(); - } else if (DbgValueInst *DVI = dyn_cast(BI)) { - Addr = DVI->getValue(); - Node = DVI->getVariable(); - } - if (Addr) - DbgVariables.insert(Node); - } -} - -/// report - Report findings. This should be invoked after finalize. -void DebugInfoProbeImpl::report() { - if (!EnableDebugInfoProbe) return; - if (NumDbgLineLost || NumDbgValueLost) { - raw_ostream *OutStream = CreateInfoOutputFile(); - if (NumDbgLineLost) - *OutStream << NumDbgLineLost - << "\t times line number info lost by " - << PassName << "\n"; - if (NumDbgValueLost) - *OutStream << NumDbgValueLost - << "\t times variable info lost by " - << PassName << "\n"; - delete OutStream; - } - NumDbgLineLost = 0; - NumDbgValueLost = 0; -} - -/// finalize - Collect information after running an optimization pass. This -/// must be used after initialization. -void DebugInfoProbeImpl::finalize(Function &F) { - if (!EnableDebugInfoProbe) return; - assert (TheFn == &F && "Invalid function to measure!"); - - std::setDbgVariables2; - for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) - for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); - BI != BE; ++BI) { - if (!isa(BI) && BI->getDebugLoc().isUnknown() && - MissingDebugLoc.count(BI) == 0) { - ++NumDbgLineLost; - DEBUG(dbgs() << "DebugInfoProbe (" << PassName << "): --- "); - DEBUG(BI->print(dbgs())); - DEBUG(dbgs() << "\n"); - } - if (!isa(BI)) continue; - Value *Addr = NULL; - MDNode *Node = NULL; - if (DbgDeclareInst *DDI = dyn_cast(BI)) { - Addr = DDI->getAddress(); - Node = DDI->getVariable(); - } else if (DbgValueInst *DVI = dyn_cast(BI)) { - Addr = DVI->getValue(); - Node = DVI->getVariable(); - } - if (Addr) - DbgVariables2.insert(Node); - } - - for (std::set::iterator I = DbgVariables.begin(), - E = DbgVariables.end(); I != E; ++I) { - if (DbgVariables2.count(*I) == 0 && (*I)->getNumOperands() >= 2) { - DEBUG(dbgs() - << "DebugInfoProbe(" - << PassName - << "): Losing dbg info for variable: "; - if (MDString *MDS = dyn_cast_or_null( - (*I)->getOperand(2))) - dbgs() << MDS->getString(); - else - dbgs() << "..."; - dbgs() << "\n"); - ++NumDbgValueLost; - } - } -} - -//===----------------------------------------------------------------------===// -// DebugInfoProbe - -DebugInfoProbe::DebugInfoProbe() { - pImpl = new DebugInfoProbeImpl(); -} - -DebugInfoProbe::~DebugInfoProbe() { - delete pImpl; -} - -/// initialize - Collect information before running an optimization pass. -void DebugInfoProbe::initialize(StringRef PName, Function &F) { - pImpl->initialize(PName, F); -} - -/// finalize - Collect information after running an optimization pass. This -/// must be used after initialization. -void DebugInfoProbe::finalize(Function &F) { - pImpl->finalize(F); -} - -/// report - Report findings. This should be invoked after finalize. -void DebugInfoProbe::report() { - pImpl->report(); -} - -//===----------------------------------------------------------------------===// -// DebugInfoProbeInfo - -/// ~DebugInfoProbeInfo - Report data collected by all probes before deleting -/// them. -DebugInfoProbeInfo::~DebugInfoProbeInfo() { - if (!EnableDebugInfoProbe) return; - for (StringMap::iterator I = Probes.begin(), - E = Probes.end(); I != E; ++I) { - I->second->report(); - delete I->second; - } - } - -/// initialize - Collect information before running an optimization pass. -void DebugInfoProbeInfo::initialize(Pass *P, Function &F) { - if (!EnableDebugInfoProbe) return; - if (P->getAsPMDataManager()) - return; - - StringMapEntry &Entry = - Probes.GetOrCreateValue(P->getPassName()); - DebugInfoProbe *&Probe = Entry.getValue(); - if (!Probe) - Probe = new DebugInfoProbe(); - Probe->initialize(P->getPassName(), F); -} - -/// finalize - Collect information after running an optimization pass. This -/// must be used after initialization. -void DebugInfoProbeInfo::finalize(Pass *P, Function &F) { - if (!EnableDebugInfoProbe) return; - if (P->getAsPMDataManager()) - return; - StringMapEntry &Entry = - Probes.GetOrCreateValue(P->getPassName()); - DebugInfoProbe *&Probe = Entry.getValue(); - assert (Probe && "DebugInfoProbe is not initialized!"); - Probe->finalize(F); -} diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 773862d2030..28fbaa66784 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -14,7 +14,6 @@ #include "llvm/PassManagers.h" #include "llvm/PassManager.h" -#include "llvm/DebugInfoProbe.h" #include "llvm/Assembly/PrintModulePass.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/CommandLine.h" @@ -26,7 +25,6 @@ #include "llvm/Support/PassNameParser.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Mutex.h" -#include "llvm/ADT/StringMap.h" #include #include using namespace llvm; @@ -421,20 +419,6 @@ char PassManagerImpl::ID = 0; namespace { -//===----------------------------------------------------------------------===// -// DebugInfoProbe - -static DebugInfoProbeInfo *TheDebugProbe; -static void createDebugInfoProbe() { - if (TheDebugProbe) return; - - // Constructed the first time this is called. This guarantees that the - // object will be constructed, if -enable-debug-info-probe is set, - // before static globals, thus it will be destroyed before them. - static ManagedStatic DIP; - TheDebugProbe = &*DIP; -} - //===----------------------------------------------------------------------===// /// TimingInfo Class - This class is used to calculate information about the /// amount of time each pass takes to execute. This only happens when @@ -1440,7 +1424,6 @@ void FunctionPassManagerImpl::releaseMemoryOnTheFly() { bool FunctionPassManagerImpl::run(Function &F) { bool Changed = false; TimingInfo::createTheTimeInfo(); - createDebugInfoProbe(); initializeAllAnalysisInfo(); for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index) @@ -1488,16 +1471,13 @@ bool FPPassManager::runOnFunction(Function &F) { dumpRequiredSet(FP); initializeAnalysisImpl(FP); - if (TheDebugProbe) - TheDebugProbe->initialize(FP, F); + { PassManagerPrettyStackEntry X(FP, F); TimeRegion PassTimer(getPassTimer(FP)); LocalChanged |= FP->runOnFunction(F); } - if (TheDebugProbe) - TheDebugProbe->finalize(FP, F); Changed |= LocalChanged; if (LocalChanged) @@ -1647,7 +1627,6 @@ Pass* MPPassManager::getOnTheFlyPass(Pass *MP, AnalysisID PI, Function &F){ bool PassManagerImpl::run(Module &M) { bool Changed = false; TimingInfo::createTheTimeInfo(); - createDebugInfoProbe(); dumpArguments(); dumpPasses();