diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 7d6f0fa1d5c..a78c8abba22 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -410,13 +410,18 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, // the size of the argument... build an index vector that is equal to // the arguments provided, except substitute 0's for any variable // indexes we find... - for (unsigned i = 0; i != GEPOperands.size(); ++i) - if (!isa(GEPOperands[i])) - GEPOperands[i] =Constant::getNullValue(GEPOperands[i]->getType()); - int64_t Offset = getTargetData().getIndexedOffset(BasePtr->getType(), - GEPOperands); - if (Offset >= (int64_t)V2Size || Offset <= -(int64_t)V1Size) - return NoAlias; + if (cast( + BasePtr->getType())->getElementType()->isSized()) { + for (unsigned i = 0; i != GEPOperands.size(); ++i) + if (!isa(GEPOperands[i])) + GEPOperands[i] = + Constant::getNullValue(GEPOperands[i]->getType()); + int64_t Offset = + getTargetData().getIndexedOffset(BasePtr->getType(), GEPOperands); + + if (Offset >= (int64_t)V2Size || Offset <= -(int64_t)V1Size) + return NoAlias; + } } } } diff --git a/test/Analysis/BasicAA/2004-12-08-BasicAACrash.ll b/test/Analysis/BasicAA/2004-12-08-BasicAACrash.ll new file mode 100644 index 00000000000..49218249981 --- /dev/null +++ b/test/Analysis/BasicAA/2004-12-08-BasicAACrash.ll @@ -0,0 +1,24 @@ +; RUN: llvm-as < %s | opt -licm + +"java/lang/Object" = type { %struct.llvm_java_object_base } + "java/lang/StringBuffer" = type { "java/lang/Object", int, { "java/lang/Object", uint, [0 x ushort] }*, bool } + %struct.llvm_java_object_base = type opaque + +implementation ; Functions: + +void "java/lang/StringBuffer/setLength(I)V"(%struct.llvm_java_object_base*) { +bc0: + br bool false, label %bc40, label %bc65 + +bc65: ; preds = %bc0, %bc40 + ret void + +bc40: ; preds = %bc0, %bc40 + %tmp75 = cast %struct.llvm_java_object_base* %0 to "java/lang/StringBuffer"* ; <"java/lang/StringBuffer"*> [#uses=1] + %tmp76 = getelementptr "java/lang/StringBuffer"* %tmp75, int 0, uint 1 ; [#uses=1] + store int 0, int* %tmp76 + %tmp381 = cast %struct.llvm_java_object_base* %0 to "java/lang/StringBuffer"* ; <"java/lang/StringBuffer"*> [#uses=1] + %tmp392 = getelementptr "java/lang/StringBuffer"* %tmp381, int 0, uint 1 ; [#uses=1] + %tmp403 = load int* %tmp392 ; [#uses=0] + br bool false, label %bc40, label %bc65 +}