Revert "[Clang] __has_builtin should return false for aux triple builtins (#121839) (#124626)

This reverts commit 1c28b9237382b093f477479c993c80181922ca6a.

Breaks CUDA on ARM, see
[here](https://github.com/llvm/llvm-project/pull/121839#issuecomment-2616858927).
This commit is contained in:
Nick Sarnie 2025-01-28 07:11:46 +09:00 committed by GitHub
parent 5d1c596ab4
commit c310b4e7bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 28 deletions

View File

@ -1804,9 +1804,8 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
diag::err_feature_check_malformed);
if (!II)
return false;
auto BuiltinID = II->getBuiltinID();
if (BuiltinID != 0) {
switch (BuiltinID) {
else if (II->getBuiltinID() != 0) {
switch (II->getBuiltinID()) {
case Builtin::BI__builtin_cpu_is:
return getTargetInfo().supportsCpuIs();
case Builtin::BI__builtin_cpu_init:
@ -1819,11 +1818,8 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
// usual allocation and deallocation functions. Required by libc++
return 201802;
default:
// __has_builtin should return false for aux builtins.
if (getBuiltinInfo().isAuxBuiltinID(BuiltinID))
return false;
return Builtin::evaluateRequiredTargetFeatures(
getBuiltinInfo().getRequiredFeatures(BuiltinID),
getBuiltinInfo().getRequiredFeatures(II->getBuiltinID()),
getTargetInfo().getTargetOpts().FeatureMap);
}
return true;

View File

@ -3,9 +3,7 @@
// RUN: %clang_cc1 %s -ffreestanding -fms-extensions -fms-compatibility \
// RUN: -fms-compatibility-version=19.00 -triple x86_64-pc-windows-msvc -emit-llvm -o -
// %clang_cc1 %s -ffreestanding -triple x86_64-w64-windows-gnu -fms-extensions -emit-llvm -o -
//
// FIXME: See https://github.com/llvm/llvm-project/pull/121839
// RUN: not %clang_cc1 %s -ffreestanding -fopenmp -fopenmp-is-target-device -aux-triple x86_64-unknown-linux-gnu
// RUN: %clang_cc1 %s -ffreestanding -fopenmp -fopenmp-is-target-device -aux-triple x86_64-unknown-linux-gnu
typedef __SIZE_TYPE__ size_t;

View File

@ -1,18 +0,0 @@
// RUN: %clang_cc1 -fopenmp -triple=spirv64 -fopenmp-is-target-device \
// RUN: -aux-triple x86_64-linux-unknown -E %s | FileCheck -implicit-check-not=BAD %s
// RUN: %clang_cc1 -fopenmp -triple=nvptx64 -fopenmp-is-target-device \
// RUN: -aux-triple x86_64-linux-unknown -E %s | FileCheck -implicit-check-not=BAD %s
// RUN: %clang_cc1 -fopenmp -triple=amdgcn-amd-amdhsa -fopenmp-is-target-device \
// RUN: -aux-triple x86_64-linux-unknown -E %s | FileCheck -implicit-check-not=BAD %s
// RUN: %clang_cc1 -fopenmp -triple=aarch64 -fopenmp-is-target-device \
// RUN: -aux-triple x86_64-linux-unknown -E %s | FileCheck -implicit-check-not=BAD %s
// CHECK: GOOD
#if __has_builtin(__builtin_ia32_pause)
BAD
#else
GOOD
#endif