Guard MemoryBuiltins against self-looping GEPs, which can occur in unreachable code due to constant propagation.

Fixes PR13621.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162098 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer
2012-08-17 14:16:37 +00:00
parent 4e81d40545
commit 823573a381
2 changed files with 21 additions and 0 deletions

View File

@@ -473,6 +473,10 @@ ObjectSizeOffsetVisitor::visitExtractValueInst(ExtractValueInst&) {
}
SizeOffsetType ObjectSizeOffsetVisitor::visitGEPOperator(GEPOperator &GEP) {
// Ignore self-referencing GEPs, they can occur in unreachable code.
if (&GEP == GEP.getPointerOperand())
return unknown();
SizeOffsetType PtrData = compute(GEP.getPointerOperand());
if (!bothKnown(PtrData) || !GEP.hasAllConstantIndices())
return unknown();