honggyu.kim created this revision.
honggyu.kim added reviewers: rjmccall, hans.
honggyu.kim added a subscriber: cfe-commits.
Since some profiling tools, such as gprof, ftrace, and uftrace, use
-pg option to generate a mcount function call at the entry of each
function. Function invocation can be detected by this hook function.
But mcount insertion is done before function inlining phase in clang,
sometime a function that already has a mcount call can be inlined in the
middle of another function. So this patch fixes it by disabling
inline-functions when -pg option is enabled.
Link: https://llvm.org/bugs/show_bug.cgi?id=28660
Signed-off-by: Honggyu Kim <[email protected]>
https://reviews.llvm.org/D22666
Files:
lib/Driver/Tools.cpp
lib/Frontend/CompilerInvocation.cpp
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -442,7 +442,7 @@
(Opts.OptimizationLevel > 1) ? CodeGenOptions::NormalInlining
: CodeGenOptions::OnlyAlwaysInlining);
// -fno-inline-functions overrides OptimizationLevel > 1.
- Opts.NoInline = Args.hasArg(OPT_fno_inline);
+ Opts.NoInline = Args.hasArg(OPT_fno_inline) || Args.hasArg(OPT_pg);
if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions,
options::OPT_finline_hint_functions,
options::OPT_fno_inline_functions)) {
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -6102,10 +6102,14 @@
if (SplitDwarf && Output.getType() == types::TY_Object)
SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output, SplitDwarfOut);
- if (Arg *A = Args.getLastArg(options::OPT_pg))
+ if (Arg *A = Args.getLastArg(options::OPT_pg)) {
if (Args.hasArg(options::OPT_fomit_frame_pointer))
D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
<< A->getAsString(Args);
+ if (Args.hasArg(options::OPT_finline_functions))
+ D.Diag(diag::err_drv_argument_not_allowed_with) << "-finline-functions"
+ << A->getAsString(Args);
+ }
// Claim some arguments which clang supports automatically.
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -442,7 +442,7 @@
(Opts.OptimizationLevel > 1) ? CodeGenOptions::NormalInlining
: CodeGenOptions::OnlyAlwaysInlining);
// -fno-inline-functions overrides OptimizationLevel > 1.
- Opts.NoInline = Args.hasArg(OPT_fno_inline);
+ Opts.NoInline = Args.hasArg(OPT_fno_inline) || Args.hasArg(OPT_pg);
if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions,
options::OPT_finline_hint_functions,
options::OPT_fno_inline_functions)) {
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -6102,10 +6102,14 @@
if (SplitDwarf && Output.getType() == types::TY_Object)
SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output, SplitDwarfOut);
- if (Arg *A = Args.getLastArg(options::OPT_pg))
+ if (Arg *A = Args.getLastArg(options::OPT_pg)) {
if (Args.hasArg(options::OPT_fomit_frame_pointer))
D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
<< A->getAsString(Args);
+ if (Args.hasArg(options::OPT_finline_functions))
+ D.Diag(diag::err_drv_argument_not_allowed_with) << "-finline-functions"
+ << A->getAsString(Args);
+ }
// Claim some arguments which clang supports automatically.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits