diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-09-29 19:39:13 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-09-29 19:39:13 +0000 |
commit | 2f0843321016091dca890c819741e06f11ceb390 (patch) | |
tree | 14a58a12ec364b18d20dd87291c8b83a999aedb3 /lib/Analysis/MemoryBuiltins.cpp | |
parent | 67a25537491bb6f9eadf4016e10bbc9504b6b75d (diff) | |
download | llvm-2f0843321016091dca890c819741e06f11ceb390.tar.gz llvm-2f0843321016091dca890c819741e06f11ceb390.tar.bz2 llvm-2f0843321016091dca890c819741e06f11ceb390.tar.xz |
ObjectSizeOffsetEvaluator: Don't run into infinite recursion if we have a cyclic GEP.
Those can occur in dead code. PR17402.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191644 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryBuiltins.cpp')
-rw-r--r-- | lib/Analysis/MemoryBuiltins.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Analysis/MemoryBuiltins.cpp b/lib/Analysis/MemoryBuiltins.cpp index e710a998bf..8e89aa9848 100644 --- a/lib/Analysis/MemoryBuiltins.cpp +++ b/lib/Analysis/MemoryBuiltins.cpp @@ -634,13 +634,15 @@ SizeOffsetEvalType ObjectSizeOffsetEvaluator::compute_(Value *V) { if (Instruction *I = dyn_cast<Instruction>(V)) Builder.SetInsertPoint(I); - // record the pointers that were handled in this run, so that they can be - // cleaned later if something fails - SeenVals.insert(V); - // now compute the size and offset SizeOffsetEvalType Result; - if (GEPOperator *GEP = dyn_cast<GEPOperator>(V)) { + + // Record the pointers that were handled in this run, so that they can be + // cleaned later if something fails. We also use this set to break cycles that + // can occur in dead code. + if (!SeenVals.insert(V)) { + Result = unknown(); + } else if (GEPOperator *GEP = dyn_cast<GEPOperator>(V)) { Result = visitGEPOperator(*GEP); } else if (Instruction *I = dyn_cast<Instruction>(V)) { Result = visit(*I); |