diff options
author | Kyrylo Tkachov <kyrylo.tkachov@arm.com> | 2018-04-10 09:58:57 +0000 |
---|---|---|
committer | Kyrylo Tkachov <ktkachov@gcc.gnu.org> | 2018-04-10 09:58:57 +0000 |
commit | 5c35bc3e16f0e238488423e37aed5dcbb9bfde46 (patch) | |
tree | 27ab70f24b85e6e1612c9b21b667002c9e38b01e /gcc/explow.c | |
parent | 8d96e546b765cf7e008584359065651008e728e1 (diff) | |
download | gcc-5c35bc3e16f0e238488423e37aed5dcbb9bfde46.zip gcc-5c35bc3e16f0e238488423e37aed5dcbb9bfde46.tar.gz gcc-5c35bc3e16f0e238488423e37aed5dcbb9bfde46.tar.bz2 |
[explow] PR target/85173: validize memory before passing it on to target probe_stack
In this PR the expansion code emits an invalid memory address for the stack probe, which the backend fails to recognise.
The address is created explicitly in anti_adjust_stack_and_probe_stack_clash in explow.c and passed down to gen_probe_stack
without any validation in emit_stack_probe.
This patch fixes the ICE by calling validize_mem on the memory location before passing it down to the target.
Jakub pointed out that we also want to create valid addresses for the probe_stack_address case, so this patch
creates an expand operand and legitimizes it before passing it down to the probe_stack_address expander.
This patch passes bootstrap and testing on arm-none-linux-gnueabihf and aarch64-none-linux-gnu
and ppc64le-redhat-linux on gcc112 in the compile farm.
PR target/85173
* explow.c (emit_stack_probe): Call validize_mem on memory location
before passing it to gen_probe_stack. Create address operand and
legitimize it for the probe_stack_address case.
* gcc.target/arm/pr85173.c: New test.
From-SVN: r259266
Diffstat (limited to 'gcc/explow.c')
-rw-r--r-- | gcc/explow.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/explow.c b/gcc/explow.c index 042e719..fb2b7ff 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -1626,18 +1626,25 @@ void emit_stack_probe (rtx address) { if (targetm.have_probe_stack_address ()) - emit_insn (targetm.gen_probe_stack_address (address)); + { + struct expand_operand ops[1]; + insn_code icode = targetm.code_for_probe_stack_address; + create_address_operand (ops, address); + maybe_legitimize_operands (icode, 0, 1, ops); + expand_insn (icode, 1, ops); + } else { rtx memref = gen_rtx_MEM (word_mode, address); MEM_VOLATILE_P (memref) = 1; + memref = validize_mem (memref); /* See if we have an insn to probe the stack. */ if (targetm.have_probe_stack ()) - emit_insn (targetm.gen_probe_stack (memref)); + emit_insn (targetm.gen_probe_stack (memref)); else - emit_move_insn (memref, const0_rtx); + emit_move_insn (memref, const0_rtx); } } |