[clang] 54967c0 - [Driver] pass -fjmc to LTO
Yuanfang Chen via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 27 13:14:33 PDT 2022
Author: Yuanfang Chen
Date: 2022-09-27T13:14:16-07:00
New Revision: 54967c01d2bb6daa1959865d9a780678e652419d
URL: https://github.com/llvm/llvm-project/commit/54967c01d2bb6daa1959865d9a780678e652419d
DIFF: https://github.com/llvm/llvm-project/commit/54967c01d2bb6daa1959865d9a780678e652419d.diff
LOG: [Driver] pass -fjmc to LTO
So the behavior is consistent with non-LTO mode.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D134659
Added:
Modified:
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/clang_f_opts.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index c926e98a7f9e..4bc16710e194 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -626,6 +626,14 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
Path));
}
+ // This controls whether or not we perform JustMyCode instrumentation.
+ if (Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false)) {
+ if (ToolChain.getEffectiveTriple().isOSBinFormatELF())
+ CmdArgs.push_back("-plugin-opt=-enable-jmc-instrument");
+ else
+ D.Diag(clang::diag::warn_drv_fjmc_for_elf_only);
+ }
+
// Setup statistics file output.
SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D);
if (!StatsFile.empty())
diff --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c
index d529f9ad5c48..9c38b5906b7b 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -601,10 +601,15 @@
// RUN: %clang -### -S -fjmc -target x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefixes=CHECK_JMC_WARN_NOT_ELF,CHECK_NOJMC %s
// RUN: %clang -### -S -fjmc -g -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_JMC %s
// RUN: %clang -### -S -fjmc -g -fno-jmc -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC %s
+// RUN: %clang -### -fjmc -g -flto -target x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefixes=CHECK_JMC_WARN_NOT_ELF,CHECK_NOJMC_LTO %s
+// RUN: %clang -### -fjmc -g -flto -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_JMC_LTO %s
+// RUN: %clang -### -fjmc -g -flto -fno-jmc -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC_LTO %s
// CHECK_JMC_WARN: -fjmc requires debug info. Use -g or debug options that enable debugger's stepping function; option ignored
// CHECK_JMC_WARN_NOT_ELF: -fjmc works only for ELF; option ignored
// CHECK_NOJMC-NOT: -fjmc
// CHECK_JMC: -fjmc
+// CHECK_NOJMC_LTO-NOT: -plugin-opt=-enable-jmc-instrument
+// CHECK_JMC_LTO: -plugin-opt=-enable-jmc-instrument
// RUN: %clang -### -fintegrated-objemitter -target x86_64 %s 2>&1 | FileCheck -check-prefix=CHECK-INT-OBJEMITTER %s
// CHECK-INT-OBJEMITTER-NOT: unsupported option '-fintegrated-objemitter' for target
More information about the cfe-commits
mailing list