diff options
author | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-12-08 23:56:15 +0000 |
---|---|---|
committer | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-12-08 23:56:15 +0000 |
commit | c49741d047f7cf1143aa34a3a97379a8d1b5f0e5 (patch) | |
tree | 9abae7b524a52e4b11681ed6f2e93af0be253de7 | |
parent | ea1c45405d8e886497cabb90370e82114d4166ba (diff) |
Add testcase and fix for yet another case where we query the size an
abstract type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18678 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/BasicAliasAnalysis.cpp | 20 | ||||
-rw-r--r-- | test/Analysis/BasicAA/2004-12-08-BasicAACrash2.ll | 22 |
2 files changed, 33 insertions, 9 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index a78c8abba2..c355f59ed0 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -456,7 +456,7 @@ CheckGEPInstructions(const Type* BasePtr1Ty, std::vector<Value*> &GEP1Ops, if (BasePtr1Ty != BasePtr2Ty) return MayAlias; - const Type *GEPPointerTy = BasePtr1Ty; + const PointerType *GEPPointerTy = cast<PointerType>(BasePtr1Ty); // Find the (possibly empty) initial sequence of equal values... which are not // necessarily constants. @@ -657,14 +657,16 @@ CheckGEPInstructions(const Type* BasePtr1Ty, std::vector<Value*> &GEP1Ops, } } - int64_t Offset1 = getTargetData().getIndexedOffset(GEPPointerTy, GEP1Ops); - int64_t Offset2 = getTargetData().getIndexedOffset(GEPPointerTy, GEP2Ops); - assert(Offset1 < Offset2 &&"There is at least one different constant here!"); - - if ((uint64_t)(Offset2-Offset1) >= SizeMax) { - //std::cerr << "Determined that these two GEP's don't alias [" - // << SizeMax << " bytes]: \n" << *GEP1 << *GEP2; - return NoAlias; + if (GEPPointerTy->getElementType()->isSized()) { + int64_t Offset1 = getTargetData().getIndexedOffset(GEPPointerTy, GEP1Ops); + int64_t Offset2 = getTargetData().getIndexedOffset(GEPPointerTy, GEP2Ops); + assert(Offset1<Offset2 && "There is at least one different constant here!"); + + if ((uint64_t)(Offset2-Offset1) >= SizeMax) { + //std::cerr << "Determined that these two GEP's don't alias [" + // << SizeMax << " bytes]: \n" << *GEP1 << *GEP2; + return NoAlias; + } } return MayAlias; } diff --git a/test/Analysis/BasicAA/2004-12-08-BasicAACrash2.ll b/test/Analysis/BasicAA/2004-12-08-BasicAACrash2.ll new file mode 100644 index 0000000000..d856260bae --- /dev/null +++ b/test/Analysis/BasicAA/2004-12-08-BasicAACrash2.ll @@ -0,0 +1,22 @@ +; RUN: llvm-as < %s | opt -dse + +"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/ensureCapacity_unsynchronized(I)V"() { +bc0: + %tmp = getelementptr "java/lang/StringBuffer"* null, int 0, uint 3 ; <bool*> [#uses=1] + br bool false, label %bc16, label %bc7 + +bc16: ; preds = %bc0 + %tmp91 = getelementptr "java/lang/StringBuffer"* null, int 0, uint 2 ; <{ "java/lang/Object", uint, [0 x ushort] }**> [#uses=1] + store { "java/lang/Object", uint, [0 x ushort] }* null, { "java/lang/Object", uint, [0 x ushort] }** %tmp91 + store bool false, bool* %tmp + ret void + +bc7: ; preds = %bc0 + ret void +} |