diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2018-10-15 10:04:59 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2018-10-15 10:04:59 +0000 |
commit | edb12a838a22f212d7bee970ff637192f7ea8576 (patch) | |
tree | b8ceecb3e12339436c13c2fb2e84ffc813ce8224 /llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | |
parent | ae98759ec5634759f15fe103b0c637e6f836829f (diff) | |
download | bcm5719-llvm-edb12a838a22f212d7bee970ff637192f7ea8576.tar.gz bcm5719-llvm-edb12a838a22f212d7bee970ff637192f7ea8576.zip |
[TI removal] Make variables declared as `TerminatorInst` and initialized
by `getTerminator()` calls instead be declared as `Instruction`.
This is the biggest remaining chunk of the usage of `getTerminator()`
that insists on the narrow type and so is an easy batch of updates.
Several files saw more extensive updates where this would cascade to
requiring API updates within the file to use `Instruction` instead of
`TerminatorInst`. All of these were trivial in nature (pervasively using
`Instruction` instead just worked).
llvm-svn: 344502
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp index f67bff7fe93..13e6bd13754 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -246,11 +246,11 @@ namespace { bool TryTrivialLoopUnswitch(bool &Changed); bool UnswitchIfProfitable(Value *LoopCond, Constant *Val, - TerminatorInst *TI = nullptr); + Instruction *TI = nullptr); void UnswitchTrivialCondition(Loop *L, Value *Cond, Constant *Val, - BasicBlock *ExitBlock, TerminatorInst *TI); + BasicBlock *ExitBlock, Instruction *TI); void UnswitchNontrivialCondition(Value *LIC, Constant *OnVal, Loop *L, - TerminatorInst *TI); + Instruction *TI); void RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC, Constant *Val, bool isEqual); @@ -258,8 +258,7 @@ namespace { void EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val, BasicBlock *TrueDest, BasicBlock *FalseDest, - BranchInst *OldBranch, - TerminatorInst *TI); + BranchInst *OldBranch, Instruction *TI); void SimplifyCode(std::vector<Instruction*> &Worklist, Loop *L); @@ -713,7 +712,7 @@ bool LoopUnswitch::processCurrentLoop() { // loop. for (Loop::block_iterator I = currentLoop->block_begin(), E = currentLoop->block_end(); I != E; ++I) { - TerminatorInst *TI = (*I)->getTerminator(); + Instruction *TI = (*I)->getTerminator(); // Unswitching on a potentially uninitialized predicate is not // MSan-friendly. Limit this to the cases when the original predicate is @@ -876,7 +875,7 @@ static BasicBlock *isTrivialLoopExitBlock(Loop *L, BasicBlock *BB) { /// simplify the loop. If we decide that this is profitable, /// unswitch the loop, reprocess the pieces, then return true. bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val, - TerminatorInst *TI) { + Instruction *TI) { // Check to see if it would be profitable to unswitch current loop. if (!BranchesInfo.CostAllowsUnswitching()) { LLVM_DEBUG(dbgs() << "NOT unswitching loop %" @@ -931,7 +930,7 @@ void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val, BasicBlock *TrueDest, BasicBlock *FalseDest, BranchInst *OldBranch, - TerminatorInst *TI) { + Instruction *TI) { assert(OldBranch->isUnconditional() && "Preheader is not split correctly"); assert(TrueDest != FalseDest && "Branch targets should be different"); // Insert a conditional branch on LIC to the two preheaders. The original @@ -996,7 +995,7 @@ void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val, /// outside of the loop and updating loop info. void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond, Constant *Val, BasicBlock *ExitBlock, - TerminatorInst *TI) { + Instruction *TI) { LLVM_DEBUG(dbgs() << "loop-unswitch: Trivial-Unswitch loop %" << loopHeader->getName() << " [" << L->getBlocks().size() << " blocks] in Function " @@ -1054,7 +1053,7 @@ void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond, Constant *Val, /// condition. bool LoopUnswitch::TryTrivialLoopUnswitch(bool &Changed) { BasicBlock *CurrentBB = currentLoop->getHeader(); - TerminatorInst *CurrentTerm = CurrentBB->getTerminator(); + Instruction *CurrentTerm = CurrentBB->getTerminator(); LLVMContext &Context = CurrentBB->getContext(); // If loop header has only one reachable successor (currently via an @@ -1227,7 +1226,7 @@ void LoopUnswitch::SplitExitEdges(Loop *L, /// Split it into loop versions and test the condition outside of either loop. /// Return the loops created as Out1/Out2. void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val, - Loop *L, TerminatorInst *TI) { + Loop *L, Instruction *TI) { Function *F = loopHeader->getParent(); LLVM_DEBUG(dbgs() << "loop-unswitch: Unswitching loop %" << loopHeader->getName() << " [" << L->getBlocks().size() |