r303644 - [AMDGPU] Do not require opencl triple environment for OpenCL
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Tue May 23 09:15:53 PDT 2017
Author: yaxunl
Date: Tue May 23 11:15:53 2017
New Revision: 303644
URL: http://llvm.org/viewvc/llvm-project?rev=303644&view=rev
Log:
[AMDGPU] Do not require opencl triple environment for OpenCL
A recent change requires opencl triple environment for compiling OpenCL
program, which causes regressions in libclc.
This patch fixes that. Instead of deducing language based on triple
environment, it checks LangOptions.
Differential Revision: https://reviews.llvm.org/D33445
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-alignment.cl
cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl
cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
cfe/trunk/test/CodeGenOpenCL/byval.cl
cfe/trunk/test/CodeGenOpenCL/size_t.cl
cfe/trunk/test/Sema/sizeof-struct-non-zero-as-member.cl
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=303644&r1=303643&r2=303644&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue May 23 11:15:53 2017
@@ -2169,15 +2169,20 @@ public:
: DataLayoutStringR600);
assert(DataLayout->getAllocaAddrSpace() == AS.Private);
- AddrSpaceMap =
- llvm::StringSwitch<const LangAS::Map *>(Triple.getEnvironmentName())
- .Case("opencl", &AMDGPUOpenCLPrivateIsZeroMap)
- .Case("amdgiz", &AMDGPUNonOpenCLGenericIsZeroMap)
- .Case("amdgizcl", &AMDGPUOpenCLGenericIsZeroMap)
- .Default(&AMDGPUNonOpenCLPrivateIsZeroMap);
UseAddrSpaceMapMangling = true;
}
+ void adjust(LangOptions &Opts) override {
+ TargetInfo::adjust(Opts);
+ if (isGenericZero(getTriple())) {
+ AddrSpaceMap = Opts.OpenCL ? &AMDGPUOpenCLGenericIsZeroMap
+ : &AMDGPUNonOpenCLGenericIsZeroMap;
+ } else {
+ AddrSpaceMap = Opts.OpenCL ? &AMDGPUOpenCLPrivateIsZeroMap
+ : &AMDGPUNonOpenCLPrivateIsZeroMap;
+ }
+ }
+
uint64_t getPointerWidthV(unsigned AddrSpace) const override {
if (GPU <= GK_CAYMAN)
return 32;
Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-alignment.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-alignment.cl?rev=303644&r1=303643&r2=303644&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-alignment.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-alignment.cl Tue May 23 11:15:53 2017
@@ -1,4 +1,5 @@
// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple amdgcn-unknown-unknown-opencl -S -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl?rev=303644&r1=303643&r2=303644&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl Tue May 23 11:15:53 2017
@@ -1,3 +1,4 @@
+// RUN: %clang -cl-std=CL2.0 -emit-llvm -g -O0 -S -target amdgcn-amd-amdhsa -mcpu=fiji -o - %s | FileCheck %s
// RUN: %clang -cl-std=CL2.0 -emit-llvm -g -O0 -S -target amdgcn-amd-amdhsa-opencl -mcpu=fiji -o - %s | FileCheck %s
// CHECK-DAG: ![[DWARF_ADDRESS_SPACE_NONE:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !{{[0-9]+}}, size: {{[0-9]+}})
Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl?rev=303644&r1=303643&r2=303644&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl Tue May 23 11:15:53 2017
@@ -1,3 +1,4 @@
+// RUN: %clang -cl-std=CL2.0 -emit-llvm -g -O0 -S -target amdgcn-amd-amdhsa -mcpu=fiji -o - %s | FileCheck %s
// RUN: %clang -cl-std=CL2.0 -emit-llvm -g -O0 -S -target amdgcn-amd-amdhsa-opencl -mcpu=fiji -o - %s | FileCheck %s
// CHECK-DAG: ![[LOCAL:[0-9]+]] = !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef)
Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl?rev=303644&r1=303643&r2=303644&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl Tue May 23 11:15:53 2017
@@ -1,5 +1,6 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -emit-llvm -o - | FileCheck --check-prefix=NOOPT %s
// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn---opencl -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 %s -O0 -cl-std=CL2.0 -include opencl-c.h -triple amdgcn---opencl -emit-llvm -o - | FileCheck --check-prefix=NOOPT %s
typedef struct {
private char *p1;
Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=303644&r1=303643&r2=303644&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Tue May 23 11:15:53 2017
@@ -1,4 +1,5 @@
// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple amdgcn-unknown-unknown-opencl -S -emit-llvm -o - %s | FileCheck %s
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
Modified: cfe/trunk/test/CodeGenOpenCL/byval.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/byval.cl?rev=303644&r1=303643&r2=303644&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/byval.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/byval.cl Tue May 23 11:15:53 2017
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---opencl %s | FileCheck %s
// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---amdgizcl %s | FileCheck %s -check-prefix=AMDGIZ
Modified: cfe/trunk/test/CodeGenOpenCL/size_t.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/size_t.cl?rev=303644&r1=303643&r2=303644&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/size_t.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/size_t.cl Tue May 23 11:15:53 2017
@@ -1,5 +1,6 @@
// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 -triple spir-unknown-unknown -o - | FileCheck --check-prefix=SZ32 %s
// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 -triple spir64-unknown-unknown -o - | FileCheck --check-prefix=SZ64 --check-prefix=SZ64ONLY %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 -triple amdgcn -o - | FileCheck --check-prefix=SZ64 --check-prefix=AMDONLY %s
// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 -triple amdgcn---opencl -o - | FileCheck --check-prefix=SZ64 --check-prefix=AMDONLY %s
//SZ32: define{{.*}} i32 @test_ptrtoint_private(i8* %x)
Modified: cfe/trunk/test/Sema/sizeof-struct-non-zero-as-member.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/sizeof-struct-non-zero-as-member.cl?rev=303644&r1=303643&r2=303644&view=diff
==============================================================================
--- cfe/trunk/test/Sema/sizeof-struct-non-zero-as-member.cl (original)
+++ cfe/trunk/test/Sema/sizeof-struct-non-zero-as-member.cl Tue May 23 11:15:53 2017
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -triple amdgcn -target-cpu verde -S -emit-llvm -o - %s
// RUN: %clang_cc1 -verify -fsyntax-only -triple amdgcn--opencl -target-cpu verde -S -emit-llvm -o - %s
// expected-no-diagnostics
More information about the cfe-commits
mailing list