As reported in PR/86662, use of __int20 in a program built with -mlarge and -flto causes a segfault for msp430 due to endless recursion in gimple_get_alias_set. The attached patch fixes this. The segfault can be observed on the gcc-7 and gcc-8 branches, and on trunk. The testcase works in gcc-6
Successfully boostrapped and regtested on x86_64-pc-linux-gnu and msp430-elf. This fixes many LTO C and C++ tests for msp430 when the testsuite is invoked with the -mlarge target flag. Ok for gcc-7-branch, gcc-8-branch, and trunk?
>From 01f8e76dbf50265ae9a3f5f665d27ac8cf811b0c Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz <joze...@mittosystems.com> Date: Tue, 24 Jul 2018 23:24:41 +0100 Subject: [PATCH][MSP430] Fix PR86662 2018-07-27 Jozef Lawrynowicz <joze...@mittosystems.com> PR target/86662 * gcc/tree.c (build_common_tree_nodes): Initialize integer_types array with all enabled __intN types. * gcc/testsuite/gcc.target/msp430/pr86662.c: New test. --- gcc/testsuite/gcc.target/msp430/pr86662.c | 13 +++++++++++++ gcc/tree.c | 3 +-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/msp430/pr86662.c diff --git a/gcc/testsuite/gcc.target/msp430/pr86662.c b/gcc/testsuite/gcc.target/msp430/pr86662.c new file mode 100644 index 0000000..1144b3e --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/pr86662.c @@ -0,0 +1,13 @@ +/* PR/86662 */ + +/* { dg-do link } */ +/* -nostdlib prevents link errors due to mismatched code models for + libgloss objects. */ +/* { dg-options "-mlarge -flto -nostdlib" } */ +/* { dg-skip-if "" { *-*-* } { "-mcpu=msp430" } } */ + +int main(void) +{ + __int20 n = 5; + return 0; +} diff --git a/gcc/tree.c b/gcc/tree.c index bace9c8..54384ad 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -9802,8 +9802,7 @@ build_common_tree_nodes (bool signed_char) int_n_trees[i].signed_type = make_signed_type (int_n_data[i].bitsize); int_n_trees[i].unsigned_type = make_unsigned_type (int_n_data[i].bitsize); - if (int_n_data[i].bitsize > LONG_LONG_TYPE_SIZE - && int_n_enabled_p[i]) + if (int_n_enabled_p[i]) { integer_types[itk_intN_0 + i * 2] = int_n_trees[i].signed_type; integer_types[itk_unsigned_intN_0 + i * 2] = int_n_trees[i].unsigned_type; -- 2.7.4