[PATCH] D134659: [Driver] pass -fjmc to LTO
Yuanfang Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 26 11:24:56 PDT 2022
ychen created this revision.
ychen added reviewers: MaskRay, probinson.
Herald added subscribers: StephenFan, inglorion.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
So the behavior is consistent with non-LTO mode.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134659
Files:
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/clang_f_opts.c
Index: clang/test/Driver/clang_f_opts.c
===================================================================
--- clang/test/Driver/clang_f_opts.c
+++ 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
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -625,6 +625,14 @@
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())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134659.462974.patch
Type: text/x-patch
Size: 2290 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220926/a91602fa/attachment.bin>
More information about the cfe-commits
mailing list