diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2016-03-01 01:19:05 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2016-03-01 01:19:05 +0000 |
| commit | f08579f5a875d599eacbef3a744972dd71fc2a51 (patch) | |
| tree | dfb259002fb08f03f455789b7d49c99eddda3b64 /llvm/lib | |
| parent | e5ec0623d15e99577e7d55c97d01fddfcc06effe (diff) | |
| download | bcm5719-llvm-f08579f5a875d599eacbef3a744972dd71fc2a51.tar.gz bcm5719-llvm-f08579f5a875d599eacbef3a744972dd71fc2a51.zip | |
[Verifier] Diagnose when unwinding out of cycles of blocks
Generally speaking, this can only happen with unreachable code.
However, neglecting to check for this condition would lead us to loop
forever.
llvm-svn: 262284
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/IR/Verifier.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 8367a2702eb..bea9b340f7b 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3064,6 +3064,7 @@ void Verifier::visitEHPadPredecessors(Instruction &I) { } // The edge may exit from zero or more nested pads. + SmallSet<Value *, 8> Seen; for (;; FromPad = getParentPad(FromPad)) { Assert(FromPad != ToPad, "EH pad cannot handle exceptions raised within it", FromPad, TI); @@ -3073,6 +3074,8 @@ void Verifier::visitEHPadPredecessors(Instruction &I) { } Assert(!isa<ConstantTokenNone>(FromPad), "A single unwind edge may only enter one EH pad", TI); + Assert(Seen.insert(FromPad).second, + "EH pad jumps through a cycle of pads", FromPad); } } } @@ -3171,7 +3174,7 @@ void Verifier::visitFuncletPadInst(FuncletPadInst &FPI) { User *FirstUser = nullptr; Value *FirstUnwindPad = nullptr; SmallVector<FuncletPadInst *, 8> Worklist({&FPI}); - std::set<FuncletPadInst *> Seen; + SmallSet<FuncletPadInst *, 8> Seen; while (!Worklist.empty()) { FuncletPadInst *CurrentPad = Worklist.pop_back_val(); |

