Skip to content

Commit a8c6363

Browse files
committed
[Clang] Fix __cpuidex conflict with other offloading targets
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 5c17af4 commit a8c6363

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

clang/lib/Headers/cpuid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static __inline int __get_cpuid_count (unsigned int __leaf,
348348
// In some cases, offloading will set the host as the aux triple and define the
349349
// builtin. Given __has_builtin does not detect builtins on aux triples, we need
350350
// to explicitly check for some offloading cases.
351-
#ifndef __NVPTX__
351+
#if !defined(__NVPTX__) && !defined(__AMDGPU__) && !defined(__SPIRV__)
352352
static __inline void __cpuidex(int __cpu_info[4], int __leaf, int __subleaf) {
353353
__cpuid_count(__leaf, __subleaf, __cpu_info[0], __cpu_info[1], __cpu_info[2],
354354
__cpu_info[3]);

clang/test/Headers/__cpuidex_conflict.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
// Ensure that we do not run into conflicts when offloading.
77
// RUN: %clang_cc1 %s -DIS_STATIC=static -ffreestanding -fopenmp -fopenmp-is-target-device -aux-triple x86_64-unknown-linux-gnu
88
// RUN: %clang_cc1 -DIS_STATIC="" -triple nvptx64-nvidia-cuda -aux-triple x86_64-unknown-linux-gnu -aux-target-cpu x86-64 -fcuda-is-device -x cuda %s -o -
9+
// RUN: %clang_cc1 -DIS_STATIC="" -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -aux-target-cpu x86-64 -fcuda-is-device -x cuda %s -o -
10+
// RUN: %clang_cc1 -DIS_STATIC="" -triple spirv64 -aux-triple x86_64-unknown-linux-gnu -aux-target-cpu x86-64 -fcuda-is-device -x cuda %s -o -
11+
// RUN: %clang_cc1 -DIS_STATIC="" -triple spirv64 -aux-triple x86_64-unknown-linux-gnu -aux-target-cpu x86-64 -fsycl-is-device %s -o -
912

1013
typedef __SIZE_TYPE__ size_t;
1114

0 commit comments

Comments
 (0)