mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 18:16:06 +00:00
[Passes] Remove some legacy printer passes
MemDepPrinter doesn't have a new PM equivalent, but MemDep is soft deprecated anyway and adding one should be easy if somebody wants to.
This commit is contained in:
parent
1ebad216ef
commit
eb3d21be37
@ -798,7 +798,6 @@ public:
|
||||
|
||||
protected:
|
||||
// Used by Memory SSA dumpers and wrapper pass
|
||||
friend class MemorySSAPrinterLegacyPass;
|
||||
friend class MemorySSAUpdater;
|
||||
|
||||
void verifyOrderingDominationAndDefUses(
|
||||
@ -919,18 +918,6 @@ protected:
|
||||
AliasAnalysis &AA);
|
||||
};
|
||||
|
||||
// This pass does eager building and then printing of MemorySSA. It is used by
|
||||
// the tests to be able to build, dump, and verify Memory SSA.
|
||||
class MemorySSAPrinterLegacyPass : public FunctionPass {
|
||||
public:
|
||||
MemorySSAPrinterLegacyPass();
|
||||
|
||||
bool runOnFunction(Function &) override;
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
||||
|
||||
static char ID;
|
||||
};
|
||||
|
||||
/// An analysis that produces \c MemorySSA for a function.
|
||||
///
|
||||
class MemorySSAAnalysis : public AnalysisInfoMixin<MemorySSAAnalysis> {
|
||||
|
@ -58,39 +58,6 @@ namespace llvm {
|
||||
// in a function and builds the region hierarchy.
|
||||
//
|
||||
FunctionPass *createRegionInfoPass();
|
||||
|
||||
// Print module-level debug info metadata in human-readable form.
|
||||
ModulePass *createModuleDebugInfoPrinterPass();
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
//
|
||||
// createMemDepPrinter - This pass exhaustively collects all memdep
|
||||
// information and prints it with -analyze.
|
||||
//
|
||||
FunctionPass *createMemDepPrinter();
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
//
|
||||
// createMemDerefPrinter - This pass collects memory dereferenceability
|
||||
// information and prints it with -analyze.
|
||||
//
|
||||
FunctionPass *createMemDerefPrinter();
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
//
|
||||
// createMustExecutePrinter - This pass collects information about which
|
||||
// instructions within a loop are guaranteed to execute if the loop header is
|
||||
// entered and prints it with -analyze.
|
||||
//
|
||||
FunctionPass *createMustExecutePrinter();
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
//
|
||||
// createMustBeExecutedContextPrinter - This pass prints information about which
|
||||
// instructions are guaranteed to execute together (run with -analyze).
|
||||
//
|
||||
ModulePass *createMustBeExecutedContextPrinter();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -237,18 +237,12 @@ void initializeMachineTraceMetricsPass(PassRegistry&);
|
||||
void initializeMachineUniformityInfoPrinterPassPass(PassRegistry &);
|
||||
void initializeMachineUniformityAnalysisPassPass(PassRegistry &);
|
||||
void initializeMachineVerifierPassPass(PassRegistry&);
|
||||
void initializeMemDepPrinterPass(PassRegistry&);
|
||||
void initializeMemDerefPrinterPass(PassRegistry&);
|
||||
void initializeMemoryDependenceWrapperPassPass(PassRegistry&);
|
||||
void initializeMemorySSAPrinterLegacyPassPass(PassRegistry&);
|
||||
void initializeMemorySSAWrapperPassPass(PassRegistry&);
|
||||
void initializeMergeICmpsLegacyPassPass(PassRegistry &);
|
||||
void initializeMergedLoadStoreMotionLegacyPassPass(PassRegistry&);
|
||||
void initializeModuleDebugInfoLegacyPrinterPass(PassRegistry &);
|
||||
void initializeModuleSummaryIndexWrapperPassPass(PassRegistry&);
|
||||
void initializeModuloScheduleTestPass(PassRegistry&);
|
||||
void initializeMustExecutePrinterPass(PassRegistry&);
|
||||
void initializeMustBeExecutedContextPrinterPass(PassRegistry&);
|
||||
void initializeNaryReassociateLegacyPassPass(PassRegistry&);
|
||||
void initializeObjCARCContractLegacyPassPass(PassRegistry &);
|
||||
void initializeOptimizationRemarkEmitterWrapperPassPass(PassRegistry&);
|
||||
|
@ -146,10 +146,8 @@ namespace {
|
||||
llvm::raw_string_ostream os(buf);
|
||||
(void) llvm::createPrintModulePass(os);
|
||||
(void) llvm::createPrintFunctionPass(os);
|
||||
(void) llvm::createModuleDebugInfoPrinterPass();
|
||||
(void) llvm::createSinkingPass();
|
||||
(void) llvm::createLowerAtomicPass();
|
||||
(void) llvm::createMemDepPrinter();
|
||||
(void) llvm::createLoadStoreVectorizerPass();
|
||||
(void) llvm::createPartiallyInlineLibCallsPass();
|
||||
(void) llvm::createScalarizerPass();
|
||||
@ -158,9 +156,6 @@ namespace {
|
||||
(void) llvm::createSpeculativeExecutionIfHasBranchDivergencePass();
|
||||
(void) llvm::createRewriteSymbolsPass();
|
||||
(void) llvm::createStraightLineStrengthReducePass();
|
||||
(void) llvm::createMemDerefPrinter();
|
||||
(void) llvm::createMustExecutePrinter();
|
||||
(void) llvm::createMustBeExecutedContextPrinter();
|
||||
(void)llvm::createScalarizeMaskedMemIntrinLegacyPass();
|
||||
(void) llvm::createHardwareLoopsLegacyPass();
|
||||
(void) llvm::createUnifyLoopExitsPass();
|
||||
|
@ -54,13 +54,8 @@ void llvm::initializeAnalysis(PassRegistry &Registry) {
|
||||
initializeLazyValueInfoWrapperPassPass(Registry);
|
||||
initializeLazyValueInfoPrinterPass(Registry);
|
||||
initializeLoopInfoWrapperPassPass(Registry);
|
||||
initializeMemDepPrinterPass(Registry);
|
||||
initializeMemDerefPrinterPass(Registry);
|
||||
initializeMemoryDependenceWrapperPassPass(Registry);
|
||||
initializeModuleDebugInfoLegacyPrinterPass(Registry);
|
||||
initializeModuleSummaryIndexWrapperPassPass(Registry);
|
||||
initializeMustExecutePrinterPass(Registry);
|
||||
initializeMustBeExecutedContextPrinterPass(Registry);
|
||||
initializeOptimizationRemarkEmitterWrapperPassPass(Registry);
|
||||
initializePhiValuesWrapperPassPass(Registry);
|
||||
initializePostDominatorTreeWrapperPassPass(Registry);
|
||||
@ -78,7 +73,6 @@ void llvm::initializeAnalysis(PassRegistry &Registry) {
|
||||
initializeScopedNoAliasAAWrapperPassPass(Registry);
|
||||
initializeLCSSAVerificationPassPass(Registry);
|
||||
initializeMemorySSAWrapperPassPass(Registry);
|
||||
initializeMemorySSAPrinterLegacyPassPass(Registry);
|
||||
}
|
||||
|
||||
LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
|
||||
|
@ -92,7 +92,6 @@ add_llvm_component_library(LLVMAnalysis
|
||||
LoopInfo.cpp
|
||||
LoopPass.cpp
|
||||
MLInlineAdvisor.cpp
|
||||
MemDepPrinter.cpp
|
||||
MemDerefPrinter.cpp
|
||||
MemoryBuiltins.cpp
|
||||
MemoryDependenceAnalysis.cpp
|
||||
|
@ -1,164 +0,0 @@
|
||||
//===- MemDepPrinter.cpp - Printer for MemoryDependenceAnalysis -----------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
|
||||
#include "llvm/Analysis/Passes.h"
|
||||
#include "llvm/IR/InstIterator.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/InitializePasses.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
struct MemDepPrinter : public FunctionPass {
|
||||
const Function *F;
|
||||
|
||||
enum DepType {
|
||||
Clobber = 0,
|
||||
Def,
|
||||
NonFuncLocal,
|
||||
Unknown
|
||||
};
|
||||
|
||||
static const char *const DepTypeStr[];
|
||||
|
||||
typedef PointerIntPair<const Instruction *, 2, DepType> InstTypePair;
|
||||
typedef std::pair<InstTypePair, const BasicBlock *> Dep;
|
||||
typedef SmallSetVector<Dep, 4> DepSet;
|
||||
typedef DenseMap<const Instruction *, DepSet> DepSetMap;
|
||||
DepSetMap Deps;
|
||||
|
||||
static char ID; // Pass identifcation, replacement for typeid
|
||||
MemDepPrinter() : FunctionPass(ID) {
|
||||
initializeMemDepPrinterPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
bool runOnFunction(Function &F) override;
|
||||
|
||||
void print(raw_ostream &OS, const Module * = nullptr) const override;
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.addRequiredTransitive<AAResultsWrapperPass>();
|
||||
AU.addRequiredTransitive<MemoryDependenceWrapperPass>();
|
||||
AU.setPreservesAll();
|
||||
}
|
||||
|
||||
void releaseMemory() override {
|
||||
Deps.clear();
|
||||
F = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
static InstTypePair getInstTypePair(MemDepResult dep) {
|
||||
if (dep.isClobber())
|
||||
return InstTypePair(dep.getInst(), Clobber);
|
||||
if (dep.isDef())
|
||||
return InstTypePair(dep.getInst(), Def);
|
||||
if (dep.isNonFuncLocal())
|
||||
return InstTypePair(dep.getInst(), NonFuncLocal);
|
||||
assert(dep.isUnknown() && "unexpected dependence type");
|
||||
return InstTypePair(dep.getInst(), Unknown);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
char MemDepPrinter::ID = 0;
|
||||
INITIALIZE_PASS_BEGIN(MemDepPrinter, "print-memdeps",
|
||||
"Print MemDeps of function", false, true)
|
||||
INITIALIZE_PASS_DEPENDENCY(MemoryDependenceWrapperPass)
|
||||
INITIALIZE_PASS_END(MemDepPrinter, "print-memdeps",
|
||||
"Print MemDeps of function", false, true)
|
||||
|
||||
FunctionPass *llvm::createMemDepPrinter() {
|
||||
return new MemDepPrinter();
|
||||
}
|
||||
|
||||
const char *const MemDepPrinter::DepTypeStr[]
|
||||
= {"Clobber", "Def", "NonFuncLocal", "Unknown"};
|
||||
|
||||
bool MemDepPrinter::runOnFunction(Function &F) {
|
||||
this->F = &F;
|
||||
MemoryDependenceResults &MDA = getAnalysis<MemoryDependenceWrapperPass>().getMemDep();
|
||||
|
||||
// All this code uses non-const interfaces because MemDep is not
|
||||
// const-friendly, though nothing is actually modified.
|
||||
for (auto &I : instructions(F)) {
|
||||
Instruction *Inst = &I;
|
||||
|
||||
if (!Inst->mayReadFromMemory() && !Inst->mayWriteToMemory())
|
||||
continue;
|
||||
|
||||
MemDepResult Res = MDA.getDependency(Inst);
|
||||
if (!Res.isNonLocal()) {
|
||||
Deps[Inst].insert(std::make_pair(getInstTypePair(Res),
|
||||
static_cast<BasicBlock *>(nullptr)));
|
||||
} else if (auto *Call = dyn_cast<CallBase>(Inst)) {
|
||||
const MemoryDependenceResults::NonLocalDepInfo &NLDI =
|
||||
MDA.getNonLocalCallDependency(Call);
|
||||
|
||||
DepSet &InstDeps = Deps[Inst];
|
||||
for (const NonLocalDepEntry &I : NLDI) {
|
||||
const MemDepResult &Res = I.getResult();
|
||||
InstDeps.insert(std::make_pair(getInstTypePair(Res), I.getBB()));
|
||||
}
|
||||
} else {
|
||||
SmallVector<NonLocalDepResult, 4> NLDI;
|
||||
assert( (isa<LoadInst>(Inst) || isa<StoreInst>(Inst) ||
|
||||
isa<VAArgInst>(Inst)) && "Unknown memory instruction!");
|
||||
MDA.getNonLocalPointerDependency(Inst, NLDI);
|
||||
|
||||
DepSet &InstDeps = Deps[Inst];
|
||||
for (const NonLocalDepResult &I : NLDI) {
|
||||
const MemDepResult &Res = I.getResult();
|
||||
InstDeps.insert(std::make_pair(getInstTypePair(Res), I.getBB()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void MemDepPrinter::print(raw_ostream &OS, const Module *M) const {
|
||||
for (const auto &I : instructions(*F)) {
|
||||
const Instruction *Inst = &I;
|
||||
|
||||
DepSetMap::const_iterator DI = Deps.find(Inst);
|
||||
if (DI == Deps.end())
|
||||
continue;
|
||||
|
||||
const DepSet &InstDeps = DI->second;
|
||||
|
||||
for (const auto &I : InstDeps) {
|
||||
const Instruction *DepInst = I.first.getPointer();
|
||||
DepType type = I.first.getInt();
|
||||
const BasicBlock *DepBB = I.second;
|
||||
|
||||
OS << " ";
|
||||
OS << DepTypeStr[type];
|
||||
if (DepBB) {
|
||||
OS << " in block ";
|
||||
DepBB->printAsOperand(OS, /*PrintType=*/false, M);
|
||||
}
|
||||
if (DepInst) {
|
||||
OS << " from: ";
|
||||
DepInst->print(OS);
|
||||
}
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
Inst->print(OS);
|
||||
OS << "\n\n";
|
||||
}
|
||||
}
|
@ -18,65 +18,6 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
struct MemDerefPrinter : public FunctionPass {
|
||||
SmallVector<Value *, 4> Deref;
|
||||
SmallPtrSet<Value *, 4> DerefAndAligned;
|
||||
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
MemDerefPrinter() : FunctionPass(ID) {
|
||||
initializeMemDerefPrinterPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.setPreservesAll();
|
||||
}
|
||||
bool runOnFunction(Function &F) override;
|
||||
void print(raw_ostream &OS, const Module * = nullptr) const override;
|
||||
void releaseMemory() override {
|
||||
Deref.clear();
|
||||
DerefAndAligned.clear();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
char MemDerefPrinter::ID = 0;
|
||||
INITIALIZE_PASS_BEGIN(MemDerefPrinter, "print-memderefs",
|
||||
"Memory Dereferenciblity of pointers in function", false, true)
|
||||
INITIALIZE_PASS_END(MemDerefPrinter, "print-memderefs",
|
||||
"Memory Dereferenciblity of pointers in function", false, true)
|
||||
|
||||
FunctionPass *llvm::createMemDerefPrinter() {
|
||||
return new MemDerefPrinter();
|
||||
}
|
||||
|
||||
bool MemDerefPrinter::runOnFunction(Function &F) {
|
||||
const DataLayout &DL = F.getParent()->getDataLayout();
|
||||
for (auto &I: instructions(F)) {
|
||||
if (LoadInst *LI = dyn_cast<LoadInst>(&I)) {
|
||||
Value *PO = LI->getPointerOperand();
|
||||
if (isDereferenceablePointer(PO, LI->getType(), DL))
|
||||
Deref.push_back(PO);
|
||||
if (isDereferenceableAndAlignedPointer(PO, LI->getType(), LI->getAlign(),
|
||||
DL))
|
||||
DerefAndAligned.insert(PO);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MemDerefPrinter::print(raw_ostream &OS, const Module *M) const {
|
||||
OS << "The following are dereferenceable:\n";
|
||||
for (Value *V: Deref) {
|
||||
OS << " ";
|
||||
V->print(OS);
|
||||
if (DerefAndAligned.count(V))
|
||||
OS << "\t(aligned)";
|
||||
else
|
||||
OS << "\t(unaligned)";
|
||||
OS << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
PreservedAnalyses MemDerefPrinterPass::run(Function &F,
|
||||
FunctionAnalysisManager &AM) {
|
||||
OS << "Memory Dereferencibility of pointers in function '" << F.getName()
|
||||
|
@ -71,12 +71,6 @@ INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
|
||||
INITIALIZE_PASS_END(MemorySSAWrapperPass, "memoryssa", "Memory SSA", false,
|
||||
true)
|
||||
|
||||
INITIALIZE_PASS_BEGIN(MemorySSAPrinterLegacyPass, "print-memoryssa",
|
||||
"Memory SSA Printer", false, false)
|
||||
INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass)
|
||||
INITIALIZE_PASS_END(MemorySSAPrinterLegacyPass, "print-memoryssa",
|
||||
"Memory SSA Printer", false, false)
|
||||
|
||||
static cl::opt<unsigned> MaxCheckLimit(
|
||||
"memssa-check-limit", cl::Hidden, cl::init(100),
|
||||
cl::desc("The maximum number of stores/phis MemorySSA"
|
||||
@ -2219,17 +2213,6 @@ void MemoryAccess::dump() const {
|
||||
#endif
|
||||
}
|
||||
|
||||
char MemorySSAPrinterLegacyPass::ID = 0;
|
||||
|
||||
MemorySSAPrinterLegacyPass::MemorySSAPrinterLegacyPass() : FunctionPass(ID) {
|
||||
initializeMemorySSAPrinterLegacyPassPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
void MemorySSAPrinterLegacyPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.setPreservesAll();
|
||||
AU.addRequired<MemorySSAWrapperPass>();
|
||||
}
|
||||
|
||||
class DOTFuncMSSAInfo {
|
||||
private:
|
||||
const Function &F;
|
||||
@ -2314,20 +2297,6 @@ struct DOTGraphTraits<DOTFuncMSSAInfo *> : public DefaultDOTGraphTraits {
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
bool MemorySSAPrinterLegacyPass::runOnFunction(Function &F) {
|
||||
auto &MSSA = getAnalysis<MemorySSAWrapperPass>().getMSSA();
|
||||
MSSA.ensureOptimizedUses();
|
||||
if (DotCFGMSSA != "") {
|
||||
DOTFuncMSSAInfo CFGInfo(F, MSSA);
|
||||
WriteGraph(&CFGInfo, "", false, "MSSA", DotCFGMSSA);
|
||||
} else
|
||||
MSSA.print(dbgs());
|
||||
|
||||
if (VerifyMemorySSA)
|
||||
MSSA.verifyMemorySSA();
|
||||
return false;
|
||||
}
|
||||
|
||||
AnalysisKey MemorySSAAnalysis::Key;
|
||||
|
||||
MemorySSAAnalysis::Result MemorySSAAnalysis::run(Function &F,
|
||||
|
@ -25,39 +25,6 @@
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
class ModuleDebugInfoLegacyPrinter : public ModulePass {
|
||||
DebugInfoFinder Finder;
|
||||
|
||||
public:
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
ModuleDebugInfoLegacyPrinter() : ModulePass(ID) {
|
||||
initializeModuleDebugInfoLegacyPrinterPass(
|
||||
*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
bool runOnModule(Module &M) override;
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.setPreservesAll();
|
||||
}
|
||||
void print(raw_ostream &O, const Module *M) const override;
|
||||
};
|
||||
}
|
||||
|
||||
char ModuleDebugInfoLegacyPrinter::ID = 0;
|
||||
INITIALIZE_PASS(ModuleDebugInfoLegacyPrinter, "module-debuginfo",
|
||||
"Decodes module-level debug info", false, true)
|
||||
|
||||
ModulePass *llvm::createModuleDebugInfoPrinterPass() {
|
||||
return new ModuleDebugInfoLegacyPrinter();
|
||||
}
|
||||
|
||||
bool ModuleDebugInfoLegacyPrinter::runOnModule(Module &M) {
|
||||
Finder.processModule(M);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void printFile(raw_ostream &O, StringRef Filename, StringRef Directory,
|
||||
unsigned Line = 0) {
|
||||
if (Filename.empty())
|
||||
@ -132,11 +99,6 @@ static void printModuleDebugInfo(raw_ostream &O, const Module *M,
|
||||
}
|
||||
}
|
||||
|
||||
void ModuleDebugInfoLegacyPrinter::print(raw_ostream &O,
|
||||
const Module *M) const {
|
||||
printModuleDebugInfo(O, M, Finder);
|
||||
}
|
||||
|
||||
ModuleDebugInfoPrinterPass::ModuleDebugInfoPrinterPass(raw_ostream &OS)
|
||||
: OS(OS) {}
|
||||
|
||||
|
@ -309,101 +309,6 @@ bool ICFLoopSafetyInfo::doesNotWriteMemoryBefore(const Instruction &I,
|
||||
doesNotWriteMemoryBefore(BB, CurLoop);
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct MustExecutePrinter : public FunctionPass {
|
||||
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
MustExecutePrinter() : FunctionPass(ID) {
|
||||
initializeMustExecutePrinterPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.setPreservesAll();
|
||||
AU.addRequired<DominatorTreeWrapperPass>();
|
||||
AU.addRequired<LoopInfoWrapperPass>();
|
||||
}
|
||||
bool runOnFunction(Function &F) override;
|
||||
};
|
||||
struct MustBeExecutedContextPrinter : public ModulePass {
|
||||
static char ID;
|
||||
|
||||
MustBeExecutedContextPrinter() : ModulePass(ID) {
|
||||
initializeMustBeExecutedContextPrinterPass(
|
||||
*PassRegistry::getPassRegistry());
|
||||
}
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.setPreservesAll();
|
||||
}
|
||||
bool runOnModule(Module &M) override;
|
||||
};
|
||||
}
|
||||
|
||||
char MustExecutePrinter::ID = 0;
|
||||
INITIALIZE_PASS_BEGIN(MustExecutePrinter, "print-mustexecute",
|
||||
"Instructions which execute on loop entry", false, true)
|
||||
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
|
||||
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
|
||||
INITIALIZE_PASS_END(MustExecutePrinter, "print-mustexecute",
|
||||
"Instructions which execute on loop entry", false, true)
|
||||
|
||||
FunctionPass *llvm::createMustExecutePrinter() {
|
||||
return new MustExecutePrinter();
|
||||
}
|
||||
|
||||
char MustBeExecutedContextPrinter::ID = 0;
|
||||
INITIALIZE_PASS_BEGIN(MustBeExecutedContextPrinter,
|
||||
"print-must-be-executed-contexts",
|
||||
"print the must-be-executed-context for all instructions",
|
||||
false, true)
|
||||
INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass)
|
||||
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
|
||||
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
|
||||
INITIALIZE_PASS_END(MustBeExecutedContextPrinter,
|
||||
"print-must-be-executed-contexts",
|
||||
"print the must-be-executed-context for all instructions",
|
||||
false, true)
|
||||
|
||||
ModulePass *llvm::createMustBeExecutedContextPrinter() {
|
||||
return new MustBeExecutedContextPrinter();
|
||||
}
|
||||
|
||||
bool MustBeExecutedContextPrinter::runOnModule(Module &M) {
|
||||
// We provide non-PM analysis here because the old PM doesn't like to query
|
||||
// function passes from a module pass.
|
||||
SmallVector<std::unique_ptr<PostDominatorTree>, 8> PDTs;
|
||||
SmallVector<std::unique_ptr<DominatorTree>, 8> DTs;
|
||||
SmallVector<std::unique_ptr<LoopInfo>, 8> LIs;
|
||||
|
||||
GetterTy<LoopInfo> LIGetter = [&](const Function &F) {
|
||||
DTs.push_back(std::make_unique<DominatorTree>(const_cast<Function &>(F)));
|
||||
LIs.push_back(std::make_unique<LoopInfo>(*DTs.back()));
|
||||
return LIs.back().get();
|
||||
};
|
||||
GetterTy<DominatorTree> DTGetter = [&](const Function &F) {
|
||||
DTs.push_back(std::make_unique<DominatorTree>(const_cast<Function&>(F)));
|
||||
return DTs.back().get();
|
||||
};
|
||||
GetterTy<PostDominatorTree> PDTGetter = [&](const Function &F) {
|
||||
PDTs.push_back(
|
||||
std::make_unique<PostDominatorTree>(const_cast<Function &>(F)));
|
||||
return PDTs.back().get();
|
||||
};
|
||||
MustBeExecutedContextExplorer Explorer(
|
||||
/* ExploreInterBlock */ true,
|
||||
/* ExploreCFGForward */ true,
|
||||
/* ExploreCFGBackward */ true, LIGetter, DTGetter, PDTGetter);
|
||||
|
||||
for (Function &F : M) {
|
||||
for (Instruction &I : instructions(F)) {
|
||||
dbgs() << "-- Explore context of: " << I << "\n";
|
||||
for (const Instruction *CI : Explorer.range(&I))
|
||||
dbgs() << " [F: " << CI->getFunction()->getName() << "] " << *CI
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool isMustExecuteIn(const Instruction &I, Loop *L, DominatorTree *DT) {
|
||||
// TODO: merge these two routines. For the moment, we display the best
|
||||
// result obtained by *either* implementation. This is a bit unfair since no
|
||||
@ -467,16 +372,6 @@ public:
|
||||
};
|
||||
} // namespace
|
||||
|
||||
bool MustExecutePrinter::runOnFunction(Function &F) {
|
||||
auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
|
||||
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
||||
|
||||
MustExecuteAnnotatedWriter Writer(F, DT, LI);
|
||||
F.print(dbgs(), &Writer);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Return true if \p L might be an endless loop.
|
||||
static bool maybeEndlessLoop(const Loop &L) {
|
||||
if (L.getHeader()->getParent()->hasFnAttribute(Attribute::WillReturn))
|
||||
|
@ -81,7 +81,6 @@ static_library("Analysis") {
|
||||
"LoopPass.cpp",
|
||||
"LoopUnrollAnalyzer.cpp",
|
||||
"MLInlineAdvisor.cpp",
|
||||
"MemDepPrinter.cpp",
|
||||
"MemDerefPrinter.cpp",
|
||||
"MemoryBuiltins.cpp",
|
||||
"MemoryDependenceAnalysis.cpp",
|
||||
|
Loading…
x
Reference in New Issue
Block a user