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
This commit is contained in:
Benjamin Kramer
2013-09-29 19:39:13 +00:00
parent 67a2553749
commit 2f08433210
2 changed files with 24 additions and 5 deletions

View File

@ -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);