diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2017-07-18 14:46:03 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2017-07-18 14:46:03 +0000 |
commit | b8d6b711721ae52eb05d4d39837e494c07e8b78f (patch) | |
tree | 8ecbc2f32108dad971ece3d004be700243c94a9a /test | |
parent | 2e7468f0ae6383a87d726d31cde0620cb4b4852d (diff) |
CodeGen: Insert addr space cast for automatic/temp var at right position
The uses of alloca may be in different blocks other than the block containing the alloca.
Therefore if the alloca addr space is non-zero and it needs to be casted to default
address space, the cast needs to be inserted in the same BB as the alloca insted of
the current builder insert point since the current insert point may be in a different BB.
Differential Revision: https://reviews.llvm.org/D35438
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308313 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGenCXX/amdgcn-automatic-variable.cpp | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/test/CodeGenCXX/amdgcn-automatic-variable.cpp b/test/CodeGenCXX/amdgcn-automatic-variable.cpp index a82275206c..9830a7845e 100644 --- a/test/CodeGenCXX/amdgcn-automatic-variable.cpp +++ b/test/CodeGenCXX/amdgcn-automatic-variable.cpp @@ -13,31 +13,32 @@ void func1(int *x) { // CHECK-LABEL: define void @_Z5func2v() void func2(void) { // CHECK: %lv1 = alloca i32, align 4, addrspace(5) + // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32* // CHECK: %lv2 = alloca i32, align 4, addrspace(5) + // CHECK: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %lv2 to i32* // CHECK: %la = alloca [100 x i32], align 4, addrspace(5) + // CHECK: %[[r2:.*]] = addrspacecast [100 x i32] addrspace(5)* %la to [100 x i32]* // CHECK: %lp1 = alloca i32*, align 8, addrspace(5) + // CHECK: %[[r3:.*]] = addrspacecast i32* addrspace(5)* %lp1 to i32** // CHECK: %lp2 = alloca i32*, align 8, addrspace(5) + // CHECK: %[[r4:.*]] = addrspacecast i32* addrspace(5)* %lp2 to i32** // CHECK: %lvc = alloca i32, align 4, addrspace(5) + // CHECK: %[[r5:.*]] = addrspacecast i32 addrspace(5)* %lvc to i32* - // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32* // CHECK: store i32 1, i32* %[[r0]] int lv1; lv1 = 1; - // CHECK: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %lv2 to i32* // CHECK: store i32 2, i32* %[[r1]] int lv2 = 2; - // CHECK: %[[r2:.*]] = addrspacecast [100 x i32] addrspace(5)* %la to [100 x i32]* // CHECK: %[[arrayidx:.*]] = getelementptr inbounds [100 x i32], [100 x i32]* %[[r2]], i64 0, i64 0 // CHECK: store i32 3, i32* %[[arrayidx]], align 4 int la[100]; la[0] = 3; - // CHECK: %[[r3:.*]] = addrspacecast i32* addrspace(5)* %lp1 to i32** // CHECK: store i32* %[[r0]], i32** %[[r3]], align 8 int *lp1 = &lv1; - // CHECK: %[[r4:.*]] = addrspacecast i32* addrspace(5)* %lp2 to i32** // CHECK: %[[arraydecay:.*]] = getelementptr inbounds [100 x i32], [100 x i32]* %[[r2]], i32 0, i32 0 // CHECK: store i32* %[[arraydecay]], i32** %[[r4]], align 8 int *lp2 = la; @@ -45,7 +46,6 @@ void func2(void) { // CHECK: call void @_Z5func1Pi(i32* %[[r0]]) func1(&lv1); - // CHECK: %[[r5:.*]] = addrspacecast i32 addrspace(5)* %lvc to i32* // CHECK: store i32 4, i32* %[[r5]] // CHECK: store i32 4, i32* %[[r0]] const int lvc = 4; @@ -81,4 +81,25 @@ void func4(int x) { func1(&x); } +// CHECK-LABEL: define void @_Z5func5v +void func5() { + return; + int x = 0; +} + +// CHECK-LABEL: define void @_Z5func6v +void func6() { + return; + int x; +} + +// CHECK-LABEL: define void @_Z5func7v +extern void use(int *); +void func7() { + goto later; + int x; +later: + use(&x); +} + // CHECK-NOT: !opencl.ocl.version |