[llvm] r347610 - [stack-safety] Empty local passes for Stack Safety Global Analysis
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 26 15:05:48 PST 2018
Author: vitalybuka
Date: Mon Nov 26 15:05:48 2018
New Revision: 347610
URL: http://llvm.org/viewvc/llvm-project?rev=347610&view=rev
Log:
[stack-safety] Empty local passes for Stack Safety Global Analysis
Reviewers: eugenis, vlad.tsyrklevich
Subscribers: hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D54541
Modified:
llvm/trunk/include/llvm/Analysis/StackSafetyAnalysis.h
llvm/trunk/include/llvm/InitializePasses.h
llvm/trunk/lib/Analysis/Analysis.cpp
llvm/trunk/lib/Analysis/StackSafetyAnalysis.cpp
llvm/trunk/lib/Passes/PassRegistry.def
llvm/trunk/test/Analysis/StackSafetyAnalysis/local.ll
Modified: llvm/trunk/include/llvm/Analysis/StackSafetyAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/StackSafetyAnalysis.h?rev=347610&r1=347609&r2=347610&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/StackSafetyAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/StackSafetyAnalysis.h Mon Nov 26 15:05:48 2018
@@ -73,6 +73,48 @@ public:
bool runOnFunction(Function &F) override;
};
+using StackSafetyGlobalInfo = std::map<const GlobalValue *, StackSafetyInfo>;
+
+/// This pass performs the global (interprocedural) stack safety analysis (new
+/// pass manager).
+class StackSafetyGlobalAnalysis
+ : public AnalysisInfoMixin<StackSafetyGlobalAnalysis> {
+ friend AnalysisInfoMixin<StackSafetyGlobalAnalysis>;
+ static AnalysisKey Key;
+
+public:
+ using Result = StackSafetyGlobalInfo;
+ Result run(Module &M, ModuleAnalysisManager &AM);
+};
+
+/// Printer pass for the \c StackSafetyGlobalAnalysis results.
+class StackSafetyGlobalPrinterPass
+ : public PassInfoMixin<StackSafetyGlobalPrinterPass> {
+ raw_ostream &OS;
+
+public:
+ explicit StackSafetyGlobalPrinterPass(raw_ostream &OS) : OS(OS) {}
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+/// This pass performs the global (interprocedural) stack safety analysis
+/// (legacy pass manager).
+class StackSafetyGlobalInfoWrapperPass : public ModulePass {
+ StackSafetyGlobalInfo SSI;
+
+public:
+ static char ID;
+
+ StackSafetyGlobalInfoWrapperPass();
+
+ const StackSafetyGlobalInfo &getResult() const { return SSI; }
+
+ void print(raw_ostream &O, const Module *M) const override;
+ void getAnalysisUsage(AnalysisUsage &AU) const override;
+
+ bool runOnModule(Module &M) override;
+};
+
} // end namespace llvm
#endif // LLVM_ANALYSIS_STACKSAFETYANALYSIS_H
Modified: llvm/trunk/include/llvm/InitializePasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=347610&r1=347609&r2=347610&view=diff
==============================================================================
--- llvm/trunk/include/llvm/InitializePasses.h (original)
+++ llvm/trunk/include/llvm/InitializePasses.h Mon Nov 26 15:05:48 2018
@@ -372,6 +372,7 @@ void initializeSpillPlacementPass(PassRe
void initializeStackColoringPass(PassRegistry&);
void initializeStackMapLivenessPass(PassRegistry&);
void initializeStackProtectorPass(PassRegistry&);
+void initializeStackSafetyGlobalInfoWrapperPassPass(PassRegistry &);
void initializeStackSafetyInfoWrapperPassPass(PassRegistry &);
void initializeStackSlotColoringPass(PassRegistry&);
void initializeStraightLineStrengthReducePass(PassRegistry&);
Modified: llvm/trunk/lib/Analysis/Analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Analysis.cpp?rev=347610&r1=347609&r2=347610&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/Analysis.cpp (original)
+++ llvm/trunk/lib/Analysis/Analysis.cpp Mon Nov 26 15:05:48 2018
@@ -77,6 +77,7 @@ void llvm::initializeAnalysis(PassRegist
initializeRegionOnlyPrinterPass(Registry);
initializeSCEVAAWrapperPassPass(Registry);
initializeScalarEvolutionWrapperPassPass(Registry);
+ initializeStackSafetyGlobalInfoWrapperPassPass(Registry);
initializeStackSafetyInfoWrapperPassPass(Registry);
initializeTargetTransformInfoWrapperPassPass(Registry);
initializeTypeBasedAAWrapperPassPass(Registry);
Modified: llvm/trunk/lib/Analysis/StackSafetyAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/StackSafetyAnalysis.cpp?rev=347610&r1=347609&r2=347610&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/StackSafetyAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/StackSafetyAnalysis.cpp Mon Nov 26 15:05:48 2018
@@ -373,6 +373,10 @@ StackSafetyInfo StackSafetyLocalAnalysis
return StackSafetyInfo(std::move(Info));
}
+void print(const StackSafetyGlobalInfo &SSI, raw_ostream &O, const Module &M) {
+ O << "Not Implemented\n";
+}
+
} // end anonymous namespace
StackSafetyInfo::StackSafetyInfo() = default;
@@ -423,6 +427,40 @@ bool StackSafetyInfoWrapperPass::runOnFu
return false;
}
+AnalysisKey StackSafetyGlobalAnalysis::Key;
+
+StackSafetyGlobalInfo
+StackSafetyGlobalAnalysis::run(Module &M, ModuleAnalysisManager &AM) {
+ return {};
+}
+
+PreservedAnalyses StackSafetyGlobalPrinterPass::run(Module &M,
+ ModuleAnalysisManager &AM) {
+ OS << "'Stack Safety Analysis' for module '" << M.getName() << "'\n";
+ print(AM.getResult<StackSafetyGlobalAnalysis>(M), OS, M);
+ return PreservedAnalyses::all();
+}
+
+char StackSafetyGlobalInfoWrapperPass::ID = 0;
+
+StackSafetyGlobalInfoWrapperPass::StackSafetyGlobalInfoWrapperPass()
+ : ModulePass(ID) {
+ initializeStackSafetyGlobalInfoWrapperPassPass(
+ *PassRegistry::getPassRegistry());
+}
+
+void StackSafetyGlobalInfoWrapperPass::print(raw_ostream &O,
+ const Module *M) const {
+ ::print(SSI, O, *M);
+}
+
+void StackSafetyGlobalInfoWrapperPass::getAnalysisUsage(
+ AnalysisUsage &AU) const {
+ AU.addRequired<StackSafetyInfoWrapperPass>();
+}
+
+bool StackSafetyGlobalInfoWrapperPass::runOnModule(Module &M) { return false; }
+
static const char LocalPassArg[] = "stack-safety-local";
static const char LocalPassName[] = "Stack Safety Local Analysis";
INITIALIZE_PASS_BEGIN(StackSafetyInfoWrapperPass, LocalPassArg, LocalPassName,
@@ -430,3 +468,10 @@ INITIALIZE_PASS_BEGIN(StackSafetyInfoWra
INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
INITIALIZE_PASS_END(StackSafetyInfoWrapperPass, LocalPassArg, LocalPassName,
false, true)
+
+static const char GlobalPassName[] = "Stack Safety Analysis";
+INITIALIZE_PASS_BEGIN(StackSafetyGlobalInfoWrapperPass, DEBUG_TYPE,
+ GlobalPassName, false, false)
+INITIALIZE_PASS_DEPENDENCY(StackSafetyInfoWrapperPass)
+INITIALIZE_PASS_END(StackSafetyGlobalInfoWrapperPass, DEBUG_TYPE,
+ GlobalPassName, false, false)
Modified: llvm/trunk/lib/Passes/PassRegistry.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Passes/PassRegistry.def?rev=347610&r1=347609&r2=347610&view=diff
==============================================================================
--- llvm/trunk/lib/Passes/PassRegistry.def (original)
+++ llvm/trunk/lib/Passes/PassRegistry.def Mon Nov 26 15:05:48 2018
@@ -24,6 +24,7 @@ MODULE_ANALYSIS("lcg", LazyCallGraphAnal
MODULE_ANALYSIS("module-summary", ModuleSummaryIndexAnalysis())
MODULE_ANALYSIS("no-op-module", NoOpModuleAnalysis())
MODULE_ANALYSIS("profile-summary", ProfileSummaryAnalysis())
+MODULE_ANALYSIS("stack-safety", StackSafetyGlobalAnalysis())
MODULE_ANALYSIS("targetlibinfo", TargetLibraryAnalysis())
MODULE_ANALYSIS("verify", VerifierAnalysis())
MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
@@ -71,6 +72,7 @@ MODULE_PASS("print-callgraph", CallGraph
MODULE_PASS("print", PrintModulePass(dbgs()))
MODULE_PASS("print-lcg", LazyCallGraphPrinterPass(dbgs()))
MODULE_PASS("print-lcg-dot", LazyCallGraphDOTPrinterPass(dbgs()))
+MODULE_PASS("print-stack-safety", StackSafetyGlobalPrinterPass(dbgs()))
MODULE_PASS("rewrite-statepoints-for-gc", RewriteStatepointsForGC())
MODULE_PASS("rewrite-symbols", RewriteSymbolPass())
MODULE_PASS("rpo-functionattrs", ReversePostOrderFunctionAttrsPass())
Modified: llvm/trunk/test/Analysis/StackSafetyAnalysis/local.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/StackSafetyAnalysis/local.ll?rev=347610&r1=347609&r2=347610&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/StackSafetyAnalysis/local.ll (original)
+++ llvm/trunk/test/Analysis/StackSafetyAnalysis/local.ll Mon Nov 26 15:05:48 2018
@@ -1,5 +1,9 @@
; RUN: opt -S -analyze -stack-safety-local < %s | FileCheck %s
; RUN: opt -S -passes="print<stack-safety-local>" -disable-output < %s 2>&1 | FileCheck %s
+; RUN: opt -S -analyze -stack-safety < %s | FileCheck %s --check-prefix=GLOBAL
+; RUN: opt -S -passes="print-stack-safety" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=GLOBAL
+
+; GLOBAL: Not Implemented
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
More information about the llvm-commits
mailing list