diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2017-07-08 13:24:52 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2017-07-08 13:24:52 +0000 |
commit | 2ce35b601db031549e4a2113fc40deafe24751fe (patch) | |
tree | d2e6acd66f794051e0eaeafe0e24dcf13ea2f9a8 /test/CodeGen | |
parent | e1e45e872fe06f853a7d717c7fe92eee9d0c856c (diff) |
CodeGen: Fix address space of global variable
Certain targets (e.g. amdgcn) require global variable to stay in global or constant address
space. In C or C++ global variables are emitted in the default (generic) address space.
This patch introduces virtual functions TargetCodeGenInfo::getGlobalVarAddressSpace
and TargetInfo::getConstantAddressSpace to handle this in a general approach.
It only affects IR generated for amdgcn target.
Differential Revision: https://reviews.llvm.org/D33842
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307470 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen')
-rw-r--r-- | test/CodeGen/address-space.c | 10 | ||||
-rw-r--r-- | test/CodeGen/default-address-space.c | 28 |
2 files changed, 20 insertions, 18 deletions
diff --git a/test/CodeGen/address-space.c b/test/CodeGen/address-space.c index 54e0593857..28b3954ab7 100644 --- a/test/CodeGen/address-space.c +++ b/test/CodeGen/address-space.c @@ -24,11 +24,13 @@ int test2(int i) { return ban[i]; } __attribute__((address_space(2))) int *A, *B; // CHECK-LABEL: define void @test3() -// GIZ: load i32 addrspace(2)*, i32 addrspace(2)** @B -// PIZ: load i32 addrspace(2)*, i32 addrspace(2)* addrspace(4)* @B +// X86: load i32 addrspace(2)*, i32 addrspace(2)** @B +// AMDGIZ: load i32 addrspace(2)*, i32 addrspace(2)** addrspacecast (i32 addrspace(2)* addrspace(1)* @B to i32 addrspace(2)**) +// PIZ: load i32 addrspace(2)*, i32 addrspace(2)* addrspace(4)* addrspacecast (i32 addrspace(2)* addrspace(1)* @B to i32 addrspace(2)* addrspace(4)*) // CHECK: load i32, i32 addrspace(2)* -// GIZ: load i32 addrspace(2)*, i32 addrspace(2)** @A -// PIZ: load i32 addrspace(2)*, i32 addrspace(2)* addrspace(4)* @A +// X86: load i32 addrspace(2)*, i32 addrspace(2)** @A +// AMDGIZ: load i32 addrspace(2)*, i32 addrspace(2)** addrspacecast (i32 addrspace(2)* addrspace(1)* @A to i32 addrspace(2)**) +// PIZ: load i32 addrspace(2)*, i32 addrspace(2)* addrspace(4)* addrspacecast (i32 addrspace(2)* addrspace(1)* @A to i32 addrspace(2)* addrspace(4)*) // CHECK: store i32 {{.*}}, i32 addrspace(2)* void test3() { *A = *B; diff --git a/test/CodeGen/default-address-space.c b/test/CodeGen/default-address-space.c index becbc4ac50..b7f40585b2 100644 --- a/test/CodeGen/default-address-space.c +++ b/test/CodeGen/default-address-space.c @@ -1,24 +1,24 @@ // RUN: %clang_cc1 -triple amdgcn -emit-llvm < %s | FileCheck -check-prefixes=PIZ,COM %s // RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,COM %s -// PIZ-DAG: @foo = common addrspace(4) global i32 0 -// CHECK-DAG: @foo = common global i32 0 +// PIZ-DAG: @foo = common addrspace(1) global i32 0 +// CHECK-DAG: @foo = common addrspace(1) global i32 0 int foo; -// PIZ-DAG: @ban = common addrspace(4) global [10 x i32] zeroinitializer -// CHECK-DAG: @ban = common global [10 x i32] zeroinitializer +// PIZ-DAG: @ban = common addrspace(1) global [10 x i32] zeroinitializer +// CHECK-DAG: @ban = common addrspace(1) global [10 x i32] zeroinitializer int ban[10]; -// PIZ-DAG: @A = common addrspace(4) global i32 addrspace(4)* null -// PIZ-DAG: @B = common addrspace(4) global i32 addrspace(4)* null -// CHECK-DAG: @A = common global i32* null -// CHECK-DAG: @B = common global i32* null +// PIZ-DAG: @A = common addrspace(1) global i32 addrspace(4)* null +// PIZ-DAG: @B = common addrspace(1) global i32 addrspace(4)* null +// CHECK-DAG: @A = common addrspace(1) global i32* null +// CHECK-DAG: @B = common addrspace(1) global i32* null int *A; int *B; // COM-LABEL: define i32 @test1() -// PIZ: load i32, i32 addrspace(4)* @foo -// CHECK: load i32, i32* @foo +// PIZ: load i32, i32 addrspace(4)* addrspacecast{{[^@]+}} @foo +// CHECK: load i32, i32* addrspacecast{{[^@]+}} @foo int test1() { return foo; } // COM-LABEL: define i32 @test2(i32 %i) @@ -30,13 +30,13 @@ int test1() { return foo; } int test2(int i) { return ban[i]; } // COM-LABEL: define void @test3() -// PIZ: load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* @B +// PIZ: load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* addrspacecast{{[^@]+}} @B // PIZ: load i32, i32 addrspace(4)* -// PIZ: load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* @A +// PIZ: load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* addrspacecast{{[^@]+}} @A // PIZ: store i32 {{.*}}, i32 addrspace(4)* -// CHECK: load i32*, i32** @B +// CHECK: load i32*, i32** addrspacecast{{.*}} @B // CHECK: load i32, i32* -// CHECK: load i32*, i32** @A +// CHECK: load i32*, i32** addrspacecast{{.*}} @A // CHECK: store i32 {{.*}}, i32* void test3() { *A = *B; |