[TI removal] Test predicate rather than casting to detect a terminator
and use the range based successor API. llvm-svn: 344730
This commit is contained in:
parent
64c92df7cb
commit
4aaaaabe87
|
@ -12,6 +12,7 @@
|
||||||
#include "clang/AST/Attr.h"
|
#include "clang/AST/Attr.h"
|
||||||
#include "clang/Sema/LoopHint.h"
|
#include "clang/Sema/LoopHint.h"
|
||||||
#include "llvm/IR/BasicBlock.h"
|
#include "llvm/IR/BasicBlock.h"
|
||||||
|
#include "llvm/IR/CFG.h"
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/InstrTypes.h"
|
#include "llvm/IR/InstrTypes.h"
|
||||||
#include "llvm/IR/Instructions.h"
|
#include "llvm/IR/Instructions.h"
|
||||||
|
@ -335,10 +336,10 @@ void LoopInfoStack::InsertHelper(Instruction *I) const {
|
||||||
if (!L.getLoopID())
|
if (!L.getLoopID())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (TerminatorInst *TI = dyn_cast<TerminatorInst>(I)) {
|
if (I->isTerminator()) {
|
||||||
for (unsigned i = 0, ie = TI->getNumSuccessors(); i < ie; ++i)
|
for (BasicBlock *Succ : successors(I))
|
||||||
if (TI->getSuccessor(i) == L.getHeader()) {
|
if (Succ == L.getHeader()) {
|
||||||
TI->setMetadata(llvm::LLVMContext::MD_loop, L.getLoopID());
|
I->setMetadata(llvm::LLVMContext::MD_loop, L.getLoopID());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue