diff options
author | Chris Lattner <sabre@nondot.org> | 2011-01-03 21:03:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-01-03 21:03:33 +0000 |
commit | 895ace08e01578b5490ed9d064df6d89acf5420a (patch) | |
tree | 052c0b4752fedd4fe7d243545d679bb55d834760 | |
parent | 135bf42187df2d1f50622a7901949c43d2392fc3 (diff) |
fix rdar://8813415 - a miscompilation of 164.gzip that loop-idiom
exposed. It turns out to be a latent bug in basicaa, scary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122772 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/BasicAliasAnalysis.cpp | 2 | ||||
-rw-r--r-- | test/Analysis/BasicAA/global-size.ll | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 1a526fc930..8e0637a49b 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -103,6 +103,8 @@ static bool isObjectSmallerThan(const Value *V, uint64_t Size, const TargetData &TD) { const Type *AccessTy; if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) { + if (!GV->hasDefinitiveInitializer()) + return false; AccessTy = GV->getType()->getElementType(); } else if (const AllocaInst *AI = dyn_cast<AllocaInst>(V)) { if (!AI->isArrayAllocation()) diff --git a/test/Analysis/BasicAA/global-size.ll b/test/Analysis/BasicAA/global-size.ll index 810322e54d..a7e5aab6c1 100644 --- a/test/Analysis/BasicAA/global-size.ll +++ b/test/Analysis/BasicAA/global-size.ll @@ -16,3 +16,25 @@ define i16 @test1(i32* %P) { ; CHECK: ret i16 0 } +; Cannot know anything about the size of this global. +; rdar://8813415 +@window = external global [0 x i8] + +; CHECK: @test2 +define i8 @test2(i32 %tmp79, i32 %w.2, i32 %indvar89) nounwind { + %tmp92 = add i32 %tmp79, %indvar89 + %arrayidx412 = getelementptr [0 x i8]* @window, i32 0, i32 %tmp92 + %tmp93 = add i32 %w.2, %indvar89 + %arrayidx416 = getelementptr [0 x i8]* @window, i32 0, i32 %tmp93 + + %A = load i8* %arrayidx412, align 1 + store i8 4, i8* %arrayidx416, align 1 + + %B = load i8* %arrayidx412, align 1 + %C = sub i8 %A, %B + ret i8 %C + +; CHECK: %B = load i8 +; CHECK: ret i8 %C +} + |