summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/MemoryBuiltins.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-09-29 19:39:13 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-09-29 19:39:13 +0000
commit155c9d5d97385499f0b5edc4260ec2cf1f724d9b (patch)
treef695c4ad67e9ecc67ae1b22b3243eb9f947c7f19 /llvm/lib/Analysis/MemoryBuiltins.cpp
parent881443053977316a3624c8cb528b8b3e5e889b35 (diff)
downloadbcm5719-llvm-155c9d5d97385499f0b5edc4260ec2cf1f724d9b.tar.gz
bcm5719-llvm-155c9d5d97385499f0b5edc4260ec2cf1f724d9b.zip
ObjectSizeOffsetEvaluator: Don't run into infinite recursion if we have a cyclic GEP.
Those can occur in dead code. PR17402. llvm-svn: 191644
Diffstat (limited to 'llvm/lib/Analysis/MemoryBuiltins.cpp')
-rw-r--r--llvm/lib/Analysis/MemoryBuiltins.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index e710a998bf1..8e89aa98486 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud