This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Disable -fuse-caller-save when -pg is active


A problem is detected with building Linux kernel on MIPS platform when
both -fuse-caller-save and -pg options are present. The reason for this
is that -fuse-caller-save relies on the analysis of RTL code, but when
profiling is active (with -pg option) the code is instrumented
by adding a call to mcount function at the beginning of each function.
And this is realized on the most platforms simply by fprintf function,
so this instrumentation is not reflected in RTL code. The result is
that bad code is produced. A solution could be to disable -fuse-caller-save
when -pg is active.

Best regards,
Radovan

Patch -

diff --git a/gcc/toplev.c b/gcc/toplev.c
index eb37bfe..010228a 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1605,6 +1605,10 @@ process_options (void)
   /* Save the current optimization options.  */
   optimization_default_node = build_optimization_node (&global_options);
   optimization_current_node = optimization_default_node;
+
+  /* Disable use caller save optimization if profiler is active.  */
+  if (profile_flag)
+    flag_use_caller_save = 0;
 }
 
 /* This function can be called multiple times to reinitialize the compiler


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]