[llvm] r344715 - [TI removal] Switch ObjCARC code to directly use the nice range-based
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 17 17:38:35 PDT 2018
Author: chandlerc
Date: Wed Oct 17 17:38:34 2018
New Revision: 344715
URL: http://llvm.org/viewvc/llvm-project?rev=344715&view=rev
Log:
[TI removal] Switch ObjCARC code to directly use the nice range-based
successors API or directly build the iterators out of the terminator
instruction and avoid requiring a TerminatorInst variable.
Modified:
llvm/trunk/lib/Transforms/ObjCARC/DependencyAnalysis.cpp
llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
Modified: llvm/trunk/lib/Transforms/ObjCARC/DependencyAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ObjCARC/DependencyAnalysis.cpp?rev=344715&r1=344714&r2=344715&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/ObjCARC/DependencyAnalysis.cpp (original)
+++ llvm/trunk/lib/Transforms/ObjCARC/DependencyAnalysis.cpp Wed Oct 17 17:38:34 2018
@@ -266,13 +266,10 @@ llvm::objcarc::FindDependencies(Dependen
for (const BasicBlock *BB : Visited) {
if (BB == StartBB)
continue;
- const TerminatorInst *TI = cast<TerminatorInst>(&BB->back());
- for (succ_const_iterator SI(TI), SE(TI, false); SI != SE; ++SI) {
- const BasicBlock *Succ = *SI;
+ for (const BasicBlock *Succ : successors(BB))
if (Succ != StartBB && !Visited.count(Succ)) {
DependingInsts.insert(reinterpret_cast<Instruction *>(-1));
return;
}
- }
}
}
Modified: llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp?rev=344715&r1=344714&r2=344715&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp (original)
+++ llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp Wed Oct 17 17:38:34 2018
@@ -914,8 +914,8 @@ void ObjCARCOpt::OptimizeIndividualCalls
GetRCIdentityRoot(PN->getIncomingValue(i));
if (IsNullOrUndef(Incoming))
HasNull = true;
- else if (cast<TerminatorInst>(PN->getIncomingBlock(i)->back())
- .getNumSuccessors() != 1) {
+ else if (PN->getIncomingBlock(i)->getTerminator()->getNumSuccessors() !=
+ 1) {
HasCriticalEdges = true;
break;
}
@@ -1084,18 +1084,15 @@ ObjCARCOpt::CheckForCFGHazards(const Bas
"Unknown top down sequence state.");
const Value *Arg = I->first;
- const TerminatorInst *TI = cast<TerminatorInst>(&BB->back());
bool SomeSuccHasSame = false;
bool AllSuccsHaveSame = true;
bool NotAllSeqEqualButKnownSafe = false;
- succ_const_iterator SI(TI), SE(TI, false);
-
- for (; SI != SE; ++SI) {
+ for (const BasicBlock *Succ : successors(BB)) {
// If VisitBottomUp has pointer information for this successor, take
// what we know about it.
const DenseMap<const BasicBlock *, BBState>::iterator BBI =
- BBStates.find(*SI);
+ BBStates.find(Succ);
assert(BBI != BBStates.end());
const BottomUpPtrState &SuccS = BBI->second.getPtrBottomUpState(Arg);
const Sequence SuccSSeq = SuccS.GetSeq();
@@ -1414,21 +1411,20 @@ ComputePostOrders(Function &F,
BasicBlock *EntryBB = &F.getEntryBlock();
BBState &MyStates = BBStates[EntryBB];
MyStates.SetAsEntry();
- TerminatorInst *EntryTI = cast<TerminatorInst>(&EntryBB->back());
+ Instruction *EntryTI = EntryBB->getTerminator();
SuccStack.push_back(std::make_pair(EntryBB, succ_iterator(EntryTI)));
Visited.insert(EntryBB);
OnStack.insert(EntryBB);
do {
dfs_next_succ:
BasicBlock *CurrBB = SuccStack.back().first;
- TerminatorInst *TI = cast<TerminatorInst>(&CurrBB->back());
- succ_iterator SE(TI, false);
+ succ_iterator SE(CurrBB->getTerminator(), false);
while (SuccStack.back().second != SE) {
BasicBlock *SuccBB = *SuccStack.back().second++;
if (Visited.insert(SuccBB).second) {
- TerminatorInst *TI = cast<TerminatorInst>(&SuccBB->back());
- SuccStack.push_back(std::make_pair(SuccBB, succ_iterator(TI)));
+ SuccStack.push_back(
+ std::make_pair(SuccBB, succ_iterator(SuccBB->getTerminator())));
BBStates[CurrBB].addSucc(SuccBB);
BBState &SuccStates = BBStates[SuccBB];
SuccStates.addPred(CurrBB);
More information about the llvm-commits
mailing list