File tree Expand file tree Collapse file tree 7 files changed +34
-0
lines changed Expand file tree Collapse file tree 7 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -829,6 +829,12 @@ void AMDGPUToolChain::addClangTargetOptions(
829
829
}
830
830
}
831
831
832
+ void AMDGPUToolChain::addClangWarningOptions (ArgStringList &CC1Args) const {
833
+ // AMDGPU does not support atomic lib call. Treat atomic alignment
834
+ // warnings as errors.
835
+ CC1Args.push_back (" -Werror=atomic-alignment" );
836
+ }
837
+
832
838
StringRef
833
839
AMDGPUToolChain::getGPUArch (const llvm::opt::ArgList &DriverArgs) const {
834
840
return getProcessorFromTargetID (
Original file line number Diff line number Diff line change @@ -121,6 +121,9 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF {
121
121
// / Get GPU arch from -mcpu without checking.
122
122
StringRef getGPUArch (const llvm::opt::ArgList &DriverArgs) const ;
123
123
124
+ // / Common warning options shared by AMDGPU HIP, OpenCL and OpenMP toolchains.
125
+ // / Language specific warning options should go to derived classes.
126
+ void addClangWarningOptions (llvm::opt::ArgStringList &CC1Args) const override ;
124
127
};
125
128
126
129
class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain {
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ llvm::opt::DerivedArgList *AMDGPUOpenMPToolChain::TranslateArgs(
118
118
119
119
void AMDGPUOpenMPToolChain::addClangWarningOptions (
120
120
ArgStringList &CC1Args) const {
121
+ AMDGPUToolChain::addClangWarningOptions (CC1Args);
121
122
HostTC.addClangWarningOptions (CC1Args);
122
123
}
123
124
Original file line number Diff line number Diff line change @@ -308,6 +308,7 @@ Tool *HIPAMDToolChain::buildLinker() const {
308
308
}
309
309
310
310
void HIPAMDToolChain::addClangWarningOptions (ArgStringList &CC1Args) const {
311
+ AMDGPUToolChain::addClangWarningOptions (CC1Args);
311
312
HostTC.addClangWarningOptions (CC1Args);
312
313
}
313
314
Original file line number Diff line number Diff line change 74
74
// RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a \
75
75
// RUN: -O3 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-OPT
76
76
// CHECK-OPT: clang-linker-wrapper{{.*}}"--opt-level=O3"
77
+
78
+ // RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-WARN-ATOMIC
79
+ // CHECK-WARN-ATOMIC-NOT: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-Werror=atomic-alignment"
80
+ // CHECK-WARN-ATOMIC: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-Werror=atomic-alignment"
Original file line number Diff line number Diff line change 32
32
// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
33
33
// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Xlinker --unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
34
34
// CHK-LINK_UR: ld.lld{{.*}} "--no-undefined"{{.*}} "--unresolved-symbols=ignore-all"
35
+
36
+ // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -c -emit-llvm -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHECK-WARN-ATOMIC %s
37
+ // CHECK-WARN-ATOMIC: "-cc1"{{.*}} "-Werror=atomic-alignment"
Original file line number Diff line number Diff line change 229
229
230
230
// RUN: %clang -fdriver-only -c -Werror --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib -fno-offload-uniform-block \
231
231
// RUN: -foffload-uniform-block --cuda-gpu-arch=gfx906 %s 2>&1 | count 0
232
+
233
+ // Check -Werror=atomic-alignment is passed for amdpu by default.
234
+
235
+ // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
236
+ // RUN: --cuda-gpu-arch=gfx906 %s 2>&1 | FileCheck -check-prefix=WARN-ATOMIC %s
237
+ // WARN-ATOMIC: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-Werror=atomic-alignment"
238
+ // WARN-ATOMIC-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-Werror=atomic-alignment"
239
+
240
+ // Check the default -Werror=atomic-alignment can be overridden.
241
+
242
+ // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
243
+ // RUN: --cuda-gpu-arch=gfx906 -Xarch_device -Wno-error=atomic-alignment %s \
244
+ // RUN: 2>&1 | FileCheck -check-prefix=NO-WARN-ATOMIC %s
245
+ // NO-WARN-ATOMIC: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-Werror=atomic-alignment" {{.*}} "-Wno-error=atomic-alignment"
246
+ // NO-WARN-ATOMIC-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-Werror=atomic-alignment"
247
+ // NO-WARN-ATOMIC-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-Wno-error=atomic-alignment"
You can’t perform that action at this time.
0 commit comments