Skip to content

Commit 19b73b3

Browse files
committed
[Clang][HIP] Remove 'clangPostLink' from SDL handling
Summary: This feature is not needed anymore and is replaced by different implementations. The code guarded by this flag also causes us to emit an invalid argument to `-mlink-builtin-bitcode` that will cause errors if ever actually executed. Remove this feature.
1 parent 791b279 commit 19b73b3

File tree

3 files changed

+18
-30
lines changed

3 files changed

+18
-30
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,8 +2023,7 @@ void tools::addX86AlignBranchArgs(const Driver &D, const ArgList &Args,
20232023
bool tools::SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
20242024
llvm::opt::ArgStringList &CC1Args,
20252025
SmallVector<std::string, 8> LibraryPaths, std::string Lib,
2026-
StringRef Arch, StringRef Target, bool isBitCodeSDL,
2027-
bool postClangLink) {
2026+
StringRef Arch, StringRef Target, bool isBitCodeSDL) {
20282027
SmallVector<std::string, 12> SDLs;
20292028

20302029
std::string LibDeviceLoc = "/libdevice";
@@ -2083,8 +2082,6 @@ bool tools::SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
20832082
for (auto SDL : SDLs) {
20842083
auto FullName = Twine(LPath + SDL).str();
20852084
if (llvm::sys::fs::exists(FullName)) {
2086-
if (postClangLink)
2087-
CC1Args.push_back("-mlink-builtin-bitcode");
20882085
CC1Args.push_back(DriverArgs.MakeArgString(FullName));
20892086
FoundSDL = true;
20902087
break;
@@ -2104,8 +2101,7 @@ bool tools::GetSDLFromOffloadArchive(
21042101
Compilation &C, const Driver &D, const Tool &T, const JobAction &JA,
21052102
const InputInfoList &Inputs, const llvm::opt::ArgList &DriverArgs,
21062103
llvm::opt::ArgStringList &CC1Args, SmallVector<std::string, 8> LibraryPaths,
2107-
StringRef Lib, StringRef Arch, StringRef Target, bool isBitCodeSDL,
2108-
bool postClangLink) {
2104+
StringRef Lib, StringRef Arch, StringRef Target, bool isBitCodeSDL) {
21092105

21102106
// We don't support bitcode archive bundles for nvptx
21112107
if (isBitCodeSDL && Arch.contains("nvptx"))
@@ -2203,8 +2199,6 @@ bool tools::GetSDLFromOffloadArchive(
22032199
C.addCommand(std::make_unique<Command>(
22042200
JA, T, ResponseFileSupport::AtFileCurCP(), UBProgram, UBArgs, Inputs,
22052201
InputInfo(&JA, C.getArgs().MakeArgString(OutputLib))));
2206-
if (postClangLink)
2207-
CC1Args.push_back("-mlink-builtin-bitcode");
22082202

22092203
CC1Args.push_back(DriverArgs.MakeArgString(OutputLib));
22102204

@@ -2213,14 +2207,14 @@ bool tools::GetSDLFromOffloadArchive(
22132207

22142208
// Wrapper function used by driver for adding SDLs during link phase.
22152209
void tools::AddStaticDeviceLibsLinking(Compilation &C, const Tool &T,
2216-
const JobAction &JA,
2217-
const InputInfoList &Inputs,
2218-
const llvm::opt::ArgList &DriverArgs,
2219-
llvm::opt::ArgStringList &CC1Args,
2220-
StringRef Arch, StringRef Target,
2221-
bool isBitCodeSDL, bool postClangLink) {
2210+
const JobAction &JA,
2211+
const InputInfoList &Inputs,
2212+
const llvm::opt::ArgList &DriverArgs,
2213+
llvm::opt::ArgStringList &CC1Args,
2214+
StringRef Arch, StringRef Target,
2215+
bool isBitCodeSDL) {
22222216
AddStaticDeviceLibs(&C, &T, &JA, &Inputs, C.getDriver(), DriverArgs, CC1Args,
2223-
Arch, Target, isBitCodeSDL, postClangLink);
2217+
Arch, Target, isBitCodeSDL);
22242218
}
22252219

22262220
// User defined Static Device Libraries(SDLs) can be passed to clang for
@@ -2252,7 +2246,7 @@ void tools::AddStaticDeviceLibs(Compilation *C, const Tool *T,
22522246
const llvm::opt::ArgList &DriverArgs,
22532247
llvm::opt::ArgStringList &CC1Args,
22542248
StringRef Arch, StringRef Target,
2255-
bool isBitCodeSDL, bool postClangLink) {
2249+
bool isBitCodeSDL) {
22562250

22572251
SmallVector<std::string, 8> LibraryPaths;
22582252
// Add search directories from LIBRARY_PATH env variable
@@ -2308,10 +2302,10 @@ void tools::AddStaticDeviceLibs(Compilation *C, const Tool *T,
23082302
for (auto SDLName : SDLNames) {
23092303
// This is the only call to SDLSearch
23102304
if (!SDLSearch(D, DriverArgs, CC1Args, LibraryPaths, SDLName, Arch, Target,
2311-
isBitCodeSDL, postClangLink)) {
2305+
isBitCodeSDL)) {
23122306
GetSDLFromOffloadArchive(*C, D, *T, *JA, *Inputs, DriverArgs, CC1Args,
23132307
LibraryPaths, SDLName, Arch, Target,
2314-
isBitCodeSDL, postClangLink);
2308+
isBitCodeSDL);
23152309
}
23162310
}
23172311
}

clang/lib/Driver/ToolChains/CommonArgs.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,25 @@ void AddStaticDeviceLibsLinking(Compilation &C, const Tool &T,
5959
const llvm::opt::ArgList &DriverArgs,
6060
llvm::opt::ArgStringList &CmdArgs,
6161
StringRef Arch, StringRef Target,
62-
bool isBitCodeSDL, bool postClangLink);
62+
bool isBitCodeSDL);
6363
void AddStaticDeviceLibs(Compilation *C, const Tool *T, const JobAction *JA,
6464
const InputInfoList *Inputs, const Driver &D,
6565
const llvm::opt::ArgList &DriverArgs,
6666
llvm::opt::ArgStringList &CmdArgs, StringRef Arch,
67-
StringRef Target, bool isBitCodeSDL,
68-
bool postClangLink);
67+
StringRef Target, bool isBitCodeSDL);
6968

7069
bool SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
7170
llvm::opt::ArgStringList &CmdArgs,
7271
SmallVector<std::string, 8> LibraryPaths, std::string Lib,
73-
StringRef Arch, StringRef Target, bool isBitCodeSDL,
74-
bool postClangLink);
72+
StringRef Arch, StringRef Target, bool isBitCodeSDL);
7573

