On 10/23/18 1:49 PM, Jozef Lawrynowicz wrote: > msp430-elf uses the partial int type __int20 for pointers in the large memory > > model. __int20 has PSImode, with bitsize of 20. > > A few DejaGNU tests fail when built with -mlarge for msp430-elf, when > transparent unions are used containing pointers. > These are: > - gcc.c-torture/compile/pr34885.c > - gcc.dg/transparent-union-{1,2,3,4,5}.c > > The issue is that the union is considered to have size of 32 bits (the > in-memory size of __int20), so unless mode_for_size as called by > compute_record_mode (both in stor-layout.c) is explicitly told to look for a > > mode of class MODE_PARTIAL_INT, then a size of 32 will always return MODE_INT. > > In this case, the union will have TYPE_MODE of SImode, but its field is > PSImode, so transparent_union has no effect. > > The attached patch fixes the issue by allowing the TYPE_MODE of a union to be > > set to the DECL_MODE of the widest field, if the mode is of class > MODE_PARTIAL_INT and the union would be passed by reference. > > Some target ABIs mandate that unions be passed in integer registers, so to > avoid any potential ABI violations, the mode of the union is only changed if > > it would be passed by reference. > > Successfully bootstrapped and regstested trunk for x86_64-pc-linux-gnu, and > msp430-elf with -mlarge. For msp430-elf with -mlarge, the above DejaGNU tests > > are also fixed. > > Ok for trunk? > > > 0001-Allow-union-TYPE_MODE-to-be-set-to-the-mode-of-the-w.patch > > From cc1ccfcc0d8adf7b0e1ca95a47a8a8e7e12fc99c Mon Sep 17 00:00:00 2001 > From: Jozef Lawrynowicz <joze...@mittosystems.com> > Date: Mon, 22 Oct 2018 21:02:10 +0100 > Subject: [PATCH] Allow union TYPE_MODE to be set to the mode of the widest > element if the union would be passed by reference > > 2018-10-23 Jozef Lawrynowicz <joze...@mittosystems.com> > > PR c/87691 > * gcc/stor-layout.c (compute_record_mode): Set TYPE_MODE of UNION_TYPE > to the mode of the widest field iff the widest field has mode class > MODE_INT, or MODE_PARTIAL_INT and the union would be passed by > reference. > * gcc/testsuite/gcc.target/msp430/pr87691.c: New test. OK. SOrry for the delay.
jeff