mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 04:33:05 +00:00
Teach scalarrepl about address spaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193720 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
415b33f161
commit
9effcbb879
@ -963,7 +963,7 @@ ConvertScalar_InsertValue(Value *SV, Value *Old,
|
|||||||
if (SV->getType()->isFloatingPointTy() || SV->getType()->isVectorTy())
|
if (SV->getType()->isFloatingPointTy() || SV->getType()->isVectorTy())
|
||||||
SV = Builder.CreateBitCast(SV, IntegerType::get(SV->getContext(),SrcWidth));
|
SV = Builder.CreateBitCast(SV, IntegerType::get(SV->getContext(),SrcWidth));
|
||||||
else if (SV->getType()->isPointerTy())
|
else if (SV->getType()->isPointerTy())
|
||||||
SV = Builder.CreatePtrToInt(SV, TD.getIntPtrType(SV->getContext()));
|
SV = Builder.CreatePtrToInt(SV, TD.getIntPtrType(SV->getType()));
|
||||||
|
|
||||||
// Zero extend or truncate the value if needed.
|
// Zero extend or truncate the value if needed.
|
||||||
if (SV->getType() != AllocaType) {
|
if (SV->getType() != AllocaType) {
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
; PR892
|
; PR892
|
||||||
; RUN: opt < %s -scalarrepl -S | \
|
; RUN: opt < %s -scalarrepl -S | FileCheck %s
|
||||||
; RUN: not grep alloca
|
|
||||||
; RUN: opt < %s -scalarrepl -S | grep "ret i8"
|
|
||||||
|
|
||||||
target datalayout = "e-p:32:32-n8:16:32"
|
|
||||||
|
target datalayout = "e-p:32:32-p1:16:16-n8:16:32"
|
||||||
target triple = "i686-apple-darwin8.7.2"
|
target triple = "i686-apple-darwin8.7.2"
|
||||||
%struct.Val = type { i32*, i32 }
|
|
||||||
|
%struct.Val = type { i32*, i32 }
|
||||||
|
|
||||||
define i8* @test(i16* %X) {
|
define i8* @test(i16* %X) {
|
||||||
|
; CHECK-LABEL: @test(
|
||||||
|
; CHECK-NOT: alloca
|
||||||
|
; CHECK: ret i8*
|
||||||
%X_addr = alloca i16* ; <i16**> [#uses=2]
|
%X_addr = alloca i16* ; <i16**> [#uses=2]
|
||||||
store i16* %X, i16** %X_addr
|
store i16* %X, i16** %X_addr
|
||||||
%X_addr.upgrd.1 = bitcast i16** %X_addr to i8** ; <i8**> [#uses=1]
|
%X_addr.upgrd.1 = bitcast i16** %X_addr to i8** ; <i8**> [#uses=1]
|
||||||
@ -15,7 +18,37 @@ define i8* @test(i16* %X) {
|
|||||||
ret i8* %tmp
|
ret i8* %tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define i8 addrspace(1)* @test_as1(i16 addrspace(1)* %x) {
|
||||||
|
; CHECK-LABEL: @test_as1(
|
||||||
|
; CHECK-NEXT: %1 = ptrtoint i16 addrspace(1)* %x to i16
|
||||||
|
; CHECK-NEXT: %2 = inttoptr i16 %1 to i8 addrspace(1)*
|
||||||
|
; CHECK-NEXT: ret i8 addrspace(1)* %2
|
||||||
|
%x_addr = alloca i16 addrspace(1)*
|
||||||
|
store i16 addrspace(1)* %x, i16 addrspace(1)** %x_addr
|
||||||
|
%x_addr.upgrd.1 = bitcast i16 addrspace(1)** %x_addr to i8 addrspace(1)**
|
||||||
|
%tmp = load i8 addrspace(1)** %x_addr.upgrd.1
|
||||||
|
ret i8 addrspace(1)* %tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
define i8 addrspace(1)* @test_as1_array(i16 addrspace(1)* %x) {
|
||||||
|
; CHECK-LABEL: @test_as1_array(
|
||||||
|
; CHECK-NEXT: %1 = ptrtoint i16 addrspace(1)* %x to i16
|
||||||
|
; CHECK-NEXT: %2 = inttoptr i16 %1 to i8 addrspace(1)*
|
||||||
|
; CHECK-NEXT: ret i8 addrspace(1)* %2
|
||||||
|
%as_ptr_array = alloca [4 x i16 addrspace(1)*]
|
||||||
|
%elem1 = getelementptr [4 x i16 addrspace(1)*]* %as_ptr_array, i32 0, i32 1
|
||||||
|
store i16 addrspace(1)* %x, i16 addrspace(1)** %elem1
|
||||||
|
%elem1.cast = bitcast i16 addrspace(1)** %elem1 to i8 addrspace(1)**
|
||||||
|
%tmp = load i8 addrspace(1)** %elem1.cast
|
||||||
|
ret i8 addrspace(1)* %tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
define void @test2(i64 %Op.0) {
|
define void @test2(i64 %Op.0) {
|
||||||
|
; CHECK-LABEL: @test2(
|
||||||
|
; CHECK-NOT: alloca
|
||||||
|
; CHECK: ret void
|
||||||
|
|
||||||
%tmp = alloca %struct.Val, align 8 ; <%struct.Val*> [#uses=3]
|
%tmp = alloca %struct.Val, align 8 ; <%struct.Val*> [#uses=3]
|
||||||
%tmp1 = alloca %struct.Val, align 8 ; <%struct.Val*> [#uses=3]
|
%tmp1 = alloca %struct.Val, align 8 ; <%struct.Val*> [#uses=3]
|
||||||
%tmp.upgrd.2 = call i64 @_Z3foov( ) ; <i64> [#uses=1]
|
%tmp.upgrd.2 = call i64 @_Z3foov( ) ; <i64> [#uses=1]
|
||||||
|
Loading…
Reference in New Issue
Block a user