mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-26 21:32:10 +00:00
Use correct size for address space in BasicAA.
The tests just hit this with a different sized address space since I haven't figured out how to use this to break it. I thought I committed this a long time ago, and I'm not sure why missing this hasn't caused any problems. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194903 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1dc2723996
commit
74c996cbd1
@ -326,6 +326,7 @@ DecomposeGEPExpression(const Value *V, int64_t &BaseOffs,
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned AS = GEPOp->getPointerAddressSpace();
|
||||
// Walk the indices of the GEP, accumulating them into BaseOff/VarIndices.
|
||||
gep_type_iterator GTI = gep_type_begin(GEPOp);
|
||||
for (User::const_op_iterator I = GEPOp->op_begin()+1,
|
||||
@ -354,7 +355,7 @@ DecomposeGEPExpression(const Value *V, int64_t &BaseOffs,
|
||||
// If the integer type is smaller than the pointer size, it is implicitly
|
||||
// sign extended to pointer size.
|
||||
unsigned Width = Index->getType()->getIntegerBitWidth();
|
||||
if (TD->getPointerSizeInBits() > Width)
|
||||
if (TD->getPointerSizeInBits(AS) > Width)
|
||||
Extension = EK_SignExt;
|
||||
|
||||
// Use GetLinearExpression to decompose the index into a C1*V+C2 form.
|
||||
@ -382,7 +383,7 @@ DecomposeGEPExpression(const Value *V, int64_t &BaseOffs,
|
||||
|
||||
// Make sure that we have a scale that makes sense for this target's
|
||||
// pointer size.
|
||||
if (unsigned ShiftBits = 64-TD->getPointerSizeInBits()) {
|
||||
if (unsigned ShiftBits = 64 - TD->getPointerSizeInBits(AS)) {
|
||||
Scale <<= ShiftBits;
|
||||
Scale = (int64_t)Scale >> ShiftBits;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
; RUN: opt < %s -basicaa -gvn -instcombine -S 2>&1 | FileCheck %s
|
||||
|
||||
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
|
||||
target datalayout = "e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
|
||||
|
||||
; Make sure that basicaa thinks R and r are must aliases.
|
||||
define i32 @test1(i8 * %P) {
|
||||
@ -86,6 +86,33 @@ define i32 @test5(i32* %p, i64 %i) {
|
||||
; CHECK: ret i32 0
|
||||
}
|
||||
|
||||
define i32 @test5_as1_smaller_size(i32 addrspace(1)* %p, i8 %i) {
|
||||
%pi = getelementptr i32 addrspace(1)* %p, i8 %i
|
||||
%i.next = add i8 %i, 1
|
||||
%pi.next = getelementptr i32 addrspace(1)* %p, i8 %i.next
|
||||
%x = load i32 addrspace(1)* %pi
|
||||
store i32 42, i32 addrspace(1)* %pi.next
|
||||
%y = load i32 addrspace(1)* %pi
|
||||
%z = sub i32 %x, %y
|
||||
ret i32 %z
|
||||
; CHECK-LABEL: @test5_as1_smaller_size(
|
||||
; CHECK: sext
|
||||
; CHECK: ret i32 0
|
||||
}
|
||||
|
||||
define i32 @test5_as1_same_size(i32 addrspace(1)* %p, i16 %i) {
|
||||
%pi = getelementptr i32 addrspace(1)* %p, i16 %i
|
||||
%i.next = add i16 %i, 1
|
||||
%pi.next = getelementptr i32 addrspace(1)* %p, i16 %i.next
|
||||
%x = load i32 addrspace(1)* %pi
|
||||
store i32 42, i32 addrspace(1)* %pi.next
|
||||
%y = load i32 addrspace(1)* %pi
|
||||
%z = sub i32 %x, %y
|
||||
ret i32 %z
|
||||
; CHECK-LABEL: @test5_as1_same_size(
|
||||
; CHECK: ret i32 0
|
||||
}
|
||||
|
||||
; P[i] != p[(i*4)|1]
|
||||
define i32 @test6(i32* %p, i64 %i1) {
|
||||
%i = shl i64 %i1, 2
|
||||
|
@ -2,7 +2,7 @@
|
||||
; the global.
|
||||
|
||||
; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
|
||||
target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
|
||||
target datalayout = "E-p:64:64:64-p1:16:16:16-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
|
||||
|
||||
@B = global i16 8
|
||||
|
||||
@ -16,6 +16,18 @@ define i16 @test1(i32* %P) {
|
||||
; CHECK: ret i16 0
|
||||
}
|
||||
|
||||
@B_as1 = addrspace(1) global i16 8
|
||||
|
||||
define i16 @test1_as1(i32 addrspace(1)* %P) {
|
||||
; CHECK-LABEL: @test1_as1(
|
||||
; CHECK: ret i16 0
|
||||
%X = load i16 addrspace(1)* @B_as1
|
||||
store i32 7, i32 addrspace(1)* %P
|
||||
%Y = load i16 addrspace(1)* @B_as1
|
||||
%Z = sub i16 %Y, %X
|
||||
ret i16 %Z
|
||||
}
|
||||
|
||||
; Cannot know anything about the size of this global.
|
||||
; rdar://8813415
|
||||
@window = external global [0 x i8]
|
||||
|
Loading…
Reference in New Issue
Block a user