mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 04:09:45 +00:00
[PM] Port PartiallyInlineLibCalls to the new pass manager.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270798 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fe303ed1b8
commit
613d807439
@ -237,7 +237,7 @@ void initializeObjCARCContractPass(PassRegistry&);
|
||||
void initializeObjCARCOptPass(PassRegistry&);
|
||||
void initializePAEvalPass(PassRegistry &);
|
||||
void initializeOptimizePHIsPass(PassRegistry&);
|
||||
void initializePartiallyInlineLibCallsPass(PassRegistry&);
|
||||
void initializePartiallyInlineLibCallsLegacyPassPass(PassRegistry &);
|
||||
void initializePEIPass(PassRegistry&);
|
||||
void initializePHIEliminationPass(PassRegistry&);
|
||||
void initializePartialInlinerPass(PassRegistry&);
|
||||
|
@ -73,6 +73,7 @@
|
||||
#include "llvm/Transforms/Scalar/LoopSimplifyCFG.h"
|
||||
#include "llvm/Transforms/Scalar/LowerAtomic.h"
|
||||
#include "llvm/Transforms/Scalar/LowerExpectIntrinsic.h"
|
||||
#include "llvm/Transforms/Scalar/PartiallyInlineLibCalls.h"
|
||||
#include "llvm/Transforms/Scalar/Reassociate.h"
|
||||
#include "llvm/Transforms/Scalar/SCCP.h"
|
||||
#include "llvm/Transforms/Scalar/SROA.h"
|
||||
|
@ -121,6 +121,7 @@ FUNCTION_PASS("loweratomic", LowerAtomicPass())
|
||||
FUNCTION_PASS("lower-expect", LowerExpectIntrinsicPass())
|
||||
FUNCTION_PASS("guard-widening", GuardWideningPass())
|
||||
FUNCTION_PASS("gvn", GVN())
|
||||
FUNCTION_PASS("partially-inline-libcalls", PartiallyInlineLibCallsPass())
|
||||
FUNCTION_PASS("print", PrintFunctionPass(dbgs()))
|
||||
FUNCTION_PASS("print<assumptions>", AssumptionPrinterPass(dbgs()))
|
||||
FUNCTION_PASS("print<block-freq>", BlockFrequencyPrinterPass(dbgs()))
|
||||
|
@ -13,6 +13,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Transforms/Scalar/PartiallyInlineLibCalls.h"
|
||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
@ -23,35 +24,6 @@ using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "partially-inline-libcalls"
|
||||
|
||||
namespace {
|
||||
class PartiallyInlineLibCalls : public FunctionPass {
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
PartiallyInlineLibCalls() :
|
||||
FunctionPass(ID) {
|
||||
initializePartiallyInlineLibCallsPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.addRequired<TargetLibraryInfoWrapperPass>();
|
||||
AU.addRequired<TargetTransformInfoWrapperPass>();
|
||||
FunctionPass::getAnalysisUsage(AU);
|
||||
}
|
||||
|
||||
bool runOnFunction(Function &F) override;
|
||||
};
|
||||
|
||||
char PartiallyInlineLibCalls::ID = 0;
|
||||
}
|
||||
|
||||
INITIALIZE_PASS_BEGIN(PartiallyInlineLibCalls, "partially-inline-libcalls",
|
||||
"Partially inline calls to library functions", false,
|
||||
false)
|
||||
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
|
||||
INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
|
||||
INITIALIZE_PASS_END(PartiallyInlineLibCalls, "partially-inline-libcalls",
|
||||
"Partially inline calls to library functions", false, false)
|
||||
|
||||
static bool optimizeSQRT(CallInst *Call, Function *CalledFunc,
|
||||
BasicBlock &CurrBB, Function::iterator &BB) {
|
||||
@ -108,16 +80,11 @@ static bool optimizeSQRT(CallInst *Call, Function *CalledFunc,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartiallyInlineLibCalls::runOnFunction(Function &F) {
|
||||
if (skipFunction(F))
|
||||
return false;
|
||||
|
||||
static bool runPartiallyInlineLibCalls(Function &F, TargetLibraryInfo *TLI,
|
||||
const TargetTransformInfo *TTI) {
|
||||
bool Changed = false;
|
||||
|
||||
Function::iterator CurrBB;
|
||||
TargetLibraryInfo *TLI =
|
||||
&getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
|
||||
const TargetTransformInfo *TTI =
|
||||
&getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
|
||||
for (Function::iterator BB = F.begin(), BE = F.end(); BB != BE;) {
|
||||
CurrBB = BB++;
|
||||
|
||||
@ -155,6 +122,55 @@ bool PartiallyInlineLibCalls::runOnFunction(Function &F) {
|
||||
return Changed;
|
||||
}
|
||||
|
||||
FunctionPass *llvm::createPartiallyInlineLibCallsPass() {
|
||||
return new PartiallyInlineLibCalls();
|
||||
PreservedAnalyses
|
||||
PartiallyInlineLibCallsPass::run(Function &F, AnalysisManager<Function> &AM) {
|
||||
auto &TLI = AM.getResult<TargetLibraryAnalysis>(F);
|
||||
auto &TTI = AM.getResult<TargetIRAnalysis>(F);
|
||||
if (!runPartiallyInlineLibCalls(F, &TLI, &TTI))
|
||||
return PreservedAnalyses::all();
|
||||
return PreservedAnalyses::none();
|
||||
}
|
||||
|
||||
namespace {
|
||||
class PartiallyInlineLibCallsLegacyPass : public FunctionPass {
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
PartiallyInlineLibCallsLegacyPass() : FunctionPass(ID) {
|
||||
initializePartiallyInlineLibCallsLegacyPassPass(
|
||||
*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.addRequired<TargetLibraryInfoWrapperPass>();
|
||||
AU.addRequired<TargetTransformInfoWrapperPass>();
|
||||
FunctionPass::getAnalysisUsage(AU);
|
||||
}
|
||||
|
||||
bool runOnFunction(Function &F) override {
|
||||
if (skipFunction(F))
|
||||
return false;
|
||||
|
||||
TargetLibraryInfo *TLI =
|
||||
&getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
|
||||
const TargetTransformInfo *TTI =
|
||||
&getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
|
||||
return runPartiallyInlineLibCalls(F, TLI, TTI);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
char PartiallyInlineLibCallsLegacyPass::ID = 0;
|
||||
INITIALIZE_PASS_BEGIN(PartiallyInlineLibCallsLegacyPass,
|
||||
"partially-inline-libcalls",
|
||||
"Partially inline calls to library functions", false,
|
||||
false)
|
||||
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
|
||||
INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
|
||||
INITIALIZE_PASS_END(PartiallyInlineLibCallsLegacyPass,
|
||||
"partially-inline-libcalls",
|
||||
"Partially inline calls to library functions", false, false)
|
||||
|
||||
FunctionPass *llvm::createPartiallyInlineLibCallsPass() {
|
||||
return new PartiallyInlineLibCallsLegacyPass();
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
|
||||
initializeMemCpyOptPass(Registry);
|
||||
initializeMergedLoadStoreMotionPass(Registry);
|
||||
initializeNaryReassociatePass(Registry);
|
||||
initializePartiallyInlineLibCallsPass(Registry);
|
||||
initializePartiallyInlineLibCallsLegacyPassPass(Registry);
|
||||
initializeReassociateLegacyPassPass(Registry);
|
||||
initializeRegToMemPass(Registry);
|
||||
initializeRewriteStatepointsForGCPass(Registry);
|
||||
|
@ -1,4 +1,5 @@
|
||||
; RUN: opt -S -partially-inline-libcalls < %s | FileCheck %s
|
||||
; RUN: opt -S -passes=partially-inline-libcalls < %s | FileCheck %s
|
||||
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user