------- Comment #3 from alond at il dot ibm dot com  2008-01-07 13:01 -------
I have tested the following patch. It fixes the problem. All struct-reorg tests
has also passed on my machine.

It looks like the input to malloc was not calculated correctly in case the size
of the structure is not the order of 2.

Index: ipa-struct-reorg.c
===================================================================
--- ipa-struct-reorg.c  (revision 131371)
+++ ipa-struct-reorg.c  (working copy)
@@ -623,7 +623,12 @@
     add_referenced_var (*res);

   if (exact_log2 (struct_size_int) == -1)
-    new_stmt = build_gimple_modify_stmt (num, struct_size);
+    {
+      tree size = build_int_cst (TREE_TYPE (num), struct_size_int);
+      new_stmt = build_gimple_modify_stmt (*res, build2 (MULT_EXPR,
+                                                        TREE_TYPE (num),
+                                                        num, size));
+    }
   else
     {
       tree C = build_int_cst (TREE_TYPE (num), exact_log2 (struct_size_int));

Ok to submit this patch?

Alon


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34701

Reply via email to