[clang] 416731b - [NvlinkWrapper] Use `-plugin-opt=mattr=` instead of a custom feature (#111712)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 18 15:32:26 PDT 2024
Author: Joseph Huber
Date: 2024-10-18T17:32:23-05:00
New Revision: 416731bf7fe4c44437765a467267a9cdff75bfcf
URL: https://github.com/llvm/llvm-project/commit/416731bf7fe4c44437765a467267a9cdff75bfcf
DIFF: https://github.com/llvm/llvm-project/commit/416731bf7fe4c44437765a467267a9cdff75bfcf.diff
LOG: [NvlinkWrapper] Use `-plugin-opt=mattr=` instead of a custom feature (#111712)
Summary:
We don't need a custom flag for this, LLVM had a way to get the features
which are forwarded via `plugin-opt`.
Added:
Modified:
clang/lib/Driver/ToolChains/Cuda.cpp
clang/test/Driver/cuda-cross-compiling.c
clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp
index b368c473756731..e9d2e3fe6d5ce0 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -634,8 +634,8 @@ void NVPTX::Linker::ConstructJob(Compilation &C, const JobAction &JA,
std::vector<StringRef> Features;
getNVPTXTargetFeatures(C.getDriver(), getToolChain().getTriple(), Args,
Features);
- for (StringRef Feature : Features)
- CmdArgs.append({"--feature", Args.MakeArgString(Feature)});
+ CmdArgs.push_back(
+ Args.MakeArgString("--plugin-opt=mattr=" + llvm::join(Features, ",")));
// Add paths for the default clang library path.
SmallString<256> DefaultLibPath =
diff --git a/clang/test/Driver/cuda-cross-compiling.c b/clang/test/Driver/cuda-cross-compiling.c
index 5f24e7a5accb08..54c291fac66ffd 100644
--- a/clang/test/Driver/cuda-cross-compiling.c
+++ b/clang/test/Driver/cuda-cross-compiling.c
@@ -104,4 +104,4 @@
// RUN: %clang -target nvptx64-nvidia-cuda --cuda-feature=+ptx63 -march=sm_52 -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=FEATURE %s
-// FEATURE: clang-nvlink-wrapper{{.*}}"--feature" "+ptx63"
+// FEATURE: clang-nvlink-wrapper{{.*}}"--plugin-opt=mattr=+ptx63"
diff --git a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
index b4b376fe0d114e..b9767a7a03d0b5 100644
--- a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
+++ b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
@@ -344,7 +344,7 @@ Expected<std::unique_ptr<lto::LTO>> createLTO(const ArgList &Args) {
Conf.RemarksHotnessThreshold = RemarksHotnessThreshold;
Conf.RemarksFormat = RemarksFormat;
- Conf.MAttrs = {Args.getLastArgValue(OPT_feature, "").str()};
+ Conf.MAttrs = llvm::codegen::getMAttrs();
std::optional<CodeGenOptLevel> CGOptLevelOrNone =
CodeGenOpt::parseLevel(Args.getLastArgValue(OPT_O, "2")[0]);
assert(CGOptLevelOrNone && "Invalid optimization level");
diff --git a/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td b/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
index eeb9d1a6228240..a80c5937b42992 100644
--- a/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
+++ b/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
@@ -47,9 +47,6 @@ def arch : Separate<["--", "-"], "arch">,
def : Joined<["--", "-"], "plugin-opt=mcpu=">,
Flags<[HelpHidden, WrapperOnlyOption]>, Alias<arch>;
-def feature : Separate<["--", "-"], "feature">, Flags<[WrapperOnlyOption]>,
- HelpText<"Specify the '+ptx' freature to use for LTO.">;
-
def g : Flag<["-"], "g">, HelpText<"Specify that this was a debug compile.">;
def debug : Flag<["--"], "debug">, Alias<g>;
More information about the cfe-commits
mailing list