https://gcc.gnu.org/g:0faea63da28b7cb110744c24f432539b883aa2cc
commit 0faea63da28b7cb110744c24f432539b883aa2cc Author: Roger Sayle <ro...@nextmovesoftware.com> Date: Wed May 22 13:48:52 2024 +0100 Avoid ICE in except.cc on targets that don't support exceptions. A number of testcases currently fail on nvptx with the ICE: during RTL pass: final openmp-simd-2.c: In function 'foo': openmp-simd-2.c:28:1: internal compiler error: in get_personality_function, at expr.cc:14037 28 | } | ^ 0x98a38f get_personality_function(tree_node*) /home/roger/GCC/nvptx-none/gcc/gcc/expr.cc:14037 0x969d3b output_function_exception_table(int) /home/roger/GCC/nvptx-none/gcc/gcc/except.cc:3226 0x9b760d rest_of_handle_final /home/roger/GCC/nvptx-none/gcc/gcc/final.cc:4252 The simple oversight in output_function_exception_table is that it calls get_personality_function (immediately) before checking the target's except_unwind_info hook (which on nvptx always returns UI_NONE). The (perhaps obvious) fix is to move the assignments of fname and personality after the tests that they are needed, and before their first use. 2024-05-22 Roger Sayle <ro...@nextmovesoftware.com> gcc/ChangeLog * except.cc (output_function_exception_table): Move call to get_personality_function after targetm_common.except_unwind_info check, to avoid ICE on targets that don't support exceptions. (cherry picked from commit 26df7b4684e201e66c09dd018603a248ddc5f437) Diff: --- gcc/ChangeLog.omp | 7 +++++++ gcc/except.cc | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index b6d1f4c58877..a95ac57ca76f 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,5 +1,12 @@ 2025-02-18 Thomas Schwinge <tschwi...@baylibre.com> + Backported from trunk: + 2024-05-22 Roger Sayle <ro...@nextmovesoftware.com> + + * except.cc (output_function_exception_table): Move call to + get_personality_function after targetm_common.except_unwind_info + check, to avoid ICE on targets that don't support exceptions. + Backported from trunk: 2025-02-07 Thomas Schwinge <tschwi...@baylibre.com> diff --git a/gcc/except.cc b/gcc/except.cc index c6c9c80d2864..e0a9d5e686ee 100644 --- a/gcc/except.cc +++ b/gcc/except.cc @@ -3224,9 +3224,6 @@ output_one_function_exception_table (int section) void output_function_exception_table (int section) { - const char *fnname = get_fnname_from_decl (current_function_decl); - rtx personality = get_personality_function (current_function_decl); - /* Not all functions need anything. */ if (!crtl->uses_eh_lsda || targetm_common.except_unwind_info (&global_options) == UI_NONE) @@ -3236,6 +3233,9 @@ output_function_exception_table (int section) if (section == 1 && !crtl->eh.call_site_record_v[1]) return; + const char *fnname = get_fnname_from_decl (current_function_decl); + rtx personality = get_personality_function (current_function_decl); + if (personality) { assemble_external_libcall (personality);