From d60df0a8adbc8b074602752e9ed14e25d5d73b4b Mon Sep 17 00:00:00 2001 From: uros Date: Sun, 6 Aug 2017 15:48:37 +0000 Subject: [PATCH] * config/alpha/alpha.c (alpha_reorg): If trap is the last active insn in the function, emit NOP after the insn. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250901 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/config/alpha/alpha.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 51ed7c991623..4ed00a29bb02 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-08-06 Uros Bizjak + + * config/alpha/alpha.c (alpha_reorg): If trap is the last active + insn in the function, emit NOP after the insn. + 2017-08-06 Tom de Vries * omp-expand.c (expand_oacc_for): Add missing edge probability for tile diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 9f5dae290546..341ec20d340f 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -9456,6 +9456,25 @@ And in the noreturn case: if (current_function_has_exception_handlers ()) alpha_pad_function_end (); + + /* CALL_PAL that implements trap insn, updates program counter to point + after the insn. In case trap is the last insn in the function, + emit NOP to guarantee that PC remains inside function boundaries. + This workaround is needed to get reliable backtraces. */ + + rtx_insn *insn = prev_active_insn (get_last_insn ()); + + if (insn && NONJUMP_INSN_P (insn)) + { + rtx pat = PATTERN (insn); + if (GET_CODE (pat) == PARALLEL) + { + rtx vec = XVECEXP (pat, 0, 0); + if (GET_CODE (vec) == TRAP_IF + && XEXP (vec, 0) == const1_rtx) + emit_insn_after (gen_unop (), insn); + } + } } static void -- 2.47.2