mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[stack-safety] Empty local passes for Stack Safety Local Analysis
Reviewers: eugenis, vlad.tsyrklevich Subscribers: mgorny, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D54502 llvm-svn: 347602
This commit is contained in:
parent
e5fe5c1654
commit
1d2c594b1b
64
include/llvm/Analysis/StackSafetyAnalysis.h
Normal file
64
include/llvm/Analysis/StackSafetyAnalysis.h
Normal file
@ -0,0 +1,64 @@
|
||||
//===- StackSafetyAnalysis.h - Stack memory safety analysis -----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Stack Safety Analysis detects allocas and arguments with safe access.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_ANALYSIS_STACKSAFETYANALYSIS_H
|
||||
#define LLVM_ANALYSIS_STACKSAFETYANALYSIS_H
|
||||
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/Pass.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class StackSafetyInfo {
|
||||
public:
|
||||
void print(raw_ostream &O) const;
|
||||
};
|
||||
|
||||
/// StackSafetyInfo wrapper for the new pass manager.
|
||||
class StackSafetyAnalysis : public AnalysisInfoMixin<StackSafetyAnalysis> {
|
||||
friend AnalysisInfoMixin<StackSafetyAnalysis>;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
using Result = StackSafetyInfo;
|
||||
StackSafetyInfo run(Function &F, FunctionAnalysisManager &AM);
|
||||
};
|
||||
|
||||
/// Printer pass for the \c StackSafetyAnalysis results.
|
||||
class StackSafetyPrinterPass : public PassInfoMixin<StackSafetyPrinterPass> {
|
||||
raw_ostream &OS;
|
||||
|
||||
public:
|
||||
explicit StackSafetyPrinterPass(raw_ostream &OS) : OS(OS) {}
|
||||
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
|
||||
};
|
||||
|
||||
/// StackSafetyInfo wrapper for the legacy pass manager
|
||||
class StackSafetyInfoWrapperPass : public FunctionPass {
|
||||
StackSafetyInfo SSI;
|
||||
|
||||
public:
|
||||
static char ID;
|
||||
StackSafetyInfoWrapperPass();
|
||||
|
||||
const StackSafetyInfo &getResult() const { return SSI; }
|
||||
|
||||
void print(raw_ostream &O, const Module *M) const override;
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
||||
|
||||
bool runOnFunction(Function &F) override;
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_ANALYSIS_STACKSAFETYANALYSIS_H
|
@ -372,6 +372,7 @@ void initializeSpillPlacementPass(PassRegistry&);
|
||||
void initializeStackColoringPass(PassRegistry&);
|
||||
void initializeStackMapLivenessPass(PassRegistry&);
|
||||
void initializeStackProtectorPass(PassRegistry&);
|
||||
void initializeStackSafetyInfoWrapperPassPass(PassRegistry &);
|
||||
void initializeStackSlotColoringPass(PassRegistry&);
|
||||
void initializeStraightLineStrengthReducePass(PassRegistry&);
|
||||
void initializeStripDeadDebugInfoPass(PassRegistry&);
|
||||
|
@ -77,6 +77,7 @@ void llvm::initializeAnalysis(PassRegistry &Registry) {
|
||||
initializeRegionOnlyPrinterPass(Registry);
|
||||
initializeSCEVAAWrapperPassPass(Registry);
|
||||
initializeScalarEvolutionWrapperPassPass(Registry);
|
||||
initializeStackSafetyInfoWrapperPassPass(Registry);
|
||||
initializeTargetTransformInfoWrapperPassPass(Registry);
|
||||
initializeTypeBasedAAWrapperPassPass(Registry);
|
||||
initializeScopedNoAliasAAWrapperPassPass(Registry);
|
||||
|
@ -81,6 +81,7 @@ add_llvm_library(LLVMAnalysis
|
||||
ScalarEvolutionAliasAnalysis.cpp
|
||||
ScalarEvolutionExpander.cpp
|
||||
ScalarEvolutionNormalization.cpp
|
||||
StackSafetyAnalysis.cpp
|
||||
SyncDependenceAnalysis.cpp
|
||||
SyntheticCountsUtils.cpp
|
||||
TargetLibraryInfo.cpp
|
||||
|
60
lib/Analysis/StackSafetyAnalysis.cpp
Normal file
60
lib/Analysis/StackSafetyAnalysis.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
//===- StackSafetyAnalysis.cpp - Stack memory safety analysis -------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Analysis/StackSafetyAnalysis.h"
|
||||
|
||||
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "stack-safety"
|
||||
|
||||
AnalysisKey StackSafetyAnalysis::Key;
|
||||
|
||||
void StackSafetyInfo::print(raw_ostream &O) const { O << "Not Implemented\n"; }
|
||||
|
||||
StackSafetyInfo StackSafetyAnalysis::run(Function &F,
|
||||
FunctionAnalysisManager &AM) {
|
||||
return StackSafetyInfo();
|
||||
}
|
||||
|
||||
PreservedAnalyses StackSafetyPrinterPass::run(Function &F,
|
||||
FunctionAnalysisManager &AM) {
|
||||
OS << "'Stack Safety Local Analysis' for function '" << F.getName() << "'\n";
|
||||
AM.getResult<StackSafetyAnalysis>(F).print(OS);
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
char StackSafetyInfoWrapperPass::ID = 0;
|
||||
|
||||
StackSafetyInfoWrapperPass::StackSafetyInfoWrapperPass() : FunctionPass(ID) {
|
||||
initializeStackSafetyInfoWrapperPassPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
void StackSafetyInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired<ScalarEvolutionWrapperPass>();
|
||||
AU.setPreservesAll();
|
||||
}
|
||||
|
||||
void StackSafetyInfoWrapperPass::print(raw_ostream &O, const Module *M) const {
|
||||
SSI.print(O);
|
||||
}
|
||||
|
||||
bool StackSafetyInfoWrapperPass::runOnFunction(Function &F) { return false; }
|
||||
|
||||
static const char LocalPassArg[] = "stack-safety-local";
|
||||
static const char LocalPassName[] = "Stack Safety Local Analysis";
|
||||
INITIALIZE_PASS_BEGIN(StackSafetyInfoWrapperPass, LocalPassArg, LocalPassName,
|
||||
false, true)
|
||||
INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
|
||||
INITIALIZE_PASS_END(StackSafetyInfoWrapperPass, LocalPassArg, LocalPassName,
|
||||
false, true)
|
@ -48,6 +48,7 @@
|
||||
#include "llvm/Analysis/ScalarEvolution.h"
|
||||
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
|
||||
#include "llvm/Analysis/ScopedNoAliasAA.h"
|
||||
#include "llvm/Analysis/StackSafetyAnalysis.h"
|
||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
#include "llvm/Analysis/TypeBasedAliasAnalysis.h"
|
||||
@ -62,7 +63,6 @@
|
||||
#include "llvm/Support/Regex.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h"
|
||||
#include "llvm/Transforms/Instrumentation/CGProfile.h"
|
||||
#include "llvm/Transforms/IPO/AlwaysInliner.h"
|
||||
#include "llvm/Transforms/IPO/ArgumentPromotion.h"
|
||||
#include "llvm/Transforms/IPO/CalledValuePropagation.h"
|
||||
@ -89,6 +89,7 @@
|
||||
#include "llvm/Transforms/IPO/WholeProgramDevirt.h"
|
||||
#include "llvm/Transforms/InstCombine/InstCombine.h"
|
||||
#include "llvm/Transforms/Instrumentation/BoundsChecking.h"
|
||||
#include "llvm/Transforms/Instrumentation/CGProfile.h"
|
||||
#include "llvm/Transforms/Instrumentation/ControlHeightReduction.h"
|
||||
#include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
|
||||
#include "llvm/Transforms/Instrumentation/InstrProfiling.h"
|
||||
|
@ -120,6 +120,7 @@ FUNCTION_ANALYSIS("regions", RegionInfoAnalysis())
|
||||
FUNCTION_ANALYSIS("no-op-function", NoOpFunctionAnalysis())
|
||||
FUNCTION_ANALYSIS("opt-remark-emit", OptimizationRemarkEmitterAnalysis())
|
||||
FUNCTION_ANALYSIS("scalar-evolution", ScalarEvolutionAnalysis())
|
||||
FUNCTION_ANALYSIS("stack-safety-local", StackSafetyAnalysis())
|
||||
FUNCTION_ANALYSIS("targetlibinfo", TargetLibraryAnalysis())
|
||||
FUNCTION_ANALYSIS("targetir",
|
||||
TM ? TM->getTargetIRAnalysis() : TargetIRAnalysis())
|
||||
@ -204,6 +205,7 @@ FUNCTION_PASS("print<memoryssa>", MemorySSAPrinterPass(dbgs()))
|
||||
FUNCTION_PASS("print<phi-values>", PhiValuesPrinterPass(dbgs()))
|
||||
FUNCTION_PASS("print<regions>", RegionInfoPrinterPass(dbgs()))
|
||||
FUNCTION_PASS("print<scalar-evolution>", ScalarEvolutionPrinterPass(dbgs()))
|
||||
FUNCTION_PASS("print<stack-safety-local>", StackSafetyPrinterPass(dbgs()))
|
||||
FUNCTION_PASS("reassociate", ReassociatePass())
|
||||
FUNCTION_PASS("scalarizer", ScalarizerPass())
|
||||
FUNCTION_PASS("sccp", SCCPPass())
|
||||
|
13
test/Analysis/StackSafetyAnalysis/local.ll
Normal file
13
test/Analysis/StackSafetyAnalysis/local.ll
Normal file
@ -0,0 +1,13 @@
|
||||
; 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
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
; CHECK: 'Stack Safety Local Analysis' for function 'Foo'
|
||||
; CHECK-NEXT: Not Implemented
|
||||
|
||||
define dso_local void @Foo() {
|
||||
entry:
|
||||
ret void
|
||||
}
|
Loading…
Reference in New Issue
Block a user