forked from OSchip/llvm-project
Access the TargetLoweringInfo from the TargetMachine object instead of caching it. The TLI may change between functions. No functionality change.
llvm-svn: 184352
This commit is contained in:
parent
9fbe530d74
commit
7a639ea2a4
|
@ -329,7 +329,7 @@ namespace llvm {
|
|||
/// This pass implements the target transform info analysis using the target
|
||||
/// independent information available to the LLVM code generator.
|
||||
ImmutablePass *
|
||||
createBasicTargetTransformInfoPass(const TargetMachine *TLI);
|
||||
createBasicTargetTransformInfoPass(const TargetMachine *TM);
|
||||
|
||||
/// createUnreachableBlockEliminationPass - The LLVM code generator does not
|
||||
/// work well with unreachable basic blocks (what live ranges make sense for a
|
||||
|
|
|
@ -23,6 +23,7 @@ class GetElementPtrInst;
|
|||
class PassInfo;
|
||||
class TerminatorInst;
|
||||
class TargetLowering;
|
||||
class TargetMachine;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
|
@ -119,7 +120,7 @@ Pass *createLICMPass();
|
|||
//
|
||||
Pass *createLoopStrengthReducePass();
|
||||
|
||||
Pass *createGlobalMergePass(const TargetLowering *TLI = 0);
|
||||
Pass *createGlobalMergePass(const TargetMachine *TM = 0);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
|
@ -253,9 +254,8 @@ extern char &LowerSwitchID;
|
|||
// purpose "my LLVM-to-LLVM pass doesn't support the invoke instruction yet"
|
||||
// lowering pass.
|
||||
//
|
||||
FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0);
|
||||
FunctionPass *createLowerInvokePass(const TargetLowering *TLI,
|
||||
bool useExpensiveEHSupport);
|
||||
FunctionPass *createLowerInvokePass(const TargetMachine *TM = 0,
|
||||
bool useExpensiveEHSupport = false);
|
||||
extern char &LowerInvokePassID;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -311,7 +311,7 @@ FunctionPass *createSimplifyLibCallsPass();
|
|||
//
|
||||
// CodeGenPrepare - This pass prepares a function for instruction selection.
|
||||
//
|
||||
FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0);
|
||||
FunctionPass *createCodeGenPreparePass(const TargetMachine *TM = 0);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
|
|
|
@ -404,7 +404,7 @@ void TargetPassConfig::addPassesToHandleExceptions() {
|
|||
addPass(createDwarfEHPass(TM));
|
||||
break;
|
||||
case ExceptionHandling::None:
|
||||
addPass(createLowerInvokePass(TM->getTargetLowering()));
|
||||
addPass(createLowerInvokePass(TM));
|
||||
|
||||
// The lower invoke pass may create unreachable code. Remove it.
|
||||
addPass(createUnreachableBlockEliminationPass());
|
||||
|
@ -416,7 +416,7 @@ void TargetPassConfig::addPassesToHandleExceptions() {
|
|||
/// before exception handling preparation passes.
|
||||
void TargetPassConfig::addCodeGenPrepare() {
|
||||
if (getOptLevel() != CodeGenOpt::None && !DisableCGP)
|
||||
addPass(createCodeGenPreparePass(getTargetLowering()));
|
||||
addPass(createCodeGenPreparePass(TM));
|
||||
}
|
||||
|
||||
/// Add common passes that perform LLVM IR to IR transforms in preparation for
|
||||
|
|
|
@ -150,7 +150,7 @@ TargetPassConfig *ARMBaseTargetMachine::createPassConfig(PassManagerBase &PM) {
|
|||
|
||||
bool ARMPassConfig::addPreISel() {
|
||||
if (TM->getOptLevel() != CodeGenOpt::None && EnableGlobalMerge)
|
||||
addPass(createGlobalMergePass(TM->getTargetLowering()));
|
||||
addPass(createGlobalMergePass(TM));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ namespace {
|
|||
class CodeGenPrepare : public FunctionPass {
|
||||
/// TLI - Keep a pointer of a TargetLowering to consult for determining
|
||||
/// transformation profitability.
|
||||
const TargetMachine *TM;
|
||||
const TargetLowering *TLI;
|
||||
const TargetLibraryInfo *TLInfo;
|
||||
DominatorTree *DT;
|
||||
|
@ -100,8 +101,8 @@ namespace {
|
|||
|
||||
public:
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
explicit CodeGenPrepare(const TargetLowering *tli = 0)
|
||||
: FunctionPass(ID), TLI(tli) {
|
||||
explicit CodeGenPrepare(const TargetMachine *TM = 0)
|
||||
: FunctionPass(ID), TM(TM), TLI(0) {
|
||||
initializeCodeGenPreparePass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
bool runOnFunction(Function &F);
|
||||
|
@ -139,14 +140,15 @@ INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo)
|
|||
INITIALIZE_PASS_END(CodeGenPrepare, "codegenprepare",
|
||||
"Optimize for code generation", false, false)
|
||||
|
||||
FunctionPass *llvm::createCodeGenPreparePass(const TargetLowering *TLI) {
|
||||
return new CodeGenPrepare(TLI);
|
||||
FunctionPass *llvm::createCodeGenPreparePass(const TargetMachine *TM) {
|
||||
return new CodeGenPrepare(TM);
|
||||
}
|
||||
|
||||
bool CodeGenPrepare::runOnFunction(Function &F) {
|
||||
bool EverMadeChange = false;
|
||||
|
||||
ModifiedDT = false;
|
||||
if (TM) TLI = TM->getTargetLowering();
|
||||
TLInfo = &getAnalysis<TargetLibraryInfo>();
|
||||
DT = getAnalysisIfAvailable<DominatorTree>();
|
||||
PFI = getAnalysisIfAvailable<ProfileInfo>();
|
||||
|
|
|
@ -78,9 +78,7 @@ EnableGlobalMergeOnConst("global-merge-on-const", cl::Hidden,
|
|||
STATISTIC(NumMerged , "Number of globals merged");
|
||||
namespace {
|
||||
class GlobalMerge : public FunctionPass {
|
||||
/// TLI - Keep a pointer of a TargetLowering to consult for determining
|
||||
/// target type sizes.
|
||||
const TargetLowering *TLI;
|
||||
const TargetMachine *TM;
|
||||
|
||||
bool doMerge(SmallVectorImpl<GlobalVariable*> &Globals,
|
||||
Module &M, bool isConst, unsigned AddrSpace) const;
|
||||
|
@ -104,8 +102,8 @@ namespace {
|
|||
|
||||
public:
|
||||
static char ID; // Pass identification, replacement for typeid.
|
||||
explicit GlobalMerge(const TargetLowering *tli = 0)
|
||||
: FunctionPass(ID), TLI(tli) {
|
||||
explicit GlobalMerge(const TargetMachine *TM = 0)
|
||||
: FunctionPass(ID), TM(TM) {
|
||||
initializeGlobalMergePass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
|
@ -144,6 +142,7 @@ INITIALIZE_PASS(GlobalMerge, "global-merge",
|
|||
|
||||
bool GlobalMerge::doMerge(SmallVectorImpl<GlobalVariable*> &Globals,
|
||||
Module &M, bool isConst, unsigned AddrSpace) const {
|
||||
const TargetLowering *TLI = TM->getTargetLowering();
|
||||
const DataLayout *TD = TLI->getDataLayout();
|
||||
|
||||
// FIXME: Infer the maximum possible offset depending on the actual users
|
||||
|
@ -234,6 +233,7 @@ void GlobalMerge::setMustKeepGlobalVariables(Module &M) {
|
|||
bool GlobalMerge::doInitialization(Module &M) {
|
||||
DenseMap<unsigned, SmallVector<GlobalVariable*, 16> > Globals, ConstGlobals,
|
||||
BSSGlobals;
|
||||
const TargetLowering *TLI = TM->getTargetLowering();
|
||||
const DataLayout *TD = TLI->getDataLayout();
|
||||
unsigned MaxOffset = TLI->getMaximalGlobalOffset();
|
||||
bool Changed = false;
|
||||
|
@ -305,6 +305,6 @@ bool GlobalMerge::doFinalization(Module &M) {
|
|||
return false;
|
||||
}
|
||||
|
||||
Pass *llvm::createGlobalMergePass(const TargetLowering *tli) {
|
||||
return new GlobalMerge(tli);
|
||||
Pass *llvm::createGlobalMergePass(const TargetMachine *TM) {
|
||||
return new GlobalMerge(TM);
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ static cl::opt<bool> ExpensiveEHSupport("enable-correct-eh-support",
|
|||
|
||||
namespace {
|
||||
class LowerInvoke : public FunctionPass {
|
||||
const TargetMachine *TM;
|
||||
|
||||
// Used for both models.
|
||||
Constant *AbortFn;
|
||||
|
||||
|
@ -70,15 +72,12 @@ namespace {
|
|||
Constant *SetJmpFn, *LongJmpFn, *StackSaveFn, *StackRestoreFn;
|
||||
bool useExpensiveEHSupport;
|
||||
|
||||
// We peek in TLI to grab the target's jmp_buf size and alignment
|
||||
const TargetLowering *TLI;
|
||||
|
||||
public:
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
explicit LowerInvoke(const TargetLowering *tli = NULL,
|
||||
explicit LowerInvoke(const TargetMachine *TM = 0,
|
||||
bool useExpensiveEHSupport = ExpensiveEHSupport)
|
||||
: FunctionPass(ID), useExpensiveEHSupport(useExpensiveEHSupport),
|
||||
TLI(tli) {
|
||||
: FunctionPass(ID), TM(TM),
|
||||
useExpensiveEHSupport(useExpensiveEHSupport) {
|
||||
initializeLowerInvokePass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
bool doInitialization(Module &M);
|
||||
|
@ -108,12 +107,9 @@ INITIALIZE_PASS(LowerInvoke, "lowerinvoke",
|
|||
char &llvm::LowerInvokePassID = LowerInvoke::ID;
|
||||
|
||||
// Public Interface To the LowerInvoke pass.
|
||||
FunctionPass *llvm::createLowerInvokePass(const TargetLowering *TLI) {
|
||||
return new LowerInvoke(TLI, ExpensiveEHSupport);
|
||||
}
|
||||
FunctionPass *llvm::createLowerInvokePass(const TargetLowering *TLI,
|
||||
FunctionPass *llvm::createLowerInvokePass(const TargetMachine *TM,
|
||||
bool useExpensiveEHSupport) {
|
||||
return new LowerInvoke(TLI, useExpensiveEHSupport);
|
||||
return new LowerInvoke(TM, useExpensiveEHSupport || ExpensiveEHSupport);
|
||||
}
|
||||
|
||||
// doInitialization - Make sure that there is a prototype for abort in the
|
||||
|
@ -122,6 +118,7 @@ bool LowerInvoke::doInitialization(Module &M) {
|
|||
Type *VoidPtrTy = Type::getInt8PtrTy(M.getContext());
|
||||
if (useExpensiveEHSupport) {
|
||||
// Insert a type for the linked list of jump buffers.
|
||||
const TargetLowering *TLI = TM ? TM->getTargetLowering() : 0;
|
||||
unsigned JBSize = TLI ? TLI->getJumpBufSize() : 0;
|
||||
JBSize = JBSize ? JBSize : 200;
|
||||
Type *JmpBufTy = ArrayType::get(VoidPtrTy, JBSize);
|
||||
|
@ -430,6 +427,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
|
|||
// Create an alloca for the incoming jump buffer ptr and the new jump buffer
|
||||
// that needs to be restored on all exits from the function. This is an
|
||||
// alloca because the value needs to be live across invokes.
|
||||
const TargetLowering *TLI = TM ? TM->getTargetLowering() : 0;
|
||||
unsigned Align = TLI ? TLI->getJumpBufAlignment() : 0;
|
||||
AllocaInst *JmpBuf =
|
||||
new AllocaInst(JBLinkTy, 0, Align,
|
||||
|
|
Loading…
Reference in New Issue