Skip to content

Commit

Permalink
[clang][FMV] Pass the '+fmv' target-feature when FMV is enabled.
Browse files Browse the repository at this point in the history
This will allow the backend to enable the corresponding subtarget
feature (FeatureFMV), which in turn can be queried for llvm codegen
decisions. See llvm#87939 for example.
  • Loading branch information
labrinea committed Apr 7, 2024
1 parent a522dbb commit 38eea2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 7 additions & 6 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7815,13 +7815,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,

addOutlineAtomicsArgs(D, getToolChain(), Args, CmdArgs, Triple);

if (Triple.isAArch64() &&
(Args.hasArg(options::OPT_mno_fmv) ||
(Triple.isAndroid() && Triple.isAndroidVersionLT(23)) ||
getToolChain().GetRuntimeLibType(Args) != ToolChain::RLT_CompilerRT)) {
// Disable Function Multiversioning on AArch64 target.
if (Triple.isAArch64()) {
CmdArgs.push_back("-target-feature");
CmdArgs.push_back("-fmv");
if (Args.hasArg(options::OPT_mno_fmv) ||
(Triple.isAndroid() && Triple.isAndroidVersionLT(23)) ||
getToolChain().GetRuntimeLibType(Args) != ToolChain::RLT_CompilerRT)
CmdArgs.push_back("-fmv");
else
CmdArgs.push_back("+fmv");
}

if (Args.hasFlag(options::OPT_faddrsig, options::OPT_fno_addrsig,
Expand Down
1 change: 1 addition & 0 deletions clang/test/Driver/aarch64-features.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

// CHECK-FMV-OFF: "-target-feature" "-fmv"
// CHECK-FMV-NOT: "-target-feature" "-fmv"
// CHECK-FMV: "-target-feature" "+fmv"

// Check for AArch64 out-of-line atomics default settings.
// RUN: %clang --target=aarch64-linux-android -rtlib=compiler-rt \
Expand Down

0 comments on commit 38eea2e

Please sign in to comment.