public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [00/32] Support multiple ABIs in the same translation unit
@ 2019-09-11 19:02 Richard Sandiford
  2019-09-11 19:03 ` [01/32] Add function_abi.{h,cc} Richard Sandiford
                   ` (34 more replies)
  0 siblings, 35 replies; 97+ messages in thread
From: Richard Sandiford @ 2019-09-11 19:02 UTC (permalink / raw)
  To: gcc-patches

This series of patches introduces some classes and helpers for handling
multiple ABIs in the same translation unit.  At the moment "ABI" maans
specifically the choice of call-clobbered registers, but I'm hoping the
structures could be used for other ABI properties in future.

The main point of the series is to use these ABI structures instead of
global information like regs_invalidated_by_call, call_used_or_fixed_regs
and targetm.hard_regno_call_part_clobbered.  This has the side effect
of making all passes take -fipa-ra into account (except sel-sched.c,
see its patch for details).

The series also makes -fipa-ra work for partially-clobbered registers too.
Previously, if the ABI said that only the upper bits of a register are
call-clobbered, we'd enforce that rule separately from the -fipa-ra
information and apply it even when -fipa-ra can prove that the registers
aren't modified.  It turns out that fixing this interacts badly with
vzeroupper on x86, so the series has a patch to fix that.

Another general knock-on change is that we now always use the equivalent
of regs_invalidated_by_call rather than call_used_reg_set when deciding
whether a register is clobbered.  Among other things, this means that
cselib no longer invalidates expressions involving the stack pointer
when processing a call, since calls are guaranteed to return with the
same stack pointer.

The main motivating case for the series is the AArch64 vector PCS
and the SVE PCS, which are variants of the base AArch64 ABI but are
interoperable with it.  (Specifically, vector PCS calls preserve the
low 128 bits of 16 vector registers rather than the usual low 64 bits
of 8 registers.  SVE PCS calls instead preserve the whole of those 16
vector registers.)  However, I realised later that we could also use
this for the tlsdesc ABI on SVE targets, which would remove the need
for CLOBBER_HIGH.  I have follow-on patches to do that.

I also think the new structures would be useful for targets that
implement interrupt-handler attributes.  At the moment, we compile
interrupt handlers pretty much like ordinary functions, using the
same optimisation heuristics as for ordinary functions, and then
account for the extra call-saved registers in the prologue and
epilogue code.  Hooks like TARGET_HARD_REGNO_SCRATCH_OK then
prevent later optimisers from introducing new uses of unprotected
call-saved registers.  If the interrupt handler ABI was described
directly, the middle-end code would work with it in the same way
as for ordinary functions, including taking it into account when
making optimisation decisions.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  There were
some extra guality.exp failures due to the extra optimisation,
but they look like acceptable regressions.

Also tested by compiling at least one target per CPU directory and
checking for no new warnings.  It's quite hard to test for accidental
code differences given the general optimisation changes above, so I
resorted to comparing the gcc.c-torture, gcc.dg and g++.dg code at
-O0 only.  This came back clean except on PRU.

