diff mbox

[3/5] Fix NOTE_INSN_PROLOGUE_END after unconditional jump.

Message ID 1451762204-13364-4-git-send-email-koriakin@0x04.net
State New
Headers show

Commit Message

Marcin Kościelnicki Jan. 2, 2016, 7:16 p.m. UTC
With the new s390 split-stack support, when optimization is enabled,
the cold path of calling __morestack is likely to be moved to the
end of the function.  This will result in the function ending in
split_stack_call_esa, which is an unconditional jump instruction and
part of the function prologue.  reposition_prologue_and_epilogue_notes
will insert NOTE_INSN_PROLOGUE_END right after it (and before the
following barrier), causing a verification error.  Insert it after
the barrier instead (and outside of basic block).

gcc/ChangeLog:

	* function.c (reposition_prologue_and_epilogue_notes): Avoid
	verification error if the last insn of prologue is an unconditional
	jump.
---
 gcc/ChangeLog  | 6 ++++++
 gcc/function.c | 6 ++++++
 2 files changed, 12 insertions(+)

Comments

Jeff Law April 17, 2016, 6:56 p.m. UTC | #1
On 01/02/2016 12:16 PM, Marcin Kościelnicki wrote:
> With the new s390 split-stack support, when optimization is enabled,
> the cold path of calling __morestack is likely to be moved to the
> end of the function.  This will result in the function ending in
> split_stack_call_esa, which is an unconditional jump instruction and
> part of the function prologue.  reposition_prologue_and_epilogue_notes
> will insert NOTE_INSN_PROLOGUE_END right after it (and before the
> following barrier), causing a verification error.  Insert it after
> the barrier instead (and outside of basic block).
>
> gcc/ChangeLog:
>
> 	* function.c (reposition_prologue_and_epilogue_notes): Avoid
> 	verification error if the last insn of prologue is an unconditional
> 	jump.
> ---
>   gcc/ChangeLog  | 6 ++++++
>   gcc/function.c | 6 ++++++
>   2 files changed, 12 insertions(+)
>
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 6aef3f9..56e31f6 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,5 +1,11 @@
>   2016-01-02  Marcin Kościelnicki  <koriakin@0x04.net>
>
> +	* function.c (reposition_prologue_and_epilogue_notes): Avoid
> +	verification error if the last insn of prologue is an unconditional
> +	jump.
I'm guessing the BARRIER is actually in the hash table of prologue 
insns?  Oh how I wish we didn't express barriers rtl.


Can this leave NOTEs with no associated basic block in the chain? 
reorder_blocks only fixes the block boundaries, it doesn't fix 
BLOCK_FOR_INSN.

Jeff
diff mbox

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6aef3f9..56e31f6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@ 
 2016-01-02  Marcin Kościelnicki  <koriakin@0x04.net>
 
+	* function.c (reposition_prologue_and_epilogue_notes): Avoid
+	verification error if the last insn of prologue is an unconditional
+	jump.
+
+2016-01-02  Marcin Kościelnicki  <koriakin@0x04.net>
+
 	* config/s390/s390.c (s390_asm_declare_function_size): Add code
 	to actually emit the .size directive.
 
diff --git a/gcc/function.c b/gcc/function.c
index 035a49e..921945f 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -6348,6 +6348,12 @@  reposition_prologue_and_epilogue_notes (void)
 	  /* Avoid placing note between CODE_LABEL and BASIC_BLOCK note.  */
 	  if (LABEL_P (last))
 	    last = NEXT_INSN (last);
+	  if (BARRIER_P (last) && BLOCK_FOR_INSN (note))
+	    {
+	      if (BB_END (BLOCK_FOR_INSN (note)) == note)
+		BB_END (BLOCK_FOR_INSN (note)) = PREV_INSN (note);
+	      BLOCK_FOR_INSN (note) = 0;
+	    }
 	  reorder_insns (note, note, last);
 	}
     }