diff mbox

[5/9] regrename: Don't run if function was separately shrink-wrapped

Message ID fb99bf2f5a70c60f262469a6d55d59390afe7564.1470015604.git.segher@kernel.crashing.org
State New
Headers show

Commit Message

Segher Boessenkool Aug. 1, 2016, 1:42 a.m. UTC
Unfortunately even after the previous patch there are still a few cases
where regrename creates invalid code when used together with separate
shrink-wrapping.  At noreturn exits regrename thinks it can use all
callee-saved registers, but that is not true.  This patch disables
regrename for functions that were separately shrink-wrapped.

2016-06-07  Segher Boessenkool  <segher@kernel.crashing.org>

	* regrename.c (gate): Disable regrename if shrink_wrapped_separate
	is set in crtl.
---
 gcc/regrename.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Jeff Law Sept. 8, 2016, 5:53 p.m. UTC | #1
On 07/31/2016 07:42 PM, Segher Boessenkool wrote:
> Unfortunately even after the previous patch there are still a few cases
> where regrename creates invalid code when used together with separate
> shrink-wrapping.  At noreturn exits regrename thinks it can use all
> callee-saved registers, but that is not true.  This patch disables
> regrename for functions that were separately shrink-wrapped.
>
> 2016-06-07  Segher Boessenkool  <segher@kernel.crashing.org>
>
> 	* regrename.c (gate): Disable regrename if shrink_wrapped_separate
> 	is set in crtl.
I think this (and the prior patches) are masking a deeper issue.  It's 
almost as if we don't have correct lifetime information and the various 
return points.  I'd really like to see a deeper analysis of these issues.

jeff
diff mbox

Patch

diff --git a/gcc/regrename.c b/gcc/regrename.c
index 00a5d02..e2d2483 100644
--- a/gcc/regrename.c
+++ b/gcc/regrename.c
@@ -1956,7 +1956,12 @@  public:
   /* opt_pass methods: */
   virtual bool gate (function *)
     {
-      return (optimize > 0 && (flag_rename_registers));
+      /* regrename can decide to use callee-saved registers in places where
+	 those should hold their original contents.  This happens when
+	 separate shrink-wrapping is used.  Disable regrename in that case,
+	 until this problem is fixed.  */
+      return (optimize > 0 && flag_rename_registers
+	      && !crtl->shrink_wrapped_separate);
     }
 
   virtual unsigned int execute (function *) { return regrename_optimize (); }