From cc8a9b8755bf92899be8a936b1a1229e06e942fd Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Sun, 6 Aug 2017 17:48:37 +0200 Subject: [PATCH] alpha.c (alpha_reorg): If trap is the last active insn in the function, emit NOP after the insn. * config/alpha/alpha.c (alpha_reorg): If trap is the last active insn in the function, emit NOP after the insn. From-SVN: r250901 --- gcc/ChangeLog | 5 +++++ gcc/config/alpha/alpha.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 51ed7c99162..4ed00a29bb0 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 9f5dae29054..341ec20d340 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.30.2