Skip to content

Commit bb99a93

Browse files
authored
Merge branch 'main' into xegpu_simt_dist_prefetch_gpu_index
2 parents 5b00531 + 2815653 commit bb99a93

File tree

36 files changed

+564
-117
lines changed

36 files changed

+564
-117
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8452,6 +8452,11 @@ def objc_isystem : Separate<["-"], "objc-isystem">,
84528452
def objcxx_isystem : Separate<["-"], "objcxx-isystem">,
84538453
MetaVarName<"<directory>">,
84548454
HelpText<"Add directory to the ObjC++ SYSTEM include search path">;
8455+
def internal_iframework : Separate<["-"], "internal-iframework">,
8456+
MetaVarName<"<directory>">,
8457+
HelpText<"Add directory to the internal system framework search path; these "
8458+
"are assumed to not be user-provided and are used to model system "
8459+
"and standard frameworks' paths.">;
84558460
def internal_isystem : Separate<["-"], "internal-isystem">,
84568461
MetaVarName<"<directory>">,
84578462
HelpText<"Add directory to the internal system include search path; these "

clang/include/clang/Driver/ToolChain.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ class ToolChain {
226226

227227
/// \name Utilities for implementing subclasses.
228228
///@{
229+
static void addSystemFrameworkInclude(const llvm::opt::ArgList &DriverArgs,
230+
llvm::opt::ArgStringList &CC1Args,
231+
const Twine &Path);
229232
static void addSystemInclude(const llvm::opt::ArgList &DriverArgs,
230233
llvm::opt::ArgStringList &CC1Args,
231234
const Twine &Path);
@@ -236,6 +239,9 @@ class ToolChain {
236239
addExternCSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs,
237240
llvm::opt::ArgStringList &CC1Args,
238241
const Twine &Path);
242+
static void addSystemFrameworkIncludes(const llvm::opt::ArgList &DriverArgs,
243+
llvm::opt::ArgStringList &CC1Args,
244+
ArrayRef<StringRef> Paths);
239245
static void addSystemIncludes(const llvm::opt::ArgList &DriverArgs,
240246
llvm::opt::ArgStringList &CC1Args,
241247
ArrayRef<StringRef> Paths);

clang/lib/Driver/Job.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,15 @@ static bool skipArgs(const char *Flag, bool HaveCrashVFS, int &SkipNum,
6767
return true;
6868

6969
// Some include flags shouldn't be skipped if we have a crash VFS
70-
IsInclude = llvm::StringSwitch<bool>(Flag)
71-
.Cases("-include", "-header-include-file", true)
72-
.Cases("-idirafter", "-internal-isystem", "-iwithprefix", true)
73-
.Cases("-internal-externc-isystem", "-iprefix", true)
74-
.Cases("-iwithprefixbefore", "-isystem", "-iquote", true)
75-
.Cases("-isysroot", "-I", "-F", "-resource-dir", true)
76-
.Cases("-iframework", "-include-pch", true)
77-
.Default(false);
70+
IsInclude =
71+
llvm::StringSwitch<bool>(Flag)
72+
.Cases("-include", "-header-include-file", true)
73+
.Cases("-idirafter", "-internal-isystem", "-iwithprefix", true)
74+
.Cases("-internal-externc-isystem", "-iprefix", true)
75+
.Cases("-iwithprefixbefore", "-isystem", "-iquote", true)
76+
.Cases("-isysroot", "-I", "-F", "-resource-dir", true)
77+
.Cases("-internal-iframework", "-iframework", "-include-pch", true)
78+
.Default(false);
7879
if (IsInclude)
7980
return !HaveCrashVFS;
8081

clang/lib/Driver/ToolChain.cpp

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,10 +1366,17 @@ ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
13661366
return *cxxStdlibType;
13671367
}
13681368

1369+
/// Utility function to add a system framework directory to CC1 arguments.
1370+
void ToolChain::addSystemFrameworkInclude(const llvm::opt::ArgList &DriverArgs,
1371+
llvm::opt::ArgStringList &CC1Args,
1372+
const Twine &Path) {
1373+
CC1Args.push_back("-internal-iframework");
1374+
CC1Args.push_back(DriverArgs.MakeArgString(Path));
1375+
}
1376+
13691377
/// Utility function to add a system include directory to CC1 arguments.
1370-
/*static*/ void ToolChain::addSystemInclude(const ArgList &DriverArgs,
1371-
ArgStringList &CC1Args,
1372-
const Twine &Path) {
1378+
void ToolChain::addSystemInclude(const ArgList &DriverArgs,
1379+
ArgStringList &CC1Args, const Twine &Path) {
13731380
CC1Args.push_back("-internal-isystem");
13741381
CC1Args.push_back(DriverArgs.MakeArgString(Path));
13751382
}
@@ -1382,9 +1389,9 @@ ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
13821389
/// "C" semantics. These semantics are *ignored* by and large today, but its
13831390
/// important to preserve the preprocessor changes resulting from the
13841391
/// classification.
1385-
/*static*/ void ToolChain::addExternCSystemInclude(const ArgList &DriverArgs,
1386-
ArgStringList &CC1Args,
1387-
const Twine &Path) {
1392+
void ToolChain::addExternCSystemInclude(const ArgList &DriverArgs,
1393+
ArgStringList &CC1Args,
1394+
const Twine &Path) {
13881395
CC1Args.push_back("-internal-externc-isystem");
13891396
CC1Args.push_back(DriverArgs.MakeArgString(Path));
13901397
}
@@ -1396,19 +1403,28 @@ void ToolChain::addExternCSystemIncludeIfExists(const ArgList &DriverArgs,
13961403
addExternCSystemInclude(DriverArgs, CC1Args, Path);
13971404
}
13981405

1406+
/// Utility function to add a list of system framework directories to CC1.
1407+
void ToolChain::addSystemFrameworkIncludes(const ArgList &DriverArgs,
1408+
ArgStringList &CC1Args,
1409+
ArrayRef<StringRef> Paths) {
1410+
for (const auto &Path : Paths) {
1411+
CC1Args.push_back("-internal-iframework");
1412+
CC1Args.push_back(DriverArgs.MakeArgString(Path));
1413+
}
1414+
}
1415+
13991416
/// Utility function to add a list of system include directories to CC1.
1400-
/*static*/ void ToolChain::addSystemIncludes(const ArgList &DriverArgs,
1401-
ArgStringList &CC1Args,
1402-
ArrayRef<StringRef> Paths) {
1417+
void ToolChain::addSystemIncludes(const ArgList &DriverArgs,
1418+
ArgStringList &CC1Args,
1419+
ArrayRef<StringRef> Paths) {
14031420
for (const auto &Path : Paths) {
14041421
CC1Args.push_back("-internal-isystem");
14051422
CC1Args.push_back(DriverArgs.MakeArgString(Path));
14061423
}
14071424
}
14081425

1409-
/*static*/ std::string ToolChain::concat(StringRef Path, const Twine &A,
1410-
const Twine &B, const Twine &C,
1411-
const Twine &D) {
1426+
std::string ToolChain::concat(StringRef Path, const Twine &A, const Twine &B,
1427+
const Twine &C, const Twine &D) {
14121428
SmallString<128> Result(Path);
14131429
llvm::sys::path::append(Result, llvm::sys::path::Style::posix, A, B, C, D);
14141430
return std::string(Result);

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,27 @@ void AppleMachO::AddClangSystemIncludeArgs(
25772577
}
25782578
}
25792579

2580+
void DarwinClang::AddClangSystemIncludeArgs(
2581+
const llvm::opt::ArgList &DriverArgs,
2582+
llvm::opt::ArgStringList &CC1Args) const {
2583+
AppleMachO::AddClangSystemIncludeArgs(DriverArgs, CC1Args);
2584+
2585+
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
2586+
DriverArgs.hasArg(options::OPT_nostdlibinc))
2587+
return;
2588+
2589+
llvm::SmallString<128> Sysroot = GetEffectiveSysroot(DriverArgs);
2590+
2591+
// Add <sysroot>/System/Library/Frameworks
2592+
// Add <sysroot>/System/Library/SubFrameworks
2593+
// Add <sysroot>/Library/Frameworks
2594+
SmallString<128> P1(Sysroot), P2(Sysroot), P3(Sysroot);
2595+
llvm::sys::path::append(P1, "System", "Library", "Frameworks");
2596+
llvm::sys::path::append(P2, "System", "Library", "SubFrameworks");
2597+
llvm::sys::path::append(P3, "Library", "Frameworks");
2598+
addSystemFrameworkIncludes(DriverArgs, CC1Args, {P1, P2, P3});
2599+
}
2600+
25802601
bool DarwinClang::AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverArgs,
25812602
llvm::opt::ArgStringList &CC1Args,
25822603
llvm::SmallString<128> Base,

clang/lib/Driver/ToolChains/Darwin.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,10 @@ class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin {
647647
/// @name Apple ToolChain Implementation
648648
/// {
649649

650+
void
651+
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
652+
llvm::opt::ArgStringList &CC1Args) const override;
653+
650654
RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
651655

652656
void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3373,6 +3373,8 @@ static void GenerateHeaderSearchArgs(const HeaderSearchOptions &Opts,
33733373
: OPT_internal_externc_isystem;
33743374
GenerateArg(Consumer, Opt, It->Path);
33753375
}
3376+
for (; It < End && Matches(*It, {frontend::System}, true, true); ++It)
3377+
GenerateArg(Consumer, OPT_internal_iframework, It->Path);
33763378

33773379
assert(It == End && "Unhandled HeaderSearchOption::Entry.");
33783380

@@ -3505,6 +3507,8 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
35053507
Group = frontend::ExternCSystem;
35063508
Opts.AddPath(A->getValue(), Group, false, true);
35073509
}
3510+
for (const auto *A : Args.filtered(OPT_internal_iframework))
3511+
Opts.AddPath(A->getValue(), frontend::System, true, true);
35083512

35093513
// Add the path prefixes which are implicitly treated as being system headers.
35103514
for (const auto *A :

clang/lib/Lex/InitHeaderSearch.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ bool InitHeaderSearch::ShouldAddDefaultIncludePaths(
321321
break;
322322
}
323323

324+
if (triple.isOSDarwin())
325+
return false;
326+
324327
return true; // Everything else uses AddDefaultIncludePaths().
325328
}
326329

@@ -335,22 +338,6 @@ void InitHeaderSearch::AddDefaultIncludePaths(
335338
if (!ShouldAddDefaultIncludePaths(triple))
336339
return;
337340

338-
// NOTE: some additional header search logic is handled in the driver for
339-
// Darwin.
340-
if (triple.isOSDarwin()) {
341-
if (HSOpts.UseStandardSystemIncludes) {
342-
// Add the default framework include paths on Darwin.
343-
if (triple.isDriverKit()) {
344-
AddPath("/System/DriverKit/System/Library/Frameworks", System, true);
345-
} else {
346-
AddPath("/System/Library/Frameworks", System, true);
347-
AddPath("/System/Library/SubFrameworks", System, true);
348-
AddPath("/Library/Frameworks", System, true);
349-
}
350-
}
351-
return;
352-
}
353-
354341
if (Lang.CPlusPlus && !Lang.AsmPreprocessor &&
355342
HSOpts.UseStandardCXXIncludes && HSOpts.UseStandardSystemIncludes) {
356343
if (HSOpts.UseLibcxx) {

clang/test/Driver/Inputs/DriverKit19.0.sdk/System/DriverKit/System/Library/SubFrameworks/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/MacOSX15.1.sdk/Library/Frameworks/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)