[Bug tree-optimization/43567] linear loop transform

2010-07-11 Thread tjvries at xs4all dot nl


--- Comment #4 from tjvries at xs4all dot nl  2010-07-11 06:10 ---
submitted patch for review:
http://gcc.gnu.org/ml/gcc-patches/2010-07/msg00879.html


-- 

tjvries at xs4all dot nl changed:

   What|Removed |Added

 CC||tjvries at xs4all dot nl


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



[Bug tree-optimization/43567] linear loop transform

2010-06-25 Thread tjvries at xs4all dot nl


--- Comment #2 from tjvries at xs4all dot nl  2010-06-25 19:16 ---
Created an attachment (id=21007)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21007action=view)
slightly more minimal testcase

reproduced on trunk revision 161295


-- 


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



[Bug tree-optimization/43567] linear loop transform

2010-06-25 Thread tjvries at xs4all dot nl


--- Comment #3 from tjvries at xs4all dot nl  2010-06-25 20:06 ---
Created an attachment (id=21008)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21008action=view)
partially redoing the fix for bug 20612

The problem is in this piece of code in lambda_loopnest_gcc_loopnest:
...
  /* Create the new iv.  */

  standard_iv_increment_position (temp, bsi, insert_after);
  create_iv (newlowerbound,
 build_int_cst (type, LL_STEP (newloop)),
 ivvar, temp, bsi, insert_after, ivvar,
 NULL);

  /* Unfortunately, the incremented ivvar that create_iv inserted may not
 dominate the block containing the exit condition.
 So we simply create our own incremented iv to use in the new exit
 test,  and let redundancy elimination sort it out.  */
  inc_stmt = gimple_build_assign_with_ops (PLUS_EXPR, SSA_NAME_VAR (ivvar),
   ivvar,
   build_int_cst (type, LL_STEP
(newloop)));

  ivvarinced = make_ssa_name (SSA_NAME_VAR (ivvar), inc_stmt);
  gimple_assign_set_lhs (inc_stmt, ivvarinced);
  bsi = gsi_for_stmt (exitcond);
  gsi_insert_before (bsi, inc_stmt, GSI_SAME_STMT);
...

In case the loop header is copied (-ftree-ch), the second increment is in the
same block as the first increment:
...
  lnivtmp.6_13 = lnivtmp.6_20 + 1;
  lnivtmp.6_1 = lnivtmp.6_20 + 1;
  if (lletmp.8_21 = lnivtmp.6_1)
...
indeed redundancy elimination sorts this out.

However, if the loop header is not copied:
...bb 5:
  i_11 = i_1 + 1;
  lnivtmp.2_19 = lnivtmp.2_5 + 1;

bb 6:
  # i_1 = PHI 0(2), i_11(5)
  # lnivtmp.2_5 = PHI 0(2), lnivtmp.2_19(5)
  lletmp.4_16 = n_4(D) + -1;
  lnivtmp.2_17 = lnivtmp.2_5 + 1;
  if (lletmp.4_16 = lnivtmp.2_17)
...
the second increment is an extra increment, on top of the first one.

The patches fixes this, I'm not sure how minimal or efficient, but I did a
x86_64-unknown-linux-gnu bootstrap build and ran testsuites (gcc, objc,
gfortran, g++, libgomp, libstdc++, libjava, libmudflap, libffi) for r161295
and r161295+patch, with identical results.


-- 


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



[Bug debug/31230] debug information depends on gc parameters

2010-06-21 Thread tjvries at xs4all dot nl


--- Comment #4 from tjvries at xs4all dot nl  2010-06-21 10:20 ---
Created an attachment (id=20953)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20953action=view)
 minimal test case of 14 lines, cut down from varasm.i

I also ran into this bug, while building gcc 4.3.5 for x86_64-unknown-linux-gnu
with make {CFLAGS,BOOT_CFLAGS,STAGE1_CFLAGS}=\-g3\ -O0\ -dH\.

I managed to minimized the test case down to 14 lines.

The difference in debug info can be reproduced using:
...
$ cc1 varasm.i -O0 -g -quiet -o varasm.s 
$ cc1 varasm.i -O0 -g -quiet -o varasm.s.0.0 --param ggc-min-expand=0 --param
ggc-min-heapsize=0 
...


-- 


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



[Bug debug/31230] debug information depends on gc parameters

2010-06-21 Thread tjvries at xs4all dot nl


--- Comment #5 from tjvries at xs4all dot nl  2010-06-21 10:32 ---
Created an attachment (id=20954)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20954action=view)
naive patch. run callbacks on hashtable entries exhaustively before deleting

Furthermore, I investigated why this problem does not occur with 4.4.0 onwards,
and I found that this is due to the fact that -funit-at-a-time is hard coded to
on for 4.4.0, which causes f1 to be live at the same time as f3 (no
cgraph_release_function_body() in between). An easy workaround for this problem
in 4.3.5 is therefore -funit-at-a-time.

I also managed to reproduce the problem for -gstabs. The patch from comment 3
works indeed, but not for -gstabs, which makes a lot of sense since the patch
is dwarf specific. Of course we might attempt to fix the stab format (and
possible others) in a similar way, but the fact that the fix needs to be
repeated made me wonder whether the problem had to be dealt with at another
level than specific debug formats.

Let's take a look at what happens exactly during garbage collection in between
f1 and f3 in mark_roots():
- gt_ggc_rtab is traversed, and neither array type nor index type is marked
live
- gt_ggc_cache_rtab is traversed, in particular type_hash_table, and the hash
entry with the index type is hit (before the entry with the array type, but
this is non-deterministic) and processed by ggc_htab_delete(). The entry is not
considered live, and consequently the entry is cleared.
- next the entry with the array type is hit and processed by ggc_htab_delete().
The entry is considered live due to TYPE_SYMTAB_POINTER (type). Consequently
the callback is called, marking the entry and everything reachable from it
live, including the index type. Unfortunately, the hash entry for the index
type is already gone.

During parsing of f3, a new index type equivalent to the old one is created,
but type_hash_canon cannot find the old index type in the hash table (since
that entry has been deleted), so the new index type is now a canonical type,
and gets an entry in the type_hash_table. Next, a new array type equivalent to
the old one is created, but type_hash_canon cannot find the old array type,
even though the entry has not been deleted. The new array type has a different
index type than the old array type, and consequently the hashcode for the new
array type is different than the hascode for the old array type, so the old
array type is not found. The new array type is now also a canonical type, and
gets an entry in the type_hash_table. The old index type, the old array type
and the hash table entry associated with the old array type are now unused but
not freed.

The question is whether to blame this on 
- invalid use of the garbage collection infrastructure. Using the if_marked
construction to mark an object live, is only allowed if everything reachable
from that object is also live. 
- the garbage collection infrastructure itself. If the if_marked construction
is used to mark an object live, the garbage collection infrastructure should
mark everything that is reachable from that object also as live.

The patch in comment 3 seems to take the first choice. I decided to explore the
second choice, and created a naive patch of ggc_mark_roots(). It solves the
inconsistent debug info problem, both for dwarf2 and for stabs. I did a debug
bootstrap build (-g3 -O0 -dH) with the patch and ran the testsuites (gcc, objc,
gfortran, g++, libgomp, libstdc++, libjava, libmudflap, libffi), with the same
results as a normal bootstrap build without the patch, so the patch looks sane
at least.

This is my first time looking into the gcc garbage collector, so I'd appreciate
some comments on my findings.


-- 


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