diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2018-06-22 05:33:57 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2018-06-22 05:33:57 +0000 |
| commit | aa5f4d2e23d34ac08cb7eb0f8810cc9db4760f3a (patch) | |
| tree | 32995cfb3509dd029317810a8d385ae038ec2823 /llvm/lib/Transforms | |
| parent | 6af73076505d9a845740c99b0fb89898dab36797 (diff) | |
| download | bcm5719-llvm-aa5f4d2e23d34ac08cb7eb0f8810cc9db4760f3a.tar.gz bcm5719-llvm-aa5f4d2e23d34ac08cb7eb0f8810cc9db4760f3a.zip | |
Revert r335306 (and r335314) - the Call Graph Profile pass.
This is the first pass in the main pipeline to use the legacy PM's
ability to run function analyses "on demand". Unfortunately, it turns
out there are bugs in that somewhat-hacky approach. At the very least,
it leaks memory and doesn't support -debug-pass=Structure. Unclear if
there are larger issues or not, but this should get the sanitizer bots
back to green by fixing the memory leaks.
llvm-svn: 335320
Diffstat (limited to 'llvm/lib/Transforms')
4 files changed, 0 insertions, 114 deletions
diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index defb54e19bf..a2559bc70b1 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -694,8 +694,6 @@ void PassManagerBuilder::populateModulePassManager( MPM.add(createConstantMergePass()); // Merge dup global constants } - MPM.add(createCGProfilePass()); - if (MergeFunctions) MPM.add(createMergeFunctionsPass()); diff --git a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp deleted file mode 100644 index cb1fcb21425..00000000000 --- a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp +++ /dev/null @@ -1,110 +0,0 @@ -//===-- CGProfile.cpp -----------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/ADT/MapVector.h" -#include "llvm/Analysis/BlockFrequencyInfo.h" -#include "llvm/Analysis/BranchProbabilityInfo.h" -#include "llvm/IR/Constants.h" -#include "llvm/IR/Instructions.h" -#include "llvm/IR/MDBuilder.h" -#include "llvm/IR/PassManager.h" -#include "llvm/Transforms/Instrumentation.h" - -#include <array> - -using namespace llvm; - -class CGProfilePass : public ModulePass { -public: - static char ID; - - CGProfilePass() : ModulePass(ID) { - initializeCGProfilePassPass(*PassRegistry::getPassRegistry()); - } - - StringRef getPassName() const override { return "CGProfilePass"; } - -private: - bool runOnModule(Module &M) override; - bool addModuleFlags( - Module &M, - MapVector<std::pair<Function *, Function *>, uint64_t> &Counts) const; - - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.addRequired<BlockFrequencyInfoWrapperPass>(); - AU.addRequired<BranchProbabilityInfoWrapperPass>(); - } -}; - -bool CGProfilePass::runOnModule(Module &M) { - if (skipModule(M)) - return false; - - MapVector<std::pair<Function *, Function *>, uint64_t> Counts; - - for (auto &F : M) { - if (F.isDeclaration()) - continue; - getAnalysis<BranchProbabilityInfoWrapperPass>(F).getBPI(); - auto &BFI = getAnalysis<BlockFrequencyInfoWrapperPass>(F).getBFI(); - for (const auto &BB : F) { - Optional<uint64_t> BBCount = BFI.getBlockProfileCount(&BB); - if (!BBCount) - continue; - for (const auto &I : BB) { - auto *CI = dyn_cast<CallInst>(&I); - if (!CI) - continue; - Function *CalledF = CI->getCalledFunction(); - if (!CalledF || CalledF->isIntrinsic()) - continue; - - uint64_t &Count = Counts[std::make_pair(&F, CalledF)]; - Count = SaturatingAdd(Count, *BBCount); - } - } - } - - return addModuleFlags(M, Counts); -} - -bool CGProfilePass::addModuleFlags( - Module &M, - MapVector<std::pair<Function *, Function *>, uint64_t> &Counts) const { - if (Counts.empty()) - return false; - - LLVMContext &Context = M.getContext(); - MDBuilder MDB(Context); - std::vector<Metadata *> Nodes; - - for (auto E : Counts) { - SmallVector<Metadata *, 3> Vals; - Vals.push_back(ValueAsMetadata::get(E.first.first)); - Vals.push_back(ValueAsMetadata::get(E.first.second)); - Vals.push_back(MDB.createConstant( - ConstantInt::get(Type::getInt64Ty(Context), E.second))); - Nodes.push_back(MDNode::get(Context, Vals)); - } - - M.addModuleFlag(Module::Append, "CG Profile", MDNode::get(Context, Nodes)); - return true; -} - -char CGProfilePass::ID = 0; -INITIALIZE_PASS_BEGIN(CGProfilePass, "cg-profile", - "Generate profile information from the call graph.", - false, false) -INITIALIZE_PASS_DEPENDENCY(BlockFrequencyInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(BranchProbabilityInfoWrapperPass) -INITIALIZE_PASS_END(CGProfilePass, "cg-profile", - "Generate profile information from the call graph.", false, - false) - -ModulePass *llvm::createCGProfilePass() { return new CGProfilePass(); } diff --git a/llvm/lib/Transforms/Instrumentation/CMakeLists.txt b/llvm/lib/Transforms/Instrumentation/CMakeLists.txt index 5d008482319..66fdcb3ccc4 100644 --- a/llvm/lib/Transforms/Instrumentation/CMakeLists.txt +++ b/llvm/lib/Transforms/Instrumentation/CMakeLists.txt @@ -1,7 +1,6 @@ add_llvm_library(LLVMInstrumentation AddressSanitizer.cpp BoundsChecking.cpp - CGProfile.cpp DataFlowSanitizer.cpp GCOVProfiling.cpp MemorySanitizer.cpp diff --git a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp index fbd651f3f20..8e9eea96ced 100644 --- a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp @@ -60,7 +60,6 @@ void llvm::initializeInstrumentation(PassRegistry &Registry) { initializeAddressSanitizerModulePass(Registry); initializeBoundsCheckingLegacyPassPass(Registry); initializeGCOVProfilerLegacyPassPass(Registry); - initializeCGProfilePassPass(Registry); initializePGOInstrumentationGenLegacyPassPass(Registry); initializePGOInstrumentationUseLegacyPassPass(Registry); initializePGOIndirectCallPromotionLegacyPassPass(Registry); |

