diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-10-13 19:26:58 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-10-13 19:26:58 +0000 |
commit | be4d8cba1ccf6f0611db50e8c7ba366ce3a3137d (patch) | |
tree | 4f4f4b1bd5dddda9e75f4258b2e80104f17cd2b8 /llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp | |
parent | ea244fcb84c807a7d213754657e452d30acfcab8 (diff) | |
download | bcm5719-llvm-be4d8cba1ccf6f0611db50e8c7ba366ce3a3137d.tar.gz bcm5719-llvm-be4d8cba1ccf6f0611db50e8c7ba366ce3a3137d.zip |
Scalar: Remove remaining ilist iterator implicit conversions
Remove remaining `ilist_iterator` implicit conversions from
LLVMScalarOpts.
This change exposed some scary behaviour in
lib/Transforms/Scalar/SCCP.cpp around line 1770. This patch changes a
call from `Function::begin()` to `&Function::front()`, since the return
was immediately being passed into another function that takes a
`Function*`. `Function::front()` started to assert, since the function
was empty. Note that `Function::end()` does not point at a legal
`Function*` -- it points at an `ilist_half_node` -- so the other
function was getting garbage before. (I added the missing check for
`Function::isDeclaration()`.)
Otherwise, no functionality change intended.
llvm-svn: 250211
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp index f5b61edd5cc..f757297dc96 100644 --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -258,10 +258,10 @@ bool LoopIdiomRecognize::runOnLoopBlock( bool MadeChange = false; for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E;) { - Instruction *Inst = I++; + Instruction *Inst = &*I++; // Look for store instructions, which may be optimized to memset/memcpy. if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) { - WeakVH InstPtr(I); + WeakVH InstPtr(&*I); if (!processLoopStore(SI, BECount)) continue; MadeChange = true; @@ -275,7 +275,7 @@ bool LoopIdiomRecognize::runOnLoopBlock( // Look for memset instructions, which may be optimized to a larger memset. if (MemSetInst *MSI = dyn_cast<MemSetInst>(Inst)) { - WeakVH InstPtr(I); + WeakVH InstPtr(&*I); if (!processLoopMemSet(MSI, BECount)) continue; MadeChange = true; @@ -416,7 +416,7 @@ static bool mayLoopAccessLocation(Value *Ptr, ModRefInfo Access, Loop *L, for (Loop::block_iterator BI = L->block_begin(), E = L->block_end(); BI != E; ++BI) for (BasicBlock::iterator I = (*BI)->begin(), E = (*BI)->end(); I != E; ++I) - if (&*I != IgnoredStore && (AA.getModRefInfo(I, StoreLoc) & Access)) + if (&*I != IgnoredStore && (AA.getModRefInfo(&*I, StoreLoc) & Access)) return true; return false; @@ -777,10 +777,10 @@ static bool detectPopcountIdiom(Loop *CurLoop, BasicBlock *PreCondBB, // step 4: Find the instruction which count the population: cnt2 = cnt1 + 1 { CountInst = nullptr; - for (BasicBlock::iterator Iter = LoopEntry->getFirstNonPHI(), + for (BasicBlock::iterator Iter = LoopEntry->getFirstNonPHI()->getIterator(), IterE = LoopEntry->end(); Iter != IterE; Iter++) { - Instruction *Inst = Iter; + Instruction *Inst = &*Iter; if (Inst->getOpcode() != Instruction::Add) continue; @@ -972,7 +972,7 @@ void LoopIdiomRecognize::transformLoopToPopcount(BasicBlock *PreCondBB, ICmpInst *LbCond = cast<ICmpInst>(LbBr->getCondition()); Type *Ty = TripCnt->getType(); - PHINode *TcPhi = PHINode::Create(Ty, 2, "tcphi", Body->begin()); + PHINode *TcPhi = PHINode::Create(Ty, 2, "tcphi", &Body->front()); Builder.SetInsertPoint(LbCond); Instruction *TcDec = cast<Instruction>( |