This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Disable -fuse-caller-save when -pg is active
- From: Radovan Obradovic <Radovan dot Obradovic at imgtec dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 13 Nov 2014 14:37:56 +0000
- Subject: [PATCH] Disable -fuse-caller-save when -pg is active
- Authentication-results: sourceware.org; auth=none
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