diff mbox

Fix ICE with invalid use of flags output operand

Message ID AM4PR0701MB2162054D27450ACE04AC4B8FE4510@AM4PR0701MB2162.eurprd07.prod.outlook.com
State New
Headers show

Commit Message

Bernd Edlinger June 11, 2016, 3:01 p.m. UTC
Hi,

this fixes an ICE that happens when an asm statement tries to print
the flags output operand.

Boot-strapped and reg-tested on x86_64-linux-gnu.
OK for trunk?


Thanks
Bernd.
gcc:
2016-06-11  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* config/i386/i386.c (print_reg): Emit an error message on attempt to
	print FLAGS_REG.

testsuite:
2016-06-11  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* gcc.target/i386/asm-flag-7.c: New test.

Comments

Bernd Edlinger June 21, 2016, 8:09 a.m. UTC | #1
Ping...

for this patch: https://gcc.gnu.org/ml/gcc-patches/2016-06/msg00871.html

I'd say it's a no-brainer...


> Hi,
> 
> this fixes an ICE that happens when an asm statement tries to print
> the flags output operand.
> 
> Boot-strapped and reg-tested on x86_64-linux-gnu.
> OK for trunk?
> 
> 
> Thanks
> Bernd.
Jeff Law June 21, 2016, 3:04 p.m. UTC | #2
On 06/21/2016 02:09 AM, Bernd Edlinger wrote:
> Ping...
>
> for this patch: https://gcc.gnu.org/ml/gcc-patches/2016-06/msg00871.html
>
> I'd say it's a no-brainer...
You might want to contact Uros directly.  He does the most with the x86 
backend these days.

jeff
Bernd Edlinger June 21, 2016, 3:39 p.m. UTC | #3
Oh, yes.

Uros...  ?


Thanks
Bernd.

Am 21.06.2016 um 17:04 schrieb Jeff Law:
> On 06/21/2016 02:09 AM, Bernd Edlinger wrote:
>> Ping...
>>
>> for this patch: https://gcc.gnu.org/ml/gcc-patches/2016-06/msg00871.html
>>
>> I'd say it's a no-brainer...
> You might want to contact Uros directly.  He does the most with the x86
> backend these days.
>
> jeff
>
diff mbox

Patch

Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	(revision 237323)
+++ gcc/config/i386/i386.c	(working copy)
@@ -17180,10 +17180,15 @@  print_reg (rtx x, int code, FILE *file)
 
   gcc_assert (regno != ARG_POINTER_REGNUM
 	      && regno != FRAME_POINTER_REGNUM
-	      && regno != FLAGS_REG
 	      && regno != FPSR_REG
 	      && regno != FPCR_REG);
 
+  if (regno == FLAGS_REG)
+    {
+      output_operand_lossage ("invalid use of asm flag output");
+      return;
+    }
+
   duplicated = code == 'd' && TARGET_AVX;
 
   switch (msize)
Index: gcc/testsuite/gcc.target/i386/asm-flag-7.c
===================================================================
--- gcc/testsuite/gcc.target/i386/asm-flag-7.c	(revision 0)
+++ gcc/testsuite/gcc.target/i386/asm-flag-7.c	(working copy)
@@ -0,0 +1,9 @@ 
+/* Test error conditions of asm flag outputs.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void test(void)
+{
+  char x;
+  asm("# %0" : "=@ccz"(x)); /* { dg-error "invalid use of asm flag output" } */
+}