From: Uros Bizjak Date: Mon, 18 Oct 2021 15:03:28 +0000 (+0200) Subject: i386: Fix ICE in ix86_print_opreand_address [PR 102761] X-Git-Tag: releases/gcc-11.3.0~722 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9c3a7243bf7a4db9b0dec44d278e9bf527f3d9b;p=thirdparty%2Fgcc.git i386: Fix ICE in ix86_print_opreand_address [PR 102761] 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. --- diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index fa80daba5231..42c47d2b12b1 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -13767,7 +13767,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" } */ +}