Skip to content

Commit 69198ca

Browse files
committed
check only for aux builtins, expect fail in failing test
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 3ce5111 commit 69198ca

File tree

4 files changed

+6
-37
lines changed

4 files changed

+6
-37
lines changed

clang/include/clang/Basic/Builtins.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ struct Info {
7474
const char *Features;
7575
HeaderDesc Header;
7676
LanguageID Langs;
77-
bool operator==(const Info &Other) const;
7877
};
7978

8079
/// Holds information about both target-independent and
@@ -269,10 +268,6 @@ class Context {
269268
/// for AuxTarget).
270269
unsigned getAuxBuiltinID(unsigned ID) const { return ID - TSRecords.size(); }
271270

272-
// Return true if the AuxBuiltin ID represents a target-specific builtin that
273-
// is always unsupported on the default target.
274-
bool isAuxBuiltinIDAlwaysUnsupportedOnDefaultTarget(unsigned ID) const;
275-
276271
/// Returns true if this is a libc/libm function without the '__builtin_'
277272
/// prefix.
278273
static bool isBuiltinFunc(llvm::StringRef Name);

clang/lib/Basic/Builtins.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ static constexpr Builtin::Info BuiltinInfo[] = {
4141
#include "clang/Basic/Builtins.inc"
4242
};
4343

44-
bool Builtin::Info::operator==(const Builtin::Info &Other) const {
45-
auto StrCompare = [](StringRef A, StringRef B) { return A == B; };
46-
return Name == Other.Name && StrCompare(Type, Other.Type) &&
47-
StrCompare(Attributes, Other.Attributes) &&
48-
StrCompare(Features, Other.Features) && Header.ID == Other.Header.ID &&
49-
Langs == Other.Langs;
50-
}
51-
5244
const Builtin::Info &Builtin::Context::getRecord(unsigned ID) const {
5345
if (ID < Builtin::FirstTSBuiltin)
5446
return BuiltinInfo[ID];
@@ -191,17 +183,6 @@ unsigned Builtin::Context::getRequiredVectorWidth(unsigned ID) const {
191183
return Width;
192184
}
193185

194-
bool Builtin::Context::isAuxBuiltinIDAlwaysUnsupportedOnDefaultTarget(
195-
unsigned ID) const {
196-
assert(isAuxBuiltinID(ID) && "Expected aux target builtin ID");
197-
const auto &Record = getRecord(ID);
198-
for (const auto &MainTargetBuiltin : TSRecords)
199-
if (Record == MainTargetBuiltin)
200-
return false;
201-
202-
return true;
203-
}
204-
205186
bool Builtin::Context::isLike(unsigned ID, unsigned &FormatIdx,
206187
bool &HasVAListArg, const char *Fmt) const {
207188
assert(Fmt && "Not passed a format string");

clang/lib/Lex/PPMacroExpansion.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,18 +1819,8 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
18191819
// usual allocation and deallocation functions. Required by libc++
18201820
return 201802;
18211821
default:
1822-
// We may get here because of aux builtins which may not be
1823-
// supported on the default target, for example if we have an X86
1824-
// specific builtin and the current target is SPIR-V. Sometimes we
1825-
// rely on __has_builtin returning true when passed a builtin that
1826-
// is not supported on the default target due to LangOpts but is
1827-
// supported on the aux target. See
1828-
// test/Headers/__cpuidex_conflict.c for an example. If the builtin
1829-
// is an aux builtin and it can never be supported on the default
1830-
// target, __has_builtin should return false.
1831-
if (getBuiltinInfo().isAuxBuiltinID(BuiltinID) &&
1832-
getBuiltinInfo().isAuxBuiltinIDAlwaysUnsupportedOnDefaultTarget(
1833-
BuiltinID))
1822+
// __has_builtin should return false for aux builtins.
1823+
if (getBuiltinInfo().isAuxBuiltinID(BuiltinID))
18341824
return false;
18351825
return Builtin::evaluateRequiredTargetFeatures(
18361826
getBuiltinInfo().getRequiredFeatures(BuiltinID),

clang/test/Headers/__cpuidex_conflict.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
// RUN: %clang_cc1 %s -ffreestanding -fms-extensions -fms-compatibility \
44
// RUN: -fms-compatibility-version=19.00 -triple x86_64-pc-windows-msvc -emit-llvm -o -
55
// %clang_cc1 %s -ffreestanding -triple x86_64-w64-windows-gnu -fms-extensions -emit-llvm -o -
6-
// RUN: %clang_cc1 %s -ffreestanding -fopenmp -fopenmp-is-target-device -aux-triple x86_64-unknown-linux-gnu
6+
//
7+
// TODO(boomanaiden154)
8+
// See https://github.com/llvm/llvm-project/pull/121839
9+
// RUN: not %clang_cc1 %s -ffreestanding -fopenmp -fopenmp-is-target-device -aux-triple x86_64-unknown-linux-gnu
710

811
typedef __SIZE_TYPE__ size_t;
912

0 commit comments

Comments
 (0)