[PATCH, PR40351] When creating artificial (copy-propagation) sub-accesses, check that they make sense
Martin Jambor
mjambor@suse.cz
Mon Jun 8 20:37:00 GMT 2009
Hi,
this patch fixes PR 40351, caused by the fact that we propagate
sub-accesses across assignments, unions can now trick us into creating
some which do not make sense (they do not exist in a union field).
The patch below checks that does not happen before creating an
artificial access.
Bootstrapped and regression tested on x86_64-linux. OK for trunk?
Thanks,
Martin
2009-06-05 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/40351
* tree-sra.c (propagate_subacesses_accross_link): Check that a refrence
to a potential artifical subaccess can be constructed.
* testsuite/gcc.c-torture/compile/pr40351.c: New file.
Index: gcc/testsuite/gcc.c-torture/compile/pr40351.c
===================================================================
--- gcc/testsuite/gcc.c-torture/compile/pr40351.c (revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/pr40351.c (revision 0)
@@ -0,0 +1,22 @@
+/* PR tree-optimizations/40351 */
+
+struct IO_APIC_route_entry {
+ unsigned int vector : 8;
+ unsigned int delivery_mode : 1;
+ unsigned int mask : 1;
+ unsigned int __reserved_2 : 15;
+ unsigned int __reserved_3 : 8;
+} __attribute__ ((packed));
+union entry_union {
+ struct {
+ unsigned int w1, w2;
+ };
+ struct IO_APIC_route_entry entry;
+};
+unsigned int io_apic_read(void);
+struct IO_APIC_route_entry ioapic_read_entry(void)
+{
+ union entry_union eu;
+ eu.w1 = io_apic_read();
+ return eu.entry;
+}
Index: gcc/tree-sra.c
===================================================================
--- gcc/tree-sra.c (revision 148205)
+++ gcc/tree-sra.c (working copy)
@@ -1544,6 +1544,10 @@ propagate_subacesses_accross_link (struc
continue;
}
+ if (!build_ref_for_offset (NULL, TREE_TYPE (lacc->base), norm_offset,
+ rchild->type, false))
+ continue;
+
new_acc = create_artificial_child_access (lacc, rchild, norm_offset);
if (racc->first_child)
propagate_subacesses_accross_link (new_acc, rchild);
More information about the Gcc-patches
mailing list