[PATCH] Fix PR42397

Richard Guenther rguenther@suse.de
Thu Dec 17 15:07:00 GMT 2009


This fixes an ICE with an LTO testcase that uncovers a middle-end
problem.  get_object_alignment does not properly handle &CONST_DECL.

Fixed thus, bootstrapped and tested on x86_64-unknown-linux-gnu,
committed to trunk.

Richard.

2009-12-17  Richard Guenther  <rguenther@suse.de>

	PR middle-end/42397
	* builtins.c (get_object_alignment): Properly deal with
	a CONST_DECL base.
	* expr.c (emit_block_move_hints): Assert the alignment makes
	sense.

Index: gcc/builtins.c
===================================================================
*** gcc/builtins.c	(revision 155297)
--- gcc/builtins.c	(working copy)
*************** get_object_alignment (tree exp, unsigned
*** 323,328 ****
--- 323,330 ----
  	  offset = next_offset;
  	}
      }
+   if (TREE_CODE (exp) == CONST_DECL)
+     exp = DECL_INITIAL (exp);
    if (DECL_P (exp))
      align = MIN (inner, DECL_ALIGN (exp));
  #ifdef CONSTANT_ALIGNMENT
Index: gcc/expr.c
===================================================================
*** gcc/expr.c	(revision 155297)
--- gcc/expr.c	(working copy)
*************** emit_block_move_hints (rtx x, rtx y, rtx
*** 1194,1199 ****
--- 1194,1200 ----
      }
  
    align = MIN (MEM_ALIGN (x), MEM_ALIGN (y));
+   gcc_assert (align >= BITS_PER_UNIT);
  
    gcc_assert (MEM_P (x));
    gcc_assert (MEM_P (y));



More information about the Gcc-patches mailing list