diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-08-16 23:57:56 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-08-16 23:57:56 +0000 |
commit | 0a12729f99aacee25aecb5a166129188240c8853 (patch) | |
tree | 8f7202031990a26fe4fa7963bb2aac0c371264dc /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 39eec466a220cfa4152bbcbc956f9a4fd3a84699 (diff) | |
download | bcm5719-llvm-0a12729f99aacee25aecb5a166129188240c8853.tar.gz bcm5719-llvm-0a12729f99aacee25aecb5a166129188240c8853.zip |
SimplifyCFG: Avoid dereferencing end()
When comparing a User* to a BasicBlock::iterator in
passingValueIsAlwaysUndefined, don't dereference the iterator in case it
is end().
llvm-svn: 278872
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index e88d7ebaf6f..0120adcbb3d 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -5499,7 +5499,10 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I) { // Now make sure that there are no instructions in between that can alter // control flow (eg. calls) - for (BasicBlock::iterator i = ++BasicBlock::iterator(I); &*i != Use; ++i) + for (BasicBlock::iterator + i = ++BasicBlock::iterator(I), + UI = BasicBlock::iterator(dyn_cast<Instruction>(Use)); + i != UI; ++i) if (i == I->getParent()->end() || i->mayHaveSideEffects()) return false; |