The reason for the PRU differences is that the port defines
targetm.hard_regno_call_part_clobbered, but uses it to test whether
a multi-register value contains a mixture of fully-clobbered and
fully-preserved registers.  AFAICT the port doesn't actually have
individual registers that are partly clobbered, so it doesn't need
to define the hook.  (I can see how the documentation gave a misleading
impression though.  I've tried to improve it in one of the patches.)
The series moves away from testing hard_regno_call_part_clobbered
directly to testing cached information instead, and the way that the
cached information is calculated means that defining the hook the way
the PRU port does has no effect.  In other words, after the series we
treat it (rightly IMO) as having a "normal" ABI whereas before we didn't.

Sorry for the long write-up.

Richard

^ permalink raw reply	[flat|nested] 97+ messages in thread

end of thread, other threads:[~2019-10-29  9:19 UTC | newest]

Thread overview: 97+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11 19:02 [00/32] Support multiple ABIs in the same translation unit Richard Sandiford
2019-09-11 19:03 ` [01/32] Add function_abi.{h,cc} Richard Sandiford
2019-09-29 20:51   ` Jeff Law
2019-09-30  9:19     ` Richard Sandiford
2019-09-30 21:16       ` Jeff Law
2019-09-11 19:03 ` [02/32] Add a target hook for getting an ABI from a function type Richard Sandiford
2019-09-29 20:52   ` Jeff Law
2019-09-11 19:04 ` [03/32] Add a function for getting the ABI of a call insn target Richard Sandiford
2019-09-25 15:38   ` Richard Sandiford
2019-09-30 15:52     ` Jeff Law
2019-09-30 16:32       ` Richard Sandiford
2019-09-30 16:46         ` Jeff Law
2019-09-11 19:05 ` [05/32] Pass an ABI identifier to hard_regno_call_part_clobbered Richard Sandiford
2019-09-29 20:58   ` Jeff Law
2019-09-11 19:05 ` [04/32] [x86] Robustify vzeroupper handling across calls Richard Sandiford
2019-09-25 15:48   ` Richard Sandiford
2019-09-25 18:11     ` Uros Bizjak
2019-10-01 10:14     ` Uros Bizjak
2019-10-08 18:17       ` Uros Bizjak
2019-09-11 19:06 ` [06/32] Pass an ABI to choose_hard_reg_mode Richard Sandiford
2019-09-29 21:00   ` Jeff Law
2019-09-11 19:07 ` [07/32] Remove global call sets: caller-save.c Richard Sandiford
2019-09-29 21:01   ` Jeff Law
2019-09-11 19:07 ` [08/32] Remove global call sets: cfgcleanup.c Richard Sandiford
2019-09-29 21:02   ` Jeff Law
2019-09-11 19:08 ` [09/32] Remove global call sets: cfgloopanal.c Richard Sandiford
2019-09-29 21:02   ` Jeff Law
2019-09-11 19:08 ` [10/32] Remove global call sets: combine.c Richard Sandiford
2019-09-12  2:18   ` Segher Boessenkool
2019-09-12  7:52     ` Richard Sandiford
2019-09-20  0:43       ` Segher Boessenkool
2019-09-25 15:52         ` Richard Sandiford
2019-09-25 16:30           ` Segher Boessenkool
2019-09-29 22:32           ` Jeff Law
2019-09-29 22:43             ` Segher Boessenkool
2019-09-11 19:09 ` [11/32] Remove global call sets: cse.c Richard Sandiford
2019-09-25 15:57   ` Richard Sandiford
2019-09-29 21:04     ` Jeff Law
2019-09-30 16:23       ` Richard Sandiford
2019-09-11 19:09 ` [12/32] Remove global call sets: cselib.c Richard Sandiford
2019-09-29 21:05   ` Jeff Law
2019-10-29  9:20     ` Martin Liška
2019-09-11 19:10 ` [14/32] Remove global call sets: DF (entry/exit defs) Richard Sandiford
2019-09-29 21:07   ` Jeff Law
2019-09-11 19:10 ` [13/32] Remove global call sets: DF (EH edges) Richard Sandiford
2019-09-29 21:07   ` Jeff Law
2019-09-11 19:11 ` [16/32] Remove global call sets: function.c Richard Sandiford
2019-09-29 21:10   ` Jeff Law
2019-09-11 19:11 ` [15/32] Remove global call sets: early-remat.c Richard Sandiford
2019-09-29 21:09   ` Jeff Law
2019-09-11 19:11 ` [17/32] Remove global call sets: gcse.c Richard Sandiford
2019-09-25 16:04   ` Richard Sandiford
2019-09-29 21:10   ` Jeff Law
2019-09-11 19:12 ` [18/32] Remove global call sets: haifa-sched.c Richard Sandiford
2019-09-29 21:11   ` Jeff Law
2019-09-11 19:12 ` [19/32] Remove global call sets: IRA Richard Sandiford
2019-09-30 15:16   ` Jeff Law
2019-09-11 19:13 ` [20/32] Remove global call sets: loop-iv.c Richard Sandiford
2019-09-29 21:20   ` Jeff Law
2019-09-11 19:14 ` [22/32] Remove global call sets: postreload.c Richard Sandiford
2019-09-29 21:33   ` Jeff Law
2019-09-11 19:14 ` [23/32] Remove global call sets: postreload-gcse.c Richard Sandiford
2019-09-25 16:08   ` Richard Sandiford
2019-09-29 22:22     ` Jeff Law
2019-09-11 19:14 ` [21/32] Remove global call sets: LRA Richard Sandiford
2019-09-30 15:29   ` Jeff Law
2019-10-04 18:03   ` H.J. Lu
2019-10-04 21:52     ` H.J. Lu
2019-10-05 13:33       ` Richard Sandiford
2019-09-11 19:15 ` [25/32] Remove global call sets: regcprop.c Richard Sandiford
2019-09-29 21:34   ` Jeff Law
2019-09-11 19:15 ` [24/32] Remove global call sets: recog.c Richard Sandiford
2019-09-29 21:33   ` Jeff Law
2019-09-11 19:16 ` [27/32] Remove global call sets: reload.c Richard Sandiford
2019-09-29 22:26   ` Jeff Law
2019-09-11 19:16 ` [26/32] Remove global call sets: regrename.c Richard Sandiford
2019-09-29 22:25   ` Jeff Law
2019-09-11 19:17 ` [29/32] Remove global call sets: sched-deps.c Richard Sandiford
2019-09-29 22:20   ` Jeff Law
2019-10-04 14:32     ` Christophe Lyon
2019-10-04 14:35       ` Richard Sandiford
2019-10-04 14:37         ` Christophe Lyon
2019-10-07 13:29         ` Christophe Lyon
2019-09-11 19:17 ` [00/32] Remove global call sets: rtlanal.c Richard Sandiford
2019-09-29 22:21   ` Jeff Law
2019-09-11 19:18 ` [30/32] Remove global call sets: sel-sched.c Richard Sandiford
2019-09-30 15:08   ` Jeff Law
2019-09-11 19:18 ` [31/32] Remove global call sets: shrink-wrap.c Richard Sandiford
2019-09-29 22:21   ` Jeff Law
2019-09-11 19:19 ` [32/32] Hide regs_invalidated_by_call etc Richard Sandiford
2019-09-29 22:22   ` Jeff Law
2019-09-12 20:42 ` [00/32] Support multiple ABIs in the same translation unit Steven Bosscher
2019-09-26 19:24 ` Dimitar Dimitrov
2019-09-27  8:58   ` Richard Sandiford
2019-10-01  2:09 ` build-failure for cris-elf with "[00/32] Support multiple ABIs in the same translation unit" Hans-Peter Nilsson
2019-10-01  7:51   ` Richard Sandiford
2019-10-01 10:58     ` Hans-Peter Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).