From 4abc0c196b10251dc80d0743ba9e8ab3e56c61ed Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Mon, 18 Oct 2021 17:03:28 +0200 Subject: [PATCH] i386: Fix ICE in ix86_print_opreand_address [PR 102761] MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2021-10-18 Uroš Bizjak PR target/102761 gcc/ChangeLog: * config/i386/i386.c (ix86_print_operand_address): Error out for non-address_operand asm operands. gcc/testsuite/ChangeLog: * gcc.target/i386/pr102761.c: New test. --- gcc/config/i386/i386.c | 5 ++++- gcc/testsuite/gcc.target/i386/pr102761.c | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr102761.c diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 3c3336d230a2..f111411e5996 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -13921,7 +13921,10 @@ ix86_print_operand_address_as (FILE *file, rtx addr, static void ix86_print_operand_address (FILE *file, machine_mode /*mode*/, rtx addr) { - ix86_print_operand_address_as (file, addr, ADDR_SPACE_GENERIC, false); + if (this_is_asm_operands && ! address_operand (addr, VOIDmode)) + output_operand_lossage ("invalid constraints for operand"); + else + ix86_print_operand_address_as (file, addr, ADDR_SPACE_GENERIC, false); } /* Implementation of TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA. */ diff --git a/gcc/testsuite/gcc.target/i386/pr102761.c b/gcc/testsuite/gcc.target/i386/pr102761.c new file mode 100644 index 000000000000..58ff27e4bcc7 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr102761.c @@ -0,0 +1,11 @@ +/* PR target/102761 */ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +int foo (void); + +void +bar (void) +{ + asm volatile ("%a0" : : "X"(foo () ? 2 : 1)); /* { dg-error "invalid constraints for operand" } */ +} -- 2.47.2