diff mbox

[i386] : Fix PR 52330, valgrind problem on invalid asm

Message ID CAFULd4bkoCsSfnqA-e2YnLeP5DCbq+wTxN3ZvB5PWLyPxXHTSg@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Feb. 22, 2012, 4:14 p.m. UTC
Hello!

2012-02-22  Uros Bizjak  <ubizjak@gmail.com>

	PR target/52330
	* config/i386/i386.c (ix86_print_operand) <case 'H'>: Error out if x
	is not offsettable memory reference.

testsuite/ChangeLog:

2012-02-22  Uros Bizjak  <ubizjak@gmail.com>

	PR target/52330
	* gcc.target/i386/pr52330.c: New test.

Tested on x86_64-pc-linux-gnu, will commit to mainline SVN and release branches.

Uros.
diff mbox

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 184483)
+++ config/i386/i386.c	(working copy)
@@ -14091,6 +14091,13 @@  ix86_print_operand (FILE *file, rtx x, int code)
 	  return;
 
 	case 'H':
+	  if (!offsettable_memref_p (x))
+	    {
+	      output_operand_lossage ("operand is not an offsettable memory "
+				      "reference, invalid operand "
+				      "code 'H'");
+	      return;
+	    }
 	  /* It doesn't actually matter what mode we use here, as we're
 	     only going to use this for printing.  */
 	  x = adjust_address_nv (x, DImode, 8);
Index: testsuite/gcc.target/i386/pr52330.c
===================================================================
--- testsuite/gcc.target/i386/pr52330.c	(revision 0)
+++ testsuite/gcc.target/i386/pr52330.c	(revision 0)
@@ -0,0 +1,6 @@ 
+/* { dg-do compile } */
+
+void foo (int a)
+{
+  asm volatile ("# %H0" : : "r" (a));  /* { dg-error "not an offsettable" } */
+}