patch ping: Add static branch predict heuristic of comparing IV to loop_bound variable
http://gcc.gnu.org/ml/gcc-patches/2012-01/msg00377.html Thanks! Dehao
Re: PR other/51165: add new adress_escapes predicate
On Mon, Jan 16, 2012 at 4:58 PM, Aldy Hernandez wrote: > >> Not really - you handle both ptr and *ptr in the same predicate and >> call both "address escaped". What I suggested was sth like > > > I think I confused myself and you by asking the wrong question in the first > place. > > Actually, what I want is to handle VAR_DECL correctly, and your original > suggestion of using may_be_aliased() fits the bill. The other calls to > ptr_deref_may_alias_global_p() were fine because we have an SSA_NAME. > > We're now down to a one-liner :). > > How about this? All TM memory optimization tests fixed, and no regressions. Ok. Note that may_be_aliased (x) is also true if x is an automatic variable that has its address taken. You can use is_global_var (x) instead if you only want to test for "global memory". Richard.
Re: C++ PATCH for c++/51827 (mangling error with PCH and LTO)
On Mon, Jan 16, 2012 at 10:29 PM, Jason Merrill wrote: > When outputting PCH/LTO, the compiler tries to generate mangled names for > all decls before discarding language-specific data. But that doesn't make > sense for templates, and leads to conflicts in this case. Fixed by refusing > to mangle templates. > > Tested x86_64-pc-linux-gnu, applying to trunk. Hmm. Using -flto when generating a precompiled header doesn't make sense. We probably should drop -flto silently or complain here. Thus, Index: c-family/c-opts.c === --- c-family/c-opts.c (revision 183205) +++ c-family/c-opts.c (working copy) @@ -1058,6 +1058,13 @@ c_common_post_options (const char **pfil && flag_preprocess_only && !flag_no_line_commands) pp_dir_change (parse_in, get_src_pwd ()); + /* Disable LTO output when outputting a precompiled header. */ + if (pch_file && flag_lto) +{ + flag_lto = 0; + flag_generate_lto = 0; +} + return flag_preprocess_only; } any objection to that? Thanks, Richard.
Re: [PATCH] Fix PR 33512 Folding of x & ((~x) | y) into x & y on the tree level
On Tue, Jan 17, 2012 at 8:06 AM, Andrew Pinski wrote: > Hi, > This adds the folding of x & ((~x) | y)) into x & y on the tree > level via fold-const.c > There is already partly done on the RTL level but it would be a good > thing for the tree level also. > > > OK for 4.8 (yes I know we have not branched yet but I thought I would > send it out so I don't forget about it)? > Bootstrapped and tested on x86_64-linux-gnu with no regressions. Can you instead patch tree-ssa-forwprop.c:simplify_bitwise_binary? Thanks, Richard. > Thanks, > Andrew Pinski > > ChangeLog: > * fold-const.c (fold_binary_loc ): Add folding of x > & (~x | y) into x & y. > > testsuite/ChangeLog: > * gcc.dg/tree-ssa/andor-3.c: New testcase.
[build] Disable dl_iterate_phdr on Solaris 10
Mainline bootstrap is currently failing on Solaris 10 Update 10 with GNU ld. cc1 etc. are failing to link in stage2 like this: /var/gcc/regression/trunk/10-gcc-gas-gld/build/./prev-gcc/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `_Unwind_Find_FDE': /vol/gcc/src/hg/trunk/local/libgcc/unwind-dw2-fde-dip.c:451: undefined reference to `dl_iterate_phdr' collect2: error: ld returned 1 exit status make[3]: *** [lto1] Error 1 This happens because most of the Solaris 11 linker changes have been backported to Solaris 10 Update 10, dl_iterate_phdr support among them. Unfortunately, the function is only available in libdl there, not in libc as on Solaris 11. At first I thought about linking with -ldl if this condition is detected during configure, but decided against it for two reasons: * dl_iterate_phdr is referenced from both libgcc_eh.a and libgcc_s.so.1, so every executable and shared library would have to be linked with -ldl. Such a change is certainly not stage4 material. * Even if it were installed (perhaps in 4.8 stage1), it would break compatibility between Solaris 10 updates, which I consider a bad thing. Therefore I'm disabling the check for dl_iterate_phdr in target headers before Solaris 11 to avoid this situation. This fixes the bootstrap with gld. If Sun ld is in use, bootstrap isn't broken because the requisite ld version isn't detected due to differences in linker version numbering between OS releases. Bootstrapped without regressions on i386-pc-solaris2.10 with as/ld, gas/ld, and gas/gld. Installed on mainline. Rainer 2012-01-15 Rainer Orth * configure.ac (gcc_cv_target_dl_iterate_phdr): Only check on Solaris 11+. * configure: Regenerate. -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Re: [build] Disable dl_iterate_phdr on Solaris 10
Rainer Orth writes: > 2012-01-15 Rainer Orth > > * configure.ac (gcc_cv_target_dl_iterate_phdr): Only check on > Solaris 11+. > * configure: Regenerate. It helps to actually attach the patch. diff --git a/gcc/configure.ac b/gcc/configure.ac --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -4642,7 +4642,11 @@ fi AC_MSG_CHECKING(dl_iterate_phdr in target C library) gcc_cv_target_dl_iterate_phdr=unknown case "$target" in - *-*-solaris2*) + # Restrict to Solaris 11+. While most of the Solaris 11 linker changes + # were backported to Solaris 10 Update 10, dl_iterate_phdr only lives in + # libdl there, both complicating its use and breaking compatibility + # between Solaris 10 updates. + *-*-solaris2.1[[1-9]]*) # needs both a dl_iterate_phdr declaration and support for # compilation with largefile support. if grep dl_iterate_phdr $target_header_dir/link.h > /dev/null 2>&1 \ -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Re: [libitm] Skip static_ctor.C test (PR libitm/51173)
Mike Stump writes: > On Jan 16, 2012, at 9:14 AM, Rainer Orth wrote: >> As suggested in the PR, it would be better to just skip the test to >> avoid noise in mail-report.log: > > Usually we avoid noise in the testing log files by making testcases > pass? I know, this one is kinda inelegant, but I'd just leave it as Agreed, but from my understanding this is 4.8 material in this case: Target Milestone is set to 4.8.0. > is. If it doesn't pass on any useful target, I suppose skipping or It doesn't and is therefore xfailed on *-*-*. > just removing the testcase would be fine, with the idea that the > testcases is added back or reenabled when the PR is fixed. Let's give > the TM people a chance to weigh in, if they'd like, but, if they > don't, I'll Ok it if you prefer to disable or remove it. I'd like to simply disable it if they don't have other preferences. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
[PATCH] Fix ICE with -Wp,-pie (PR driver/47249)
Hi! We ICE with -Wp,-pie, as -pie (and -shared/--pie/--shared) are marked as Common options, but aren't handled in the cc1/cc1plus/etc. options handling. Fixed by making those options Driver specific, and for the time being add their help strings to display_help. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Alternatively there is a second (untested) patch. 2012-01-17 Jakub Jelinek PR driver/47249 * common.opt (-pie, -shared, pie, shared): Change from Common to Driver. * gcc.c (display_help): Display help for -pie and -shared. --- gcc/common.opt.jj 2012-01-13 21:47:35.0 +0100 +++ gcc/common.opt 2012-01-16 13:44:44.905958270 +0100 @@ -1,6 +1,6 @@ ; Options for the language- and target-independent parts of the compiler. -; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 +; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 ; Free Software Foundation, Inc. ; ; This file is part of GCC. @@ -313,7 +313,7 @@ Common Alias(pedantic) Common Alias(pedantic-errors) -pie -Common Alias(pie) +Driver Alias(pie) -pipe Driver Alias(pipe) @@ -367,7 +367,7 @@ Common Alias(p) Driver Alias(save-temps) -shared -Common Alias(shared) +Driver Alias(shared) -specs Driver Separate Alias(specs=) @@ -2380,7 +2380,7 @@ x Driver Joined Separate shared -Common RejectNegative Negative(pie) +Driver RejectNegative Negative(pie) Create a shared library shared-libgcc @@ -2413,7 +2413,7 @@ symbolic Driver pie -Common RejectNegative Negative(shared) +Driver RejectNegative Negative(shared) Create a position independent executable z --- gcc/gcc.c.jj2012-01-01 19:59:36.0 +0100 +++ gcc/gcc.c 2012-01-16 14:12:39.761217387 +0100 @@ -2988,6 +2988,8 @@ display_help (void) fputs (_(" -S Compile only; do not assemble or link\n"), stdout); fputs (_(" -c Compile and assemble, but do not link\n"), stdout); fputs (_(" -o Place the output into \n"), stdout); + fputs (_(" -pie Create a position independent executable\n"), stdout); + fputs (_(" -shared Create a shared library\n"), stdout); fputs (_("\ -x Specify the language of the following input files\n\ Permissible languages include: c c++ assembler none\n\ Jakub 2012-01-17 Jakub Jelinek PR driver/47249 * opts.c (common_handle_option): Reject OPT_pie and OPT_shared. --- gcc/opts.c.jj 2012-01-13 21:47:35.0 +0100 +++ gcc/opts.c 2012-01-16 14:46:22.126400331 +0100 @@ -1744,6 +1744,12 @@ common_handle_option (struct gcc_options opts->x_warn_maybe_uninitialized = value; break; +case OPT_pie: +case OPT_shared: + error ("command line option %qs is valid only for the driver", +decoded->orig_option_with_args_text); + break; + default: /* If the flag was handled in a standard way, assume the lack of processing here is intentional. */
[PATCH] Fix powerpc64-linux -mminimal-toc shrink-wrapping bootstrap failure (PR bootstrap/51872)
Hi! crtbegin.o is miscompiled on powerpc64-linux with -mminimal-toc (and likely many other sources). The problem is that when flag_pic is 0, the shrink-wrapping code doesn't consider register r30 being set up by the prologue, so instructions that use r30 (TOC_REGISTER) can be considered usable even without an earlier prologue that computes it. Unfortunately the generic code adds just a couple of selected registers to set_up_by_prologue regset, and I don't see without a target hook a way to add further registers to the hard regset. So, this patch implements such a hook and uses it on rs6000 to indicate that r30 is computed by the prologue if the prologue does that. Bootstrapped/regtested on powerpc64-linux (with -mminimal-toc in CFLAGS/CXXFLAGS/etc., which previously failed to bootstrap) and on x86_64-linux and i686-linux. Ok for trunk? 2012-01-17 Jakub Jelinek PR bootstrap/51872 * hard-reg-set.h (struct hard_reg_set_container): New type. * target.h (struct hard_reg_set_container): Forward declare. * target.def (set_up_by_prologue): New target hook. * doc/tm.texi (TARGET_SET_UP_BY_PROLOGUE): Document it. * function.c (thread_prologue_and_epilogue_insns): Change set_up_by_prologue HARD_REG_SET into struct hard_reg_set_container. Call targetm.set_up_by_prologue on it. * config/rs6000/rs6000.c (rs6000_set_up_by_prologue): New function. (TARGET_SET_UP_BY_PROLOGUE): Redefine to it. --- gcc/hard-reg-set.h.jj 2011-11-28 17:58:04.0 +0100 +++ gcc/hard-reg-set.h 2012-01-16 17:27:35.837610779 +0100 @@ -54,6 +54,14 @@ typedef HARD_REG_ELT_TYPE HARD_REG_SET[H #endif +/* HARD_REG_SET wrapped into a structure, to make it possible to + use HARD_REG_SET even in APIs that should not include + hard-reg-set.h. */ +struct hard_reg_set_container +{ + HARD_REG_SET set; +}; + /* HARD_CONST is used to cast a constant to the appropriate type for use with a HARD_REG_SET. */ --- gcc/target.h.jj 2011-06-17 11:02:19.0 +0200 +++ gcc/target.h2012-01-16 17:28:13.348394331 +0100 @@ -92,6 +92,7 @@ extern bool target_default_pointer_addre struct stdarg_info; struct spec_info_def; +struct hard_reg_set_container; /* The struct used by the secondary_reload target hook. */ typedef struct secondary_reload_info --- gcc/target.def.jj 2011-12-27 11:39:49.0 +0100 +++ gcc/target.def 2012-01-16 19:51:00.171464193 +0100 @@ -2644,6 +2644,14 @@ DEFHOOK void, (bitmap regs), hook_void_bitmap) +/* Fill in additional registers set up by prologue into a regset. */ +DEFHOOK +(set_up_by_prologue, + "This hook should add additional registers that are computed by the prologue\ + to the hard regset for shrink-wrapping optimization purposes.", + void, (struct hard_reg_set_container *), + NULL) + /* Determine the type of unwind info to emit for debugging. */ DEFHOOK (debug_unwind_info, --- gcc/doc/tm.texi.jj 2011-12-27 11:39:47.0 +0100 +++ gcc/doc/tm.texi 2012-01-16 19:51:59.0 +0100 @@ -4959,6 +4959,10 @@ TARGET_STRUCT_VALUE_RTX, FRAME_POINTER_R FRAME_POINTER_REGNUM, ARG_POINTER_REGNUM, and the PIC_OFFSET_TABLE_REGNUM. @end deftypefn +@deftypefn {Target Hook} void TARGET_SET_UP_BY_PROLOGUE (struct hard_reg_set_container *@var{}) +This hook should add additional registers that are computed by the prologue to the hard regset for shrink-wrapping optimization purposes. +@end deftypefn + @node Stack Smashing Protection @subsection Stack smashing protection @cindex stack smashing protection --- gcc/doc/tm.texi.in.jj 2011-12-27 11:39:47.0 +0100 +++ gcc/doc/tm.texi.in 2012-01-16 19:51:38.531284609 +0100 @@ -4906,6 +4906,8 @@ TARGET_STRUCT_VALUE_RTX, FRAME_POINTER_R FRAME_POINTER_REGNUM, ARG_POINTER_REGNUM, and the PIC_OFFSET_TABLE_REGNUM. @end deftypefn +@hook TARGET_SET_UP_BY_PROLOGUE + @node Stack Smashing Protection @subsection Stack smashing protection @cindex stack smashing protection --- gcc/function.c.jj 2012-01-13 21:47:35.0 +0100 +++ gcc/function.c 2012-01-16 17:42:49.485331902 +0100 @@ -5899,7 +5899,7 @@ thread_prologue_and_epilogue_insns (void && nonempty_prologue && !crtl->calls_eh_return) { HARD_REG_SET prologue_clobbered, prologue_used, live_on_edge; - HARD_REG_SET set_up_by_prologue; + struct hard_reg_set_container set_up_by_prologue; rtx p_insn; VEC(basic_block, heap) *vec; basic_block bb; @@ -5939,18 +5939,22 @@ thread_prologue_and_epilogue_insns (void vec = VEC_alloc (basic_block, heap, n_basic_blocks); - CLEAR_HARD_REG_SET (set_up_by_prologue); - add_to_hard_reg_set (&set_up_by_prologue, Pmode, STACK_POINTER_REGNUM); - add_to_hard_reg_set (&set_up_by_prologue, Pmode, ARG_POINTER_REGNUM); + CLEAR_HARD_REG_SET (set_up_by_prologue.set); + add_to_hard_reg_set (&set_up_by_prologue.set, Pmode, + STACK_POINTER_RE
[PATCH] Fix tail merging (PR tree-optimization/51877)
Hi! We tail merge a = bar (7); with *x = bar (7); completely ignoring the case that the lhs are different. IMHO we can't merge if one of the calls has lhs and the other doesn't, or if both calls have non-SSA_NAME lhs and they aren't equal (this case). If both calls have SSA_NAME lhs, I can see why it might be nice to tail merge both if the calls have the same argument same destination even when the lhs don't valueize the same (sccvn will value number the same just pure/const calls, right), but I don't see how it can actually work, the SSA_NAMEs will be used somewhere later on in the BB or in the PHI, and there we compare vn_valueize anyway. We'd need to somehow mark those two SSA_NAMEs as equivalent for further VN. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2012-01-17 Jakub Jelinek PR tree-optimization/51877 * tree-ssa-tail-merge.c (gimple_equal_p): Don't return true whenever call arguments and fndecls compare equal, instead return false if they don't. Return true only if lhs1 and lhs2 are either both NULL, or both SSA_NAMEs that are valueized the same, or they satisfy operand_equal_p. * gcc.c-torture/execute/pr51877.c: New test. --- gcc/tree-ssa-tail-merge.c.jj2011-12-12 22:10:26.0 +0100 +++ gcc/tree-ssa-tail-merge.c 2012-01-17 08:28:56.903471558 +0100 @@ -1071,14 +1071,18 @@ gimple_equal_p (same_succ same_succ, gim equal = false; break; } - if (equal) - return true; + if (!equal) + return false; lhs1 = gimple_get_lhs (s1); lhs2 = gimple_get_lhs (s2); - return (lhs1 != NULL_TREE && lhs2 != NULL_TREE - && TREE_CODE (lhs1) == SSA_NAME && TREE_CODE (lhs2) == SSA_NAME - && vn_valueize (lhs1) == vn_valueize (lhs2)); + if (lhs1 == NULL_TREE && lhs2 == NULL_TREE) + return true; + if (lhs1 == NULL_TREE || lhs2 == NULL_TREE) + return false; + if (TREE_CODE (lhs1) == SSA_NAME && TREE_CODE (lhs2) == SSA_NAME) + return vn_valueize (lhs1) == vn_valueize (lhs2); + return operand_equal_p (lhs1, lhs2, 0); case GIMPLE_ASSIGN: lhs1 = gimple_get_lhs (s1); --- gcc/testsuite/gcc.c-torture/execute/pr51877.c.jj2012-01-17 08:36:31.012781551 +0100 +++ gcc/testsuite/gcc.c-torture/execute/pr51877.c 2012-01-17 08:35:26.0 +0100 @@ -0,0 +1,50 @@ +/* PR tree-optimization/51877 */ + +extern void abort (void); +struct A { int a; char b[32]; } a, b; + +__attribute__((noinline, noclone)) +struct A +bar (int x) +{ + struct A r; + static int n; + r.a = ++n; + __builtin_memset (r.b, 0, sizeof (r.b)); + r.b[0] = x; + return r; +} + +__attribute__((noinline, noclone)) +void +baz (void) +{ + asm volatile ("" : : : "memory"); +} + +__attribute__((noinline, noclone)) +void +foo (struct A *x, int y) +{ + if (y == 6) +a = bar (7); + else +*x = bar (7); + baz (); +} + +int +main () +{ + a = bar (3); + b = bar (4); + if (a.a != 1 || a.b[0] != 3 || b.a != 2 || b.b[0] != 4) +abort (); + foo (&b, 0); + if (a.a != 1 || a.b[0] != 3 || b.a != 3 || b.b[0] != 7) +abort (); + foo (&b, 6); + if (a.a != 4 || a.b[0] != 7 || b.a != 3 || b.b[0] != 7) +abort (); + return 0; +} Jakub
Re: [PATCH] Fix tail merging (PR tree-optimization/51877)
On Tue, 17 Jan 2012, Jakub Jelinek wrote: > Hi! > > We tail merge > a = bar (7); > with > *x = bar (7); > completely ignoring the case that the lhs are different. > IMHO we can't merge if one of the calls has lhs and the other doesn't, > or if both calls have non-SSA_NAME lhs and they aren't equal (this case). > If both calls have SSA_NAME lhs, I can see why it might be nice to tail > merge both if the calls have the same argument same destination even when > the lhs don't valueize the same (sccvn will value number the same just > pure/const calls, right), but I don't see how it can actually work, > the SSA_NAMEs will be used somewhere later on in the BB or in the PHI, > and there we compare vn_valueize anyway. We'd need to somehow mark > those two SSA_NAMEs as equivalent for further VN. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Ok. Thanks, Richard. > 2012-01-17 Jakub Jelinek > > PR tree-optimization/51877 > * tree-ssa-tail-merge.c (gimple_equal_p): Don't return true whenever > call arguments and fndecls compare equal, instead return false if they > don't. Return true only if lhs1 and lhs2 are either both NULL, or > both SSA_NAMEs that are valueized the same, or they satisfy > operand_equal_p. > > * gcc.c-torture/execute/pr51877.c: New test. > > --- gcc/tree-ssa-tail-merge.c.jj 2011-12-12 22:10:26.0 +0100 > +++ gcc/tree-ssa-tail-merge.c 2012-01-17 08:28:56.903471558 +0100 > @@ -1071,14 +1071,18 @@ gimple_equal_p (same_succ same_succ, gim > equal = false; > break; > } > - if (equal) > - return true; > + if (!equal) > + return false; > >lhs1 = gimple_get_lhs (s1); >lhs2 = gimple_get_lhs (s2); > - return (lhs1 != NULL_TREE && lhs2 != NULL_TREE > - && TREE_CODE (lhs1) == SSA_NAME && TREE_CODE (lhs2) == SSA_NAME > - && vn_valueize (lhs1) == vn_valueize (lhs2)); > + if (lhs1 == NULL_TREE && lhs2 == NULL_TREE) > + return true; > + if (lhs1 == NULL_TREE || lhs2 == NULL_TREE) > + return false; > + if (TREE_CODE (lhs1) == SSA_NAME && TREE_CODE (lhs2) == SSA_NAME) > + return vn_valueize (lhs1) == vn_valueize (lhs2); > + return operand_equal_p (lhs1, lhs2, 0); > > case GIMPLE_ASSIGN: >lhs1 = gimple_get_lhs (s1); > --- gcc/testsuite/gcc.c-torture/execute/pr51877.c.jj 2012-01-17 > 08:36:31.012781551 +0100 > +++ gcc/testsuite/gcc.c-torture/execute/pr51877.c 2012-01-17 > 08:35:26.0 +0100 > @@ -0,0 +1,50 @@ > +/* PR tree-optimization/51877 */ > + > +extern void abort (void); > +struct A { int a; char b[32]; } a, b; > + > +__attribute__((noinline, noclone)) > +struct A > +bar (int x) > +{ > + struct A r; > + static int n; > + r.a = ++n; > + __builtin_memset (r.b, 0, sizeof (r.b)); > + r.b[0] = x; > + return r; > +} > + > +__attribute__((noinline, noclone)) > +void > +baz (void) > +{ > + asm volatile ("" : : : "memory"); > +} > + > +__attribute__((noinline, noclone)) > +void > +foo (struct A *x, int y) > +{ > + if (y == 6) > +a = bar (7); > + else > +*x = bar (7); > + baz (); > +} > + > +int > +main () > +{ > + a = bar (3); > + b = bar (4); > + if (a.a != 1 || a.b[0] != 3 || b.a != 2 || b.b[0] != 4) > +abort (); > + foo (&b, 0); > + if (a.a != 1 || a.b[0] != 3 || b.a != 3 || b.b[0] != 7) > +abort (); > + foo (&b, 6); > + if (a.a != 4 || a.b[0] != 7 || b.a != 3 || b.b[0] != 7) > +abort (); > + return 0; > +} > > Jakub > > -- Richard Guenther SUSE / SUSE Labs SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
[PATCH] Fix PR51782(?)
This should fix PR51782 - we need to look at the base address operand of MEM_REF and TARGET_MEM_REF to get at the address-space information as both can have an embedded VIEW_CONVERT_EXPR. This is then consistent with the gimple type system which keeps address-space changing conversions of pointers in the IL. Note that set_mem_attributes_minus_bitpos also looks broken in this regard as it requires that even explicit VIEW_CONVERT_EXPRs have the address-space encoded (or COMPONENT_REFs, too). I'm not sure that you get a proper TYPE_ADDR_SPACE from even s.i for struct S { int i; } s; but somebody with a target available could check that. Pointless bootstrap & regtest running on x86_64-unknown-linux-gnu. Richard. 2012-01-17 Richard Guenther PR middle-end/51782 * expr.c (expand_assignment): Take address-space information from the address operand of MEM_REF and TARGET_MEM_REF. (expand_expr_real_1): Likewise. Index: gcc/expr.c === *** gcc/expr.c (revision 183205) --- gcc/expr.c (working copy) *** expand_assignment (tree to, tree from, b *** 4590,4596 if (TREE_CODE (to) == MEM_REF) { addr_space_t as ! = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (to, 1; tree base = TREE_OPERAND (to, 0); address_mode = targetm.addr_space.address_mode (as); op0 = expand_expr (base, NULL_RTX, VOIDmode, EXPAND_NORMAL); --- 4590,4596 if (TREE_CODE (to) == MEM_REF) { addr_space_t as ! = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (to, 0; tree base = TREE_OPERAND (to, 0); address_mode = targetm.addr_space.address_mode (as); op0 = expand_expr (base, NULL_RTX, VOIDmode, EXPAND_NORMAL); *** expand_assignment (tree to, tree from, b *** 4608,4614 } else if (TREE_CODE (to) == TARGET_MEM_REF) { ! addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (to)); struct mem_address addr; get_address_description (to, &addr); --- 4608,4615 } else if (TREE_CODE (to) == TARGET_MEM_REF) { ! addr_space_t as ! = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (to, 0; struct mem_address addr; get_address_description (to, &addr); *** expand_expr_real_1 (tree exp, rtx target *** 9253,9259 case TARGET_MEM_REF: { ! addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (exp)); struct mem_address addr; enum insn_code icode; unsigned int align; --- 9254,9261 case TARGET_MEM_REF: { ! addr_space_t as ! = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0; struct mem_address addr; enum insn_code icode; unsigned int align; *** expand_expr_real_1 (tree exp, rtx target *** 9288,9294 case MEM_REF: { addr_space_t as ! = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 1; enum machine_mode address_mode; tree base = TREE_OPERAND (exp, 0); gimple def_stmt; --- 9290,9296 case MEM_REF: { addr_space_t as ! = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0; enum machine_mode address_mode; tree base = TREE_OPERAND (exp, 0); gimple def_stmt;
Re: Support Solaris 11/SPARC in MD_FALLBACK_FRAME_STATE_FOR (PR ada/41929)
> Unfortunately, this version completely breaks Solaris 11. Given that > your primary (only?) justification for this patch seems to be a 7-year > old Beta version of Solaris 10 (s10_72) nobody in his right mind should > be running right now, I suggest simply reverting this patch. I think that we shoudn't have changed the pattern matching code in the first place, as it had gradually evolved over almost an entire decade. It was quite robust as a consequence and the new code is clearly inferior in this respect. Usually adapting it to a new version of the OS only takes a handful of minutes. Would you mind having a quick look? I don't have access to Solaris 11 myself. -- Eric Botcazou
[Patch, Fortran] PR 51869 - fix realloc on assignment issue
This patch nullifies (scalar) allocatables after malloc, if (and only if) they contain allocatable components to make sure that no uninitialized memory is accessed. Build and regtested on x86-64-linux. OK for the trunk? Tobias 2012-01-17 Tobias Burnus PR fortran/51869 * trans-expr.c (alloc_scalar_allocatable_for_assignment): Nullify LHS after allocation, if it has allocatable components. 2012-01-17 Tobias Burnus PR fortran/51869 * gfortran.dg/realloc_on_assign_9.f90: New. diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 14411e0..c709265 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -6590,6 +6597,15 @@ alloc_scalar_allocatable_for_assignment (stmtblock_t *block, 1, size_in_bytes); tmp = fold_convert (TREE_TYPE (lse.expr), tmp); gfc_add_modify (block, lse.expr, tmp); + + if (expr1->ts.type == BT_DERIVED && expr1->ts.u.derived->attr.alloc_comp) +{ + tmp = build_call_expr_loc (input_location, + builtin_decl_explicit (BUILT_IN_MEMSET), + 3, lse.expr, integer_zero_node, size_in_bytes); + gfc_add_expr_to_block (block, tmp); +} + if (expr1->ts.type == BT_CHARACTER && expr1->ts.deferred) { /* Deferred characters need checking for lhs and rhs string --- /dev/null 2012-01-17 08:41:28.951768065 +0100 +++ gcc/gcc/testsuite/gfortran.dg/realloc_on_assign_9.f90 2012-01-17 11:41:41.0 +0100 @@ -0,0 +1,34 @@ +! { dg-do run } +! +! PR fortran/51869 +! +module soop_stars_class + implicit none + type soop_stars +real ,dimension(:,:) ,allocatable :: position + end type + type show +type(soop_stars) :: rocket + end type +contains + function new_show(boom) +type(soop_stars) ,intent(in) :: boom +type(show) :: new_show +new_show%rocket = boom + end function +end module + +program main + use soop_stars_class + implicit none + + type(soop_stars) :: fireworks + type(show), allocatable :: july4 + + allocate (fireworks%position(2,2)) + fireworks%position = 33.0 + + july4 = new_show(boom=fireworks) +end program + +! { dg-final { cleanup-modules "soop_stars_class" } }
Re: [Patch, Fortran] PR 51869 - fix realloc on assignment issue
On Tue, Jan 17, 2012 at 13:24, Tobias Burnus wrote: > This patch nullifies (scalar) allocatables after malloc, if (and only if) > they contain allocatable components to make sure that no uninitialized > memory is accessed. > > Build and regtested on x86-64-linux. > OK for the trunk? calloc potentially has better performance than malloc+memset, and has smaller generated code size too. -- Janne Blomqvist
Re: [RFC] Fixing expansion of misaligned MEM_REFs on strict-alignment targets
> Eric, do you have any objections in principle of handling > get_object_or_type_alignment () < GET_MODE_ALIGNMENT (mode) > stores/loads this way? None, extract_bit_field/store_bit_field are the right devices for this purpose. What I have objections against is to have types that are less aligned than their modes, but I guess that I can look elsewhere when there is one. :-) -- Eric Botcazou
Re: [RFC] Fixing expansion of misaligned MEM_REFs on strict-alignment targets
On Tue, 17 Jan 2012, Eric Botcazou wrote: > > Eric, do you have any objections in principle of handling > > get_object_or_type_alignment () < GET_MODE_ALIGNMENT (mode) > > stores/loads this way? > > None, extract_bit_field/store_bit_field are the right devices for this > purpose. > What I have objections against is to have types that are less aligned than > their modes, but I guess that I can look elsewhere when there is one. :-) :-) Not sure if it would be easier to have integer types with BLKmode in GIMPLE though ... that surely will have more fallout. Well, another reason to look back at the first mem-ref branch where it had an explicit alignment operand (and thus no need to encode alignment info in the type). Thus, consider that type-with-alignment-less-than-its-mode an artifact of that. Richard.
Re: [PATCH] Fix tree_function_versioning with void type DECL_RESULT (PR tree-optimization/51865)
> The recent changes in tree_function_versioning broke the following > testcase. If DECL_RESULT exists, but has void type, then we used to > remap_decl it before, but now we don't, so in this case the same > RESULT_DECL is used in two different functions, which upsets ipa-pta, but > could upset other code too. > > Fixed by calling remap_decl again for void type. Bootstrapped/regtested > on x86_64-linux and i686-linux (on x86_64 including ada). Ok for trunk? > > 2012-01-15 Jakub Jelinek > > PR tree-optimization/51865 > * tree-inline.c (tree_function_versioning): Call remap_decl > on DECL_RESULT whenever it has VOID_TYPE_P type. > > * gcc.dg/pr51865.c: New test. Thanks for fixing this! -- Eric Botcazou
[Patch, fortran] PR51634 - [OOP] ICE with polymorphic operators
Dear All, The attached is self-explanatory and fixes the last wrinkles with PR51634. In addition, the patch incorporates the requirements of class expressions being used throughout, as reflected in the second testcase. Bootstrapped and regtested on FC9/x86_64 - OK for trunk. Cheers Paul 2012-01-17 Paul Thomas PR fortran/51634 * trans-expr.c (gfc_conv_procedure_call): Deallocate allocatable components of temporary class arguments. 2012-01-17 Paul Thomas PR fortran/51634 * gfortran.dg/typebound_operator_12.f03: New. * gfortran.dg/typebound_operator_13.f03: New. Index: gcc/fortran/trans-expr.c === *** gcc/fortran/trans-expr.c (revision 183125) --- gcc/fortran/trans-expr.c (working copy) *** gfc_conv_procedure_call (gfc_se * se, gf *** 3736,3742 /* Allocated allocatable components of derived types must be deallocated for non-variable scalars. Non-variable arrays are dealt with in trans-array.c(gfc_conv_array_parameter). */ ! if (e && e->ts.type == BT_DERIVED && e->ts.u.derived->attr.alloc_comp && !(e->symtree && e->symtree->n.sym->attr.pointer) && (e->expr_type != EXPR_VARIABLE && !e->rank)) --- 3736,3742 /* Allocated allocatable components of derived types must be deallocated for non-variable scalars. Non-variable arrays are dealt with in trans-array.c(gfc_conv_array_parameter). */ ! if (e && (e->ts.type == BT_DERIVED || e->ts.type == BT_CLASS) && e->ts.u.derived->attr.alloc_comp && !(e->symtree && e->symtree->n.sym->attr.pointer) && (e->expr_type != EXPR_VARIABLE && !e->rank)) *** gfc_conv_procedure_call (gfc_se * se, gf *** 3768,3773 --- 3768,3783 gfc_add_expr_to_block (&se->post, local_tmp); } + if (e->ts.type == BT_DERIVED && fsym && fsym->ts.type == BT_CLASS) + { + /* The derived type is passed to gfc_deallocate_alloc_comp. + Therefore, class actuals can handled correctly but derived + types passed to class formals need the _data component. */ + tmp = gfc_class_data_get (tmp); + if (!CLASS_DATA (fsym)->attr.dimension) + tmp = build_fold_indirect_ref_loc (input_location, tmp); + } + tmp = gfc_deallocate_alloc_comp (e->ts.u.derived, tmp, parm_rank); gfc_add_expr_to_block (&se->post, tmp); Index: gcc/testsuite/gfortran.dg/typebound_operator_12.f03 === *** gcc/testsuite/gfortran.dg/typebound_operator_12.f03 (revision 0) --- gcc/testsuite/gfortran.dg/typebound_operator_12.f03 (revision 0) *** *** 0 --- 1,45 + ! { dg-do run } + ! PR51634 - Handle allocatable components correctly in expressions + ! involving typebound operators. See comment 2 of PR. + ! + ! Reported by Tobias Burnus + ! + module soop_stars_class + implicit none + type soop_stars + real, dimension(:), allocatable :: position,velocity + contains + procedure :: total + procedure :: product + generic :: operator(+) => total + generic :: operator(*) => product + end type + contains + type(soop_stars) function product(lhs,rhs) + class(soop_stars) ,intent(in) :: lhs + real ,intent(in) :: rhs + product%position = lhs%position*rhs + product%velocity = lhs%velocity*rhs + end function + + type(soop_stars) function total(lhs,rhs) + class(soop_stars) ,intent(in) :: lhs,rhs + total%position = lhs%position + rhs%position + total%velocity = lhs%velocity + rhs%velocity + end function + end module + + program main + use soop_stars_class ,only : soop_stars + implicit none + type(soop_stars) :: fireworks + real :: dt + fireworks%position = [1,2,3] + fireworks%velocity = [4,5,6] + dt = 5 + fireworks = fireworks + fireworks*dt + if (any (fireworks%position .ne. [6, 12, 18])) call abort + if (any (fireworks%velocity .ne. [24, 30, 36])) call abort + end program + ! { dg-final { cleanup-modules "soop_stars_class" } } + Index: gcc/testsuite/gfortran.dg/typebound_operator_13.f03 === *** gcc/testsuite/gfortran.dg/typebound_operator_13.f03 (revision 0) --- gcc/testsuite/gfortran.dg/typebound_operator_13.f03 (revision 0) *** *** 0 --- 1,59 + ! { dg-do run } + ! PR51634 - Handle allocatable components correctly in expressions + ! involving typebound operators. From comment 2 of PR but using + ! classes throughout. + ! + ! Reported by Tobias Burnus + ! + module soop_stars_class + implicit none + type soop_stars + real, dimension(:), allocatable :: position,velocity + contains + procedure :: total + procedure :: mult + procedure :: assign + generic :: operator(+) => total + generic :: operator(*) => mult + generic :: assignment(=) => assign + end typ
Re: [Patch, Fortran] PR 51869 - fix realloc on assignment issue
Dear Tobias and Janne, I had preparedand was about to submit the identical patch :-) On Tue, Jan 17, 2012 at 12:45 PM, Janne Blomqvist wrote: > On Tue, Jan 17, 2012 at 13:24, Tobias Burnus wrote: >> This patch nullifies (scalar) allocatables after malloc, if (and only if) >> they contain allocatable components to make sure that no uninitialized >> memory is accessed. >> >> Build and regtested on x86-64-linux. >> OK for the trunk? > > calloc potentially has better performance than malloc+memset, and has > smaller generated code size too. On a previous occasion (for class array allocation), I looked for and was unable to find a __BUILTIN_CALLOC. If it exists, use that. Otherwise, OK for trunk. Thanks to you both. Paul
Re: [Patch, Fortran] PR 51869 - fix realloc on assignment issue
On Tue, Jan 17, 2012 at 14:29, Paul Richard Thomas wrote: > Dear Tobias and Janne, > > I had preparedand was about to submit the identical patch :-) > > On Tue, Jan 17, 2012 at 12:45 PM, Janne Blomqvist > wrote: >> On Tue, Jan 17, 2012 at 13:24, Tobias Burnus wrote: >>> This patch nullifies (scalar) allocatables after malloc, if (and only if) >>> they contain allocatable components to make sure that no uninitialized >>> memory is accessed. >>> >>> Build and regtested on x86-64-linux. >>> OK for the trunk? >> >> calloc potentially has better performance than malloc+memset, and has >> smaller generated code size too. > > On a previous occasion (for class array allocation), I looked for and > was unable to find a __BUILTIN_CALLOC. If it exists, use that. It exists in the middle end, but doesn't seem to be wired up in the Fortran frontend yet. A simple --- f95-lang.c.orig 2012-01-17 14:32:10.0 +0200 +++ f95-lang.c 2012-01-17 14:35:13.0 +0200 @@ -1007,6 +1007,12 @@ gfc_init_builtin_functions (void) "malloc", ATTR_NOTHROW_LEAF_LIST); DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_MALLOC)) = 1; + ftype = build_function_type_list (pvoid_type_node, size_type_node, + size_type_node, NULL_TREE); + gfc_define_builtin ("__builtin_calloc", ftype, BUILT_IN_CALLOC, + "calloc", ATTR_NOTHROW_LEAF_LIST); + DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_MALLOC)) = 1; + ftype = build_function_type_list (pvoid_type_node, size_type_node, pvoid_type_node, NULL_TREE); ought to do it (untested). -- Janne Blomqvist
Re: Support Solaris 11/SPARC in MD_FALLBACK_FRAME_STATE_FOR (PR ada/41929)
Eric Botcazou writes: >> Unfortunately, this version completely breaks Solaris 11. Given that >> your primary (only?) justification for this patch seems to be a 7-year >> old Beta version of Solaris 10 (s10_72) nobody in his right mind should >> be running right now, I suggest simply reverting this patch. > > I think that we shoudn't have changed the pattern matching code in the first > place, as it had gradually evolved over almost an entire decade. It was > quite > robust as a consequence and the new code is clearly inferior in this respect. > > Usually adapting it to a new version of the OS only takes a handful of > minutes. That's not my experience in the first place: when I tried to get it working on Solaris 11, I failed so completely that I decided to instead follow the route already trodden by the Solaris/x86 file. > Would you mind having a quick look? I don't have access to Solaris 11 myself. I doubt I'll have the time: there's quite a lot on my plate before 4.7.0 and I don't have that much time left for gcc issues these days. Again: what's the justification for changing this code so late in the game when it has been like this since 4.6.0 with no issues? I don't buy it that support for s10_72 (a 7-year old Solaris 10 Beta) is enough to break Solaris 11 (the current shipping release). Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Re: [Patch, Fortran] PR 51869 - fix realloc on assignment issue
On Tue, Jan 17, 2012 at 14:36, Janne Blomqvist wrote: > On Tue, Jan 17, 2012 at 14:29, Paul Richard Thomas > wrote: >> Dear Tobias and Janne, >> >> I had preparedand was about to submit the identical patch :-) >> >> On Tue, Jan 17, 2012 at 12:45 PM, Janne Blomqvist >> wrote: >>> On Tue, Jan 17, 2012 at 13:24, Tobias Burnus wrote: This patch nullifies (scalar) allocatables after malloc, if (and only if) they contain allocatable components to make sure that no uninitialized memory is accessed. Build and regtested on x86-64-linux. OK for the trunk? >>> >>> calloc potentially has better performance than malloc+memset, and has >>> smaller generated code size too. >> >> On a previous occasion (for class array allocation), I looked for and >> was unable to find a __BUILTIN_CALLOC. If it exists, use that. > > It exists in the middle end, but doesn't seem to be wired up in the > Fortran frontend yet. A simple > > --- f95-lang.c.orig 2012-01-17 14:32:10.0 +0200 > +++ f95-lang.c 2012-01-17 14:35:13.0 +0200 > @@ -1007,6 +1007,12 @@ gfc_init_builtin_functions (void) > "malloc", ATTR_NOTHROW_LEAF_LIST); > DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_MALLOC)) = 1; > > + ftype = build_function_type_list (pvoid_type_node, size_type_node, > + size_type_node, NULL_TREE); > + gfc_define_builtin ("__builtin_calloc", ftype, BUILT_IN_CALLOC, > + "calloc", ATTR_NOTHROW_LEAF_LIST); > + DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_MALLOC)) = 1; > + > ftype = build_function_type_list (pvoid_type_node, > size_type_node, pvoid_type_node, > NULL_TREE); > > > ought to do it (untested). Make that --- f95-lang.c.orig 2012-01-17 14:32:10.0 +0200 +++ f95-lang.c 2012-01-17 14:40:25.0 +0200 @@ -1007,6 +1007,12 @@ gfc_init_builtin_functions (void) "malloc", ATTR_NOTHROW_LEAF_LIST); DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_MALLOC)) = 1; + ftype = build_function_type_list (pvoid_type_node, size_type_node, + size_type_node, NULL_TREE); + gfc_define_builtin ("__builtin_calloc", ftype, BUILT_IN_CALLOC, + "calloc", ATTR_NOTHROW_LEAF_LIST); + DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_CALLOC)) = 1; + ftype = build_function_type_list (pvoid_type_node, size_type_node, pvoid_type_node, NULL_TREE); -- Janne Blomqvist
Re: [libitm] Skip static_ctor.C test (PR libitm/51173)
I'd like to simply disable it if they don't have other preferences. Disabling is fine with me.
[PATCH] Fix -fdump-rtl-ira segfault
Hi, -fdump-rtl-ira currently segfaults on s390 if not also a reload dump is requested. The problem is that the ira_dump_file variable during reload still points to the ira dump file although the file has already been closed by the pass manager already. Ok for mainline? Bye, -Andreas- 2012-01-17 Andreas Krebbel * ira.c (do_reload): Make sure ira_dump_file is re-set if no reload dump is requested. --- gcc/ira.c |2 !! 1 file changed, 2 modifications(!) Index: gcc/ira.c === *** gcc/ira.c.orig --- gcc/ira.c *** do_reload (void) *** 3722,3728 basic_block bb; bool need_dce; ! if (flag_ira_verbose < 10 && dump_file) ira_dump_file = dump_file; df_set_flags (DF_NO_INSN_RESCAN); --- 3722,3728 basic_block bb; bool need_dce; ! if (flag_ira_verbose < 10) ira_dump_file = dump_file; df_set_flags (DF_NO_INSN_RESCAN);
Re: [Patch, fortran] PR51634 - [OOP] ICE with polymorphic operators
On 01/17/2012 01:25 PM, Paul Richard Thomas wrote: The attached is self-explanatory and fixes the last wrinkles with PR51634. In addition, the patch incorporates the requirements of class expressions being used throughout, as reflected in the second testcase. Bootstrapped and regtested on FC9/x86_64 - OK for trunk. OK. Thanks for the patch! Tobias 2012-01-17 Paul Thomas PR fortran/51634 * trans-expr.c (gfc_conv_procedure_call): Deallocate allocatable components of temporary class arguments. 2012-01-17 Paul Thomas PR fortran/51634 * gfortran.dg/typebound_operator_12.f03: New. * gfortran.dg/typebound_operator_13.f03: New.
Re: [PATCH] Fix -fdump-rtl-ira segfault
On Tue, Jan 17, 2012 at 1:58 PM, Andreas Krebbel wrote: > Hi, > > -fdump-rtl-ira currently segfaults on s390 if not also a reload dump > is requested. The problem is that the ira_dump_file variable during > reload still points to the ira dump file although the file has already > been closed by the pass manager already. > > Ok for mainline? Looks obvious. Richard. > Bye, > > -Andreas- > > > 2012-01-17 Andreas Krebbel > > * ira.c (do_reload): Make sure ira_dump_file is re-set if no > reload dump is requested. > > --- > gcc/ira.c | 2 !! > 1 file changed, 2 modifications(!) > > Index: gcc/ira.c > === > *** gcc/ira.c.orig > --- gcc/ira.c > *** do_reload (void) > *** 3722,3728 > basic_block bb; > bool need_dce; > > ! if (flag_ira_verbose < 10 && dump_file) > ira_dump_file = dump_file; > > df_set_flags (DF_NO_INSN_RESCAN); > --- 3722,3728 > basic_block bb; > bool need_dce; > > ! if (flag_ira_verbose < 10) > ira_dump_file = dump_file; > > df_set_flags (DF_NO_INSN_RESCAN); >
Re: PR other/51165: add new adress_escapes predicate
On 01/17/12 03:09, Richard Guenther wrote: On Mon, Jan 16, 2012 at 4:58 PM, Aldy Hernandez wrote: Not really - you handle both ptr and *ptr in the same predicate and call both "address escaped". What I suggested was sth like I think I confused myself and you by asking the wrong question in the first place. Actually, what I want is to handle VAR_DECL correctly, and your original suggestion of using may_be_aliased() fits the bill. The other calls to ptr_deref_may_alias_global_p() were fine because we have an SSA_NAME. We're now down to a one-liner :). How about this? All TM memory optimization tests fixed, and no regressions. Ok. Note that may_be_aliased (x) is also true if x is an automatic variable that has its address taken. You can use is_global_var (x) instead if you only want to test for "global memory". Richard. is_global_var is fine. Thanks. Committed.
Re: C++ PATCH for c++/51827 (mangling error with PCH and LTO)
On Tue, Jan 17, 2012 at 3:35 AM, Richard Guenther wrote: > On Mon, Jan 16, 2012 at 10:29 PM, Jason Merrill wrote: >> When outputting PCH/LTO, the compiler tries to generate mangled names for >> all decls before discarding language-specific data. But that doesn't make >> sense for templates, and leads to conflicts in this case. Fixed by refusing >> to mangle templates. >> >> Tested x86_64-pc-linux-gnu, applying to trunk. > > Hmm. Using -flto when generating a precompiled header doesn't make sense. > We probably should drop -flto silently or complain here. Thus, > > Index: c-family/c-opts.c > === > --- c-family/c-opts.c (revision 183205) > +++ c-family/c-opts.c (working copy) > @@ -1058,6 +1058,13 @@ c_common_post_options (const char **pfil > && flag_preprocess_only && !flag_no_line_commands) > pp_dir_change (parse_in, get_src_pwd ()); > > + /* Disable LTO output when outputting a precompiled header. */ > + if (pch_file && flag_lto) > + { > + flag_lto = 0; > + flag_generate_lto = 0; > + } > + > return flag_preprocess_only; > } > > any objection to that? I think we should issue a diagnostic about the combination of these two flags. Silent ignorance would lead to false user expectations and supposed "bug" reports, if not confusion. -- Gaby
Re: C++ PATCH for c++/51827 (mangling error with PCH and LTO)
On Tue, Jan 17, 2012 at 04:35, Richard Guenther wrote: > + /* Disable LTO output when outputting a precompiled header. */ > + if (pch_file && flag_lto) > + { > + flag_lto = 0; > + flag_generate_lto = 0; > + } > + Emit a warning when you do this? Diego.
Re: libgo patch committed: Update to weekly.2011-12-22
Uros Bizjak writes: > The library compiles OK, with following small patch: > > --cut here-- > Index: mksysinfo.sh > === > --- mksysinfo.sh(revision 183192) > +++ mksysinfo.sh(working copy) > @@ -538,7 +538,7 @@ > # We need TIOCGWINSZ. > if ! grep '^const TIOCGWINSZ' ${OUT} >/dev/null 2>&1; then >if grep '^const _TIOCGWINSZ_val' ${OUT} >/dev/null 2>&1; then > -echo 'const TIOCGWINSZ = TIOCGWINSZ_val' >> ${OUT} > +echo 'const TIOCGWINSZ = _TIOCGWINSZ_val' >> ${OUT} >fi > fi > > --cut here-- Whoops. Thanks. Committed. Ian
Re: libgo patch committed: Update to weekly.2011-12-22
Rainer Orth writes: > Ian Lance Taylor writes: > >> I have committed a patch to libgo to update it to the weekly.2011-12-22 >> release. As usual I am not including all the changes here, only the >> ones to files which are specific to gccgo. Bootstrapped and ran Go >> testsuite on x86_64-unknown-linux-gnu. Committed to mainline. > > The patch introduced a couple of other problems: > > * There's a warning during libgo configure: > > * Bootstrap on Solaris < 11 is broken: > > * The IRIX libgo build is broken like this: Thanks a lot. All committed. Ian
Re: [Patch, Fortran] PR 51869 - fix realloc on assignment issue
Dear Janne, dear Paul, thanks for the review - and for the f95-lang.c patch. I have updated the patch to use calloc, build & regtested it, and committed it as Rev. 183247. Tobias 2012-01-17 Tobias Burnus Janne Blomqvist PR fortran/51869 * trans-expr.c (alloc_scalar_allocatable_for_assignment): Nullify LHS after allocation, if it has allocatable components. * f95-lang.c (gfc_init_builtin_functions): Add BUILT_IN_CALLOC. 2012-01-17 Tobias Burnus PR fortran/51869 * gfortran.dg/realloc_on_assign_9.f90: New. diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c index 57c0114..a68d2fc 100644 --- a/gcc/fortran/f95-lang.c +++ b/gcc/fortran/f95-lang.c @@ -1007,6 +1007,12 @@ gfc_init_builtin_functions (void) "malloc", ATTR_NOTHROW_LEAF_LIST); DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_MALLOC)) = 1; + ftype = build_function_type_list (pvoid_type_node, size_type_node, +size_type_node, NULL_TREE); + gfc_define_builtin ("__builtin_calloc", ftype, BUILT_IN_CALLOC, + "calloc", ATTR_NOTHROW_LEAF_LIST); + DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_CALLOC)) = 1; + ftype = build_function_type_list (pvoid_type_node, size_type_node, pvoid_type_node, NULL_TREE); diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 14411e0..07b9c6d 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -6585,11 +6592,24 @@ alloc_scalar_allocatable_for_assignment (stmtblock_t *block, size_in_bytes = size; } - tmp = build_call_expr_loc (input_location, - builtin_decl_explicit (BUILT_IN_MALLOC), - 1, size_in_bytes); - tmp = fold_convert (TREE_TYPE (lse.expr), tmp); - gfc_add_modify (block, lse.expr, tmp); + if (expr1->ts.type == BT_DERIVED && expr1->ts.u.derived->attr.alloc_comp) +{ + tmp = build_call_expr_loc (input_location, + builtin_decl_explicit (BUILT_IN_CALLOC), + 2, build_one_cst (size_type_node), + size_in_bytes); + tmp = fold_convert (TREE_TYPE (lse.expr), tmp); + gfc_add_modify (block, lse.expr, tmp); +} + else +{ + tmp = build_call_expr_loc (input_location, + builtin_decl_explicit (BUILT_IN_MALLOC), + 1, size_in_bytes); + tmp = fold_convert (TREE_TYPE (lse.expr), tmp); + gfc_add_modify (block, lse.expr, tmp); +} + if (expr1->ts.type == BT_CHARACTER && expr1->ts.deferred) { /* Deferred characters need checking for lhs and rhs string --- /dev/null 2012-01-17 08:41:28.951768065 +0100 +++ gcc/gcc/testsuite/gfortran.dg/realloc_on_assign_9.f90 2012-01-17 11:41:41.0 +0100 @@ -0,0 +1,34 @@ +! { dg-do run } +! +! PR fortran/51869 +! +module soop_stars_class + implicit none + type soop_stars +real ,dimension(:,:) ,allocatable :: position + end type + type show +type(soop_stars) :: rocket + end type +contains + function new_show(boom) +type(soop_stars) ,intent(in) :: boom +type(show) :: new_show +new_show%rocket = boom + end function +end module + +program main + use soop_stars_class + implicit none + + type(soop_stars) :: fireworks + type(show), allocatable :: july4 + + allocate (fireworks%position(2,2)) + fireworks%position = 33.0 + + july4 = new_show(boom=fireworks) +end program + +! { dg-final { cleanup-modules "soop_stars_class" } }
Re: C++ PATCH for c++/51827 (mangling error with PCH and LTO)
On Tue, Jan 17, 2012 at 2:23 PM, Diego Novillo wrote: > On Tue, Jan 17, 2012 at 04:35, Richard Guenther > wrote: > >> + /* Disable LTO output when outputting a precompiled header. */ >> + if (pch_file && flag_lto) >> + { >> + flag_lto = 0; >> + flag_generate_lto = 0; >> + } >> + > > Emit a warning when you do this? Well, I'd say peoples Makefiles may not strip -flto properly here (you need to pass optimization level for example), so I'm not sure that would be good QOI. > I think we should issue a diagnostic about the combination of these > two flags. Silent ignorance would lead to false user expectations > and supposed "bug" reports, if not confusion. I'm not sure what "expectation" there would be? OTOH the bug is fixed by Jason, so we can just do nothing. Richard.
Re: [PATCH] Fix powerpc64-linux -mminimal-toc shrink-wrapping bootstrap failure (PR bootstrap/51872)
On Tue, Jan 17, 2012 at 5:16 AM, Jakub Jelinek wrote: > Hi! > > crtbegin.o is miscompiled on powerpc64-linux with -mminimal-toc (and likely > many other sources). The problem is that when flag_pic is 0, the > shrink-wrapping code doesn't consider register r30 being set up by the > prologue, so instructions that use r30 (TOC_REGISTER) can be considered > usable even without an earlier prologue that computes it. > Unfortunately the generic code adds just a couple of selected registers > to set_up_by_prologue regset, and I don't see without a target hook a way > to add further registers to the hard regset. > > So, this patch implements such a hook and uses it on rs6000 to indicate that > r30 is computed by the prologue if the prologue does that. > > Bootstrapped/regtested on powerpc64-linux (with -mminimal-toc in > CFLAGS/CXXFLAGS/etc., which previously failed to bootstrap) and on > x86_64-linux and i686-linux. Ok for trunk? > > 2012-01-17 Jakub Jelinek > > PR bootstrap/51872 > * hard-reg-set.h (struct hard_reg_set_container): New type. > * target.h (struct hard_reg_set_container): Forward declare. > * target.def (set_up_by_prologue): New target hook. > * doc/tm.texi (TARGET_SET_UP_BY_PROLOGUE): Document it. > * function.c (thread_prologue_and_epilogue_insns): Change > set_up_by_prologue HARD_REG_SET into struct hard_reg_set_container. > Call targetm.set_up_by_prologue on it. > * config/rs6000/rs6000.c (rs6000_set_up_by_prologue): New function. > (TARGET_SET_UP_BY_PROLOGUE): Redefine to it. The rs6000 bits are okay with me. Thanks, David
Re: C++ PATCH for c++/51827 (mangling error with PCH and LTO)
On Tue, Jan 17, 2012 at 8:43 AM, Richard Guenther wrote: >> I think we should issue a diagnostic about the combination of these >> two flags. Silent ignorance would lead to false user expectations >> and supposed "bug" reports, if not confusion. > > I'm not sure what "expectation" there would be? that PCH works with LTO :-) (especially when PCH means precompiled header :-) -- Gaby
Re: [PATCH] Fix powerpc64-linux -mminimal-toc shrink-wrapping bootstrap failure (PR bootstrap/51872)
On Tue, 17 Jan 2012, David Edelsohn wrote: > On Tue, Jan 17, 2012 at 5:16 AM, Jakub Jelinek wrote: > > Hi! > > > > crtbegin.o is miscompiled on powerpc64-linux with -mminimal-toc (and likely > > many other sources). The problem is that when flag_pic is 0, the > > shrink-wrapping code doesn't consider register r30 being set up by the > > prologue, so instructions that use r30 (TOC_REGISTER) can be considered > > usable even without an earlier prologue that computes it. > > Unfortunately the generic code adds just a couple of selected registers > > to set_up_by_prologue regset, and I don't see without a target hook a way > > to add further registers to the hard regset. > > > > So, this patch implements such a hook and uses it on rs6000 to indicate that > > r30 is computed by the prologue if the prologue does that. > > > > Bootstrapped/regtested on powerpc64-linux (with -mminimal-toc in > > CFLAGS/CXXFLAGS/etc., which previously failed to bootstrap) and on > > x86_64-linux and i686-linux. Ok for trunk? > > > > 2012-01-17 Jakub Jelinek > > > > PR bootstrap/51872 > > * hard-reg-set.h (struct hard_reg_set_container): New type. > > * target.h (struct hard_reg_set_container): Forward declare. > > * target.def (set_up_by_prologue): New target hook. > > * doc/tm.texi (TARGET_SET_UP_BY_PROLOGUE): Document it. > > * function.c (thread_prologue_and_epilogue_insns): Change > > set_up_by_prologue HARD_REG_SET into struct hard_reg_set_container. > > Call targetm.set_up_by_prologue on it. > > * config/rs6000/rs6000.c (rs6000_set_up_by_prologue): New function. > > (TARGET_SET_UP_BY_PROLOGUE): Redefine to it. > > The rs6000 bits are okay with me. The middle-end bits are ok as well. Thanks, Richard.
Re: C++ PATCH for c++/51827 (mangling error with PCH and LTO)
On Tue, Jan 17, 2012 at 3:50 PM, Gabriel Dos Reis wrote: > On Tue, Jan 17, 2012 at 8:43 AM, Richard Guenther > wrote: > >>> I think we should issue a diagnostic about the combination of these >>> two flags. Silent ignorance would lead to false user expectations >>> and supposed "bug" reports, if not confusion. >> >> I'm not sure what "expectation" there would be? > > that PCH works with LTO :-) > > (especially when PCH means precompiled header :-) Sure it works. PCH is just a stage where LTO is not active yet. Richard. > -- Gaby
Go patch committed: fix gccgo -S
Using gccgo -S without -o did not work correctly because it generated BASE.o rather than BASE.s. This happened because the gccgo driver adds an explicit -o option, but did not take -S into account. A cleaner approach here would be some gcc driver interface to set combine_inputs, but this approach works fine for now. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian 2012-01-17 Ian Lance Taylor * gospec.c (lang_specific_driver): If we see -S without -o, add -o BASE.s rather than -o BASE.o. Index: gcc/go/gospec.c === --- gcc/go/gospec.c (revision 183119) +++ gcc/go/gospec.c (working copy) @@ -1,5 +1,5 @@ /* gospec.c -- Specific flags and argument handling of the gcc Go front end. - Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This file is part of GCC. @@ -109,6 +109,9 @@ lang_specific_driver (struct cl_decoded_ /* Whether the -o option was used. */ bool saw_opt_o = false; + /* Whether the -S option was used. */ + bool saw_opt_S = false; + /* The first input file with an extension of .go. */ const char *first_go_file = NULL; @@ -163,7 +166,6 @@ lang_specific_driver (struct cl_decoded_ break; case OPT_c: - case OPT_S: case OPT_E: case OPT_M: case OPT_MM: @@ -173,6 +175,11 @@ lang_specific_driver (struct cl_decoded_ library = -1; break; + case OPT_S: + saw_opt_S = true; + library = -1; + break; + case OPT_o: saw_opt_o = true; break; @@ -280,10 +287,13 @@ lang_specific_driver (struct cl_decoded_ alen = baselen + 3; out = XNEWVEC (char, alen); memcpy (out, base, baselen); - /* The driver will convert .o to some other suffix if - appropriate. */ + /* The driver will convert .o to some other suffix (e.g., .obj) + if appropriate. */ out[baselen] = '.'; - out[baselen + 1] = 'o'; + if (saw_opt_S) + out[baselen + 1] = 's'; + else + out[baselen + 1] = 'o'; out[baselen + 2] = '\0'; generate_option (OPT_o, out, 1, CL_DRIVER, &new_decoded_options[j]);
[pph] Fix relocations of included_from indices (issue5549045)
In a line map entry, there is a field 'included_from' which is the index into the line table corresponding to the file that is including the current line map entry. This index is an absolute value, but given that PPH images may be loaded in different order from different TUs, absolute values cannot be used. Instead, we save an offset from the entry back to its includer. The problem we were having is that I had messed up the reconstruction of the value. I switched the order of the subtraction operands, so we were computing negative absolute values. Produces various failures in larger tests. * pph-in.c (pph_in_line_table_and_includes): Fix computation of includer file index relocation. * pph-out.c (pph_out_line_map_ordinary): Add documentation. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/pph@183229 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog.pph |6 ++ gcc/cp/pph-in.c |7 ++- gcc/cp/pph-out.c | 18 -- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph index d04a55d..8ea94b2 100644 --- a/gcc/cp/ChangeLog.pph +++ b/gcc/cp/ChangeLog.pph @@ -1,3 +1,9 @@ +2012-01-13 Diego Novillo + + * pph-in.c (pph_in_line_table_and_includes): Fix computation of + includer file index relocation. + * pph-out.c (pph_out_line_map_ordinary): Add documentation. + 2011-12-12 Diego Novillo * pph-out.c (pph_out_global_binding): Do not assert that diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c index 780d208..aba7be0 100644 --- a/gcc/cp/pph-in.c +++ b/gcc/cp/pph-in.c @@ -409,7 +409,12 @@ pph_in_line_table_and_includes (pph_stream *stream) if (ORDINARY_MAP_INCLUDER_FILE_INDEX (lm) == -1) ORDINARY_MAP_INCLUDER_FILE_INDEX (lm) = top_includer_ix; else - ORDINARY_MAP_INCLUDER_FILE_INDEX (lm) -= last_entry_ix; + { + gcc_assert (last_entry_ix + > ORDINARY_MAP_INCLUDER_FILE_INDEX (lm)); + ORDINARY_MAP_INCLUDER_FILE_INDEX (lm) + = last_entry_ix - ORDINARY_MAP_INCLUDER_FILE_INDEX (lm); + } lm->start_location += pph_loc_offset; } diff --git a/gcc/cp/pph-out.c b/gcc/cp/pph-out.c index a001aa4..4aa1d65 100644 --- a/gcc/cp/pph-out.c +++ b/gcc/cp/pph-out.c @@ -226,8 +226,22 @@ pph_out_line_map_ordinary (pph_stream *stream, struct line_map *lm, int ix) /* To support relocating this table into other translation units, emit a relative index to LM's includer. All the relative indices - are positive values indicating the distance from LM to the line - map for its includer. */ + are positive values indicating the distance from LM *back* to the + line map for its includer. + + So, if we had header top.h including [1234].h, the line table + entries look something like this: + + Map #10 LC_ENTER "top.h" FROM: -1 (top file). + Map #11 LC_ENTER "1.h" FROM: 10 (top.h) -> saved as offset 1 (11 - 10). + Map #12 LC_ENTER "2.h" FROM: 10 (top.h) -> saved as offset 2 (12 - 10). + Map #13 LC_ENTER "3.h" FROM: 10 (top.h) -> saved as offset 3 (13 - 10). + Map #14 LC_ENTER "4.h" FROM: 10 (top.h) -> saved as offset 4 (14 - 10). + + When saving the map entry for #13 (3.h), we do not want to save + the absolute index value '10', since top.pph may be included from + different TUs. Instead, we save the offset 3, so that the reader + knows that the includer for 3.h is 3 slots before 3.h's entry. */ includer_ix = ORDINARY_MAP_INCLUDER_FILE_INDEX (lm); if (includer_ix >= 0) { -- 1.7.7.3 -- This patch is available for review at http://codereview.appspot.com/5549045
[pph] Add registry for open PPH images (issue5540067)
This patch adds a centralized registry for all open PPH images. This has three different uses: 1- To associate header pathnames (HEADER_NAME field in pph_stream) and images. Used for looking up PPH streams from header names (e.g., pph_out_line_table_and_includes). 2- To associate PPH file names (NAME field in pph_stream) and images. Used for deciding whether a PPH file has been opened already (e.g., pph_stream_open). 3- To look for symbols and types in the pickle cache of opened PPH streams (e.g., pph_cache_lookup_in_includes). We used to have a simple VEC array that we would always traverse looking for an image. But this is slow and we sometimes need to lookup PPH images by the full path name of the original header file or by the full path name of the PPH file itself. This patch simply introduces the new registry. It does not yet uses it for looking up header files during line table emission. That comes in the next patch. * pph-core.c (struct pph_name_stream_map): Declare. (struct pph_stream_registry_d): Declare. (pph_stream_registry): New. (pph_read_images): Remove. Update all users. (pph_find_stream_for): Remove. Update all users. (pph_mark_stream_read): Remove. Update all users. (pph_stream_register): New. (pph_stream_unregister): New (pph_stream_registry_ix_for): New. (pph_stream_registered_p): New. (pph_stream_registry_add_name): New. (pph_stream_registry_lookup): New. (pph_stream_open): Call it. Call pph_stream_register. (pph_stream_close): Call pph_stream_unregister. (pph_header_image_hash): New. (pph_header_image_eq): New. (pph_init): Initialize pph_stream_registry. (pph_streamer_finish): Free memory used by pph_stream_registry. * pph-in.c (pph_read_file_1): Do not call pph_mark_stream_read. Set STREAM->IN_MEMORY_P to true. * pph-streamer.h (pph_mark_stream_read): Remove. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/pph@183230 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog.pph | 25 gcc/cp/pph-core.c | 195 gcc/cp/pph-in.c|2 +- gcc/cp/pph-streamer.h |1 - gcc/testsuite/g++.dg/pph/c1deepincl4.h |6 + gcc/testsuite/g++.dg/pph/c2deepincl.cc |2 +- gcc/testsuite/g++.dg/pph/c2deepincl3.h |1 + 7 files changed, 205 insertions(+), 27 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pph/c1deepincl4.h diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph index 8ea94b2..7e5b90f 100644 --- a/gcc/cp/ChangeLog.pph +++ b/gcc/cp/ChangeLog.pph @@ -1,3 +1,28 @@ +2012-01-16 Diego Novillo + + * pph-core.c (struct pph_name_stream_map): Declare. + (struct pph_stream_registry_d): Declare. + (pph_stream_registry): New. + (pph_read_images): Remove. Update all users. + (pph_find_stream_for): Remove. Update all users. + (pph_mark_stream_read): Remove. Update all users. + (pph_stream_register): New. + (pph_stream_unregister): New + (pph_stream_registry_ix_for): New. + (pph_stream_registered_p): New. + (pph_stream_registry_add_name): New. + (pph_stream_registry_lookup): New. + (pph_stream_open): Call it. + Call pph_stream_register. + (pph_stream_close): Call pph_stream_unregister. + (pph_header_image_hash): New. + (pph_header_image_eq): New. + (pph_init): Initialize pph_stream_registry. + (pph_streamer_finish): Free memory used by pph_stream_registry. + * pph-in.c (pph_read_file_1): Do not call pph_mark_stream_read. + Set STREAM->IN_MEMORY_P to true. + * pph-streamer.h (pph_mark_stream_read): Remove. + 2012-01-13 Diego Novillo * pph-in.c (pph_in_line_table_and_includes): Fix computation of diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c index 1cd202a..57dc53d 100644 --- a/gcc/cp/pph-core.c +++ b/gcc/cp/pph-core.c @@ -49,6 +49,46 @@ along with GCC; see the file COPYING3. If not see #include "streamer-hooks.h" +/* Mapping between a name string and the registry index for the + corresponding PPH image. */ +struct pph_name_stream_map { + const char *name; + unsigned ix; +}; + +/* Registry of all the PPH images opened during this compilation. + This registry is used in three different ways: + +1- To associate header pathnames (HEADER_NAME field in + pph_stream) and images. Used for looking up PPH streams from + header names (e.g., pph_out_line_table_and_includes). + +2- To associate PPH file names (NAME field in pph_stream) and + images. Used for deciding whether a PPH file has been + opened already (e.g., pph_stream_open). + +3- To look for symbols and types in the pickle cache of opened + PPH streams (e.g., pph_cache_lookup_
[pph] Consult PPH registry when processing LC_ENTER events (issue5539074)
This patch changes pph_out_line_table_and_includes to use the registry when deciding whether an LC_ENTER linemap is entering a PPH image. We used to keep track of entered images by using a "next" index on the table of read PPH files. The problem with this is that this table contains the transitive closure of all the read images and the loop in pph_out_line_table_and_includes skips over all the entries of PPH images. So, if a PPH file includes another, we would miss the second one and ICE at the end of the loop. With the new registry, we simply examine all the LC_ENTER linemaps after PPH_NUM_IGNORED_LINE_TABLE_ENTRIES. If the file being entered is in the registry, then we are entering a PPH image and we have to skip all the linemaps until we leave that file (because those will be processed when we read that image). This fixes the test failures in the first patch of this series. * pph-core.c (pph_stream_register): Move later in the file. (pph_stream_unregister): Likewise. (pph_stream_registry_ix_for): Fix comparison to !=. (pph_stream_registry_add_name): Make extern. Allocate a new slot in the table. (pph_stream_set_header_name): New. (pph_stream_registry_lookup): Fix computation of SLOT_IX. (pph_stream_open): Call pph_stream_register earlier. * pph-in.c (pph_in_line_table_and_includes): Call pph_stream_set_header_name. * pph-out.c (pph_init_write): Likewise. (pph_get_next_include): Remove. Update all users. (pph_out_line_table_and_includes): Call pph_stream_registry_lookup to determine if the file being entered is a PPH image. * pph-streamer.h (pph_stream_registry_lookup): Declare. (pph_stream_set_header_name): Declare. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/pph@183231 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog.pph | 20 gcc/cp/pph-core.c | 120 - gcc/cp/pph-in.c |2 +- gcc/cp/pph-out.c | 34 +++--- gcc/cp/pph-streamer.h |2 + 5 files changed, 98 insertions(+), 80 deletions(-) diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph index 7e5b90f..b545e05 100644 --- a/gcc/cp/ChangeLog.pph +++ b/gcc/cp/ChangeLog.pph @@ -1,5 +1,25 @@ 2012-01-16 Diego Novillo + * pph-core.c (pph_stream_register): Move later in the file. + (pph_stream_unregister): Likewise. + (pph_stream_registry_ix_for): Fix comparison to !=. + (pph_stream_registry_add_name): Make extern. + Allocate a new slot in the table. + (pph_stream_set_header_name): New. + (pph_stream_registry_lookup): Fix computation of SLOT_IX. + (pph_stream_open): Call pph_stream_register earlier. + * pph-in.c (pph_in_line_table_and_includes): Call + pph_stream_set_header_name. + * pph-out.c (pph_init_write): Likewise. + (pph_get_next_include): Remove. Update all users. + (pph_out_line_table_and_includes): Call + pph_stream_registry_lookup to determine if the file being + entered is a PPH image. + * pph-streamer.h (pph_stream_registry_lookup): Declare. + (pph_stream_set_header_name): Declare. + +2012-01-16 Diego Novillo + * pph-core.c (struct pph_name_stream_map): Declare. (struct pph_stream_registry_d): Declare. (pph_stream_registry): New. diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c index 57dc53d..5d22c5e 100644 --- a/gcc/cp/pph-core.c +++ b/gcc/cp/pph-core.c @@ -855,48 +855,6 @@ pph_loaded (void) /*** stream handling */ -/* Register STREAM in the table of open streams. */ - -static void -pph_stream_register (pph_stream *stream) -{ - void **slot; - unsigned vlen; - - slot = pointer_map_insert (pph_stream_registry.image_ix, stream); - - /* Disallow multpile registration of the same STREAM. This is overly - strict, but it prevents some unnecessary overhead. */ - gcc_assert (*slot == NULL); - - VEC_safe_push (pph_stream_ptr, heap, pph_stream_registry.v, stream); - vlen = VEC_length (pph_stream_ptr, pph_stream_registry.v); - *slot = (void *)(intptr_t) (vlen - 1); -} - - -/* Unregister STREAM from the table of open streams. */ - -static void -pph_stream_unregister (pph_stream *stream) -{ - void **slot; - unsigned ix; - - slot = pointer_map_contains (pph_stream_registry.image_ix, stream); - gcc_assert (slot); - ix = (unsigned)(intptr_t) *slot; - - /* Mark it unregistered in the image index. */ - *slot = (void *)(intptr_t) -1; - - /* Remove it from the image list. Note that we do not need to - remove the index from the name index. Any further lookups will - simply return NULL. */ - VEC_replace (pph_stream_ptr, pph_stream_registry.v, ix, NULL); -} - - /* Return the index into the registry for STREAM. If STREAM has not been registered yet, return -1. */ @@ -918,13
[pph] Fix C errors for stage 1 bootstrap (issue5549046)
Various fixes to avoid C syntax errors during stage 1. * name-lookup.c (pph_set_global_identifier_bindings): Make parameter list void. * pph.h (pph_set_global_identifier_bindings): Likewise. * pph-core.c (pph_stream_registry_add_name): Fix use of struct pph_name_stream_map. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/pph@183232 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog.pph |8 gcc/cp/name-lookup.c |2 +- gcc/cp/pph-core.c|6 +++--- gcc/cp/pph.h | 10 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph index b545e05..6d3debe 100644 --- a/gcc/cp/ChangeLog.pph +++ b/gcc/cp/ChangeLog.pph @@ -1,5 +1,13 @@ 2012-01-16 Diego Novillo + * name-lookup.c (pph_set_global_identifier_bindings): Make + parameter list void. + * pph.h (pph_set_global_identifier_bindings): Likewise. + * pph-core.c (pph_stream_registry_add_name): Fix use of struct + pph_name_stream_map. + +2012-01-16 Diego Novillo + * pph-core.c (pph_stream_register): Move later in the file. (pph_stream_unregister): Likewise. (pph_stream_registry_ix_for): Fix comparison to !=. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index dee4bc2..0d92ebe 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -6112,7 +6112,7 @@ pph_set_chain_identifier_bindings (tree first, cp_binding_level *bl) after having read all the PPH files. */ void -pph_set_global_identifier_bindings () +pph_set_global_identifier_bindings (void) { cp_binding_level *bl = scope_chain->bindings; pph_set_chain_identifier_bindings (bl->names, bl); diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c index 5d22c5e..6d34bd0 100644 --- a/gcc/cp/pph-core.c +++ b/gcc/cp/pph-core.c @@ -886,7 +886,7 @@ static void pph_stream_registry_add_name (pph_stream *stream, const char *name) { void **slot; - pph_name_stream_map e; + struct pph_name_stream_map e; /* STREAM should have been registered beforehand. */ gcc_assert (pph_stream_registered_p (stream)); @@ -896,8 +896,8 @@ pph_stream_registry_add_name (pph_stream *stream, const char *name) e.ix = pph_stream_registry_ix_for (stream); slot = htab_find_slot (pph_stream_registry.name_ix, &e, INSERT); gcc_assert (*slot == NULL); - *slot = (void *) XNEW (pph_name_stream_map); - memcpy ((pph_name_stream_map *) *slot, &e, sizeof (e)); + *slot = (void *) XNEW (struct pph_name_stream_map); + memcpy ((struct pph_name_stream_map *) *slot, &e, sizeof (e)); } diff --git a/gcc/cp/pph.h b/gcc/cp/pph.h index 7b2e1d3..63acd66 100644 --- a/gcc/cp/pph.h +++ b/gcc/cp/pph.h @@ -164,13 +164,13 @@ extern enum pph_record_marker pph_in_record_marker (pph_stream *stream, struct binding_table_s; extern void pph_out_binding_table (pph_stream *, struct binding_table_s *); extern struct binding_table_s *pph_in_binding_table (pph_stream *); -extern void pph_set_global_identifier_bindings (); +extern void pph_set_global_identifier_bindings (void); /* In pt.c. */ -extern void pph_out_pending_templates_list (pph_stream *stream); -extern void pph_out_spec_entry_tables (pph_stream *stream); -extern void pph_in_pending_templates_list (pph_stream *stream); -extern void pph_in_spec_entry_tables (pph_stream *stream); +extern void pph_out_pending_templates_list (pph_stream *); +extern void pph_out_spec_entry_tables (pph_stream *); +extern void pph_in_pending_templates_list (pph_stream *); +extern void pph_in_spec_entry_tables (pph_stream *); /* Inline functions. */ -- 1.7.7.3 -- This patch is available for review at http://codereview.appspot.com/5549046
[pph] Fix marking of in-memory streams (issue5544085)
We were marking STREAM in-memory too late. This was causing repeated attempts to open the same PPH stream more than once. Leading to confusion. * pph-in.c (pph_read_file_1): Move in-memory marking for STREAM... * pph-core.c (pph_stream_register): ... here. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/pph@183250 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog.pph |5 + gcc/cp/pph-core.c|4 gcc/cp/pph-in.c |8 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph index 6d3debe..88bc68f 100644 --- a/gcc/cp/ChangeLog.pph +++ b/gcc/cp/ChangeLog.pph @@ -1,3 +1,8 @@ +2012-01-17 Diego Novillo + + * pph-in.c (pph_read_file_1): Move in-memory marking for STREAM... + * pph-core.c (pph_stream_register): ... here. + 2012-01-16 Diego Novillo * name-lookup.c (pph_set_global_identifier_bindings): Make diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c index 6d34bd0..9f7f063 100644 --- a/gcc/cp/pph-core.c +++ b/gcc/cp/pph-core.c @@ -953,6 +953,10 @@ pph_stream_register (pph_stream *stream) /* Add a mapping between STREAM's PPH file name and STREAM. */ pph_stream_registry_add_name (stream, stream->name); + + /* Mark this file as being in memory. This prevents opening the + same file more than twice. */ + stream->in_memory_p = true; } diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c index 6a8fbf8..e9a5563 100644 --- a/gcc/cp/pph-in.c +++ b/gcc/cp/pph-in.c @@ -2839,8 +2839,8 @@ pph_read_file_1 (pph_stream *stream) VEC(tree,gc) *file_unemitted_tinfo_decls; source_location cpp_token_replay_loc; - /* If we have read STREAM before, we do not need to re-read the rest - of its body. We only needed to read its line table. */ + /* If we have opened STREAM before, we do not need to re-read the rest + of its body. */ if (stream->in_memory_p) return; @@ -2890,10 +2890,6 @@ pph_read_file_1 (pph_stream *stream) /* Read and process the symbol table. */ pph_in_symtab (stream); - /* Mark this file as read. If other images need to access its contents, - we will not need to actually read it again. */ - stream->in_memory_p = true; - if (flag_pph_dump_tree) pph_dump_namespace (pph_logfile, global_namespace); } -- 1.7.7.3 -- This patch is available for review at http://codereview.appspot.com/5544085
Re: [PATCH] PR51280 LTO/trans-mem ICE with TM builtins
On 12/20/11 03:43, Richard Guenther wrote: On Mon, 19 Dec 2011, Patrick Marlier wrote: On 12/16/2011 03:54 AM, Richard Guenther wrote: On Thu, 15 Dec 2011, Patrick Marlier wrote: In PR51280, LTO does ICE because the object file uses TM builtin but the TM is not enabled. In the patch, it displays a error message if the builtin is not defined and due to TM. I moved is_tm_builtin() from calls.c to trans-mem.c. I splitted it into 2 functions is_tm_builtin/is_tm_builtin_code. In is_tm_builtin_code, I added some missing builtins (TM_START, TM_GETTMCLONE_SAFE, TM_MALLOC, TM_CALLOC, TM_FREE). Finally, I declared them into tree.h to be usable in calls.c and tree-streamer-in.c. Bootstrapped and LTO/TM regtested on Linux/i686. (If ok, please commit it. Thanks.) No - why should this matter? All of TM should be lowered to a point where only target specific code should be needed. Richard. Thanks Richard. In lto file, there is GIMPLE_TRANSACTION statement and a builtin call (__builtin_ITM_commitTransaction) to delimit the end of the transaction region. The transaction is not yet instrumented. So all of TM are not lowered. I guess this could be also added even if we should always break at the missing _ITM_commitTransaction builtin declaration. Index: gimple-streamer-in.c === --- gimple-streamer-in.c(revision 182487) +++ gimple-streamer-in.c(working copy) @@ -234,6 +234,9 @@ input_gimple_stmt (struct lto_input_block *ib, str break; case GIMPLE_TRANSACTION: + if (!flag_tm) +error_at (gimple_location (stmt), + "use of transactional memory without support enabled"); gimple_transaction_set_label (stmt, stream_read_tree (ib, data_in)); break; It seems a bit out of my scope of my GCC knowledge so I guess I will let GCC guys solve this in a proper way. I'd say we should stream the new IL elements and enable TM at link-time once we encounter such IL element (similar to how we enable exceptions when one TU contains EH regions). Ok, I was finally able to reproduce with the new testcase Patrick provided. I'm back on the saddle on this one. Richi, I can certainly do something similar here, but let me see if we're on the same wavelength before I commit many keystrokes. What I have in mind is to abstract out the initialization of TM builtins from gtm-builtins.def (through its inclusion in builtins.def) into a separate function that we can call either in c_define_builtins() from the C-ish front-ends, or from lto_define_builtins (once we encounter a TM builtin and enable flag_tm appropriately). We may also have to add a hook to initialize target dependent TM builtins (for example, ix86_init_tm_builtins on x86). Is this acceptable or did you have something else in mind?
Commit: RX: Predicate return pattern
Hi Guys, As pointed out by Richard Henderson the new return pattern in the RX backend should only be used when it is possible to return with just a simple RTS instruction, so I am checking in the patch below to implement this. Cheers Nick gcc/ChangeLog 2012-01-17 Nick Clifton * config/rx/rx.c (rx_can_use_simple_return): New function. * config/rx/rx-protos.h (rx_can_use_simple_return): Prototype. * config/rx/rx.md (return): Predicate on rx_can_use_simple_return. Index: gcc/config/rx/rx-protos.h === --- gcc/config/rx/rx-protos.h (revision 183234) +++ gcc/config/rx/rx-protos.h (working copy) @@ -21,6 +22,8 @@ #ifndef GCC_RX_PROTOS_H #define GCC_RX_PROTOS_H +extern bool rx_can_use_simple_return (void); +extern voidrx_expand_epilogue (bool); extern voidrx_expand_prologue (void); extern int rx_initial_elimination_offset (int, int); @@ -29,7 +32,6 @@ extern int rx_align_for_label (rtx, int); extern void rx_emit_stack_popm (rtx *, bool); extern void rx_emit_stack_pushm (rtx *); -extern voidrx_expand_epilogue (bool); extern char * rx_gen_move_template (rtx *, bool); extern boolrx_is_legitimate_constant (enum machine_mode, rtx); extern boolrx_is_restricted_memory_address (rtx, Index: gcc/config/rx/rx.md === --- gcc/config/rx/rx.md (revision 183234) +++ gcc/config/rx/rx.md (working copy) @@ -342,7 +343,7 @@ (define_expand "return" [(return)] - "" + "rx_can_use_simple_return ()" "rx_expand_epilogue (false); DONE;" ) Index: gcc/config/rx/rx.c === --- gcc/config/rx/rx.c (revision 183234) +++ gcc/config/rx/rx.c (working copy) @@ -1818,7 +1819,31 @@ return vector; } - + +/* Returns true if a simple return insn can be used. */ + +bool +rx_can_use_simple_return (void) +{ + unsigned int low; + unsigned int high; + unsigned int frame_size; + unsigned int stack_size; + unsigned int register_mask; + + if (is_naked_func (NULL_TREE) + || is_fast_interrupt_func (NULL_TREE) + || is_interrupt_func (NULL_TREE)) +return false; + + rx_get_stack_layout (& low, & high, & register_mask, + & frame_size, & stack_size); + + return (register_mask == 0 + && (frame_size + stack_size) == 0 + && low == 0); +} + void rx_expand_epilogue (bool is_sibcall) {
Re: [PATCH] PR51280 LTO/trans-mem ICE with TM builtins
On Tue, 17 Jan 2012, Aldy Hernandez wrote: > On 12/20/11 03:43, Richard Guenther wrote: > > On Mon, 19 Dec 2011, Patrick Marlier wrote: > > > > > On 12/16/2011 03:54 AM, Richard Guenther wrote: > > > > On Thu, 15 Dec 2011, Patrick Marlier wrote: > > > > > > > > > In PR51280, LTO does ICE because the object file uses TM builtin but > > > > > the > > > > > TM is > > > > > not enabled. > > > > > In the patch, it displays a error message if the builtin is not > > > > > defined > > > > > and > > > > > due to TM. > > > > > I moved is_tm_builtin() from calls.c to trans-mem.c. I splitted it > > > > > into 2 > > > > > functions is_tm_builtin/is_tm_builtin_code. In is_tm_builtin_code, I > > > > > added > > > > > some missing builtins (TM_START, TM_GETTMCLONE_SAFE, TM_MALLOC, > > > > > TM_CALLOC, > > > > > TM_FREE). Finally, I declared them into tree.h to be usable in calls.c > > > > > and > > > > > tree-streamer-in.c. > > > > > > > > > > Bootstrapped and LTO/TM regtested on Linux/i686. > > > > > (If ok, please commit it. Thanks.) > > > > > > > > No - why should this matter? All of TM should be lowered to a point > > > > where only target specific code should be needed. > > > > > > > > Richard. > > > > > > Thanks Richard. > > > > > > In lto file, there is GIMPLE_TRANSACTION statement and a builtin call > > > (__builtin_ITM_commitTransaction) to delimit the end of the transaction > > > region. The transaction is not yet instrumented. So all of TM are not > > > lowered. > > > > > > I guess this could be also added even if we should always break at the > > > missing > > > _ITM_commitTransaction builtin declaration. > > > > > > Index: gimple-streamer-in.c > > > === > > > --- gimple-streamer-in.c(revision 182487) > > > +++ gimple-streamer-in.c(working copy) > > > @@ -234,6 +234,9 @@ input_gimple_stmt (struct lto_input_block *ib, str > > > break; > > > > > > case GIMPLE_TRANSACTION: > > > + if (!flag_tm) > > > +error_at (gimple_location (stmt), > > > + "use of transactional memory without support enabled"); > > > gimple_transaction_set_label (stmt, stream_read_tree (ib, > > > data_in)); > > > break; > > > > > > > > > It seems a bit out of my scope of my GCC knowledge so I guess I will let > > > GCC > > > guys solve this in a proper way. > > > > I'd say we should stream the new IL elements and enable TM at link-time > > once we encounter such IL element (similar to how we enable exceptions > > when one TU contains EH regions). > > Ok, I was finally able to reproduce with the new testcase Patrick provided. > I'm back on the saddle on this one. > > Richi, I can certainly do something similar here, but let me see if we're on > the same wavelength before I commit many keystrokes. > > What I have in mind is to abstract out the initialization of TM builtins from > gtm-builtins.def (through its inclusion in builtins.def) into a separate > function that we can call either in c_define_builtins() from the C-ish > front-ends, or from lto_define_builtins (once we encounter a TM builtin and > enable flag_tm appropriately). Hm? They are included in builtins.def, that looks appropriate for middle-end builtins. Thus they should be initialized by lto1, too. Are they not? > We may also have to add a hook to initialize target dependent TM builtins (for > example, ix86_init_tm_builtins on x86). There is one, targetm.builtin_decl - the targets should simply initialize them on-demand (which is for what that target-hook is designed for). > Is this acceptable or did you have something else in mind? Not sure I fully understood the issue with the existing gtm-builtins.def setup. Richard.
Re: C++ PATCH for c++/51827 (mangling error with PCH and LTO)
On 01/17/2012 09:51 AM, Richard Guenther wrote: Sure it works. PCH is just a stage where LTO is not active yet. That makes sense to me. Jason
[pph] Fix in-memory marking (take 2) (issue5540069)
My previous patch moved the in_memory marker to the wrong place. We need to prevent a file from being re-read by an #include from one of its included children images. This is common in system headers. We mark the file as resident in-memory right before we start reading its includes. Before, we were marking it when the file was initially registered. This was causing us to completely ignore needed PPH images. * pph-core.c (pph_stream_register): Move in-memory marking... * pph-in.c (pph_read_file_1): ... here. diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c index 9f7f063..6d34bd0 100644 --- a/gcc/cp/pph-core.c +++ b/gcc/cp/pph-core.c @@ -953,10 +953,6 @@ pph_stream_register (pph_stream *stream) /* Add a mapping between STREAM's PPH file name and STREAM. */ pph_stream_registry_add_name (stream, stream->name); - - /* Mark this file as being in memory. This prevents opening the - same file more than twice. */ - stream->in_memory_p = true; } diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c index e9a5563..827c8fd 100644 --- a/gcc/cp/pph-in.c +++ b/gcc/cp/pph-in.c @@ -2839,11 +2839,17 @@ pph_read_file_1 (pph_stream *stream) VEC(tree,gc) *file_unemitted_tinfo_decls; source_location cpp_token_replay_loc; - /* If we have opened STREAM before, we do not need to re-read the rest - of its body. */ + /* If we already have STREAM in memory (or are reading it), ignore + this request. */ if (stream->in_memory_p) return; + /* Mark this file as being in memory. This prevents multiple reads + from the same file. This scenario can happen in #include chains + where the top header file is also included by one of its children + (common in system headers). */ + stream->in_memory_p = true; + if (flag_pph_tracer >= 1) fprintf (pph_logfile, "PPH: Reading %s\n", stream->name); -- This patch is available for review at http://codereview.appspot.com/5540069
Re: PR other/51165: add new adress_escapes predicate
On 01/17/2012 08:20 AM, Aldy Hernandez wrote: On 01/17/12 03:09, Richard Guenther wrote: On Mon, Jan 16, 2012 at 4:58 PM, Aldy Hernandez wrote: Not really - you handle both ptr and *ptr in the same predicate and call both "address escaped". What I suggested was sth like I think I confused myself and you by asking the wrong question in the first place. Actually, what I want is to handle VAR_DECL correctly, and your original suggestion of using may_be_aliased() fits the bill. The other calls to ptr_deref_may_alias_global_p() were fine because we have an SSA_NAME. We're now down to a one-liner :). How about this? All TM memory optimization tests fixed, and no regressions. Ok. Note that may_be_aliased (x) is also true if x is an automatic variable that has its address taken. You can use is_global_var (x) instead if you only want to test for "global memory". Richard. is_global_var is fine. Thanks. Committed. I disagree. is_global_var is already tested just above: if (is_global_var (x)) return !TREE_READONLY (x); Which make sense since we don't want to log if it is read-only. So you can do probably the following: Index: trans-mem.c === --- trans-mem.c (revision 183253) +++ trans-mem.c (working copy) @@ -1497,8 +1497,6 @@ requires_barrier (basic_block entry_block, tree x, to needs_to_live_in_memory until we eliminate lower_sequence_tm altogether. */ needs_to_live_in_memory (x) - /* X escapes. */ - || is_global_var (x)) return true; else { Thanks. Patrick Marlier.
Re: [Patch, Fortran] PR 51869 - fix realloc on assignment issue
Dear All, > thanks for the review - and for the f95-lang.c patch. I have updated the > patch to use calloc, build & regtested it, and committed it as Rev. 183247. Good - I will go back to array allocation and use calloc there as well. Cheers Paul
Re: [PATCH] PR51280 LTO/trans-mem ICE with TM builtins
What I have in mind is to abstract out the initialization of TM builtins from gtm-builtins.def (through its inclusion in builtins.def) into a separate function that we can call either in c_define_builtins() from the C-ish front-ends, or from lto_define_builtins (once we encounter a TM builtin and enable flag_tm appropriately). Hm? They are included in builtins.def, that looks appropriate for middle-end builtins. Thus they should be initialized by lto1, too. Are they not? Since flag_tm is NULL, when lto_define_builtins runs, the TM builtins do not get initialized. This is because DEF_TM_BUILTIN is predicated on flag_tm. It isn't until streamer_get_builtin_tree() that we realize the object file has a TM builtin.
[pph] Change representation of mutated trees (issue5540070)
This patch changes the representation of mutated trees to avoid creating unnecessary (and ultimately confusing) cache entries. Mutated trees are those that we read initially from an external PPH image and get changed during parsing. The most common case is when the external PPH image has a declaration which is converted into a full definition in the current file. When we initially read these trees, we compute a checksum of its body. So, when we write it out in the second file, we decide whether the tree has mutated by re-computing its checksum. If it did, we write a special record (PPH_RECORD_START_MUTATED) which indicates to the reader that this is a tree that exists in an external file, but its body should be re-read. Before this patch, we would also insert the tree into the cache of the current file. This converted further references to the tree into internal references. This is unnecessary, since the tree is already present in the external cache. Additionally, the new merging code that Lawrence is working on gets confused by it, as it expects to always find the tree in the external cache. This patch changes that. We now write the mutated reference to the external cache. But instead of adding the tree to the internal cache of the current file, we re-sign the tree. This way, subsequent references to the tree will resolve as regular external references (PPH_RECORD_XREF). * pph-in.c (pph_in_tree): Do not expect an internal reference when reading a mutated tree. Only add the tree to the cache for PPH_RECORD_START markers. * pph-out.c (pph_out_start_tree_record): Do not add mutated trees to the internal cache. Re-sign mutated trees. Do not write an internal reference. diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c index 827c8fd..ae918a2 100644 --- a/gcc/cp/pph-in.c +++ b/gcc/cp/pph-in.c @@ -2426,9 +2426,6 @@ pph_in_tree (pph_stream *stream) PPH image. */ expr = (tree) pph_cache_find (stream, PPH_RECORD_XREF, image_ix, ix, PPH_any_tree); - - /* Read the internal cache slot where EXPR should be stored at. */ - ix = pph_in_uint (stream); } else if (marker == PPH_RECORD_START_MERGE_BODY) { @@ -2438,12 +2435,13 @@ pph_in_tree (pph_stream *stream) expr = (tree) pph_cache_get (&stream->cache, ix); } - /* Add the new tree to the cache and read its body. The tree is - added to the cache before we read its body to handle circular - references and references from children nodes. If we are reading - a merge body, then the tree is already in the cache (it was added - by pph_in_merge_key_tree). */ - if (marker != PPH_RECORD_START_MERGE_BODY) + /* If we are starting to read a full tree, add its pointer to the + cache and read its body. The tree is added to the cache before + we read its body to handle circular references and references + from children nodes. If we are reading a merge body, then the + tree is already in the cache (it was added by + pph_in_merge_key_tree). */ + if (marker == PPH_RECORD_START) pph_cache_insert_at (&stream->cache, expr, ix, pph_tree_code_to_tag (expr)); if (flag_pph_tracer) diff --git a/gcc/cp/pph-out.c b/gcc/cp/pph-out.c index 08c9862..55b48cb 100644 --- a/gcc/cp/pph-out.c +++ b/gcc/cp/pph-out.c @@ -696,33 +696,32 @@ pph_out_start_tree_record (pph_stream *stream, tree t) } else if (marker == PPH_RECORD_START_MUTATED) { - unsigned int internal_ix; + unsigned new_crc; + size_t nbytes; + pph_cache *ext_cache; /* We found T in an external PPH file, but it has mutated since we originally read it. We are going to write out T again, - but the reader should not re-allocate T, rather it should + but the reader should not re-allocate T. Rather, it should read the contents of T on top of the existing address. - We also add T to STREAM's internal cache so further - references go to it rather than the external version. - Note that although we add an entry for T in STREAM's internal - cache, the reference we write to the stream is to the - external version of T. This way the reader will get the - location of T from the external reference and overwrite it - with the contents that we are going to write here. */ - pph_cache_add (&stream->cache, t, &internal_ix, tag); +We also re-compute T's CRC and update its cache entry. This +way, further references to T will become regular external +references. */ pph_out_record_marker (stream, marker, tag); + /* Update the CRC for T in the external cache, so we don't +continue to consider it mutated. */ + new_crc = pph_get_signature (t, &nbytes); + ext_cache = pph_cache_select (stream, PPH_RECORD_XREF, include_ix); + pph_cache_sign (ext_cache, ix, n
Fix checks for !TARGET_MACHO
TARGET_MACHO is always defined (either 0 or 1) so using #ifndef to test for !TARGET_MACHO is incorrect. Introduced here: http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00623.html The i386 case has been tested on i386-freebsd. The compiler now emits calls to __stack_chk_fail_local again when using -fstack-protector -fpic. The rs6000 cases are untested. I don't have commit access, so please commit when approved. 2011-01-10 Tijl Coosemans * config/i386/i386.c: Fix checks for !TARGET_MACHO. * config/rs6000/rs6000.c: Likewise. --- gcc/config/i386/i386.c +++ gcc/config/i386/i386.c @@ -38624,7 +38624,7 @@ ix86_autovectorize_vector_sizes (void) #undef TARGET_MANGLE_TYPE #define TARGET_MANGLE_TYPE ix86_mangle_type -#ifndef TARGET_MACHO +#if !TARGET_MACHO #undef TARGET_STACK_PROTECT_FAIL #define TARGET_STACK_PROTECT_FAIL ix86_stack_protect_fail #endif --- gcc/config/rs6000/rs6000.c +++ gcc/config/rs6000/rs6000.c @@ -939,7 +939,7 @@ static bool legitimate_lo_sum_address_p static struct machine_function * rs6000_init_machine_status (void); static bool rs6000_assemble_integer (rtx, unsigned int, int); static bool no_global_regs_above (int, bool); -#if defined (HAVE_GAS_HIDDEN) && !defined (TARGET_MACHO) +#if defined (HAVE_GAS_HIDDEN) && !TARGET_MACHO static void rs6000_assemble_visibility (tree, int); #endif static int rs6000_ra_ever_killed (void); @@ -1387,7 +1387,7 @@ static const struct attribute_spec rs600 #undef TARGET_ASM_INTEGER #define TARGET_ASM_INTEGER rs6000_assemble_integer -#if defined (HAVE_GAS_HIDDEN) && !defined (TARGET_MACHO) +#if defined (HAVE_GAS_HIDDEN) && !TARGET_MACHO #undef TARGET_ASM_ASSEMBLE_VISIBILITY #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility #endif @@ -1576,7 +1576,7 @@ static const struct attribute_spec rs600 #define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \ rs6000_builtin_vectorized_function -#ifndef TARGET_MACHO +#if !TARGET_MACHO #undef TARGET_STACK_PROTECT_FAIL #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail #endif @@ -15515,7 +15515,7 @@ rs6000_assemble_integer (rtx x, unsigned return default_assemble_integer (x, size, aligned_p); } -#if defined (HAVE_GAS_HIDDEN) && !defined (TARGET_MACHO) +#if defined (HAVE_GAS_HIDDEN) && !TARGET_MACHO /* Emit an assembler directive to set symbol visibility for DECL to VISIBILITY_TYPE. */
Re: [PATCH] PR c++/50852 - loose template parameter comparison
On 11/17/2011 04:21 PM, Dodji Seketeli wrote: + parm = TREE_VALUE (parm_desc); + if (TREE_CODE (parm) == TYPE_DECL) + val = iterative_hash_template_parm_index_no_level + (TEMPLATE_TYPE_PARM_INDEX (TREE_TYPE (parm)), val); + else if (TREE_CODE (parm) == TEMPLATE_DECL) + val = iterative_hash_template_parms + (INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (parm)), val); + else if (TREE_CODE (parm) == PARM_DECL) + val = iterative_hash_template_parm_index_no_level + (DECL_INITIAL (parm), val); It looks like type and non-type parameters will get the same hash here. You also need to hash the type of a non-type parameter, so that two non-type parameters of different types are considered different. And I don't see any strategy for dealing with hash collisions. How about if we just store a pointer to the template parameter list and do comp_template_parms? Since we normally use TYPE_CANONICAL to compare template parameters, this shouldn't be a significant bottleneck. If canonical_type_parameter gets slow we can mess with hashes there instead of the current O(N) linked list lookup. Jason
[patch c++]: Fix for PR c++/51344 - cc1plus hangs when compiling
Hello, this hang is caused by an end-less loop in private_lookup_attribute caused by double-chaining of attributes in decl2.c's save_template_attributes function. In save_template_attributes we need to check that attribute-list isn't equal to late_attrs before chaining them. ChangeLog gcc/cp 2012-01-17 Kai Tietz PR c++/51344 * decl2.c (save_template_attributes): Don't chain late-attributes with attribute-list, if they are same. ChangeLog gcc/cp 2012-01-17 Kai Tietz g++.dg/torture/pr51344.C: New test. Bootstrapped and regression tested for x86_64-unknown-linux-gnu, x86_64-w64-mingw32, and i686-w64-mingw32. Ok for apply? Regards, Kai Index: gcc/cp/decl2.c === --- gcc/cp/decl2.c (revision 183106) +++ gcc/cp/decl2.c (working copy) @@ -1202,7 +1202,8 @@ /* Place the late attributes at the beginning of the attribute list. */ - TREE_CHAIN (tree_last (late_attrs)) = *q; + if (late_attrs != *q) +TREE_CHAIN (tree_last (late_attrs)) = *q; *q = late_attrs; if (!DECL_P (*decl_p) && *decl_p == TYPE_MAIN_VARIANT (*decl_p)) Index: gcc/gcc/testsuite/g++.dg/torture/pr51344.C === --- /dev/null +++ gcc/gcc/testsuite/g++.dg/torture/pr51344.C @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +template +class B +{ + friend __attribute__((cdecl)) A& operator >>(A& a, B& b) + { +return a; + } +};
Re: RFC: allowing fwprop to propagate subregs
Richard Kenner wrote: > > Maybe the best solution would be to remove the SUBREG case from the generic > > apply_distributive_law subroutine, and instead add a special check for the > > distributed subreg case right at the above place in simplify_set; i.e. to > > perform the inverse distribution only if it is already guaranteed that we > > will also be able to move the subreg to the LHS ... > > That could indeed work. I tried to implement that suggestion, but interestingly enough I cannot really test it since I was unable to find any single case where that SUBREG case in apply_distributive_law actually causes any difference whatsoever in generated code. As test case I used the whole of libstdc++.so on the following set of platforms: - i686-pc-linux - s390x-ibm-linux - powerpc-ibm-linux - arm-linux-gnueabi and built the compiler and libstdc++.so for each of: - current mainline - current mainline plus the first patch below - current mainline plus both patches below All three resulting object files were identical for every platform. Do you have any further suggestion of how to find a testcase (some particular source code and/or architecture)? Given the current set of results, since I do not have any way to verify whether my simplify_set changes would actually trigger correctly, I'd rather propose to just remove the SUBREG case in apply_distributive_law (i.e. only apply the first patch below). Thoughts? Thanks, Ulrich Patch A: Remove SUBREG case in apply_distributive_law Index: gcc/combine.c === --- gcc/combine.c (revision 183240) +++ gcc/combine.c (working copy) @@ -9238,37 +9269,6 @@ /* This is also a multiply, so it distributes over everything. */ break; -case SUBREG: - /* Non-paradoxical SUBREGs distributes over all operations, -provided the inner modes and byte offsets are the same, this -is an extraction of a low-order part, we don't convert an fp -operation to int or vice versa, this is not a vector mode, -and we would not be converting a single-word operation into a -multi-word operation. The latter test is not required, but -it prevents generating unneeded multi-word operations. Some -of the previous tests are redundant given the latter test, -but are retained because they are required for correctness. - -We produce the result slightly differently in this case. */ - - if (GET_MODE (SUBREG_REG (lhs)) != GET_MODE (SUBREG_REG (rhs)) - || SUBREG_BYTE (lhs) != SUBREG_BYTE (rhs) - || ! subreg_lowpart_p (lhs) - || (GET_MODE_CLASS (GET_MODE (lhs)) - != GET_MODE_CLASS (GET_MODE (SUBREG_REG (lhs - || paradoxical_subreg_p (lhs) - || VECTOR_MODE_P (GET_MODE (lhs)) - || GET_MODE_SIZE (GET_MODE (SUBREG_REG (lhs))) > UNITS_PER_WORD - /* Result might need to be truncated. Don't change mode if -explicit truncation is needed. */ - || !TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (x), -GET_MODE (SUBREG_REG (lhs - return x; - - tem = simplify_gen_binary (code, GET_MODE (SUBREG_REG (lhs)), -SUBREG_REG (lhs), SUBREG_REG (rhs)); - return gen_lowpart (GET_MODE (x), tem); - default: return x; } Patch B: Re-implement SUBREG case specifically in simplify_set Index: gcc/combine.c === --- gcc/combine.c (revision 183240) +++ gcc/combine.c (working copy) @@ -6299,6 +6299,7 @@ rtx dest = SET_DEST (x); enum machine_mode mode = GET_MODE (src) != VOIDmode ? GET_MODE (src) : GET_MODE (dest); + rtx src_subreg; rtx other_insn; rtx *cc_use; @@ -6496,6 +6497,10 @@ and X being a REG or (subreg (reg)), we may be able to convert this to (set (subreg:m2 x) (op)). + Similarly, if we have (set x (op:m1 (subreg:m2 ...) (subreg:m2 ...))), + we may be able to first distribute the subreg over op, and then apply + the above transformation. + We can always do this if M1 is narrower than M2 because that means that we only care about the low bits of the result. @@ -6504,30 +6509,56 @@ be undefined. On machine where it is defined, this transformation is safe as long as M1 and M2 have the same number of words. */ + src_subreg = NULL_RTX; if (GET_CODE (src) == SUBREG && subreg_lowpart_p (src) - && !OBJECT_P (SUBREG_REG (src)) + && !OBJECT_P (SUBREG_REG (src))) +src_subreg = SUBREG_REG (src); + else if (GET_CODE (src) == IOR || GET_CODE (src) == XOR + || GET_CODE (src) == AND + || GET_CODE (src) == PLUS || GET_CODE (src) == MINUS) +{ + rtx lhs = XEXP (x, 0); + rtx rhs = XEXP (x, 1); + + /* We can distribute non-paradoxical lowpart SUBREGs if the +
Re: [patch c++]: Fix for PR c++/51344 - cc1plus hangs when compiling
How does this happen? Are we setting DECL_ATTRIBUTES twice? Jason
Re: [patch c++]: Fix for PR c++/51344 - cc1plus hangs when compiling
2012/1/17 Jason Merrill : > How does this happen? Are we setting DECL_ATTRIBUTES twice? > > Jason Yes, we call it for this example twice. One time in 'begin_class_definition'. and second time in 'do_friend'. Kai
Re: [patch c++]: Fix for PR c++/51344 - cc1plus hangs when compiling
On 01/17/2012 02:30 PM, Kai Tietz wrote: 2012/1/17 Jason Merrill: How does this happen? Are we setting DECL_ATTRIBUTES twice? Yes, we call it for this example twice. One time in 'begin_class_definition'. and second time in 'do_friend'. Surely the call from begin_class_definition isn't for the function declaration, though. Jason
Re: [patch c++]: Fix for PR c++/51344 - cc1plus hangs when compiling
2012/1/17 Jason Merrill : > On 01/17/2012 02:30 PM, Kai Tietz wrote: >> >> 2012/1/17 Jason Merrill: >>> >>> How does this happen? Are we setting DECL_ATTRIBUTES twice? >> >> >> Yes, we call it for this example twice. One time in >> 'begin_class_definition'. and second time in 'do_friend'. > > > Surely the call from begin_class_definition isn't for the function > declaration, though. > > Jason Right, but in second call we get for cplus_decl_attributes's late_attrs (as result of splice_template_attributes) the same value as already stored in decl_p's attributes. By this we chain up an endless-recusion. Kai
Go patch committed: Don't use import path for ./ or ../ imports
When importing a path which starts with ./ or ../, we should not use the import path. This patch implements that. This makes gccgo compatible with the other Go compiler in how such paths are handled. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 90c1cf927434 go/import.cc --- a/go/import.cc Tue Jan 17 06:18:15 2012 -0800 +++ b/go/import.cc Tue Jan 17 11:42:44 2012 -0800 @@ -42,8 +42,8 @@ // returns a pointer to a Stream object to read the data that it // exports. If the file is not found, it returns NULL. -// When FILENAME is not an absolute path, we use the search path -// provided by -I and -L options. +// When FILENAME is not an absolute path and does not start with ./ or +// ../, we use the search path provided by -I and -L options. // When FILENAME does not exist, we try modifying FILENAME to find the // file. We use the first of these which exists: @@ -61,7 +61,18 @@ Import::Stream* Import::open_package(const std::string& filename, Location location) { - if (!IS_ABSOLUTE_PATH(filename)) + bool is_local; + if (IS_ABSOLUTE_PATH(filename)) +is_local = true; + else if (filename[0] == '.' && IS_DIR_SEPARATOR(filename[1])) +is_local = true; + else if (filename[0] == '.' + && filename[1] == '.' + && IS_DIR_SEPARATOR(filename[2])) +is_local = true; + else +is_local = false; + if (!is_local) { for (std::vector::const_iterator p = search_path.begin(); p != search_path.end();
Re: RFC: allowing fwprop to propagate subregs
> I tried to implement that suggestion, but interestingly enough I cannot > really test it since I was unable to find any single case where that > SUBREG case in apply_distributive_law actually causes any difference > whatsoever in generated code. > > Do you have any further suggestion of how to find a testcase (some > particular source code and/or architecture)? No. It may well be irrelevant now and was only relevant in cases where we just had SImode and not the narrower modes on some of the older architectures such as a29k. It may also be that the optimizations that this caught are now done at tree level, though I think the former is the more likely. > Given the current set of results, since I do not have any way to verify > whether my simplify_set changes would actually trigger correctly, I'd > rather propose to just remove the SUBREG case in apply_distributive_law > (i.e. only apply the first patch below). > > Thoughts? I think that's reasonable. But I'd replace it with a comment saying what used to be there and why it was removed.
Re: [patch c++]: Fix for PR c++/51344 - cc1plus hangs when compiling
On 01/17/2012 02:41 PM, Kai Tietz wrote: Right, but in second call we get for cplus_decl_attributes's late_attrs (as result of splice_template_attributes) the same value as already stored in decl_p's attributes. Right, but why is it already stored there? Jason
Re: [PATCH] PR50325 store_bit_field: Fix for big endian targets
Richard Sandiford writes: > Iain Sandoe writes: >> On 17 Nov 2011, at 09:25, Andreas Krebbel wrote: >>> On 11/17/2011 03:44 AM, David Edelsohn wrote: Andreas, This patch seems to have introduced a failure for all of the gcc.dg-struct-layout tests on AIX. gcc.dg-struct-layout-1/t001_test.h:8:1: internal compiler error: in int_mode_for_mode, at stor-layout.c:424 After your change, int_mode_for_mode now is passed VOIDmode because the rtx is a CONST_INT. >>> >>> extract_bit_field is only able to deal with regs and mems. For >>> constants it should not be >>> necessary anyway. Could you please test the following patch: >>> >>> Index: gcc/expmed.c >>> === >>> *** gcc/expmed.c.orig 2011-11-15 20:03:46.0 +0100 >>> --- gcc/expmed.c2011-11-17 09:12:22.487783491 +0100 >>> *** store_bit_field_1 (rtx str_rtx, unsigned >>> *** 562,570 >>>MIN (BITS_PER_WORD, bitsize - i * BITS_PER_WORD); >>> >>> /* If the remaining chunk doesn't have full wordsize we have >>> !to make that for big endian machines the higher order >>> !bits are used. */ >>> ! if (new_bitsize < BITS_PER_WORD && BYTES_BIG_ENDIAN) >>>value_word = extract_bit_field (value_word, new_bitsize, 0, >>>true, false, NULL_RTX, >>>BLKmode, word_mode); >>> --- 562,572 >>>MIN (BITS_PER_WORD, bitsize - i * BITS_PER_WORD); >>> >>> /* If the remaining chunk doesn't have full wordsize we have >>> !to make sure that for big endian machines the higher >>> !order bits are used. */ >>> ! if (BYTES_BIG_ENDIAN >>> ! && GET_MODE (value_word) != VOIDmode >>> ! && new_bitsize < BITS_PER_WORD) >>>value_word = extract_bit_field (value_word, new_bitsize, 0, >>>true, false, NULL_RTX, >>>BLKmode, word_mode); >>> >> >> with this + r181436 on powerpc-darwin9, the ICEs are gone .. >> .. but all the struct-layout-1 tests are failing on execute. >> >> Running /GCC/gcc-live-trunk/gcc/testsuite/gcc.dg/compat/struct- >> layout-1.exp ... >> FAIL: tmpdir-gcc.dg-struct-layout-1/t001 c_compat_x_tst.o- >> c_compat_y_tst.o execute >> FAIL: tmpdir-gcc.dg-struct-layout-1/t002 c_compat_x_tst.o- >> c_compat_y_tst.o execute >> FAIL: tmpdir-gcc.dg-struct-layout-1/t003 c_compat_x_tst.o- >> c_compat_y_tst.o execute >> FAIL: tmpdir-gcc.dg-struct-layout-1/t004 c_compat_x_tst.o- >> c_compat_y_tst.o execute >> FAIL: tmpdir-gcc.dg-struct-layout-1/t005 c_compat_x_tst.o- >> c_compat_y_tst.o execute >> FAIL: tmpdir-gcc.dg-struct-layout-1/t006 c_compat_x_tst.o- >> c_compat_y_tst.o execute >> FAIL: tmpdir-gcc.dg-struct-layout-1/t007 c_compat_x_tst.o- >> c_compat_y_tst.o execute >> FAIL: tmpdir-gcc.dg-struct-layout-1/t008 c_compat_x_tst.o- >> c_compat_y_tst.o execute > > Yeah, I don't think constants are any different here. One fix might be > to use simplify_expand_binop instead of extract_bit_field, as per the > patch below. The patch also restricts the shifting to forward walks, > as discussed in the PR trail. > > But I'm not sure I understand the fieldmode != BLKmode test in: > > unsigned int backwards = WORDS_BIG_ENDIAN && fieldmode != BLKmode; > > Adding it was the (only) net effect of r7985 and r8007, > but the comment: > >However, only do that if the value is not BLKmode. */ > > is less than helpful when trying to discern a reason. Even in those days, > the code was followed by: > > /* This is the mode we must force value to, so that there will be enough >subwords to extract. Note that fieldmode will often (always?) be >VOIDmode, because that is what store_field uses to indicate that this >is a bit field, but passing VOIDmode to operand_subword_force will >result in an abort. */ > fieldmode = mode_for_size (nwords * BITS_PER_WORD, MODE_INT, 0); > > This latter comment is clearly talking about the value of fieldmode > before rather than after the call to mode_for_size, so there seems to > have been a bit of confusion about what fieldmode was actually supposed > to be (comment says VOIDmode, r8007 says that BLKmode is both possible > and special). > > The pre-r7985 code honoured the comment: > > for (i = 0; i < nwords; i++) > { > /* If I is 0, use the low-order word in both field and target; >if I is 1, use the next to lowest word; and so on. */ > > And any trimming would always happen in the last iteration (i == nwords - 1); > in other words, in the high word. > > The point of r8007 seems to be that WORDS_BIG_ENDIAN doesn't apply to > BLKmode fieldmodes, but there must surely be some endianness involved > somewhere, given that we
Ping^3: Out-of-order update of new_spill_reg_store[]
Ping for this reload patch: http://gcc.gnu.org/ml/gcc-patches/2011-12/msg00266.html or perhaps the original: http://gcc.gnu.org/ml/gcc-patches/2011-10/msg00663.html which fixes some wrong-code regressions on mips64-linux-gnu. Richard
Re: [PATCH] PR debug/45682 - wrong struct DIE nesting with -fdebug-types-section
+ /* If the original DIE was a specification, we need to put + the skeleton under the parent DIE of the declaration. */ + if (new_parent != NULL) + { + remove_child_with_prev (child, prev); + add_child_die (new_parent, skeleton); + } This adds a new declaration without removing the old one, though it's later removed by prune_unused_types. It also seems to me that copy_declaration_context and remove_child_or_replace_with_skeleton should be combined if they need to work together like this. Jason
[PATCH][Cilkplus] Array notations for Function Calls and Unary Expressions
Hello Everyone, This patch is for the Cilkplus branch affecting the C++ Compiler. This patch will allow the use of array notations triplets as a function call parameter and for post and pre increment/decrement. Thanking You, Yours Sincerely, Balaji V. Iyer.diff --git a/gcc/cp/ChangeLog.cilk b/gcc/cp/ChangeLog.cilk index 06ef1ec..072a6de 100644 --- a/gcc/cp/ChangeLog.cilk +++ b/gcc/cp/ChangeLog.cilk @@ -1,3 +1,29 @@ +2012-01-17 Balaji V. Iyer + + * cp-array-notation.c (max): New function. + (fix_unary_array_notation_exprs): Likewise. + (build_x_array_notation_expr): Added a check to see if we get an + expression has a rank of 0. Also added code to handle a case where + a function call with array notation as a parameter that results a + scalar value. Also added a check if lhs_rank is zero. Changed + modifycode to NOP_EXPR. Replaced all lhs_rank in for-loop conditions + to max of lhs and rhs rank. Added a check to see if array_expr_lhs is + null, if so then just use lhs. + (fix_conditional_array_notations): Renamed to fix_array_notation_exprs. + Also added a case for POSTINCREMENT_EXPR, POSTDECREMENT_EXPR, + PREDECREMENT_EXPR, PREINCREMENT_EXPR. + * cp-tree.h: Renamed fix_conditional_array_notations to + fix_array_notation_exprs. + * parser.c (cp_parser_assignment_expression): Modified to handle a + function-call that has array-notation as a parameter which will return + a single scalar value. + (cp_parser_compound_statement): Renamed fix_conditional array_notations + to fix_array_notation_exprs and make sure it is called only if + flag_enable_cilk is set. + * typeck.c (lvalue_or_else): Removed a error check for + ARRAY_NOTATION_REF, if flag_enable_cilk is defined. + (cp_build_addr_expr_1): Likewise. + 2012-01-12 Balaji V. Iyer * cp-array-notation.c (fix_conditional_array_notations): New function. diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c index dec87bb..a8667dd 100644 --- a/gcc/cp/cp-array-notation.c +++ b/gcc/cp/cp-array-notation.c @@ -48,6 +48,7 @@ void replace_array_notations (tree *, tree *, tree *, int); void find_rank (tree array, int *rank); static tree fix_conditional_array_notations_1 (tree stmt); +tree fix_unary_array_notation_exprs (tree stmt); /* This function is to find the rank of an array notation expression. * For example, an array notation of A[:][:] has a rank of 2. @@ -198,6 +199,16 @@ replace_array_notations (tree *orig, tree *list, tree *array_operand, return; } +/* this is a small function that will give the max of 2 integers */ +static int +max (int x, int y) +{ + if (x > y) +return x; + else +return y; +} + /* this function is synonymous to the build_x_modify_expr. This function * will build the equivalent array notation expression */ @@ -228,13 +239,22 @@ build_x_array_notation_expr (tree lhs, enum tree_code modifycode, tree rhs, find_rank (lhs, &lhs_rank); find_rank (rhs, &rhs_rank); - extract_array_notation_exprs (rhs, &rhs_list, &rhs_list_size); + /* If both are scalar, then no reason to do any of the components inside this + * function... a simple build_x_modify_expr would do. + */ + if (lhs_rank == 0 && rhs_rank == 0) +return NULL_TREE; + extract_array_notation_exprs (rhs, &rhs_list, &rhs_list_size); + if (lhs_rank == 0 && rhs_rank != 0) { - error ( "Left Hand-side rank cannot be scalar when " - "right-hand side is not"); - return error_mark_node; + if (TREE_CODE (rhs) != CALL_EXPR) + { + error ( "Left Hand-side rank cannot be scalar when " + "right-hand side is not"); + return error_mark_node; + } } if (lhs_rank != 0 && rhs_rank != 0 && lhs_rank != rhs_rank) { @@ -286,12 +306,12 @@ build_x_array_notation_expr (tree lhs, enum tree_code modifycode, tree rhs, * * In both the scenarios, just checking the LHS_RANK is OK */ - body_label = (tree *) xmalloc (sizeof (tree) * lhs_rank); - body_label_expr = (tree *) xmalloc (sizeof (tree) * lhs_rank); - exit_label = (tree *) xmalloc (sizeof (tree) * lhs_rank); - exit_label_expr = (tree *) xmalloc (sizeof (tree) * lhs_rank); - cond_expr = (tree *) xmalloc (sizeof (tree) * lhs_rank); - if_stmt_label = (tree *) xmalloc (sizeof (tree) * lhs_rank); + body_label = (tree *) xmalloc (sizeof (tree) * max (lhs_rank, rhs_rank)); + body_label_expr = (tree *) xmalloc (sizeof (tree) * max (lhs_rank, rhs_rank)); + exit_label = (tree *) xmalloc (sizeof (tree) * max(lhs_rank, rhs_rank)); + exit_label_expr = (tree *) xmalloc (sizeof (tree) * max(lhs_rank, rhs_rank)); + cond_expr = (tree *) xmalloc (sizeof (tree) * max (lhs_rank, rhs_rank)); + if_stmt_label = (tree *) xmalloc (sizeof (tree) * max (lhs_rank, rhs_rank)); lhs_expr_incr = (tree *) xmalloc (sizeof (tree) * lhs_rank); rhs_exp
[v3] doc-epub rule updates
This updates the support for generating epub docs to EPUB3. Using the EPUB3 stylesheets allows the removal of ruby and other tool checks from configure, and generates a much better documentation file. tested x86/linux -benjamin2012-01-17 Benjamin Kosnik * configure.ac (BUILD_EPUB): Adjust for epub3. * configure: Regenerate. * Makefile.in: Same. * doc/Makefile.am (stamp-epub-docbook): Update for epub3. * doc/Makefile.in: Regenerate. * include/Makefile.in: Same. * libsupc++/Makefile.in: Same. * po/Makefile.in: Same. * python/Makefile.in: Same. * src/Makefile.in: Same. * testsuite/Makefile.in: Same. * doc/xml/manual/documentation_hacking.xml: Update. diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index d453f63..1c62aea 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -373,18 +373,21 @@ AM_CONDITIONAL(BUILD_MAN, test $ac_cv_prog_DOXYGEN = "yes" && test $ac_cv_prog_DOT = "yes") -# Check for pdf/epub dependencies. +# Check for pdf dependencies. AC_CHECK_PROG([DBLATEX], dblatex, yes, no) AC_CHECK_PROG([PDFLATEX], pdflatex, yes, no) AM_CONDITIONAL(BUILD_PDF, test $ac_cv_prog_DBLATEX = "yes" && test $ac_cv_prog_PDFLATEX = "yes") -AC_CHECK_PROG([RUBY], ruby, yes, no) -AC_CHECK_PROG([DBTOEPUB], dbtoepub, yes, no) +# Check for epub dependencies. +AC_CHECK_FILE(/usr/share/xml/docbook/stylesheet/docbook-xsl-ns/epub3/chunk.xsl, + ac_cv_file_epub3_a=yes, ac_cv_file_epub3_a=no) +AC_CHECK_FILE(/usr/share/sgml/docbook/xsl-ns-stylesheets/epub3/chunk.xsl, + ac_cv_file_epub3_b=yes, ac_cv_file_epub3_b=no) AM_CONDITIONAL(BUILD_EPUB, - test $ac_cv_prog_RUBY = "yes" && - test $ac_cv_prog_DBTOEPUB = "yes") + test $ac_cv_file_epub3_a = "yes" || + test $ac_cv_file_epub3_b = "yes") # Propagate the target-specific source directories through the build chain. diff --git a/libstdc++-v3/doc/Makefile.am b/libstdc++-v3/doc/Makefile.am index 3cb6dce..0f7b285 100644 --- a/libstdc++-v3/doc/Makefile.am +++ b/libstdc++-v3/doc/Makefile.am @@ -467,10 +467,11 @@ XSLT_PARAM = --param toc.section.depth 4 XSL_FO_STYLE = $(XSL_STYLE_DIR)/fo/docbook.xsl XSL_HTML_STYLE = $(XSL_STYLE_DIR)/xhtml-1_1/chunk.xsl XSL_HTML_SINGLE_STYLE = $(XSL_STYLE_DIR)/xhtml-1_1/docbook.xsl -XSL_EPUB_STYLE = $(XSL_STYLE_DIR)/epub/docbook.xsl +XSL_EPUB_STYLE = $(XSL_STYLE_DIR)/epub3/chunk.xsl ${docbook_outdir}/epub: mkdir -p ${docbook_outdir}/epub + mkdir -p ${docbook_outdir}/epub/OEBPS/images ${docbook_outdir}/fo: mkdir -p ${docbook_outdir}/fo @@ -592,20 +593,25 @@ doc-texinfo-docbook: stamp-texinfo-docbook doc-info-docbook: stamp-info-docbook -# EPUB, via ruby + dbtoepub -# Can verify document with: epubcheck +# EPUB version 3 +# http://sourceforge.net/projects/docbook/files/epub3/ +# Can verify document with epubcheck manual_epub = ${docbook_outdir}/epub/libstdc++-manual.epub stamp-epub-docbook: stamp-xml-single-docbook ${docbook_outdir}/epub @echo "Generating epub files..." if [ ! -d "${docbook_outdir}/images" ]; then \ $(LN_S) ${top_srcdir}/doc/xml/images ${docbook_outdir}/; \ fi - ${XSL_STYLE_DIR}/epub/bin/dbtoepub -v -d -o ${manual_epub} ${set_xml} + $(XSLTPROC) $(XSLT_PARAM) $(XSLT_FLAGS) \ + --stringparam base.dir "${docbook_outdir}/epub/OEBPS/" \ + $(XSL_EPUB_STYLE) ${top_srcdir}/doc/xml/spine.xml + $(INSTALL_DATA) $(xml_images) ${docbook_outdir}/epub/OEBPS/images + zip -X0 ${manual_epub} ${docbook_outdir}/epub/mimetype + zip -r -X9 ${manual_epub} ${docbook_outdir}/epub/META-INF ${docbook_outdir}/epub/OEBPS $(STAMP) stamp-epub-docbook doc-epub-docbook: stamp-epub-docbook - # Performance doc and graph configuration. # Assumes pychart, beautiful soup installed. # Generates the plots/graph imagery for performance testing. diff --git a/libstdc++-v3/doc/xml/manual/documentation_hacking.xml b/libstdc++-v3/doc/xml/manual/documentation_hacking.xml index f6d7d55..2fe7692 100644 --- a/libstdc++-v3/doc/xml/manual/documentation_hacking.xml +++ b/libstdc++-v3/doc/xml/manual/documentation_hacking.xml @@ -611,6 +611,12 @@ info output + + epub3 stylesheets + b3 + epub output + + @@ -675,6 +681,10 @@ For Texinfo output, something that transforms valid Docbook XML to Texinfo is required. The default choice is http://www.w3.org/1999/xlink"; xlink:href="http://docbook2x.sourceforge.net/";>docbook2X. + + + For epub output, the http://www.w3.org/1999/xlink"; xmlns:href="http://sourceforge.net/projects/docbook/files/epub3/";>stylesheets for EPUB3 are required. These stylesheets are still in development. To validate the created file, http://www.w3.org/1999/xlink"; xmlns:href="https://code.google.com/p/epubcheck/";>epubcheck is necessary. + Generating the DocBook Files
Re: [PATCH] PR debug/45682 - wrong struct DIE nesting with -fdebug-types-section
On Tue, Jan 17, 2012 at 12:41 PM, Jason Merrill wrote: >> + /* If the original DIE was a specification, we need to put >> + the skeleton under the parent DIE of the declaration. */ >> + if (new_parent != NULL) >> + { >> + remove_child_with_prev (child, prev); >> + add_child_die (new_parent, skeleton); >> + } > > > This adds a new declaration without removing the old one, though it's later > removed by prune_unused_types. Yes. At this point, I don't have the "prev" pointer needed to remove the old one efficiently, and since it will get pruned anyway, it seemed more efficient to let that happen. If it doesn't actually get pruned, I think there's no harm done other than an unnecessary DIE. Would you consider it OK with a comment? > It also seems to me that copy_declaration_context and > remove_child_or_replace_with_skeleton should be combined if they need to > work together like this. How about if I call copy_declaration_context directly from remove_child_or_replace_with_skeleton, instead of calling them sequentially in break_out_comdat_types? Or would you prefer combining them into a single function? -cary
[v3] doc updates
Regerate the html docs included in the source distribution. -benjamin 20120117-2.patch.bz2 Description: application/bzip
[pph] Rebuild identifier bindings. (issue5557045)
Instead of emitting identifiers with binding information, emit them without and then patch up that information later. We switch to this technique because the cycles in binding info were causing no end of troubles. This change requires handling namespaces differently from before. In particular, we alway emit all namespaces into the PPH file. We may not emit decls within them. There is an overloading bug in this patch, but I am pushing it up now to avoid keeping so large a change hanging. Index: gcc/testsuite/ChangeLog.pph 2011-01-17 Lawrence Crowl * g++.dg/pph/x6dynarray3.cc: Add expected overload failures. * g++.dg/pph/x4namespace.cc: Remove expected failures. * g++.dg/pph/x4overset1.cc: Add expected overload asm diff failure. * g++.dg/pph/x4overset2.cc: Likewise. * g++.dg/pph/x4overset3.cc: Likewise. * g++.dg/pph/x4overset4.cc: Likewise. * g++.dg/pph/x0namespace.h: Add spacing. * g++.dg/pph/x0namespace2.h: Likewise. Index: gcc/cp/ChangeLog.pph 2012-01-17 Lawrence Crowl * pph.h (pph_files_read): New. (chain2vec): Move from static to global. * pph-streamer.h (pph_dump_namespace): Add message parameter. * pph-core.c (pph_dump_namespace): Add message parameter. (pph_trace_marker): Add PPH: label to debugging output. (pph_cache_insert_at): Remove non-static aggregate initializer. (pph_loaded): Enable pph_set_global_identifier_bindings(). * pph-out.c (chain2vec): Move from static to global. (pph_out_merge_key_namespace_decl): New. (pph_out_merge_body_namespace_decl): New. (pph_foreach_out_chain): New. (pph_out_merge_key_binding_level): Handle namespace keys separately. (pph_out_merge_key_tree): Likewise. (pph_out_merge_body_binding_level): Handle namespace bodies separately. (pph_out_identifier_bindings): No longer emit most binding info. (pph_out_merge_key_namespace_decl): Output record info. (pph_out_merge_body_namespace_decl): New. * pph-in.c (pph_in_merge_body_namespace_decl): New. (pph_in_merge_key_namespace_decl): New. (pph_in_merge_key_binding_level): Handle namespace separately. (pph_in_merge_key_tree): Likewise. (pph_in_merge_body_binding_level_1): Likewise. (pph_in_identifier_bindings): No longer emit most binding info. (pph_ensure_namespace_binding_level): New. (pph_in_merge_key_namespace_decl): Modify chain as needed. (pph_in_merge_body_namespace_decl): New. (bool pph_files_were_read): New. (pph_files_read): New. (pph_read_file_1): Set pph_files_were_read. * pt.c (pph_dump_tinst_level): Add PPH: label to debugging output. (pph_dump_pending_templates_list): Likewise. (pph_dump_spec_entry_slot): Likewise. (pph_dump_spec_entry_htab): Likewise. * parser.h (cp_debug_parser_where): New. * parser.c (cp_debug_parser_where): New. (c_parse_file): Conditionalize call to pph_loaded. * name-lookup.c (pph_debug_binding_action): New. (pph_debug_binding_inaction): New. (pph_foreach_on_chain_bl): New. (pph_set_identifier_bindings): New. (pph_set_chain_identifier_bindings): Use pph_set_identifier_bindings. (pph_set_namespace_bindings): New. (pph_set_chain_namespace_bindings): New. (pph_foreach_on_chain): New. (pph_set_namespace_namespace_binding): New. (pph_set_namespace_namespace_bindings): New. (pph_set_global_identifier_bindings): Add call to pph_set_namespace_namespace_bindings. Index: gcc/ChangeLog.pph 2012-01-17 Lawrence Crowl * langhooks.h (get_lang_hooks): New. * langhooks.c (get_lang_hooks): New. Index: gcc/testsuite/g++.dg/pph/x6dynarray3.cc === --- gcc/testsuite/g++.dg/pph/x6dynarray3.cc (revision 183260) +++ gcc/testsuite/g++.dg/pph/x6dynarray3.cc (working copy) @@ -1,6 +1,8 @@ -// pph asm xdiff 18502 -// xfail BOGUS UNKNOWN -// Some branches seem to be missing. +// { dg-bogus "a0dynarray-dfn1b.hi:8:13: error: no matching function for call to 'operator new" "" { xfail *-*-* } 0 } +// { dg-bogus "a0dynarray-dfn1b.hi:22:5: error: no suitable 'operator delete" "" { xfail *-*-* } 0 } +// { dg-bogus "a0dynarray-dfn2b.hi:8:13: error: no matching function for call to 'operator new" "" { xfail *-*-* } 0 } +// { dg-bogus "a0dynarray-dfn2b.hi:13:9: error: no suitable 'operator delete" "" { xfail *-*-* } 0 } +// { dg-bogus "a0dynarray-dcl3.hi:11:60: warning: no corresponding deallocation function for 'void. operator new" "" { xfail *-*-* } 0 } #include "x5dynarray3.h" Index: gcc/testsuite/g++.dg/pph/x4overset1.cc === --- gcc/testsuite/g++.dg/pph/x4overset1.cc (revision 183260) +++ gcc
Cross-build breakage with libstdc++-v3 doc changes
> From: Benjamin Kosnik > Date: Wed, 18 Jan 2012 00:41:59 +0100 > This updates the support for generating epub docs to EPUB3. Using the > EPUB3 stylesheets allows the removal of ruby and other tool checks from > configure, and generates a much better documentation file. ...or for cross-targets, breakage. Something went wrong with this or subsequent changes; somewhere in the r183262:183268 I've started getting: ... Configuring in cris-elf/libstdc++-v3 configure: creating cache ./config.cache checking build system type... x86_64-unknown-linux-gnu checking host system type... cris-axis-elf checking target system type... cris-axis-elf ... checking for GNU c++filt... /usr/bin/c++filt (right there's a buglet, but let's not get distracted and it's a preexisting condition anyway ) checking whether the target supports .symver directive... yes configure: versioning on shared library symbols is no checking for size_t as unsigned int... no checking for ptrdiff_t as int... no checking whether the target supports hidden visibility... yes configure: visibility supported: yes checking for makeinfo... makeinfo --split-size=500 checking for modern makeinfo... yes checking for doxygen... yes checking for dot... no checking for xsltproc... yes checking for xmllint... yes checking for stylesheets used in generation of documentation... no checking for local stylesheet directory... no checking for dblatex... no checking for pdflatex... yes checking for /usr/share/xml/docbook/stylesheet/docbook-xsl-ns/epub3/chunk.xsl... configure: error: cannot check for file existence when cross compiling make[1]: *** [configure-target-libstdc++-v3] Error 1 make[1]: Leaving directory `/tmp/hpautotest-gcc1/cris-elf/gccobj' make: *** [all] Error 2 For r183262 I got, around the above point of breakage: ... configure: visibility supported: yes checking for makeinfo... makeinfo --split-size=500 checking for modern makeinfo... yes checking for doxygen... yes checking for dot... no checking for xsltproc... yes checking for xmllint... yes checking for stylesheets used in generation of documentation... no checking for local stylesheet directory... no checking for dblatex... no checking for pdflatex... yes checking for ruby... yes checking for dbtoepub... no configure: updating cache ./config.cache checking for gxx-include-dir... no checking for --enable-version-specific-runtime-libs... no checking for install location... ${prefix}/${target_alias}/include/c++/${gcc_version} configure: creating ./config.status config.status: creating Makefile ... Pretty please cross-test for your favorite cross-target. The build system was running Fedora 12, FWIW. brgds, H-P
Go patch committed: Recognize more test lines
This patch to the Go testsuite driver recognizes a few more test lines in Go tests. I somehow failed to notice these the last time I updated the Go testsuite. This patch includes a couple of changes to make the newly recognized tests pass. Ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian 2012-01-17 Ian Lance Taylor PR go/50656 * go.test/go-test.exp (go-gc-tests): Recognize some more test lines. Index: test/fixedbugs/bug364.go === --- test/fixedbugs/bug364.go (revision 183262) +++ test/fixedbugs/bug364.go (working copy) @@ -1,3 +1,9 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package main import "fmt" Index: test/fixedbugs/bug345.dir/main.go === --- test/fixedbugs/bug345.dir/main.go (revision 183262) +++ test/fixedbugs/bug345.dir/main.go (working copy) @@ -22,7 +22,7 @@ func main() { // main.go:27: cannot use &x (type *"io".SectionReader) as type *"/Users/rsc/g/go/test/fixedbugs/bug345.dir/io".SectionReader in function argument var w io.Writer - bufio.NewWriter(w) // ERROR "test/io" + bufio.NewWriter(w) // ERROR "test/io|has incompatible type" var x goio.SectionReader - io.SR(&x) // ERROR "test/io" + io.SR(&x) // ERROR "test/io|has incompatible type" } Index: go-test.exp === --- go-test.exp (revision 183262) +++ go-test.exp (working copy) @@ -1,4 +1,4 @@ -# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. +# Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc. # Written by Ian Lance Taylor . # This program is free software; you can redistribute it and/or modify @@ -467,6 +467,9 @@ proc go-gc-tests { } { $test_line] \ || [string match \ "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \ + $test_line] \ + || [string match \ + "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \ $test_line] } { if { [string match \ "// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \ @@ -474,13 +477,20 @@ proc go-gc-tests { } { set name1 "bug0.go" set name2 "bug1.go" } elseif { [string match \ - "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \ - $test_line] } { + "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \ + $test_line] } { set name1 "p1.go" set name2 "p2.go" - } else { + } elseif { [string match \ + "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \ + $test_line] } { set name1 "b.go" set name2 "a.go" + } elseif { [string match \ + "// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \ + $test_line] } { + set name1 "io.go" + set name2 "main.go" } set hold_runtests $runtests set runtests "go-test.exp" @@ -492,6 +502,17 @@ proc go-gc-tests { } { file delete "[file rootname [file tail $file1]].o" set runtests $hold_runtests } elseif { [string match \ + "// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \ + $test_line ] } { + set hold_runtests $runtests + set runtests "go-test.exp" + set dg-do-what-default "assemble" + regsub "\\.go$" $test "1.go" file1 + dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" + errchk $test "" + file delete "[file rootname [file tail $file1]].o" + set runtests $hold_runtests + } elseif { [string match \ "// \$G \$D/\$F.dir/bug0.go && (! \$G \$D/\$F.dir/bug1.go || echo BUG*" \ $test_line] } { set hold_runtests $runtests @@ -537,14 +558,28 @@ proc go-gc-tests { } { set runtests $hold_runtests } elseif { [string match \ "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \ - $test_line] } { + $test_line] \ + || [string match \ + "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \ + $test_line] } { + if { [string match \ + "// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \ + $test_line] } { + set name1 "x.go" + set name2 "y.go" + } elseif { [string match \ + "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \ + $test_line] } { + set name1 "p.go" + set name2 "main.go" + } set hold_runtests $runtests set runtests "go-test.exp" set dg-do-what-default "assemble" - regsub "\\.go$" $test ".dir/x.go" file1 + regsub "\\.go$" $test ".dir/$name1" file1 dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" set ofile1 "[file rootname [file tail $file1]].o" - regsub "\\.go$" $test ".dir/y.go" file2 + re
Re: Go patch committed: Recognize more test lines
Hello! > This patch to the Go testsuite driver recognizes a few more test lines > in Go tests. I somehow failed to notice these the last time I updated > the Go testsuite. This patch includes a couple of changes to make the > newly recognized tests pass. Ran Go testsuite on > x86_64-unknown-linux-gnu. Committed to mainline. Some of the go tests require explicit -mieee compile flag [1]. Is there a way to conditionally pass this flag to the compiler? [1] http://gcc.gnu.org/ml/gcc-testresults/2012-01/msg01443.html Uros.
[PATCH] Improve SCEV for array element
This code change intends to improve scev for array element and reduce the common sub-expressions in loop, which may be introduced by multiple reference of expression like &a[i]. With this optimization the register pressure can be reduced in loops. The problem is originally from a real benchmark, and the test case only tries to detect the GIMPLE level changes. Bootstraped on x86-32. OK for trunk? ChangeLog: 2012-01-05 Jiangning Liu * tree-scalar-evolution (interpret_rhs_expr): generate chrec for array reference. ChangeLog for testsuite: 2012-01-05 Jiangning Liu * gcc.dg/scev-1.c: New. diff --git a/gcc/testsuite/gcc.dg/scev-1.c b/gcc/testsuite/gcc.dg/scev-1.c new file mode 100644 index 000..28d5c93 --- /dev/null +++ b/gcc/testsuite/gcc.dg/scev-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int *a_p; +int a[1000]; + +f(int k) +{ + int i; + + for (i=k; i<1000; i+=k) { + a_p = &a[i]; + *a_p = 100; +} +} + +/* { dg-final { scan-tree-dump-times "&a" 1 "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 2077c8d..de89fc4 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -1712,6 +1712,42 @@ interpret_rhs_expr (struct loop *loop, gimple at_stmt, switch (code) { case ADDR_EXPR: + if (TREE_CODE (TREE_OPERAND (rhs1, 0)) == ARRAY_REF) +{ + tree array_ref; + tree var_decl, base, offset; + tree low_bound; + tree unit_size; + tree index; + + array_ref = TREE_OPERAND (rhs1, 0); + var_decl = TREE_OPERAND (array_ref, 0); + index = TREE_OPERAND (array_ref, 1); + + low_bound = array_ref_low_bound (array_ref); + unit_size = array_ref_element_size (array_ref); + + /* We assume all arrays have sizes that are a multiple of a byte. +First subtract the lower bound, if any, in the type of the +index, then convert to sizetype and multiply by the size of +the array element. */ + if (! integer_zerop (low_bound)) + index = fold_build2 (MINUS_EXPR, TREE_TYPE (index), +index, low_bound); + + offset = size_binop (MULT_EXPR, + fold_convert (sizetype, index), + unit_size); + + base = build1 (ADDR_EXPR, TREE_TYPE (rhs1), var_decl); + chrec1 = analyze_scalar_evolution (loop, base); + chrec2 = analyze_scalar_evolution (loop, offset); + chrec1 = chrec_convert (type, chrec1, at_stmt); + chrec2 = chrec_convert (TREE_TYPE (offset), chrec2, at_stmt); + res = chrec_fold_plus (type, chrec1, chrec2); + break; +} + /* Handle &MEM[ptr + CST] which is equivalent to POINTER_PLUS_EXPR. */ if (TREE_CODE (TREE_OPERAND (rhs1, 0)) != MEM_REF) { Thanks, -Jiangning scev.patch Description: Binary data