Skip to content

Commit

Permalink
[NvlinkWrapper] Use -plugin-opt=mattr= instead of a custom feature
Browse files Browse the repository at this point in the history
Summary:
We don't need a custom flag for this, LLVM had a way to get the features
which are forwarded via `plugin-opt`.
  • Loading branch information
jhuber6 committed Oct 9, 2024
1 parent ee57a68 commit 6135a70
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions clang/lib/Driver/ToolChains/Cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,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 =
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/cuda-cross-compiling.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 0 additions & 3 deletions clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
Original file line number Diff line number Diff line change
Expand Up @@ -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>;

Expand Down

0 comments on commit 6135a70

Please sign in to comment.