From 1eb05d1695bfe166882ab48c6e5a9e08d4e6a85d Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 30 May 2017 09:59:29 +0200 Subject: [PATCH] backport: re PR target/79559 (ICE in ix86_print_operand, at config/i386/i386.c:18189) Backported from mainline 2017-02-18 Jakub Jelinek PR target/79559 * config/i386/i386.c (ix86_print_operand): Use output_operand_lossage instead of gcc_assert for K, r and R code checks. Formatting fixes. * gcc.target/i386/pr79559.c: New test. From-SVN: r248644 --- gcc/ChangeLog | 6 ++++ gcc/config/i386/i386.c | 42 ++++++++++++++++--------- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.target/i386/pr79559.c | 11 +++++++ 4 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr79559.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a776f6fc28ef..fc6155647c52 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,12 @@ 2017-05-30 Jakub Jelinek Backported from mainline + 2017-02-18 Jakub Jelinek + + PR target/79559 + * config/i386/i386.c (ix86_print_operand): Use output_operand_lossage + instead of gcc_assert for K, r and R code checks. Formatting fixes. + 2017-02-10 Jakub Jelinek PR tree-optimization/79411 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 79fb328b6d8c..ae3aa226b754 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -15581,8 +15581,8 @@ ix86_print_operand (FILE *file, rtx x, int code) break; default: - output_operand_lossage - ("invalid operand size for operand code 'O'"); + output_operand_lossage ("invalid operand size for operand " + "code 'O'"); return; } @@ -15616,15 +15616,14 @@ ix86_print_operand (FILE *file, rtx x, int code) return; default: - output_operand_lossage - ("invalid operand size for operand code 'z'"); + output_operand_lossage ("invalid operand size for operand " + "code 'z'"); return; } } if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT) - warning - (0, "non-integer operand used with operand code 'z'"); + warning (0, "non-integer operand used with operand code 'z'"); /* FALLTHRU */ case 'Z': @@ -15686,13 +15685,12 @@ ix86_print_operand (FILE *file, rtx x, int code) } else { - output_operand_lossage - ("invalid operand type used with operand code 'Z'"); + output_operand_lossage ("invalid operand type used with " + "operand code 'Z'"); return; } - output_operand_lossage - ("invalid operand size for operand code 'Z'"); + output_operand_lossage ("invalid operand size for operand code 'Z'"); return; case 'd': @@ -15884,7 +15882,12 @@ ix86_print_operand (FILE *file, rtx x, int code) break; case 'K': - gcc_assert (CONST_INT_P (x)); + if (!CONST_INT_P (x)) + { + output_operand_lossage ("operand is not an integer, invalid " + "operand code 'K'"); + return; + } if (INTVAL (x) & IX86_HLE_ACQUIRE) #ifdef HAVE_AS_IX86_HLE @@ -15907,8 +15910,12 @@ ix86_print_operand (FILE *file, rtx x, int code) return; case 'r': - gcc_assert (CONST_INT_P (x)); - gcc_assert (INTVAL (x) == ROUND_SAE); + if (!CONST_INT_P (x) || INTVAL (x) != ROUND_SAE) + { + output_operand_lossage ("operand is not a specific integer, " + "invalid operand code 'r'"); + return; + } if (ASSEMBLER_DIALECT == ASM_INTEL) fputs (", ", file); @@ -15921,7 +15928,12 @@ ix86_print_operand (FILE *file, rtx x, int code) return; case 'R': - gcc_assert (CONST_INT_P (x)); + if (!CONST_INT_P (x)) + { + output_operand_lossage ("operand is not an integer, invalid " + "operand code 'R'"); + return; + } if (ASSEMBLER_DIALECT == ASM_INTEL) fputs (", ", file); @@ -16036,7 +16048,7 @@ ix86_print_operand (FILE *file, rtx x, int code) return; default: - output_operand_lossage ("invalid operand code '%c'", code); + output_operand_lossage ("invalid operand code '%c'", code); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 31c5c72c522f..826a35d61197 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2017-05-30 Jakub Jelinek Backported from mainline + 2017-02-18 Jakub Jelinek + + PR target/79559 + * gcc.target/i386/pr79559.c: New test. + 2017-02-16 Jakub Jelinek PR c++/79512 diff --git a/gcc/testsuite/gcc.target/i386/pr79559.c b/gcc/testsuite/gcc.target/i386/pr79559.c new file mode 100644 index 000000000000..2eeb652a82ed --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr79559.c @@ -0,0 +1,11 @@ +/* PR target/79559 */ +/* { dg-do compile } */ + +void +foo (int x) +{ + __asm__ volatile ("# %K0" : : "r" (x)); /* { dg-error "invalid operand code" } */ + __asm__ volatile ("# %r0" : : "r" (x)); /* { dg-error "invalid operand code" } */ + __asm__ volatile ("# %r0" : : "n" (129)); /* { dg-error "invalid operand code" } */ + __asm__ volatile ("# %R0" : : "r" (x)); /* { dg-error "invalid operand code" } */ +} -- 2.47.2