fix rdar://8813415 - a miscompilation of 164.gzip that loop-idiom

exposed.  It turns out to be a latent bug in basicaa, scary.

llvm-svn: 122772
This commit is contained in:
Chris Lattner 2011-01-03 21:03:33 +00:00
parent 12fa3c6a94
commit 16e42128c2
2 changed files with 24 additions and 0 deletions

View File

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

View File

@ -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
}