7674
bool GetSDLFromOffloadArchive(Compilation &C, const Driver &D, const Tool &T,
7775
const JobAction &JA, const InputInfoList &Inputs,
7876
const llvm::opt::ArgList &DriverArgs,
7977
llvm::opt::ArgStringList &CC1Args,
8078
SmallVector<std::string, 8> LibraryPaths,
8179
StringRef Lib, StringRef Arch, StringRef Target,
82-
bool isBitCodeSDL, bool postClangLink);
80+
bool isBitCodeSDL);
8381

8482
const char *SplitDebugName(const JobAction &JA, const llvm::opt::ArgList &Args,
8583
const InputInfo &Input, const InputInfo &Output);

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ void AMDGCN::Linker::constructLlvmLinkCommand(Compilation &C,
9191
// for the extracted archive of bitcode to inputs.
9292
auto TargetID = Args.getLastArgValue(options::OPT_mcpu_EQ);
9393
AddStaticDeviceLibsLinking(C, *this, JA, Inputs, Args, LlvmLinkArgs, "amdgcn",
94-
TargetID,
95-
/*IsBitCodeSDL=*/true,
96-
/*PostClangLink=*/false);
94+
TargetID, /*IsBitCodeSDL=*/true);
9795

9896
const char *LlvmLink =
9997
Args.MakeArgString(getToolChain().GetProgramPath("llvm-link"));
@@ -179,9 +177,7 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
179177
// for the extracted archive of bitcode to inputs.
180178
auto TargetID = Args.getLastArgValue(options::OPT_mcpu_EQ);
181179
AddStaticDeviceLibsLinking(C, *this, JA, Inputs, Args, LldArgs, "amdgcn",
182-
TargetID,
183-
/*IsBitCodeSDL=*/true,
184-
/*PostClangLink=*/false);
180+
TargetID, /*IsBitCodeSDL=*/true);
185181

186182
LldArgs.push_back("--no-whole-archive");
187183

0 commit comments

Comments
 (0)