diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2023-02-22 11:42:43 +0100 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2023-02-22 15:54:55 +0100 |
commit | aee5ee35602e0098c2ae16fa2fc9c8845caf92ed (patch) | |
tree | d2ff1fa14f3cdc0a224031bc8c172980a0cacde5 | |
parent | 3da77f217c8b2089ecba3eb201e727c3fcdcd19d (diff) | |
download | gcc-aee5ee35602e0098c2ae16fa2fc9c8845caf92ed.zip gcc-aee5ee35602e0098c2ae16fa2fc9c8845caf92ed.tar.gz gcc-aee5ee35602e0098c2ae16fa2fc9c8845caf92ed.tar.bz2 |
Rust: In 'type_for_mode' langhook also consider all 'int_n' modes/types
As reported in "Rust related issues" at the end of
<https://inbox.sourceware.org/gcc-patches/20221219212344.ewtuzd2jtztm77x2@lug-owl.de>
"Modula-2 / Rust: Many targets failing",
<https://github.com/Rust-GCC/gccrs/issues/1713>
"Test failure on msp430-elfbare target", for '--target=msp430-elfbar' we ICE:
<built-in>: internal compiler error: Segmentation fault
0xf2efbf crash_signal
../../gcc/gcc/toplev.cc:314
0x120c8c7 build_function_type(tree_node*, tree_node*, bool)
../../gcc/gcc/tree.cc:7360
0x120cc20 build_function_type_list(tree_node*, ...)
../../gcc/gcc/tree.cc:7442
0x120d16b build_common_builtin_nodes()
../../gcc/gcc/tree.cc:9883
0x8449b4 grs_langhook_init
../../gcc/gcc/rust/rust-lang.cc:132
[...]
This is due to 'tmp == NULL' for 'gcc/tree.cc:build_common_builtin_nodes':
tmp = lang_hooks.types.type_for_mode (targetm.eh_return_filter_mode (), 0);
..., were 'targetm.eh_return_filter_mode' (that is,
'gcc/targhooks.cc:default_eh_return_filter_mode',
via calling 'targetm.unwind_word_mode':
'gcc/config/msp430/msp430.cc:msp430_unwind_word_mode') returns 'PSImode',
and 'lang_hooks.types.type_for_mode' (that is,
'gcc/rust/rust-lang.cc:grs_langhook_type_for_mode') returns 'NULL' for
'PSImode'.
As, for example, discussed in <https://gcc.gnu.org/PR46805>
"ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize",
we have to support "random" modes/types in the 'type_for_mode' langhook.
gcc/rust/
* rust-lang.cc (grs_langhook_type_for_mode): Also consider all
'int_n' modes/types.
-rw-r--r-- | gcc/rust/rust-lang.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/rust/rust-lang.cc b/gcc/rust/rust-lang.cc index 3e20c45..1fb1c25 100644 --- a/gcc/rust/rust-lang.cc +++ b/gcc/rust/rust-lang.cc @@ -231,6 +231,21 @@ grs_langhook_type_for_mode (machine_mode mode, int unsignedp) if (mode == TYPE_MODE (complex_integer_type_node) && !unsignedp) return complex_integer_type_node; } + + /* See (a) <https://github.com/Rust-GCC/gccrs/issues/1713> + "Test failure on msp430-elfbare target", and + (b) <https://gcc.gnu.org/PR46805> + "ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize" + -- we have to support "random" modes/types here. + TODO Clean all this up (either locally, or preferably per PR46805: + "Ideally we'd never use lang_hooks.types.type_for_mode (or _for_size) in the + middle-end but had a pure middle-end based implementation". */ + for (size_t i = 0; i < NUM_INT_N_ENTS; i ++) + if (int_n_enabled_p[i] + && mode == int_n_data[i].m) + return (unsignedp ? int_n_trees[i].unsigned_type + : int_n_trees[i].signed_type); + /* gcc_unreachable */ return NULL; } |