[clang] [Clang][HIP] Remove 'clangPostLink' from SDL handling (PR #67366)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 25 13:47:21 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/67366.diff
3 Files Affected:
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+7-13)
- (modified) clang/lib/Driver/ToolChains/CommonArgs.h (+4-6)
- (modified) clang/lib/Driver/ToolChains/HIPAMD.cpp (+2-6)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 6041ef4aeb673ef..6a0d35d0bef4bfb 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2023,8 +2023,7 @@ void tools::addX86AlignBranchArgs(const Driver &D, const ArgList &Args,
bool tools::SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
SmallVector<std::string, 8> LibraryPaths, std::string Lib,
- StringRef Arch, StringRef Target, bool isBitCodeSDL,
- bool postClangLink) {
+ StringRef Arch, StringRef Target, bool isBitCodeSDL) {
SmallVector<std::string, 12> SDLs;
std::string LibDeviceLoc = "/libdevice";
@@ -2083,8 +2082,6 @@ bool tools::SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
for (auto SDL : SDLs) {
auto FullName = Twine(LPath + SDL).str();
if (llvm::sys::fs::exists(FullName)) {
- if (postClangLink)
- CC1Args.push_back("-mlink-builtin-bitcode");
CC1Args.push_back(DriverArgs.MakeArgString(FullName));
FoundSDL = true;
break;
@@ -2104,8 +2101,7 @@ bool tools::GetSDLFromOffloadArchive(
Compilation &C, const Driver &D, const Tool &T, const JobAction &JA,
const InputInfoList &Inputs, const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args, SmallVector<std::string, 8> LibraryPaths,
- StringRef Lib, StringRef Arch, StringRef Target, bool isBitCodeSDL,
- bool postClangLink) {
+ StringRef Lib, StringRef Arch, StringRef Target, bool isBitCodeSDL) {
// We don't support bitcode archive bundles for nvptx
if (isBitCodeSDL && Arch.contains("nvptx"))
@@ -2203,8 +2199,6 @@ bool tools::GetSDLFromOffloadArchive(
C.addCommand(std::make_unique<Command>(
JA, T, ResponseFileSupport::AtFileCurCP(), UBProgram, UBArgs, Inputs,
InputInfo(&JA, C.getArgs().MakeArgString(OutputLib))));
- if (postClangLink)
- CC1Args.push_back("-mlink-builtin-bitcode");
CC1Args.push_back(DriverArgs.MakeArgString(OutputLib));
@@ -2218,9 +2212,9 @@ void tools::AddStaticDeviceLibsLinking(Compilation &C, const Tool &T,
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
StringRef Arch, StringRef Target,
- bool isBitCodeSDL, bool postClangLink) {
+ bool isBitCodeSDL) {
AddStaticDeviceLibs(&C, &T, &JA, &Inputs, C.getDriver(), DriverArgs, CC1Args,
- Arch, Target, isBitCodeSDL, postClangLink);
+ Arch, Target, isBitCodeSDL);
}
// User defined Static Device Libraries(SDLs) can be passed to clang for
@@ -2252,7 +2246,7 @@ void tools::AddStaticDeviceLibs(Compilation *C, const Tool *T,
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
StringRef Arch, StringRef Target,
- bool isBitCodeSDL, bool postClangLink) {
+ bool isBitCodeSDL) {
SmallVector<std::string, 8> LibraryPaths;
// Add search directories from LIBRARY_PATH env variable
@@ -2308,10 +2302,10 @@ void tools::AddStaticDeviceLibs(Compilation *C, const Tool *T,
for (auto SDLName : SDLNames) {
// This is the only call to SDLSearch
if (!SDLSearch(D, DriverArgs, CC1Args, LibraryPaths, SDLName, Arch, Target,
- isBitCodeSDL, postClangLink)) {
+ isBitCodeSDL)) {
GetSDLFromOffloadArchive(*C, D, *T, *JA, *Inputs, DriverArgs, CC1Args,
LibraryPaths, SDLName, Arch, Target,
- isBitCodeSDL, postClangLink);
+ isBitCodeSDL);
}
}
}
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h b/clang/lib/Driver/ToolChains/CommonArgs.h
index 7585d24c3c0eb63..096152bfbdcf68a 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -59,19 +59,17 @@ void AddStaticDeviceLibsLinking(Compilation &C, const Tool &T,
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CmdArgs,
StringRef Arch, StringRef Target,
- bool isBitCodeSDL, bool postClangLink);
+ bool isBitCodeSDL);
void AddStaticDeviceLibs(Compilation *C, const Tool *T, const JobAction *JA,
const InputInfoList *Inputs, const Driver &D,
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CmdArgs, StringRef Arch,
- StringRef Target, bool isBitCodeSDL,
- bool postClangLink);
+ StringRef Target, bool isBitCodeSDL);
bool SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CmdArgs,
SmallVector<std::string, 8> LibraryPaths, std::string Lib,
- StringRef Arch, StringRef Target, bool isBitCodeSDL,
- bool postClangLink);
+ StringRef Arch, StringRef Target, bool isBitCodeSDL);
bool GetSDLFromOffloadArchive(Compilation &C, const Driver &D, const Tool &T,
const JobAction &JA, const InputInfoList &Inputs,
@@ -79,7 +77,7 @@ bool GetSDLFromOffloadArchive(Compilation &C, const Driver &D, const Tool &T,
llvm::opt::ArgStringList &CC1Args,
SmallVector<std::string, 8> LibraryPaths,
StringRef Lib, StringRef Arch, StringRef Target,
- bool isBitCodeSDL, bool postClangLink);
+ bool isBitCodeSDL);
const char *SplitDebugName(const JobAction &JA, const llvm::opt::ArgList &Args,
const InputInfo &Input, const InputInfo &Output);
diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp
index 7ff880270cab3f7..3fc5669c06c3994 100644
--- a/clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -91,9 +91,7 @@ void AMDGCN::Linker::constructLlvmLinkCommand(Compilation &C,
// for the extracted archive of bitcode to inputs.
auto TargetID = Args.getLastArgValue(options::OPT_mcpu_EQ);
AddStaticDeviceLibsLinking(C, *this, JA, Inputs, Args, LlvmLinkArgs, "amdgcn",
- TargetID,
- /*IsBitCodeSDL=*/true,
- /*PostClangLink=*/false);
+ TargetID, /*IsBitCodeSDL=*/true);
const char *LlvmLink =
Args.MakeArgString(getToolChain().GetProgramPath("llvm-link"));
@@ -179,9 +177,7 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
// for the extracted archive of bitcode to inputs.
auto TargetID = Args.getLastArgValue(options::OPT_mcpu_EQ);
AddStaticDeviceLibsLinking(C, *this, JA, Inputs, Args, LldArgs, "amdgcn",
- TargetID,
- /*IsBitCodeSDL=*/true,
- /*PostClangLink=*/false);
+ TargetID, /*IsBitCodeSDL=*/true);
LldArgs.push_back("--no-whole-archive");
``````````
</details>
https://github.com/llvm/llvm-project/pull/67366
More information about the cfe-commits
mailing list