diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2018-10-18 08:16:20 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2018-10-18 08:16:20 +0000 |
commit | 4aaaaabe8799548e7dfbf9dc523ee8babe915857 (patch) | |
tree | 9e1499eb4a5b2bb9153e14a258cc565654349c88 /clang/lib/CodeGen/CGLoopInfo.cpp | |
parent | 64c92df7cb58baba7a228cdca453678c5c531da6 (diff) | |
download | bcm5719-llvm-4aaaaabe8799548e7dfbf9dc523ee8babe915857.tar.gz bcm5719-llvm-4aaaaabe8799548e7dfbf9dc523ee8babe915857.zip |
[TI removal] Test predicate rather than casting to detect a terminator
and use the range based successor API.
llvm-svn: 344730
Diffstat (limited to 'clang/lib/CodeGen/CGLoopInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGLoopInfo.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGLoopInfo.cpp b/clang/lib/CodeGen/CGLoopInfo.cpp index 8f9a9b96077..be69e26d441 100644 --- a/clang/lib/CodeGen/CGLoopInfo.cpp +++ b/clang/lib/CodeGen/CGLoopInfo.cpp @@ -12,6 +12,7 @@ #include "clang/AST/Attr.h" #include "clang/Sema/LoopHint.h" #include "llvm/IR/BasicBlock.h" +#include "llvm/IR/CFG.h" #include "llvm/IR/Constants.h" #include "llvm/IR/InstrTypes.h" #include "llvm/IR/Instructions.h" @@ -335,10 +336,10 @@ void LoopInfoStack::InsertHelper(Instruction *I) const { if (!L.getLoopID()) return; - if (TerminatorInst *TI = dyn_cast<TerminatorInst>(I)) { - for (unsigned i = 0, ie = TI->getNumSuccessors(); i < ie; ++i) - if (TI->getSuccessor(i) == L.getHeader()) { - TI->setMetadata(llvm::LLVMContext::MD_loop, L.getLoopID()); + if (I->isTerminator()) { + for (BasicBlock *Succ : successors(I)) + if (Succ == L.getHeader()) { + I->setMetadata(llvm::LLVMContext::MD_loop, L.getLoopID()); break; } return; |