On 05/19/2017 07:35 AM, Jozef Lawrynowicz wrote: > Original post: https://gcc.gnu.org/ml/gcc-patches/2017-04/msg01030.html > > The attached patch fixes an issue for the msp430 target where the TYPE_SIZE of > the __int20 type was set using the precision (20 bits) instead of the > in-memory > size (32 bits) of the type. This bug caused an ICE as reported in PR78849: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78849 > > The patch passed bootstrap and regression testing with no regressions > on recent trunk (r247020) for x86_64-pc-linux-gnu. > > The patch passed regression testing with "-mcpu=msp430x/-mlarge" for > msp430-elf on the gcc-6-branch (r247086). Trunk doesn't build with C++ > support for msp430-elf which is why gcc-6-branch was used. > > If the patch is acceptable I would appreciate if someone could commit it for > me > as I don't have write access. > > > 0001-Use-GET_MODE_BITSIZE-when-setting-TYPE_SIZE.patch > > > From 81ee936dcdde4f4a7d4036479dbbff77da1e72bb Mon Sep 17 00:00:00 2001 > From: Jozef Lawrynowicz <joze...@somniumtech.com> > Date: Wed, 12 Apr 2017 14:45:45 +0000 > Subject: [PATCH] Use GET_MODE_BITSIZE when setting TYPE_SIZE > > 2017-05-XX Jozef Lawrynowicz <joze...@somniumtech.com> > > gcc/ > PR target/78849 > * stor-layout.c (initialize_sizetypes): Use GET_MODE_BITSIZE when > setting TYPE_SIZE. > * tree.c (build_common_tree_nodes): Likewise. > > gcc/testsuite > PR target/78849 > * gcc.target/msp430/pr78849.c: New test. > * gcc.target/msp430/msp430.exp: Remove -pedantic-errors option from > DEFAULT_CFLAGS. TYPE_SIZE, according to my understanding, should be a tree for the size of the expression in bits.
The problem is for msp430 that size varies depending on where it's used. ie, in a register an object might have a bitsize of 20 bits, but in memory its size is 32 bits. I don't think that TYPE_SIZE has any concept that the use context is relevant to selecting the proper size. I wonder if we would be better off keeping TYPE_SIZE as-is and instead looking at the end use points where we might have that contextual information. Thoughts? jeff