Skip to content

Commit 416731b

Browse files
authored
[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`.
1 parent 709116c commit 416731b

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,8 @@ void NVPTX::Linker::ConstructJob(Compilation &C, const JobAction &JA,
634634
std::vector<StringRef> Features;
635635
getNVPTXTargetFeatures(C.getDriver(), getToolChain().getTriple(), Args,
636636
Features);
637-
for (StringRef Feature : Features)
638-
CmdArgs.append({"--feature", Args.MakeArgString(Feature)});
637+
CmdArgs.push_back(
638+
Args.MakeArgString("--plugin-opt=mattr=" + llvm::join(Features, ",")));
639639

640640
// Add paths for the default clang library path.
641641
SmallString<256> DefaultLibPath =

clang/test/Driver/cuda-cross-compiling.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@
104104
// RUN: %clang -target nvptx64-nvidia-cuda --cuda-feature=+ptx63 -march=sm_52 -### %s 2>&1 \
105105
// RUN: | FileCheck -check-prefix=FEATURE %s
106106

107-
// FEATURE: clang-nvlink-wrapper{{.*}}"--feature" "+ptx63"
107+
// FEATURE: clang-nvlink-wrapper{{.*}}"--plugin-opt=mattr=+ptx63"

clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ Expected<std::unique_ptr<lto::LTO>> createLTO(const ArgList &Args) {
344344
Conf.RemarksHotnessThreshold = RemarksHotnessThreshold;
345345
Conf.RemarksFormat = RemarksFormat;
346346

347-
Conf.MAttrs = {Args.getLastArgValue(OPT_feature, "").str()};
347+
Conf.MAttrs = llvm::codegen::getMAttrs();
348348
std::optional<CodeGenOptLevel> CGOptLevelOrNone =
349349
CodeGenOpt::parseLevel(Args.getLastArgValue(OPT_O, "2")[0]);
350350
assert(CGOptLevelOrNone && "Invalid optimization level");

clang/tools/clang-nvlink-wrapper/NVLinkOpts.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ def arch : Separate<["--", "-"], "arch">,
4747
def : Joined<["--", "-"], "plugin-opt=mcpu=">,
4848
Flags<[HelpHidden, WrapperOnlyOption]>, Alias<arch>;
4949

50-
def feature : Separate<["--", "-"], "feature">, Flags<[WrapperOnlyOption]>,
51-
HelpText<"Specify the '+ptx' freature to use for LTO.">;
52-
5350
def g : Flag<["-"], "g">, HelpText<"Specify that this was a debug compile.">;
5451
def debug : Flag<["--"], "debug">, Alias<g>;
5552

0 commit comments

Comments
 (0)