Re: Optimize calls to functions that return one of their arguments
Ok, that looks like three votes in favour. I've checked in the following variant with a few minor changes. I've added strcpy and memset to the list of functions, and split off a new function in ira-lives. Changes to subdirectories must be documented in the subdirectory's ChangeLog (ada, c-family, lto) and not in the main ChangeLog. -- Eric Botcazou
Re: Fix debug/52727 -- lost REG_ARGS_SIZE note
Losing REG_ARGS_SIZE notes leads to assertion failures in dwarf2cfi.c when the values don't match across CFG edges. I'd like to leave this patch on mainline for a week or so to see what falls out before copying it to the 4.7 branch. There is a new abort here, though I suppose that would probably only trigger when we would abort later in dwarf2cfi.c anyway... Can it be backported to the branch now? -Os is seriously hampered by this. -- Eric Botcazou
Re: Ping: always supply a mode to plus_constant
The following patch fixes the build (not reg-tested, but looks obvious): 2012-05-14 Tristan Gingold ging...@adacore.com * config/ia64/ia64.c (ia64_expand_prologue): Adjust calls to plus_constant. Applied as obvious after fixing the ChangeLog. -- Eric Botcazou
Re: Use sed -n … instead of sed s/…/p -e d in s-header-vars
On 5/14/2012 11:22 PM, Hans-Peter Nilsson wrote: Random non-maintainer comments: I'd suggest adding a nearby comment to avoid a future edit changing it back. The attachment with the patch had the mime-type Video/X-DV, maybe indicating an issue with your mail-client setup mismatching the .dif filename suffix. As always, comments about what you didn't do and why you didn't do it, are often the most important (and note that code can never be self-documenting in this regard :-)) brgds, H-P
Re: Missing guard in ira-color.c ?
On May 10, 2012, at 10:41 PM, Vladimir Makarov wrote: On 05/10/2012 09:10 AM, Tristan Gingold wrote: Hi, I am getting a segfault in ira-color.c:2945 on the trunk: Program received signal SIGSEGV, Segmentation fault. 0x00a79f37 in move_spill_restore () at ../../src/gcc/ira-color.c:2945 2945 || ira_reg_equiv_const[regno] != NULL_RTX (gdb) l 2940 /* don't do the optimization because it can create 2941 copies and the reload pass can spill the allocno set 2942 by copy although the allocno will not get memory 2943 slot. */ 2944 || ira_reg_equiv_invariant_p[regno] 2945 || ira_reg_equiv_const[regno] != NULL_RTX 2946 || !bitmap_bit_p (loop_node-border_allocnos, ALLOCNO_NUM (a))) 2947 continue; 2948 mode = ALLOCNO_MODE (a); 2949 rclass = ALLOCNO_CLASS (a); while building gcc (gnatcmd.adb file) for ia64-vms using a cross compiler (target=ia64-vms, host=x86_64-linux). The reason looks to be an out of bounds access: (gdb) print regno $10 = 18476 (gdb) print ira_reg_equiv_len $11 = 17984 (I suppose this setup is not easy at all to reproduce, but I can provide any files, if necessary). Tristan, thanks for reporting this. Wild guess, as I don't know IRA at all: looks like in this file most accesses to ira_reg_equiv_* are guarded. Is it expected that they aren't at this point ? Yes, I guess. It is possible to have the pseudos which are out of range ira_reg_equiv_const. It should be hard to reproduce such error because they are generated when we need to break circular dependence (e.g. when hard register 1 should be moved to hard register 2 and hard register 2 to hard register 1). Your solution is perfectly fine. So you can commit the patch into the trunk as pre-approved. Now committed, after reg-testing on GNU/Linux x86_64. Tristan.
[Patch]: Fix typo in common/config/ia64/ia64-common.c
hi, looks like a typo... Ok for trunk ? Tristan. 2012-05-14 Tristan Gingold ging...@adacore.com * common/config/ia64/ia64-common.c (ia64_except_unwind_info): Fix typo. diff --git a/gcc/common/config/ia64/ia64-common.c b/gcc/common/config/ia64/ia64- index 1168253..79aed6a 100644 --- a/gcc/common/config/ia64/ia64-common.c +++ b/gcc/common/config/ia64/ia64-common.c @@ -71,8 +71,8 @@ enum unwind_info_type ia64_except_unwind_info (struct gcc_options *opts) { /* Honor the --enable-sjlj-exceptions configure switch. */ -#ifdef CONFIG_UNWIND_EXCEPTIONS - if (CONFIG_UNWIND_EXCEPTIONS) +#ifdef CONFIG_SJLJ_EXCEPTIONS + if (CONFIG_SJLJ_EXCEPTIONS) return UI_SJLJ; #endif
[PATCH v2]: handle size_t /= ptr size in tree-ssa-strlen.c
On May 4, 2012, at 2:34 PM, Richard Guenther wrote: On Fri, May 4, 2012 at 2:27 PM, Tristan Gingold ging...@adacore.com wrote: Hi, get_string_length assumes that precision of size_t is the same as precision of a pointer, which isn't always true at least on VMS. This patch simply add a conversion in case of mismatch. Tested on ia64/VMS by cross-bootstrapping. Bootstrapped and regtested on i386/GNU Linux. Ok for trunk ? Hmm, isn't the issue that size_t precision is not the same precision as sizetype? You probably should use ptrofftype_p (TREE_TYPE (lhs)) instead of spelling out 'sizetype' here. So, second submission after bootstrapping and reg-testing on x86-64 GNU/Linux. Ok for trunk ? Tristan. 2012-05-04 Tristan Gingold ging...@adacore.com * tree-ssa-strlen.c (get_string_length): Convert lhs if needed. diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index a37633a..05fd10d 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -427,6 +427,12 @@ get_string_length (strinfo si) NULL); add_referenced_var (lhs_var); tem = gimple_call_arg (stmt, 0); + if (!ptrofftype_p (TREE_TYPE (lhs))) +{ + lhs = convert_to_ptrofftype (lhs); + lhs = force_gimple_operand_gsi (gsi, lhs, true, NULL_TREE, + true, GSI_SAME_STMT); +} lenstmt = gimple_build_assign_with_ops (POINTER_PLUS_EXPR, make_ssa_name (lhs_var, NULL),
[Patch]: Fix ICE by expand_expr_addr_expr_1
Hi, I got ICE in plus_constant (after the assertions were added) due to expand_expr_addr_expr_1 during build on ia64/Openvms. This function is called with TMODE == SImode (32 bit pointers) but EXP designating a variable on the frame (whose register is DImode). Hence the ICE. Fixed by the following patch. No regression on x86-64 GNU/Linux. Ok for trunk ? Tristan. 2012-05-15 Tristan Gingold ging...@adacore.com * expr.c (expand_expr_addr_expr_1): Call convert_memory_address_addr_space. diff --git a/gcc/expr.c b/gcc/expr.c index 3edb4a2..1b0ad8d 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -7600,6 +7600,7 @@ expand_expr_addr_expr_1 (tree exp, rtx target, enum machin TYPE_USER_ALIGN (TREE_TYPE (inner)) = 1; } result = expand_expr_addr_expr_1 (inner, subtarget, tmode, modifier, as); + result = convert_memory_address_addr_space (tmode, result, as); if (offset) {
[Patch, libgfortran] Pass mode in open for O_CREAT and on VxWorks
Dear all, the motivation for the following is rbmj's patch for libstdc++ on VxWorks, cf. http://gcc.gnu.org/ml/gcc-patches/2012-05/msg00073.html Note that gfortan is used on VxWorks as the following email proves: http://gcc.gnu.org/ml/fortran/2012-02/msg00115.html (VxWorks is a real-time embedded operating system: https://en.wikipedia.org/wiki/VxWorks) Seemingly, VxWorks differs from POSIX. POSIX [1] has int open(const char *path, int oflag, ... ); and requires only with O_CREAT as third argument at mode_t. By contrast, VxWorks has the following prototype [2] int open (const char * name, int flags, int mode) where mode is not optional and the function is not variadic. This patch does now always passes a mode on VxWorks; I assume that the mode is ignored if there is no O_CREAT. That part of the code gets only accessed if there is no access function; looking at [2], that seems to be the case for VxWorks. Additionally, in the fall-back implementation of mkstemp, open with O_CREAT is used but no mode has been passed. I added 0600 unconditionally. The patch was build on x86-64-linux, but I only expect an effect on VxWorks and on systems without mkstemp. OK for the trunk? (Is there a need for backporting?) Tobias [1] http://pubs.opengroup.org/onlinepubs/95399/functions/open.html [2] http://www-kryo.desy.de/documents/vxWorks/V5.5/vxworks/ref/ioLib.html#open 2012-05-15 Tobias Burnus bur...@net-b.de * io/unix.c (fallback_access): Pass mode to open on VxWorks. (tempfile_open): Pass mode to open for O_CREAT diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index c81163f..b5dca8e 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -154,11 +154,21 @@ fallback_access (const char *path, int mode) { int fd; + /* Note that POSIX only requires the mode argument with O_CREAT + and open is variadic while vxWorks always requires the argument. */ +#ifdef __VXWORKS__ + if ((mode R_OK) (fd = open (path, O_RDONLY, 0666)) 0) +#else if ((mode R_OK) (fd = open (path, O_RDONLY)) 0) +#endif return -1; close (fd); +#ifdef __VXWORKS__ + if ((mode W_OK) (fd = open (path, O_WRONLY, 0666)) 0) +#else if ((mode W_OK) (fd = open (path, O_WRONLY)) 0) +#endif return -1; close (fd); @@ -1099,9 +1109,9 @@ tempfile_open (const char *tempdir, char **fname) #if defined(HAVE_CRLF) defined(O_BINARY) fd = open (template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, - S_IRUSR | S_IWUSR); + S_IRUSR | S_IWUSR, 0600); #else - fd = open (template, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + fd = open (template, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, 0600); #endif } while (fd == -1 errno == EEXIST);
Re: [RFC] PR 51712 -Wtype-limits should not trigger for enum constants
On Mon, May 14, 2012 at 8:47 PM, Joseph S. Myers jos...@codesourcery.com wrote: On Mon, 14 May 2012, Manuel López-Ibáñez wrote: PING: http://gcc.gnu.org/ml/gcc-patches/2012-05/msg00383.html The general idea of checking this information in shorten_compare seems reasonable. (shorten_compare's optimization function is one that really ought to be done in generic code, but the warning function is reasonable enough.) And on a general note, what is the opinion of the C/C++ maintainers about tracking the original source code more faithfully than currently done? I consider it a good idea to do so - moving more to an explicit lowering step / conversion from front-end to middle-end internal representation. There are some places where c_fully_fold is called to avoid false positive warnings. A first approach for eliminating those would be to make the internal representation contain relevant information such as this is an implicit conversion so that the warnings can be generated later in c_fully_fold when it has the extra information from folding operands. Another possibility would be to have IR that says give this warning, if this condition can occur, and options to evaluate the condition early (with predictability but false positives) or late (fewer false positives, less predictability). Or you could lower as needed but carry around both lowered and unlowered versions of an expression (so front-end IR would include a pointer to lowered IR if lowering has taken place on-demand). I suppose it would be possible to use a new CONST_EXPR with two operands - the fully folded result (and thus constant) and the original expression which is unfolded. At the time we lower to GENERIC we can simply drop CONST_EXPR in favor of its constant operand. Richard. -- Joseph S. Myers jos...@codesourcery.com
[Patch]: Fix very large frame bug on i386
Hi, use of 'unsigned int' for i386.c:ix86_compute_frame_layout stack_alignment_needed results in truncation of frame offset in code such as: offset = (offset + stack_alignment_needed - 1) -stack_alignment_needed (as it is -stack_alignment_needed that is converted to HOST_WIDE_INT). As a consequence, frames larger than 4GB are squeezed. Also, the frame field of struct ix86_frame is never used. Bootstrapped and reg-tested on x86_64 GNU/Linux, without regressions. Ok for trunk ? Tristan. 2012-05-15 Tristan Gingold ging...@adacore.com * config/i386/i386.c (struct ix86_frame): Remove unused frame field. (ix86_compute_frame_layout): Fix type of stack_alignment_needed and preferred_alignment. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index ad4739b..353ee53 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2408,7 +2408,6 @@ struct ix86_frame int va_arg_size; int red_zone_size; int outgoing_arguments_size; - HOST_WIDE_INT frame; /* The offsets relative to ARG_POINTER. */ HOST_WIDE_INT frame_pointer_offset; @@ -8937,9 +8936,9 @@ ix86_builtin_setjmp_frame_value (void) static void ix86_compute_frame_layout (struct ix86_frame *frame) { - unsigned int stack_alignment_needed; + unsigned HOST_WIDE_INT stack_alignment_needed; HOST_WIDE_INT offset; - unsigned int preferred_alignment; + unsigned HOST_WIDE_INT preferred_alignment; HOST_WIDE_INT size = get_frame_size (); HOST_WIDE_INT to_allocate;
Re: [PATCH v2]: handle size_t /= ptr size in tree-ssa-strlen.c
On Tue, May 15, 2012 at 10:55 AM, Tristan Gingold ging...@adacore.com wrote: On May 4, 2012, at 2:34 PM, Richard Guenther wrote: On Fri, May 4, 2012 at 2:27 PM, Tristan Gingold ging...@adacore.com wrote: Hi, get_string_length assumes that precision of size_t is the same as precision of a pointer, which isn't always true at least on VMS. This patch simply add a conversion in case of mismatch. Tested on ia64/VMS by cross-bootstrapping. Bootstrapped and regtested on i386/GNU Linux. Ok for trunk ? Hmm, isn't the issue that size_t precision is not the same precision as sizetype? You probably should use ptrofftype_p (TREE_TYPE (lhs)) instead of spelling out 'sizetype' here. So, second submission after bootstrapping and reg-testing on x86-64 GNU/Linux. Ok for trunk ? Ok. Thanks, Richard. Tristan. 2012-05-04 Tristan Gingold ging...@adacore.com * tree-ssa-strlen.c (get_string_length): Convert lhs if needed. diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index a37633a..05fd10d 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -427,6 +427,12 @@ get_string_length (strinfo si) NULL); add_referenced_var (lhs_var); tem = gimple_call_arg (stmt, 0); + if (!ptrofftype_p (TREE_TYPE (lhs))) + { + lhs = convert_to_ptrofftype (lhs); + lhs = force_gimple_operand_gsi (gsi, lhs, true, NULL_TREE, + true, GSI_SAME_STMT); + } lenstmt = gimple_build_assign_with_ops (POINTER_PLUS_EXPR, make_ssa_name (lhs_var, NULL),
[PATCH] Move gimple_set_modified
This moves gimple_set_modified to be inlined. One important user is update_stmt which looks like static inline void update_stmt (gimple s) { if (gimple_has_ops (s)) { gimple_set_modified (s, true); update_stmt_operands (s); } } and thus either is not worth inlining or we should inline gimple_set_modified, too, to avoid the redundant gimple_has_ops in gimple_set_modified and basically optimize the above to inline if (gimple_code (g) = GIMPLE_COND gimple_code (g) = GIMPLE_RETURN) { s-gsbase.modified = (unsigned) modifiedp; update_stmt_operands (s); } where the gimple_code () check is possibly optimized by preceeding code. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2012-05-15 Richard Guenther rguent...@suse.de * gimple.c (gimple_set_modified): Move ... * gimple.h (gimple_set_modified): ... here. Index: gcc/gimple.c === --- gcc/gimple.c(revision 187456) +++ gcc/gimple.c(working copy) @@ -2394,17 +2394,6 @@ gimple_copy (gimple stmt) } -/* Set the MODIFIED flag to MODIFIEDP, iff the gimple statement G has - a MODIFIED field. */ - -void -gimple_set_modified (gimple s, bool modifiedp) -{ - if (gimple_has_ops (s)) -s-gsbase.modified = (unsigned) modifiedp; -} - - /* Return true if statement S has side-effects. We consider a statement to have side effects if: Index: gcc/gimple.h === --- gcc/gimple.h(revision 187456) +++ gcc/gimple.h(working copy) @@ -830,7 +830,6 @@ tree gimple_get_lhs (const_gimple); void gimple_set_lhs (gimple, tree); void gimple_replace_lhs (gimple, tree); gimple gimple_copy (gimple); -void gimple_set_modified (gimple, bool); void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, tree *); gimple gimple_build_cond_from_tree (tree, tree, tree); void gimple_cond_set_condition_from_tree (gimple, tree); @@ -1521,6 +1520,17 @@ gimple_modified_p (const_gimple g) } +/* Set the MODIFIED flag to MODIFIEDP, iff the gimple statement G has + a MODIFIED field. */ + +static inline void +gimple_set_modified (gimple s, bool modifiedp) +{ + if (gimple_has_ops (s)) +s-gsbase.modified = (unsigned) modifiedp; +} + + /* Return the tree code for the expression computed by STMT. This is only valid for GIMPLE_COND, GIMPLE_CALL and GIMPLE_ASSIGN. For GIMPLE_CALL, return CALL_EXPR as the expression code for
[Patch]: Fix call to end_prologue debug hook
Hi, the end_prologue debug hook (only used by dwarf on VMS) is currently called at the NOTE_INSN_FUNCTION_BEG. This is not what its name implies, neither what the VMS debugger expect and neither what a comment in dwarf2out.c says: /* Recall that this end-of-prologue indication is *not* the same thing as the end_prologue debug hook. The NOTE_INSN_PROLOGUE_END note, to which the hook corresponds, follows the last insn that was emitted by gen_prologue. What we need is to preceed the first insn that had been emitted after NOTE_INSN_FUNCTION_BEG, i.e. the first insn that corresponds to something the user wrote. These may be very different locations once scheduling is enabled. */ This is fixed by this patch. No regressions on x86_64 GNU/Linux. Ok for trunk ? Tristan. 2012-05-15 Tristan Gingold ging...@adacore.com * final.c (final_scan_insn): Move call to end_prologue debug hook to the NOTE_INSN_PROLOGUE_END. diff --git a/gcc/final.c b/gcc/final.c index 718caf1..6efa06f 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -1961,6 +1961,8 @@ final_scan_insn (rtx insn, FILE *file, int optimize_p ATTR case NOTE_INSN_PROLOGUE_END: targetm.asm_out.function_end_prologue (file); profile_after_prologue (file); + if (!DECL_IGNORED_P (current_function_decl)) + debug_hooks-end_prologue (last_linenum, last_filename); if ((*seen (SEEN_EMITTED | SEEN_NOTE)) == SEEN_NOTE) { @@ -1989,8 +1991,6 @@ final_scan_insn (rtx insn, FILE *file, int optimize_p ATTR case NOTE_INSN_FUNCTION_BEG: app_disable (); - if (!DECL_IGNORED_P (current_function_decl)) - debug_hooks-end_prologue (last_linenum, last_filename); if ((*seen (SEEN_EMITTED | SEEN_NOTE)) == SEEN_NOTE) {
[Ada] Deferred constants are not always compile time known values in Alfa mode
Outside of the scope of their full view, deferred constants are not anymore considered as compile time known values in Alfa mode. This allows parameterized formal verification, in which a deferred constant value if not known from client units. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Yannick Moy m...@adacore.com * sem_aux.ads: Correct typo. * sem_eval.adb (Compile_Time_Known_Value): Return False in Alfa mode for a deferred constant when outside of the scope of its full view. Index: sem_aux.ads === --- sem_aux.ads (revision 187501) +++ sem_aux.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -99,7 +99,7 @@ function Constant_Value (Ent : Entity_Id) return Node_Id; -- Ent is a variable, constant, named integer, or named real entity. This -- call obtains the initialization expression for the entity. Will return - -- Empty for for a deferred constant whose full view is not available or + -- Empty for a deferred constant whose full view is not available or -- in some other cases of internal entities, which cannot be treated as -- constants from the point of view of constant folding. Empty is also -- returned for variables with no initialization expression. Index: sem_eval.adb === --- sem_eval.adb(revision 187501) +++ sem_eval.adb(working copy) @@ -1302,7 +1302,16 @@ if Ekind (E) = E_Enumeration_Literal then return True; -elsif Ekind (E) = E_Constant then +-- In Alfa mode, the value of deferred constants should be ignored +-- outside the scope of their full view. This allows parameterized +-- formal verification, in which a deferred constant value if not +-- known from client units. + +elsif Ekind (E) = E_Constant + and then not (Alfa_Mode + and then Present (Full_View (E)) + and then not In_Open_Scopes (Scope (E))) +then V := Constant_Value (E); return Present (V) and then Compile_Time_Known_Value (V); end if;
[Ada] Avoid incorrect detection of duplicate sources that are excluded
If two projects in the hierarchy had a common source directory but through exclusion partitioned the sources in this source directory, the project manager was still finding incorrect source duplications. This patch corrects this. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Vincent Celier cel...@adacore.com * prj-nmsc.adb (Add_Source): Always add the source if it is excluded, to avoid incorrect duplicate checks. Index: prj-nmsc.adb === --- prj-nmsc.adb(revision 187501) +++ prj-nmsc.adb(working copy) @@ -642,143 +642,153 @@ Add_Src := True; - if Unit /= No_Name then - Prev_Unit := Units_Htable.Get (Data.Tree.Units_HT, Unit); - end if; + -- Always add the source if it is locally removed, to avoid incorrect + -- duplicate checks. - if Prev_Unit /= No_Unit_Index -and then (Kind = Impl or else Kind = Spec) -and then Prev_Unit.File_Names (Kind) /= null - then - -- Suspicious, we need to check later whether this is authorized + if not Locally_Removed then + if Unit /= No_Name then +Prev_Unit := Units_Htable.Get (Data.Tree.Units_HT, Unit); + end if; - Add_Src := False; - Source := Prev_Unit.File_Names (Kind); + if Prev_Unit /= No_Unit_Index + and then (Kind = Impl or else Kind = Spec) + and then Prev_Unit.File_Names (Kind) /= null + then +-- Suspicious, we need to check later whether this is authorized - else - Source := Source_Files_Htable.Get - (Data.Tree.Source_Files_HT, File_Name); +Add_Src := False; +Source := Prev_Unit.File_Names (Kind); - if Source /= No_Source and then Source.Index = Index then -Add_Src := False; + else +Source := Source_Files_Htable.Get + (Data.Tree.Source_Files_HT, File_Name); + +if Source /= No_Source and then Source.Index = Index then + Add_Src := False; +end if; end if; - end if; - -- Duplication of file/unit in same project is allowed if order of - -- source directories is known, or if there is no compiler for the - -- language. + -- Duplication of file/unit in same project is allowed if order of + -- source directories is known, or if there is no compiler for the + -- language. - if Add_Src = False then - Add_Src := True; + if Add_Src = False then +Add_Src := True; - if Project = Source.Project then -if Prev_Unit = No_Unit_Index then - if Data.Flags.Allow_Duplicate_Basenames then - Add_Src := True; +if Project = Source.Project then + if Prev_Unit = No_Unit_Index then + if Data.Flags.Allow_Duplicate_Basenames then + Add_Src := True; - elsif Lang_Id.Config.Compiler_Driver = Empty_File then - Add_Src := True; + elsif Lang_Id.Config.Compiler_Driver = Empty_File then + Add_Src := True; - elsif Source_Dir_Rank /= Source.Source_Dir_Rank then - Add_Src := False; + elsif Source_Dir_Rank /= Source.Source_Dir_Rank then + Add_Src := False; + else + Error_Msg_File_1 := File_Name; + Error_Msg + (Data.Flags, duplicate source file name {, +Location, Project); + Add_Src := False; + end if; + else - Error_Msg_File_1 := File_Name; - Error_Msg -(Data.Flags, duplicate source file name {, - Location, Project); - Add_Src := False; - end if; + if Source_Dir_Rank /= Source.Source_Dir_Rank then + Add_Src := False; -else - if Source_Dir_Rank /= Source.Source_Dir_Rank then - Add_Src := False; + -- We might be seeing the same file through a different + -- path (for instance because of symbolic links). - -- We might be seeing the same file through a different path - -- (for instance because of symbolic links). + elsif Source.Path.Name /= Path.Name then + if not Source.Duplicate_Unit then +Error_Msg_Name_1 := Unit; +Error_Msg + (Data.Flags, + \duplicate unit %%, + Location, + Project); +Source.Duplicate_Unit := True;
[Ada] Better control of help message in GNAT.Command_Line
This is a cosmetic change only, and gives better control over the help message that is automatically generated from the definition of valid switches. Instead of using the generic name ARG, users can now specify their own name, which sometimes helps clarify the intents of the parameter. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Emmanuel Briot br...@adacore.com * g-comlin.adb, g-comlin.ads (Define_Switch): Allow specifying the name of the argument, for the automatic help message. (Getopt): do not systematically initialize switches with string values to the empty string, when the user has already specified a default. Index: g-comlin.adb === --- g-comlin.adb(revision 187501) +++ g-comlin.adb(working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1999-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1999-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -128,7 +128,8 @@ Switch : String := ; Long_Switch : String := ; Help: String := ; - Section : String := ); + Section : String := ; + Argument: String := ARG); -- Initialize [Def] with the contents of the other parameters. -- This also checks consistency of the switch parameters, and will raise -- Invalid_Switch if they do not match. @@ -1280,11 +1281,12 @@ --- procedure Initialize_Switch_Def - (Def : out Switch_Definition; + (Def : out Switch_Definition; Switch : String := ; Long_Switch : String := ; Help: String := ; - Section : String := ) + Section : String := ; + Argument: String := ARG) is P1, P2 : Switch_Parameter_Type := Parameter_None; Last1, Last2 : Integer; @@ -1316,6 +1318,10 @@ Def.Section := new String'(Section); end if; + if Argument /= ARG then + Def.Argument := new String'(Argument); + end if; + if Help /= then Def.Help := new String'(Help); end if; @@ -1330,12 +1336,14 @@ Switch : String := ; Long_Switch : String := ; Help: String := ; - Section : String := ) + Section : String := ; + Argument: String := ARG) is Def : Switch_Definition; begin if Switch /= or else Long_Switch /= then - Initialize_Switch_Def (Def, Switch, Long_Switch, Help, Section); + Initialize_Switch_Def +(Def, Switch, Long_Switch, Help, Section, Argument); Add (Config, Def); end if; end Define_Switch; @@ -1375,12 +1383,14 @@ Help: String := ; Section : String := ; Initial : Integer := 0; - Default : Integer := 1) + Default : Integer := 1; + Argument: String := ARG) is Def : Switch_Definition (Switch_Integer); begin if Switch /= or else Long_Switch /= then - Initialize_Switch_Def (Def, Switch, Long_Switch, Help, Section); + Initialize_Switch_Def +(Def, Switch, Long_Switch, Help, Section, Argument); Def.Integer_Output := Output.all'Unchecked_Access; Def.Integer_Default := Default; Def.Integer_Initial := Initial; @@ -1398,12 +1408,14 @@ Switch : String := ; Long_Switch : String := ; Help: String := ; - Section : String := ) + Section : String := ; + Argument: String := ARG) is Def : Switch_Definition (Switch_String); begin if Switch /= or else Long_Switch /= then - Initialize_Switch_Def (Def, Switch, Long_Switch, Help, Section); + Initialize_Switch_Def +(Def, Switch, Long_Switch, Help, Section, Argument); Def.String_Output := Output.all'Unchecked_Access; Add (Config, Def); end if; @@ -3206,17 +3218,31 @@ Decompose_Switch (Def.Long_Switch.all, P2, Last2); Append (Result, , Def.Long_Switch (Def.Long_Switch'First .. Last2)); - Append (Result, Param_Name (P2, ARG)); + if Def.Argument = null then + Append (Result, Param_Name (P2, ARG)); + else + Append (Result, Param_Name (P2, Def.Argument.all)); +
Re: [PATCH v2]: handle size_t /= ptr size in tree-ssa-strlen.c
On May 15, 2012, at 11:13 AM, Richard Guenther wrote: On Tue, May 15, 2012 at 10:55 AM, Tristan Gingold ging...@adacore.com wrote: On May 4, 2012, at 2:34 PM, Richard Guenther wrote: On Fri, May 4, 2012 at 2:27 PM, Tristan Gingold ging...@adacore.com wrote: Hi, get_string_length assumes that precision of size_t is the same as precision of a pointer, which isn't always true at least on VMS. This patch simply add a conversion in case of mismatch. Tested on ia64/VMS by cross-bootstrapping. Bootstrapped and regtested on i386/GNU Linux. Ok for trunk ? Hmm, isn't the issue that size_t precision is not the same precision as sizetype? You probably should use ptrofftype_p (TREE_TYPE (lhs)) instead of spelling out 'sizetype' here. So, second submission after bootstrapping and reg-testing on x86-64 GNU/Linux. Ok for trunk ? Ok. Thanks, now committed. Tristan. Thanks, Richard. Tristan. 2012-05-04 Tristan Gingold ging...@adacore.com * tree-ssa-strlen.c (get_string_length): Convert lhs if needed. diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index a37633a..05fd10d 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -427,6 +427,12 @@ get_string_length (strinfo si) NULL); add_referenced_var (lhs_var); tem = gimple_call_arg (stmt, 0); + if (!ptrofftype_p (TREE_TYPE (lhs))) +{ + lhs = convert_to_ptrofftype (lhs); + lhs = force_gimple_operand_gsi (gsi, lhs, true, NULL_TREE, + true, GSI_SAME_STMT); +} lenstmt = gimple_build_assign_with_ops (POINTER_PLUS_EXPR, make_ssa_name (lhs_var, NULL),
[Ada] Clean up System.Address_To_Access_Conversions
This patch does a bit of cleanup in System.Address_To_Access_Conversions. No change in behavior; no test. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Bob Duff d...@adacore.com * s-atacco.ads s-atacco.adb: Replace pragma Elaborate_Body with pragma No_Body. (Xyz): Remove Xyz, which is apparently unnecessary. Index: s-atacco.adb === --- s-atacco.adb(revision 187501) +++ s-atacco.adb(working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009 Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -29,10 +29,8 @@ -- -- -- --- This is a dummy version of this package that is needed to solve bootstrap --- problems when compiling a library that doesn't require s-atacco.adb from --- a compiler that contains one. +-- This package does not require a body, since it is a package renaming. We +-- provide a dummy file containing a No_Body pragma so that previous versions +-- of the body (which did exist) will not interfere. -package body System.Address_To_Access_Conversions is - -end System.Address_To_Access_Conversions; +pragma No_Body; Index: s-atacco.ads === --- s-atacco.ads(revision 187501) +++ s-atacco.ads(working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- @@ -38,24 +38,12 @@ package System.Address_To_Access_Conversions is pragma Preelaborate; - pragma Elaborate_Body; - -- This pragma Elaborate_Body is there to ensure the requirement of what is - -- at the moment a dummy null body. The reason this null body is there is - -- that we used to have a real body, and it causes bootstrap problems with - -- old compilers if we try to remove the corresponding file. pragma Compile_Time_Warning (Object'Unconstrained_Array, Object is unconstrained array type ASCII.LF To_Pointer results may not have bounds); - -- Capture constrained status, suppressing warnings, since this is - -- an obsolescent feature to use Constrained in this way (RM J.4). - - pragma Warnings (Off); - Xyz : Boolean := Object'Constrained; - pragma Warnings (On); - type Object_Pointer is access all Object; for Object_Pointer'Size use Standard'Address_Size;
[PATCH, CR16] Adding memory model attributes
Hi, Please find the attachment of mem-model.patch. This patch adds memory model attributes 'data16', 'data20', 'data24' and 'data32' for CR16 target. Using these attributes, allocatable address range for each data variable can be controlled individually. Can someone please review the patch and let me know if there should be any modifications in it? No new regressions found with this patch. == ChangeLog: 2012-05-15 Ajinkya Dhobale ajinkya.dhob...@kpitcummins.com * config/cr16/cr16.c (cr16_handle_data_memory_attribute): New function. (cr16_data16_mem_p): New function. Checks 'data16' attribute assignment. (cr16_data20_mem_p): New function. Checks 'data20' attribute assignment. (cr16_data24_mem_p): New function. Checks 'data24' attribute assignment. (cr16_data32_mem_p): New function. Checks 'data32' attribute assignment. (cr16_decompose_const): Add condition for memory attributes. (cr16_decompose_address): Add condition for memory attributes. * doc/extend.texi (CR16 variable attribute): Added description for memory model attributes === Thanks Regards, Ajinkya Dhobale mem-model.patch Description: mem-model.patch
[Ada] Case statements over predicated subtypes
In Ada 2012, if a subtype has a static predicate the set of its possible values is known statically and those are the alternatives that must be covered in in case statement. If the subtype has dynamic predicates, the alternatives must cover all values of the base type. Compiling nonstaticcase.adb in Ada 2012 mode must yield: nonstaticcase.adb:7:04: missing case values: -16#8000_# .. 0 nonstaticcase.adb:7:04: missing case values: 11 .. 16#7FFF_# nonstaticcase.adb:7:09: bounds of rr are not static, alternatives must cover base type --- procedure nonstaticcase (rmin : integer) is subtype r is integer range 1 .. 10 with Dynamic_Predicate = r = rmin; rr : r; begin rr := rmin + 1; case rr is when 1 .. 10 = null; end case; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Ed Schonberg schonb...@adacore.com * sem_case.adb (Analyze_Choices): If the subtype of the expression has a non-static predicate, the case alternatives must cover the base type. Index: sem_case.adb === --- sem_case.adb(revision 187501) +++ sem_case.adb(working copy) @@ -803,8 +803,18 @@ -- bounds of its base type to determine the values covered by the -- discrete choices. + -- In Ada 2012, if the subtype has a non-static predicate the full + -- range of the base type must be covered as well. + if Is_OK_Static_Subtype (Subtyp) then -Bounds_Type := Subtyp; +if not Has_Predicates (Subtyp) + or else Present (Static_Predicate (Subtyp)) +then + Bounds_Type := Subtyp; +else + Bounds_Type := Choice_Type; +end if; + else Bounds_Type := Choice_Type; end if;
[Ada] Simplify binder code
This patch simply moves code from the binder generated file to a-except, to slightly simplify the binder. Preliminary work. No testcase as there is no functionnal change. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Tristan Gingold ging...@adacore.com * bindgen.adb (Gen_Header): Remove code to emit LE_Set. (Gen_Finalize_Library): Replace test with a call to __gnat_reraise_library_exception_if_any. * s-soflin.ads (Library_Exception): Do not export. (Library_Exception_Set): Likewise. * a-except-2005.ads, a-except-2005.adb (Reraise_Library_Exception_If_Any): New procedure. Index: bindgen.adb === --- bindgen.adb (revision 187501) +++ bindgen.adb (working copy) @@ -1357,19 +1357,6 @@ procedure Gen_Header is begin WBI ( procedure finalize_library is); - - -- The following flag is used to check for library-level exceptions - -- raised during finalization. Symbol comes from System.Soft_Links. - -- VM targets use regular Ada to reference the entity. - - if VM_Target = No_VM then -WBI ( LE_Set : Boolean;); - -Set_String ( pragma Import (Ada, LE_Set, ); -Set_String (__gnat_library_exception_set);); -Write_Statement_Buffer; - end if; - WBI ( begin); end Gen_Header; @@ -1569,28 +1556,18 @@ -- and the routine necessary to raise it. if VM_Target = No_VM then -WBI ( if LE_Set then); -WBI ( declare); -WBI (LE : Ada.Exceptions.Exception_Occurrence;); +WBI ( declare); +WBI ( procedure Reraise_Library_Exception_If_Any;); -Set_String (pragma Import (Ada, LE, ); -Set_String (__gnat_library_exception);); +Set_String (pragma Import (Ada, ); +Set_String (Reraise_Library_Exception_If_Any, ); +Set_String (__gnat_reraise_library_exception_if_any);); Write_Statement_Buffer; -Set_String (procedure Raise_From_Controlled_); -Set_String (Operation (X : Ada.Exceptions.Exception_); -Set_String (Occurrence);); -Write_Statement_Buffer; +WBI ( begin); +WBI ( Reraise_Library_Exception_If_Any;); +WBI ( end;); -Set_String (pragma Import (Ada, Raise_From_); -Set_String (Controlled_Operation, ); -Set_String (__gnat_raise_from_controlled_operation);); -Write_Statement_Buffer; - -WBI ( begin); -WBI (Raise_From_Controlled_Operation (LE);); -WBI ( end;); - -- VM-specific code, use regular Ada to produce the desired behavior else @@ -1599,9 +1576,10 @@ Set_String ( Ada.Exceptions.Reraise_Occurrence (); Set_String (System.Soft_Links.Library_Exception);); Write_Statement_Buffer; + +WBI ( end if;); end if; - WBI ( end if;); WBI ( end finalize_library;); WBI (); end if; Index: s-soflin.ads === --- s-soflin.ads(revision 187501) +++ s-soflin.ads(working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -289,12 +289,10 @@ - Library_Exception : EO; - pragma Export (Ada, Library_Exception, __gnat_library_exception); -- Library-level finalization routines use this common reference to store -- the first library-level exception which occurs during finalization. Library_Exception_Set : Boolean := False; - pragma Export (Ada, Library_Exception_Set, __gnat_library_exception_set); -- Used in conjunction with Library_Exception, set when an exception has -- been stored. Index: a-except-2005.adb === --- a-except-2005.adb (revision 187501) +++ a-except-2005.adb (working copy) @@ -6,7 +6,7 @@ -- --
[Ada] Give full msg for finalize/adjust only if -gnateE.
The circuitery to save the first exception message (reraised as PE) in finalize or adjust operations has a distributed code size impact. This circuitery is now only enabled when then switch -gnateE is specified. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Tristan Gingold ging...@adacore.com * exp_ch7.adb (Build_Exception_Handler): Save current occurrence only if -gnateE. (Build_Object_Declaration): Declare E_Id only if -gnateE. (Build_Raise_Statement): Call Raise_From_Controlled_Operation only if -gnateE (else raise PE). * s-soflin.adb (Save_Library_Occurrence): Handle null occurrence access. * a-except-2005.adb (Reraise_Library_Exception_If_Any): Call Raise_From_Controlled_Operation only if the saved occurrence is not null, otherwise raise PE. Index: exp_ch7.adb === --- exp_ch7.adb (revision 187513) +++ exp_ch7.adb (working copy) @@ -717,63 +717,95 @@ Actuals : List_Id; Proc_To_Call : Entity_Id; Except : Node_Id; + Stmts: List_Id; begin - pragma Assert (Present (Data.E_Id)); pragma Assert (Present (Data.Raised_Id)); - -- Generate: + if Exception_Extra_Info +or else (For_Library and then not Restricted_Profile) + then + if Exception_Extra_Info then +-- Generate: - --Get_Current_Excep.all +--Get_Current_Excep.all - Except := -Make_Function_Call (Data.Loc, - Name = -Make_Explicit_Dereference (Data.Loc, - Prefix = -New_Reference_To (RTE (RE_Get_Current_Excep), Data.Loc))); +Except := + Make_Function_Call (Data.Loc, +Name = + Make_Explicit_Dereference (Data.Loc, +Prefix = + New_Reference_To (RTE (RE_Get_Current_Excep), +Data.Loc))); + else +-- Generate: - if For_Library and not Restricted_Profile then - Proc_To_Call := RTE (RE_Save_Library_Occurrence); - Actuals := New_List (Except); +--null + +Except := Make_Null (Data.Loc); + end if; + + if For_Library and then not Restricted_Profile then +Proc_To_Call := RTE (RE_Save_Library_Occurrence); +Actuals := New_List (Except); + else +Proc_To_Call := RTE (RE_Save_Occurrence); + +-- The dereference occurs only when Exception_Extra_Info is true, +-- and therefore Except is not null. + +Actuals := New_List ( + New_Reference_To (Data.E_Id, Data.Loc), + Make_Explicit_Dereference (Data.Loc, Except)); + end if; + + -- Generate: + + --when others = + -- if not Raised_Id then + -- Raised_Id := True; + + -- Save_Occurrence (E_Id, Get_Current_Excep.all.all); + --or + -- Save_Library_Occurrence (Get_Current_Excep.all); + -- end if; + + Stmts := + New_List ( + Make_If_Statement (Data.Loc, + Condition = + Make_Op_Not (Data.Loc, + Right_Opnd = New_Reference_To (Data.Raised_Id, Data.Loc)), + + Then_Statements = New_List ( + Make_Assignment_Statement (Data.Loc, + Name = New_Reference_To (Data.Raised_Id, Data.Loc), + Expression = New_Reference_To (Standard_True, Data.Loc)), + + Make_Procedure_Call_Statement (Data.Loc, + Name = + New_Reference_To (Proc_To_Call, Data.Loc), + Parameter_Associations = Actuals; + else - Proc_To_Call := RTE (RE_Save_Occurrence); - Actuals := - New_List - (New_Reference_To (Data.E_Id, Data.Loc), - Make_Explicit_Dereference (Data.Loc, Except)); + -- Generate: + + --Raised_Id := True; + + Stmts := New_List ( + Make_Assignment_Statement (Data.Loc, + Name = New_Reference_To (Data.Raised_Id, Data.Loc), + Expression = New_Reference_To (Standard_True, Data.Loc))); end if; -- Generate: --when others = - -- if not Raised_Id then - -- Raised_Id := True; - -- Save_Occurrence (E_Id, Get_Current_Excep.all.all); - --or - -- Save_Library_Occurrence (Get_Current_Excep.all); - -- end if; - return Make_Exception_Handler (Data.Loc, - Exception_Choices = -New_List (Make_Others_Choice (Data.Loc)), - Statements = New_List ( -
Re: [RFC] PR 51712 -Wtype-limits should not trigger for enum constants
On 15 May 2012 11:06, Richard Guenther richard.guent...@gmail.com wrote: On Mon, May 14, 2012 at 8:47 PM, Joseph S. Myers jos...@codesourcery.com wrote: On Mon, 14 May 2012, Manuel López-Ibáñez wrote: PING: http://gcc.gnu.org/ml/gcc-patches/2012-05/msg00383.html The general idea of checking this information in shorten_compare seems reasonable. (shorten_compare's optimization function is one that really ought to be done in generic code, but the warning function is reasonable enough.) And on a general note, what is the opinion of the C/C++ maintainers about tracking the original source code more faithfully than currently done? I consider it a good idea to do so - moving more to an explicit lowering step / conversion from front-end to middle-end internal representation. There are some places where c_fully_fold is called to avoid false positive warnings. A first approach for eliminating those would be to make the internal representation contain relevant information such as this is an implicit conversion so that the warnings can be generated later in c_fully_fold when it has the extra information from folding operands. Another possibility would be to have IR that says give this warning, if this condition can occur, and options to evaluate the condition early (with predictability but false positives) or late (fewer false positives, less predictability). Or you could lower as needed but carry around both lowered and unlowered versions of an expression (so front-end IR would include a pointer to lowered IR if lowering has taken place on-demand). I suppose it would be possible to use a new CONST_EXPR with two operands - the fully folded result (and thus constant) and the original expression which is unfolded. At the time we lower to GENERIC we can simply drop CONST_EXPR in favor of its constant operand. I think that would be probably the best for the long term. But it will also require a lot of work. More work than I can dedicate to this. This seems a chicken and egg dilemma. Current full-time contributors don't have interest or time for this kind of infrastructure work. And potential contributors who have interest in using (and perhaps improving) this infrastructure prefer to invest their effort in other compilers that already has the infrastructure in place. Well, maybe someone will be brave enough to tackle this for GSoC 2013... (Did GCC get any projects for GSoC 2012?) Cheers, Manuel.
[v3] PR libstdc++/53339
Hi, tested x86_64-linux, committed to mainline (see audit trail for details) Thanks, Paolo. / 2012-05-15 Paolo Carlini paolo.carl...@oracle.com PR libstdc++/53339 * include/bits/hashtable_policy.h (__detail::_Identity, __detail::_Select1st): Add. (_Map_base, _Hashtable_base): Use the latter, adjust parameters. * include/bits/hashtable.h (_Hashtable::__key_extract): Adjust. * include/bits/unordered_set.h (__uset_hashtable, __umset_hashtable): Likewise. * include/bits/unordered_map.h (__umap_hashtable, __ummap_hashtable): Likewise. * include/bits/stl_function.h (_Identity, _Select1st, _Select2nd) Unconditionally derive from unary_function. * include/ext/functional (identity, select1st, select2nd): Remove #ifdef __GXX_EXPERIMENTAL_CXX0X__ bits. * testsuite/23_containers/unordered_map/requirements/53339.cc: New. * testsuite/23_containers/unordered_multimap/requirements/ 53339.cc: Likewise. Index: include/ext/functional === --- include/ext/functional (revision 187501) +++ include/ext/functional (working copy) @@ -184,12 +184,7 @@ */ template class _Tp struct identity -#ifdef __GXX_EXPERIMENTAL_CXX0X__ -: public std::unary_function_Tp,_Tp, - public std::_Identity_Tp {}; -#else : public std::_Identity_Tp {}; -#endif /** @c select1st and @c select2nd are extensions provided by SGI. Their * @c operator()s @@ -204,22 +199,13 @@ /// An \link SGIextensions SGI extension \endlink. template class _Pair struct select1st -#ifdef __GXX_EXPERIMENTAL_CXX0X__ -: public std::unary_function_Pair, typename _Pair::first_type, - public std::_Select1st_Pair {}; -#else : public std::_Select1st_Pair {}; -#endif /// An \link SGIextensions SGI extension \endlink. template class _Pair struct select2nd -#ifdef __GXX_EXPERIMENTAL_CXX0X__ -: public std::unary_function_Pair, typename _Pair::second_type, - public std::_Select2nd_Pair {}; -#else : public std::_Select2nd_Pair {}; -#endif + /** @} */ // extension documented next Index: include/bits/hashtable.h === --- include/bits/hashtable.h(revision 187501) +++ include/bits/hashtable.h(working copy) @@ -203,8 +203,8 @@ using __key_extract = typename std::conditional __constant_iterators::value, -std::_Identityvalue_type, -std::_Select1stvalue_type::type; +__detail::_Identity, +__detail::_Select1st::type; using __hashtable_base = __detail:: _Hashtable_base_Key, _Value, _ExtractKey, Index: include/bits/hashtable_policy.h === --- include/bits/hashtable_policy.h (revision 187501) +++ include/bits/hashtable_policy.h (working copy) @@ -86,6 +86,23 @@ noexcept(declvalconst _Hash()(declvalconst _Key())) { }; + struct _Identity + { +templatetypename _Tp + _Tp + operator()(_Tp __x) const + { return std::forward_Tp(__x); } + }; + + struct _Select1st + { +templatetypename _Tp + auto + operator()(_Tp __x) const + - decltype(std::get0(std::forward_Tp(__x))) + { return std::get0(std::forward_Tp(__x)); } + }; + // Auxiliary types used for all instantiations of _Hashtable nodes // and iterators. @@ -497,27 +514,27 @@ templatetypename _Key, typename _Pair, typename _Alloc, typename _Equal, typename _H1, typename _H2, typename _Hash, typename _RehashPolicy, typename _Traits -struct _Map_base_Key, _Pair, _Alloc, std::_Select1st_Pair, _Equal, +struct _Map_base_Key, _Pair, _Alloc, _Select1st, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits, false { - using mapped_type = typename _Pair::second_type; + using mapped_type = typename std::tuple_element1, _Pair::type; }; /// Partial specialization, __unique_keys set to true. templatetypename _Key, typename _Pair, typename _Alloc, typename _Equal, typename _H1, typename _H2, typename _Hash, typename _RehashPolicy, typename _Traits -struct _Map_base_Key, _Pair, _Alloc, std::_Select1st_Pair, _Equal, +struct _Map_base_Key, _Pair, _Alloc, _Select1st, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits, true { private: using __hashtable_base = __detail::_Hashtable_base_Key, _Pair, -std::_Select1st_Pair, +_Select1st,
Re: [Fortran, patch] PR 52158 - Regression on character function with gfortran 4.7
2012/5/13 Tobias Burnus bur...@net-b.de: Committed as Rev. 187436. Thanks for the patch and congratulation to your first GCC contribution! Thank you for your priceless support! Alessandro
[Ada] Missing DSA remote access to subprogram rules enforcement
This change adds missing code to enforce language restrictions for remote access to subprogram types in the case of 'Unchecked_Access and 'Unrestricted_ Access. The following compilation must be rejected with the given error message: $ gcc -c server_main.adb server_main.adb:11:35: prefix must statically denote a remote subprogram package Queue is pragma Remote_Call_Interface; type Result_Callback is access procedure (Job : in Integer); procedure Append_Job (Job : in Integer; Callback : in Result_Callback); procedure Set_Result (Job : in Integer); end Queue; with Ada.Text_IO; with Queue; procedure Server_Main is use Ada; procedure Set_Result (Id : in Integer) is begin null; end Set_Result; begin Text_IO.Put_Line (Start server...); Queue.Append_Job (1, Set_Result'Unrestricted_Access); end Server_Main; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Thomas Quinot qui...@adacore.com * sem_res.adb (Resolve): Enforce E.2.2(11/2) and E.2.2(12) for 'Unrestricted_Access and 'Unchecked_Access (not just 'Access): even in those cases, a remote access type may only designate a remote subprogram. Index: sem_res.adb === --- sem_res.adb (revision 187501) +++ sem_res.adb (working copy) @@ -1967,7 +1967,10 @@ -- Prefix (N) must statically denote a remote subprogram -- declared in a package specification. - if Attr = Attribute_Access then + if Attr = Attribute_Access or else + Attr = Attribute_Unchecked_Access or else + Attr = Attribute_Unrestricted_Access + then Decl := Unit_Declaration_Node (Entity (Pref)); if Nkind (Decl) = N_Subprogram_Body then @@ -1990,26 +1993,22 @@ (prefix must statically denote a remote subprogram , N); end if; - end if; - -- If we are generating code for a distributed program. - -- perform semantic checks against the corresponding - -- remote entities. + -- If we are generating code in distributed mode, perform + -- semantic checks against corresponding remote entities. - if (Attr = Attribute_Access or else - Attr = Attribute_Unchecked_Access or else - Attr = Attribute_Unrestricted_Access) - and then Full_Expander_Active - and then Get_PCS_Name /= Name_No_DSA - then - Check_Subtype_Conformant -(New_Id = Entity (Prefix (N)), - Old_Id = Designated_Type - (Corresponding_Remote_Type (Typ)), - Err_Loc = N); + if Full_Expander_Active +and then Get_PCS_Name /= Name_No_DSA + then + Check_Subtype_Conformant + (New_Id = Entity (Prefix (N)), +Old_Id = Designated_Type + (Corresponding_Remote_Type (Typ)), +Err_Loc = N); - if Is_Remote then - Process_Remote_AST_Attribute (N, Typ); + if Is_Remote then +Process_Remote_AST_Attribute (N, Typ); + end if; end if; end if; end if;
[Ada] Save occurrence on the stack before calling last chance handler
The occurrence was already saved but in dynamically allocated memory. This patch saves it on the stack to avoid the allocation, which useful in case of Storage_Error. No functional change in normal conditions. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Tristan Gingold ging...@adacore.com * a-exextr.adb (Unhandled_Exception_Terminate): Save occurrence on the stack to avoid a dynamic memory allocation. Index: a-exextr.adb === --- a-exextr.adb(revision 187501) +++ a-exextr.adb(working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -162,14 +162,15 @@ --- procedure Unhandled_Exception_Terminate is - Excep : constant EOA := Save_Occurrence (Get_Current_Excep.all.all); + Excep : Exception_Occurrence; -- This occurrence will be used to display a message after finalization. -- It is necessary to save a copy here, or else the designated value -- could be overwritten if an exception is raised during finalization -- (even if that exception is caught). begin - Last_Chance_Handler (Excep.all); + Save_Occurrence (Excep, Get_Current_Excep.all.all); + Last_Chance_Handler (Excep); end Unhandled_Exception_Terminate;
[Ada] Get rid of compilation warnings in raise-gcc.c
No functional change. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Tristan Gingold ging...@adacore.com * raise-gcc.c (db_region_for): Use %p + cast to avoid warnings. (get_region_description_for): Likewise. (db_action_for): Likewise. (get_call_site_action_for): Likewise. (get_ttype_entry_for): Remove useless 'const'. (PERSONALITY_FUNCTION): Add ATTRIBUTE_UNUSED on uw_exception_class. Index: raise-gcc.c === --- raise-gcc.c (revision 187501) +++ raise-gcc.c (working copy) @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2011, Free Software Foundation, Inc. * + * Copyright (C) 1992-2012, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -535,10 +535,10 @@ ip = get_ip_from_context (uw_context); - db (DB_REGIONS, For ip @ 0x%08x = , ip); + db (DB_REGIONS, For ip @ %p = , (void *)ip); if (region-lsda) -db (DB_REGIONS, lsda @ 0x%x, region-lsda); +db (DB_REGIONS, lsda @ %p, (void *)region-lsda); else db (DB_REGIONS, no lsda); @@ -548,7 +548,7 @@ /* Retrieve the ttype entry associated with FILTER in the REGION's ttype table. */ -static const _Unwind_Ptr +static _Unwind_Ptr get_ttype_entry_for (region_descriptor *region, long filter) { _Unwind_Ptr ttype_entry; @@ -582,7 +582,7 @@ return; /* Parse the lsda and fill the region descriptor. */ - p = (char *)region-lsda; + p = (const unsigned char *)region-lsda; region-base = _Unwind_GetRegionStart (uw_context); @@ -662,13 +662,13 @@ { _Unwind_Ptr ip = get_ip_from_context (uw_context); - db (DB_ACTIONS, For ip @ 0x%08x = , ip); + db (DB_ACTIONS, For ip @ %p = , (void *)ip); switch (action-kind) { case unknown: - db (DB_ACTIONS, lpad @ 0x%x, record @ 0x%x\n, - action-landing_pad, action-table_entry); + db (DB_ACTIONS, lpad @ %p, record @ %p\n, + (void *) action-landing_pad, action-table_entry); break; case nothing: @@ -680,7 +680,7 @@ break; case handler: - db (DB_ACTIONS, Handler, filter = %d\n, action-ttype_filter); + db (DB_ACTIONS, Handler, filter = %d\n, (int) action-ttype_filter); break; default: @@ -784,9 +784,9 @@ p = read_uleb128 (p, cs_action); db (DB_CSITE, - c_site @ 0x%08x (+0x%03x), len = %3d, lpad @ 0x%08x (+0x%03x)\n, - region-base+cs_start, cs_start, cs_len, - region-lp_base+cs_lp, cs_lp); + c_site @ %p (+%p), len = %p, lpad @ %p (+%p)\n, + (void *)region-base + cs_start, (void *)cs_start, (void *)cs_len, + (void *)region-lp_base + cs_lp, (void *)cs_lp); /* The table is sorted, so if we've passed the IP, stop. */ if (ip region-base + cs_start) @@ -1069,7 +1069,8 @@ _Unwind_Reason_Code PERSONALITY_FUNCTION (version_arg_t version_arg, phases_arg_t phases_arg, - _Unwind_Exception_Class uw_exception_class, + _Unwind_Exception_Class uw_exception_class +ATTRIBUTE_UNUSED, _Unwind_Exception *uw_exception, _Unwind_Context *uw_context) {
[Patch, Fortran] PR51055 - accept non-spec-expr i in allocate(character(len=i)::s)
A rather simple patch. Build and regtested on x86-64-linux. OK for the trunk? I think that is the last patch required for commonly used code. Remaining are issues with array constructors and concatenations - and, of course, deferred-length components. Tobias 2012-05-15 Tobias Burnus bur...@net-b.de PR fortran/51055 PR fortran/45170 * match.c (gfc_match_allocate): Set length_from_typespec for characters. * resolve.c (resolve_charlen): If set, don't check whether the len is a specification expression. 2012-05-15 Tobias Burnus bur...@net-b.de PR fortran/51055 PR fortran/45170 * gfortran.dg/allocate_with_typespec_6.f90: New. diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 3d11918..93d7fab 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -3466,6 +3466,9 @@ gfc_match_allocate (void) type parameter, old_locus); goto cleanup; } + + if (ts.type == BT_CHARACTER) + ts.u.cl-length_from_typespec = true; } else { diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 9814c14..6fd2d97 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -9945,12 +9945,24 @@ resolve_charlen (gfc_charlen *cl) cl-resolved = 1; - specification_expr = 1; - if (resolve_index_expr (cl-length) == FAILURE) + if (cl-length_from_typespec) { - specification_expr = 0; - return FAILURE; + if (gfc_resolve_expr (cl-length) == FAILURE) + return FAILURE; + + if (gfc_simplify_expr (cl-length, 0) == FAILURE) + return FAILURE; +} + else +{ + specification_expr = 1; + + if (resolve_index_expr (cl-length) == FAILURE) + { + specification_expr = 0; + return FAILURE; + } } /* If the character length parameter value evaluates to a negative --- /dev/null 2012-05-14 08:15:48.907781309 +0200 +++ gcc/gcc/testsuite/gfortran.dg/allocate_with_typespec_6.f90 2012-05-15 09:50:53.0 +0200 @@ -0,0 +1,17 @@ +! { dg-do compile } +! +! PR fortran/51055 +! PR fortran/45170 comment 14 +! +! Contributed by Juha Ruokolainen +! and Hans-Werner Boschmann +! +! gfortran was before checking whether the length +! was a specification expression. +! + +program a + character(len=:), allocatable :: s + integer :: i=10 + allocate(character(len=i)::s) +end program a
Re: [Fortran] Patch ping
On Fri, May 11, 2012 at 07:34:30PM +0200, Tobias Burnus wrote: On 18 April 2012 at 18:57, Bernhard Reutner-Fischer wrote: On Tue, Apr 17, 2012 at 12:47:48AM +0200, Tobias Burnus wrote: Approved but not yet committed: Bernhard: - [PATCH] gfortran testsuite: implicitly cleanup-modules, part 2 http://gcc.gnu.org/ml/fortran/2012-04/msg00065.html Before actually pushing this, I ment to ask if we *want* to make sure that we do not add superfluous cleanup-module calls in the future (which would slow down testing needlessly)? If so we would either have to manually reject occurances of those during patch-review or install a warning or the like if there is an explicit cleanup-modules call yielding the same set as the now automatically determined set. I would go for the manual method: As cleanup-modules is something which developers tend to forget, I do not think that many patches will include them. On then simply tries to reduce those by patch review. - If patch developers do not see it in other files, the chance is high that they do not even know (or remember) about that feature in a few months. And after some time (1/2 year, 1 year?), one can check whether a spurious clean-up modules has slipped in - or whether some cleanup-module is missing. I expect that there will be none or very, very few cases. I have committed this as r187521. thanks,
[Ada] Interfacing aspects in Ada 2012
The aspects Convention, Export, and Import are intended to replace the use of the earlier pragmas by the same names. The additional aspects External_Name and Link_Nmae provide the remaining functionality. which previously was provided by additional pragma arguments. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Ed Schonberg schonb...@adacore.com * aspects.adb, aspects.ads: Add aspects for Convention, Export, External_Name, Import, and Link_Name. * exp_prag.adb (Expand_Pragma_Import_Or_Interface): if the pragma comes from an aspect specification, the entity is the first argument. * sem_prag.adb (Analyze_Pragma, cases Pragma_Export and Pragma_Import): if the pragma comes from an aspect specification, the entity is the first argument, and the second has the value True by default. * sem_ch13.adb (Analyze_Aspect_Specifications): generate pragam for aspect Convention. Add placeholders for Link_Name and External_Name. Index: exp_prag.adb === --- exp_prag.adb(revision 187501) +++ exp_prag.adb(working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -527,10 +527,18 @@ -- seen (i.e. this elaboration cannot be deferred to the freeze point). procedure Expand_Pragma_Import_Or_Interface (N : Node_Id) is - Def_Id: constant Entity_Id := Entity (Arg2 (N)); + Def_Id: Entity_Id; Init_Call : Node_Id; begin + -- If the pragma comes from an aspect, the entity is its first argument. + + if Present (Corresponding_Aspect (N)) then + Def_Id := Entity (Arg1 (N)); + else + Def_Id := Entity (Arg2 (N)); + end if; + if Ekind (Def_Id) = E_Variable then -- Find generated initialization call for object, if any Index: sem_prag.adb === --- sem_prag.adb(revision 187501) +++ sem_prag.adb(working copy) @@ -8633,7 +8633,30 @@ Name_Entity, Name_External_Name, Name_Link_Name)); -Check_At_Least_N_Arguments (2); + +if Present (Corresponding_Aspect (N)) then + + -- If the pragma comes from an Aspect, there is a single entity + -- parameter and an optional booean value with default true. + -- The convention must be provided by a separate aspect. + + Check_At_Least_N_Arguments (1); + Check_At_Most_N_Arguments (2); + Def_Id := Entity (Arg1); + + if No (Arg2) then + + -- If the aspect has a default True value, set corresponding + -- flag on the entity. + + Set_Is_Exported (Def_Id); + end if; + return; + +else + Check_At_Least_N_Arguments (2); +end if; + Check_At_Most_N_Arguments (4); Process_Convention (C, Def_Id); @@ -9566,10 +9589,31 @@ Name_Entity, Name_External_Name, Name_Link_Name)); -Check_At_Least_N_Arguments (2); -Check_At_Most_N_Arguments (4); -Process_Import_Or_Interface; +if Present (Corresponding_Aspect (N)) then + + -- If the pragma comes from an Aspect, there is a single entity + -- parameter and an optional booean value with default true. + -- The convention must be provided by a separate aspect. + + Check_At_Least_N_Arguments (1); + Check_At_Most_N_Arguments (2); + + if No (Arg2) then + + -- If the aspect has a default True value, set corresponding + -- flag on the entity. + + Set_Is_Imported (Entity (Arg1)); + end if; + return; + +else + Check_At_Least_N_Arguments (2); + Check_At_Most_N_Arguments (4); + Process_Import_Or_Interface; +end if; + -- -- Import_Exception -- -- Index: aspects.adb
Re: Optimize calls to functions that return one of their arguments
On 05/15/2012 09:12 AM, Eric Botcazou wrote: Ok, that looks like three votes in favour. I've checked in the following variant with a few minor changes. I've added strcpy and memset to the list of functions, and split off a new function in ira-lives. Changes to subdirectories must be documented in the subdirectory's ChangeLog (ada, c-family, lto) and not in the main ChangeLog. I checked in a fix. Bernd
Re: Optimize calls to functions that return one of their arguments
I checked in a fix. Thanks! -- Eric Botcazou
[Ada] Add postconditions to numeric functions
Ada RM requires numeric functions to return values in specific ranges, and specific values for some specified argument values. Many of these are now translated as Ada 2012 Post aspects on numeric functions. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Yannick Moy m...@adacore.com * a-ngelfu.ads: Add postconditions using Ada 2012 aspect syntax, reflecting some of the RM requirements for these functions, from Annex A.5.1 or G.2.4. Index: a-ngelfu.ads === --- a-ngelfu.ads(revision 187522) +++ a-ngelfu.ads(working copy) @@ -6,11 +6,35 @@ -- -- -- S p e c -- -- -- +-- Copyright (C) 2012, Free Software Foundation, Inc. -- +-- -- -- This specification is derived from the Ada Reference Manual for use with -- --- GNAT. In accordance with the copyright of that document, you can freely -- --- copy and modify this specification, provided that if you redistribute a -- --- modified version, any changes that you have made are clearly indicated. -- +-- GNAT. The copyright notice above, and the license provisions that follow -- +-- apply solely to the Post aspects that have been added to the spec. -- +-- Except for these parts of the document, in accordance with the copyright -- +-- of that document, you can freely copy and modify this specification, -- +-- provided that if you redistribute a modified version, any changes that -- +-- you have made are clearly indicated. -- -- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. -- +-- -- +-- As a special exception under Section 7 of GPL version 3, you are granted -- +-- additional permissions described in the GCC Runtime Library Exception, -- +-- version 3.1, as published by the Free Software Foundation. -- +-- -- +-- You should have received a copy of the GNU General Public License and-- +-- a copy of the GCC Runtime Library Exception along with this program; -- +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see-- +-- http://www.gnu.org/licenses/. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- -- generic @@ -19,55 +43,141 @@ package Ada.Numerics.Generic_Elementary_Functions is pragma Pure; - function Sqrt(X : Float_Type'Base) return Float_Type'Base; - function Log (X : Float_Type'Base) return Float_Type'Base; - function Log (X, Base : Float_Type'Base) return Float_Type'Base; - function Exp (X : Float_Type'Base) return Float_Type'Base; - function **(Left, Right : Float_Type'Base) return Float_Type'Base; + function Sqrt (X : Float_Type'Base) return Float_Type'Base + with + Post = Sqrt'Result = 0.0 + and then (if X = 0.0 then Sqrt'Result = 0.0) + and then (if X = 1.0 then Sqrt'Result = 1.0); - function Sin (X : Float_Type'Base) return Float_Type'Base; - function Sin (X, Cycle: Float_Type'Base) return Float_Type'Base; - function Cos (X : Float_Type'Base) return Float_Type'Base; - function Cos (X, Cycle: Float_Type'Base) return Float_Type'Base; - function Tan (X : Float_Type'Base) return Float_Type'Base; - function Tan (X, Cycle: Float_Type'Base) return Float_Type'Base; - function Cot (X : Float_Type'Base) return Float_Type'Base; - function Cot (X, Cycle: Float_Type'Base) return Float_Type'Base; + function Log (X : Float_Type'Base) return Float_Type'Base + with + Post = (if X = 1.0 then Log'Result = 0.0); - function
[Ada] Private with-clauses in the context of generic package declarations
In ihe context of a generic package declaration, a private with-clause on a child unit implies that the implicit with clauses on its parents are private as well. Previous to this patch, GNAT applied this rule applied only to non- eneric units. Compiling the following must be rejected with: gp1.ads:4:23: Ada is not visible gp1.ads:4:23: non-visible declaration at ada.ads:16 --- private with Ada.Containers.Vectors; -- NB: private with generic type T1 is tagged private; Default_Capacity : Ada.Containers.Count_Type := 2; -- What allows 'Ada.Containers.Count_Type' to be visible? package GP1 is type T2 is tagged limited private; private package T1_Vectors is new Ada.Containers.Vectors (Natural, T1); type T2 is tagged limited record Capacity : Ada.Containers.Count_Type := Default_Capacity; V: T1_Vectors.Vector; end record; end GP1; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Ed Schonberg schonb...@adacore.com * sem_ch10.adb (Expand_With_Clause): In the context of a generic package declaration, a private with-clause on a child unit implies that the implicit with clauses on its parents are private as well. Index: sem_ch10.adb === --- sem_ch10.adb(revision 187522) +++ sem_ch10.adb(working copy) @@ -2987,10 +2987,13 @@ Set_First_Name (Withn, True); Set_Implicit_With (Withn, True); - -- If the unit is a package declaration, a private_with_clause on a - -- child unit implies the implicit with on the parent is also private. + -- If the unit is a package or generic package declaration, a private_ + -- with_clause on a child unit implies that the implicit with on the + -- parent is also private. - if Nkind (Unit (N)) = N_Package_Declaration then + if Nkind_In + (Unit (N), N_Package_Declaration, N_Generic_Package_Declaration) + then Set_Private_Present (Withn, Private_Present (Item)); end if;
[Ada] Fix cross-unit inlining on internal inline subprograms
This restores cross-unit inlining for user-defined internal inline subprograms invoked from public inline subprograms. This also reworks the algorithm used to compute the list of inlined subprograms passed to gigi. The old algorithm attempts to compute a topological order on the list, and thus stops when there is a cycle (issuing a warning that is apparently not printed by the compiler), because of the old requirement that callees be put before callers on the list. The above requirement is obsolete now, as the back-end works in unit-at-a-time mode. So we can drop the topological order, allowing cycles in the call graph, and compute the transitive closure while still reducing the complexity of the implementation. Accepting cycles means that we now optimize away cases like: with B; use B; procedure A is begin Proc1 (1); end; package B is procedure Proc1 (I : Integer); pragma Inline (Proc1); end B; package body B is procedure Proc2; pragma Inline (Proc2); procedure Proc1 (I : Integer) is begin if I /= 0 then Proc2; end if; end; procedure Proc2 is begin Proc1 (0); end; end B; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Eric Botcazou ebotca...@adacore.com * inline.adb (Subp_Info): Remove Count and Next_Nopred components, add Processed component and move around Next component. (Add_Call): Reverse meaning of Successors table to the natural one. (Add_Inlined_Body): Do not inline a package if it is in the main unit. (Add_Inlined_Subprogram): Do not add the subprogram to the list if the package is in the main unit. Do not recurse on the successors. (Add_Subp): Adjust to new contents of Subp_Info. (Analyze_Inlined_Bodies): Do not attempt to compute a topological order on the list of inlined subprograms, but compute the transitive closure from the main unit instead. (Get_Code_Unit_Entity): Always return the spec for a package. Index: inline.adb === --- inline.adb (revision 187522) +++ inline.adb (working copy) @@ -70,15 +70,12 @@ --- -- For each call to an inlined subprogram, we make entries in a table - -- that stores caller and callee, and indicates a prerequisite from + -- that stores caller and callee, and indicates the call direction from -- one to the other. We also record the compilation unit that contains -- the callee. After analyzing the bodies of all such compilation units, - -- we produce a list of subprograms in topological order, for use by the - -- back-end. If P2 is a prerequisite of P1, then P1 calls P2, and for - -- proper inlining the back-end must analyze the body of P2 before that of - -- P1. The code below guarantees that the transitive closure of inlined - -- subprograms called from the main compilation unit is made available to - -- the code generator. + -- we compute the transitive closure of inlined subprograms called from + -- the main compilation unit and make it available to the code generator + -- in no particular order, thus allowing cycles in the call graph. Last_Inlined : Entity_Id := Empty; @@ -117,12 +114,11 @@ type Subp_Info is record Name: Entity_Id := Empty; + Next: Subp_Index := No_Subp; First_Succ : Succ_Index := No_Succ; - Count : Integer:= 0; Listed : Boolean:= False; Main_Call : Boolean:= False; - Next: Subp_Index := No_Subp; - Next_Nopred : Subp_Index := No_Subp; + Processed : Boolean:= False; end record; package Inlined is new Table.Table ( @@ -139,7 +135,8 @@ function Get_Code_Unit_Entity (E : Entity_Id) return Entity_Id; pragma Inline (Get_Code_Unit_Entity); - -- Return the entity node for the unit containing E + -- Return the entity node for the unit containing E. Always return + -- the spec for a package. function Scope_In_Main_Unit (Scop : Entity_Id) return Boolean; -- Return True if Scop is in the main unit or its spec @@ -166,9 +163,7 @@ -- example, an initialization procedure). procedure Add_Inlined_Subprogram (Index : Subp_Index); - -- Add subprogram to Inlined List once all of its predecessors have been - -- placed on the list. Decrement the count of all its successors, and - -- add them to list (recursively) if count drops to zero. + -- Add the subprogram to the list of inlined subprogram for the unit -- -- Deferred Cleanup Actions -- @@ -203,29 +198,26 @@ if Present (Caller) then P2 := Add_Subp (Caller); - -- Add P2 to the list of successors of P1, if not already there. + -- Add P1 to the list of successors of P2, if not already there. -- Note that P2 may contain more than one call to P1,
[PATCH diagnostics] Make unwound macro expansion trace less redundant
Hello, As discussed previously, the unwinder for macro expansion is quite verbose [1]. This patch proposes to address that shortcoming. Consider this test case: $ cat -n test.c 1 #define MYMAX(A,B) __extension__ ({ __typeof__(A) __a = (A); \ 2 __typeof__(B) __b = (B); __a __b ? __b : __a; }) 3 4 struct mystruct {}; 5 void 6 foo() 7 { 8struct mystruct p; 9float f = 0.0; 10MYMAX (p, f); 11 } $ The output of the compiler from trunk yields: $ cc1 -quiet ./test.c ./test.c: In function ‘foo’: ./test.c:2:31: error: invalid operands to binary (have ‘struct mystruct’ and ‘float’) __typeof__(B) __b = (B); __a __b ? __b : __a; }) ^ ./test.c:2:31: note: in expansion of macro 'MYMAX' __typeof__(B) __b = (B); __a __b ? __b : __a; }) ^ ./test.c:10:3: note: expanded from here MYMAX (p, f); ^ $ After this patch, the compiler yields: $ ./cc1 -quiet ./test.c ./test.c: In function ‘foo’: ./test.c:2:31: error: invalid operands to binary (have ‘struct mystruct’ and ‘float’) __typeof__(B) __b = (B); __a __b ? __b : __a; }) ^ ./test.c:10:3: note: in expansion of macro 'MYMAX' MYMAX (p, f); ^ $ The gotcha is, in the general case, we cannot simply eliminate the context of the macro definition. That is, the line from the first output that is redundant with the first diagnostic line that has line/column number: ./test.c:2:31: note: in expansion of macro 'MYMAX' __typeof__(B) __b = (B); __a __b ? __b : __a; }) ^ We cannot simply eliminate that context of macro definition because there are cases where the first diagnostic that has a line/column number doesn't point to a location inside the definition of the macro where the relevant token is used. For instance: $ cat -n test2.c 1 #define OPERATE(OPRD1, OPRT, OPRD2) \ 2OPRD1 OPRT OPRD2; 3 4 #define SHIFTL(A,B) \ 5OPERATE (A,,B) 6 7 #define MULT(A) \ 8SHIFTL (A,1) 9 10 void 11 g () 12 { 13MULT (1.0);// 1.0 1; -- so this is an error. 14 } $ Which yields without the patch: $ cc1 -quiet ./test2.c ./test2.c: In function ‘g’: ./test2.c:5:14: error: invalid operands to binary (have ‘double’ and ‘int’) OPERATE (A,,B) ^ ./test2.c:2:9: note: in expansion of macro 'OPERATE' OPRD1 OPRT OPRD2; ^ ./test2.c:5:3: note: expanded from here OPERATE (A,,B) ^ ./test2.c:5:14: note: in expansion of macro 'SHIFTL' OPERATE (A,,B) ^ ./test2.c:8:3: note: expanded from here SHIFTL (A,1) ^ ./test2.c:8:3: note: in expansion of macro 'MULT' SHIFTL (A,1) ^ ./test2.c:13:3: note: expanded from here MULT (1.0);// 1.0 1; -- so this is an error. ^ $ Here, the line that has the context of macro definition: ./test2.c:2:9: note: in expansion of macro 'OPERATE' OPRD1 OPRT OPRD2; ^ is useful, because the first diagnostic that has line/column number wasn't pointing into the definition of the macro OPERATE, where the token '' is used. ./test2.c:5:14: error: invalid operands to binary (have ‘double’ and ‘int’) OPERATE (A,,B) ^ So in this this case, displaying the macro definition context is not redundant. I think it is even desirable. The patch changes the output in that case to be: ./test2.c: In function ‘g’: ./test2.c:5:14: erreur: invalid operands to binary (have ‘double’ and ‘int’) OPERATE (A,,B) ^ ./test2.c:2:9: note: in definition of macro 'OPERATE' OPRD1 OPRT OPRD2; ^ ./test2.c:8:3: note: in expansion of macro 'SHIFTL' SHIFTL (A,1) ^ ./test2.c:13:3: note: in expansion of macro 'MULT' MULT (1.0);// 1.0 1; -- so this is an error. ^ $ It's shorter, but I believe it has all the information that was present before the patch. [1]: http://gcc.gnu.org/ml/gcc-patches/2012-05/msg00321.html Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk. gcc/ Make unwound macro expansion trace less redundant * tree-diagnostic.c (maybe_unwind_expanded_macro_loc): Don't print context of macro definition in the trace, when it's redundant. Update comments. gcc/testsuite/ Make unwound macro expansion trace less redundant * gcc.dg/cpp/macro-exp-tracking-1.c: Adjust. * gcc.dg/cpp/macro-exp-tracking-2.c: Likewise. *
[PATCH preprocessor, diagnostics] PR preprocessor/53229 - Fix diagnostics location when pasting tokens
Hello, As stated in the audit trail of this problem report, consider this test case: $ cat test.c 1 struct x { 2int i; 3 }; 4 struct x x; 5 6 #define TEST(X) x.##X 7 8 void foo (void) 9 { 10TEST(i) = 0; 11 } $ $ cc1 -quiet test.c test.c: In function 'foo': test.c:10:1: error: pasting . and i does not give a valid preprocessing token TEST(i) = 0; ^ $ So, when pasting tokens, the error diagnostic uses the global and imprecise input_location variable, leading to an imprecise output. To properly fix this, I think libcpp should keep the token of the pasting operator '##', instead of representing it with flag on the LHS operand's token. That way, it could use its location. Doing that would be quite intrusive though. So this patch just uses the location of the LHS of the pasting operator, for now. It's IMHO better than the current situation. The patch makes paste_tokens take a location parameter that is used in the diagnostics. This change can still be useful later when we can use the location of the pasting operator, because paste_tokens will just be passed the new, more precise location. Incidentally, it appeared that when getting tokens from within preprocessor directives (like what is done in gcc.dg/cpp/paste12.c), with -ftrack-macro-expansion disabled, the location of the expansion point of macros was being lost because get_token_no_padding doesn't use cpp_get_token_with_location. The patch fixes that as well. People seem to like screenshots. Thus, after the patch, we now have: $ cc1 -quiet test.c test.c: In function 'foo': test.c:6:18: error: pasting . and i does not give a valid preprocessing token #define TEST(X) x.##X ^ test.c:10:3: note: in expansion of macro 'TEST' TEST(i) = 0; ^ $ Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk. libcpp/ PR preprocessor/53229 * directives.c (get_token_no_padding): Allow use of virtual locations in diagnostics emitted by the processor when handling directives. Update comments. This fixes gcc.dg/cpp/paste12.c. * macro.c (paste_tokens): Take a virtual location parameter for the LHS of the pasting operator. Use it in diagnostics. Update comments. (paste_all_tokens): Tighten the assert. Propagate the location of the expansion point when no virtual locations are available. Pass the virtual location to paste_tokens. gcc/testsuite/ PR preprocessor/53229 * gcc.dg/cpp/paste6.c: Force to run without -ftrack-macro-expansion. * gcc.dg/cpp/paste8.c: Likewise. * gcc.dg/cpp/paste8-2.c: New test, like paste8.c but run with -ftrack-macro-expansion. * gcc.dg/cpp/paste12.c: Force to run without -ftrack-macro-expansion. * gcc.dg/cpp/paste12-2.c: New test, like paste12.c but run with -ftrack-macro-expansion. * gcc.dg/cpp/paste13.c: Likewise. * gcc.dg/cpp/paste14.c: Likewise. * gcc.dg/cpp/paste14-2.c: New test, like paste14.c but run with -ftrack-macro-expansion. * gcc.dg/cpp/paste18.c: New test. --- gcc/testsuite/gcc.dg/cpp/paste12-2.c | 11 +++ gcc/testsuite/gcc.dg/cpp/paste12.c |5 - gcc/testsuite/gcc.dg/cpp/paste13.c |5 - gcc/testsuite/gcc.dg/cpp/paste14-2.c | 11 +++ gcc/testsuite/gcc.dg/cpp/paste14.c |5 - gcc/testsuite/gcc.dg/cpp/paste18.c | 16 gcc/testsuite/gcc.dg/cpp/paste6.c|5 - gcc/testsuite/gcc.dg/cpp/paste8-2.c | 15 +++ gcc/testsuite/gcc.dg/cpp/paste8.c|2 +- libcpp/directives.c |7 +-- libcpp/macro.c | 26 ++ 11 files changed, 93 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/cpp/paste12-2.c create mode 100644 gcc/testsuite/gcc.dg/cpp/paste14-2.c create mode 100644 gcc/testsuite/gcc.dg/cpp/paste18.c create mode 100644 gcc/testsuite/gcc.dg/cpp/paste8-2.c diff --git a/gcc/testsuite/gcc.dg/cpp/paste12-2.c b/gcc/testsuite/gcc.dg/cpp/paste12-2.c new file mode 100644 index 000..6e2e4f1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/paste12-2.c @@ -0,0 +1,11 @@ +/* + { dg-options -ftrack-macro-expansion=2 } + { dg-do preprocess } + */ + +/* Test correct diagnostics when pasting in #include. + Source: PR preprocessor/6780. */ + +#define inc2(a,b) ##a.b /* { dg-error pasting \\ and \stdio\ does not } */ +#define INC(X) inc2(X,h) +#include INC(stdio) diff --git a/gcc/testsuite/gcc.dg/cpp/paste12.c b/gcc/testsuite/gcc.dg/cpp/paste12.c index e61ec51..3e0f7b9 100644 --- a/gcc/testsuite/gcc.dg/cpp/paste12.c +++ b/gcc/testsuite/gcc.dg/cpp/paste12.c @@ -1,4 +1,7 @@ -/* { dg-do preprocess
[C++ Patch] PR 11586
Hi, this small patch fixes the problem using the approach indicated by Jason in the audit trail, already used in many other similar cases. Booted and tested x86_64-linux. Thanks, Paolo. / /cp 2012-05-15 Paolo Carlini paolo.carl...@oracle.com PR c++/11586 * pt.c (tsubst_copy_and_build): Increase / decrease c_inhibit_evaluation_warnings around build_x_binary_op call. /c-family 2012-05-15 Paolo Carlini paolo.carl...@oracle.com PR c++/11586 * c-common.c (shorten_compare): Check c_inhibit_evaluation_warnings. /testsuite 2012-05-15 Paolo Carlini paolo.carl...@oracle.com PR c++/11586 * g++.dg/warn/Wtype-limits.C: Don't warn in templates. * g++.dg/warn/Wtype-limits-Wextra.C: Likewise. Index: testsuite/g++.dg/warn/Wtype-limits-Wextra.C === --- testsuite/g++.dg/warn/Wtype-limits-Wextra.C (revision 187501) +++ testsuite/g++.dg/warn/Wtype-limits-Wextra.C (working copy) @@ -66,7 +66,7 @@ int test (int x) template typename Int, Int D void f(Int x) { - assert(0 = x and x = D); // { dg-warning comparison is always true due to limited range of data type } + assert(0 = x and x = D); } int ff(void) { Index: testsuite/g++.dg/warn/Wtype-limits.C === --- testsuite/g++.dg/warn/Wtype-limits.C(revision 187501) +++ testsuite/g++.dg/warn/Wtype-limits.C(working copy) @@ -66,7 +66,7 @@ int test (int x) template typename Int, Int D void f(Int x) { - assert(0 = x and x = D); // { dg-warning comparison is always true due to limited range of data type } + assert(0 = x and x = D); } int ff(void) { Index: cp/pt.c === --- cp/pt.c (revision 187501) +++ cp/pt.c (working copy) @@ -13608,7 +13610,11 @@ tsubst_copy_and_build (tree t, case MEMBER_REF: case DOTSTAR_EXPR: { - tree r = build_x_binary_op + tree r; + + ++c_inhibit_evaluation_warnings; + + r = build_x_binary_op (input_location, TREE_CODE (t), RECUR (TREE_OPERAND (t, 0)), (TREE_NO_WARNING (TREE_OPERAND (t, 0)) @@ -13622,6 +13628,9 @@ tsubst_copy_and_build (tree t, complain); if (EXPR_P (r) TREE_NO_WARNING (t)) TREE_NO_WARNING (r) = TREE_NO_WARNING (t); + + --c_inhibit_evaluation_warnings; + return r; } Index: c-family/c-common.c === --- c-family/c-common.c (revision 187501) +++ c-family/c-common.c (working copy) @@ -3754,7 +3754,8 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tre type = c_common_unsigned_type (type); } - if (TREE_CODE (primop0) != INTEGER_CST) + if (TREE_CODE (primop0) != INTEGER_CST + c_inhibit_evaluation_warnings == 0) { if (val == truthvalue_false_node) warning_at (loc, OPT_Wtype_limits, @@ -3834,6 +3835,7 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tre warning. */ bool warn = warn_type_limits !in_system_header +c_inhibit_evaluation_warnings == 0 !(TREE_CODE (primop0) == INTEGER_CST !TREE_OVERFLOW (convert (c_common_signed_type (type), primop0)))
Re: [PATCH preprocessor, diagnostics] PR preprocessor/53229 - Fix diagnostics location when pasting tokens
On 15 May 2012 13:18, Dodji Seketeli do...@redhat.com wrote: People seem to like screenshots. Thus, after the patch, we now have: $ cc1 -quiet test.c test.c: In function 'foo': test.c:6:18: error: pasting . and i does not give a valid preprocessing token #define TEST(X) x.##X ^ test.c:10:3: note: in expansion of macro 'TEST' TEST(i) = 0; ^ $ I like the screenshot. ;-) Thanks for fixing this! Cheers, Manuel.
Re: patch for PR53125
On Fri, May 11, 2012 at 8:42 PM, Steven Bosscher stevenb@gmail.com wrote: Now with patch On Fri, May 11, 2012 at 8:42 PM, Steven Bosscher stevenb@gmail.com wrote: 2012-05-10 Vladimir Makarovvmaka...@redhat.com PR rtl-optimization/53125 * ira.c (ira): Call find_moveable_pseudos and move_unallocated_pseudos if only ira_conflicts_p is true. And the attached patch fixes the reginfo slowness. The reginfo pass was doing: for each bb: for each insn in bb, from BB_END(bb) to BB_HEAD(bb): for each reg that died between BB_END(bb) and insn: // i.e. register is live at insn REG_LIVE_LENGTH(reg)++ With very large basic blocks, and the kind of code for the test case of the PR results in many live registers for SPARC (for x86_64 there are far fewer live registers). For SPARC, there are O(1e5) insns and O(1e4) registers live for most of the basic block. That is effectively almost quadratic behavior in the number of insns per basic block. But the above loop is a bit silly. It is much easier and computationally cheaper to just remember at what insn reg died (last used), and add to REG_LIVE_LENGTH the distance from the insn that sets reg to the insn that used reg. It turns out that (before or after the patch) partial or conditional sets never kill a register, so that REG_LIVE_LENGTH for registers set by partial or conditional stores is not very accurate. I have a few ideas for how to improve that situation a bit, but I'm not sure if it's worth the trouble. I also think that the computation of REG_FREQ and REG_FREQ_CALLS_CROSSED has been wrong for some time. The maximum REG_FREQ is REG_FREQ_MAX (see regs.h) but regstat.c just accumulates REG_FREQ_FROM_BB. I've added a few lines to limit the REG_FREQ to REG_FREQ_MAX, e.g.: REG_FREQ (dregno) += REG_FREQ_FROM_BB (bb); + REG_FREQ (dregno) = + MIN (REG_FREQ (dregno), REG_FREQ_MAX); With this patch, the reginfo pass disappears from the time report for the test case attached to PR53125, compiled at -O0. Bootstrapped and tested on x86_64-unknown-linux-gnu, and I verified for a few simple test cases that the computed REG_LIVE_LENGHTs are unchanged. OK for trunk? Ciao! Steven Ping?
[Ada] Couple of small adjustments to cross-unit inlining
The first adjustment ensures that the compiler doesn't inline back into the main unit subprograms coming from subunits, since they are already compiled. The second adjustment ensures that the transitive closure algorithm keeps excluding the subprograms not handled by Add_Inlined_Body. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Eric Botcazou ebotca...@adacore.com * inline.adb (Scope_In_Main_Unit): Rename into... (In_Main_Unit_Or_Subunit): ...this. Also return true if the subprogram is within a subunit of the main unit. (Add_Inlined_Body): Adjust for above renaming. (Add_Inlined_Subprogram): Likewise. Pass the subprogram directly. (Analyze_Inlined_Bodies): Really set aside inlined subprograms not handled by Add_Inlined_Body. Index: inline.adb === --- inline.adb (revision 187526) +++ inline.adb (working copy) @@ -138,8 +138,8 @@ -- Return the entity node for the unit containing E. Always return -- the spec for a package. - function Scope_In_Main_Unit (Scop : Entity_Id) return Boolean; - -- Return True if Scop is in the main unit or its spec + function In_Main_Unit_Or_Subunit (E : Entity_Id) return Boolean; + -- Return True if E is in the main unit or its spec or in a subunit procedure Add_Call (Called : Entity_Id; Caller : Entity_Id := Empty); -- Make two entries in Inlined table, for an inlined subprogram being @@ -341,7 +341,7 @@ elsif not Is_Inlined (Pack) and then Comes_From_Source (E) - and then not Scope_In_Main_Unit (Pack) + and then not In_Main_Unit_Or_Subunit (Pack) then Set_Is_Inlined (Pack); Inlined_Bodies.Increment_Last; @@ -433,7 +433,7 @@ and then (Is_Inlined (Pack) or else Is_Generic_Instance (Pack) or else Is_Internal (E)) -and then not Scope_In_Main_Unit (Pack) +and then not In_Main_Unit_Or_Subunit (E) and then not Is_Nested (E) and then not Has_Initialized_Type (E) then @@ -746,7 +746,7 @@ -- This means that Add_Inlined_Body added the subprogram to the -- table but wasn't able to handle its code unit. Do nothing. - null; + Inlined.Table (Index).Processed := True; elsif Inlined.Table (Index).Main_Call then Pending_Inlined.Increment_Last; Pending_Inlined.Table (Pending_Inlined.Last) := Index; @@ -767,9 +767,9 @@ while S /= No_Succ loop Subp := Successors.Table (S).Subp; - Set_Is_Called (Inlined.Table (Subp).Name); if not Inlined.Table (Subp).Processed then + Set_Is_Called (Inlined.Table (Subp).Name); Pending_Inlined.Increment_Last; Pending_Inlined.Table (Pending_Inlined.Last) := Subp; Inlined.Table (Subp).Processed := True; @@ -1156,23 +1156,27 @@ end loop; end Remove_Dead_Instance; - - -- Scope_In_Main_Unit -- - + - + -- In_Main_Unit_Or_Subunit -- + - - function Scope_In_Main_Unit (Scop : Entity_Id) return Boolean is - Comp : constant Node_Id := Cunit (Get_Code_Unit (Scop)); + function In_Main_Unit_Or_Subunit (E : Entity_Id) return Boolean is + Comp : Node_Id := Cunit (Get_Code_Unit (E)); begin - -- Check whether the scope of the subprogram to inline is within the - -- main unit or within its spec. In either case there are no additional - -- bodies to process. If the subprogram appears in a parent of the - -- current unit, the check on whether inlining is possible is done in - -- Analyze_Inlined_Bodies. + -- Check whether the subprogram or package to inline is within the main + -- unit or its spec or within a subunit. In either case there are no + -- additional bodies to process. If the subprogram appears in a parent + -- of the current unit, the check on whether inlining is possible is + -- done in Analyze_Inlined_Bodies. + while Nkind (Unit (Comp)) = N_Subunit loop + Comp := Library_Unit (Comp); + end loop; + return Comp = Cunit (Main_Unit) or else Comp = Library_Unit (Cunit (Main_Unit)); - end Scope_In_Main_Unit; + end In_Main_Unit_Or_Subunit; end Inline;
[Ada] Imaging of arbitrary precision integers
The compiler includes an arbitrary precision integer computation library, which is used to handle numeric literals in source code (which are allowed to be of arbitrary size). This change improves the code responsible for producing a string image of such integers by using a single Euclidian division operation instead of separate quotient and remainder computations, this making it more efficient. As a collateral, this works around a bug in the rem operator that would cause incorrect values to be displayed in some cases. The following compilation must produce the following output: $ gcc -c -gnatG t3.ads Source recreated from tree for t3 (spec) t3_E : short_integer := 0; package t3 is t3__x : constant := 31415926000; end t3; -- Source: package t3 is X : constant := 314_159260_00_00_00; end t3; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Thomas Quinot qui...@adacore.com * uintp.adb (Image_Uint): Use UI_Div_Rem to get quotient and remainder of U / Base in a single operation. Index: uintp.adb === --- uintp.adb (revision 187522) +++ uintp.adb (working copy) @@ -370,9 +370,12 @@ H : constant array (Int range 0 .. 15) of Character := 0123456789ABCDEF; + Q, R : Uint; begin - if U = Base then -Image_Uint (U / Base); + UI_Div_Rem (U, Base, Q, R); + + if Q Uint_0 then +Image_Uint (Q); end if; if Digs_Output = 4 and then Base = Uint_16 then @@ -380,7 +383,7 @@ Digs_Output := 0; end if; - Image_Char (H (UI_To_Int (U rem Base))); + Image_Char (H (UI_To_Int (R))); Digs_Output := Digs_Output + 1; end Image_Uint; @@ -2383,8 +2386,8 @@ -- Special cases when Right is less than 13 and Left is larger -- larger than one digit. All of these algorithms depend on the --- base being 2 ** 15 We work with Abs (Left) and Abs(Right) --- then multiply result by Sign (Left) +-- base being 2 ** 15. We work with Abs (Left) and Abs(Right) +-- then multiply result by Sign (Left). if (Right = Uint_12) and then (Right = Uint_Minus_12) then @@ -2394,7 +2397,7 @@ Sign := 1; end if; - -- All cases are listed, grouped by mathematical method It is + -- All cases are listed, grouped by mathematical method. It is -- not inefficient to do have this case list out of order since -- GCC sorts the cases we list. @@ -2403,9 +2406,10 @@ when 1 = return Uint_0; - -- Powers of two are simple AND's with LS Left Digit GCC - -- will recognise these constants as powers of 2 and replace - -- the rem with simpler operations where possible. + -- Powers of two are simple AND's with the least significant + -- digit of Left. GCC will recognise these constants as + -- powers of 2 and replace the rem with simpler operations + -- where possible. -- Least_Sig_Digit might return Negative numbers @@ -2426,7 +2430,7 @@ --If B Rem Right = 1 then --Left Rem Right = Sum_Of_Digits_Base_B (Left) Rem Right - -- Note: 2^32 mod 3 = 1 + -- Note: 2^30 mod 3 = 1 when 3 = return UI_From_Int ( @@ -2438,7 +2442,7 @@ return UI_From_Int ( Sign * (Sum_Digits (Left, 1) rem Int (7))); - -- Note: 2^32 mod 5 = -1 + -- Note: 2^30 mod 5 = -1 -- Alternating sums might be negative, but rem is always -- positive hence we must use mod here. @@ -2483,7 +2487,7 @@ -- (M1 mod m1) = (M2 mod m2) = 1 AND -- (M1 mod m2) = (M2 mod m1) = 0 - -- So u mod m = (u1 * M1 + u2 * M2) mod m Where u1 = (u mod + -- So u mod m = (u1 * M1 + u2 * M2) mod m where u1 = (u mod -- m1) AND u2 = (u mod m2); Under typical circumstances the -- last mod m can be done with a (possible) single -- subtraction.
[Ada] Better handling of illegal iterators
This patch improves on the error message for a loop iterator where the loop variable is referenced in the name of the iterator. Compiling main.adb must yield: main.adb:26:17: object X cannot be used before end of its declaration --- pragma Ada_2012; pragma Warnings (Off); with Ada.Text_IO; use Ada.Text_IO; with Ada.Containers.Vectors; procedure Main is package Integer_Vectors is new Ada.Containers.Vectors (Positive, Integer); use Integer_Vectors; function F1 (I : Integer) return Vector; function F1 (I : Integer) return Vector is V : Vector; begin return V; end F1; X : Integer; begin for X of F1 (X) loop null; end loop; end Main; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Ed Schonberg schonb...@adacore.com * sem_ch5.adb (Analyze_Iterator_Specification): Set kind of loop variable after pre-analysis of iterator name, to prevent premature usage of loop variable. Index: sem_ch5.adb === --- sem_ch5.adb (revision 187522) +++ sem_ch5.adb (working copy) @@ -1650,7 +1650,6 @@ begin Enter_Name (Def_Id); - Set_Ekind (Def_Id, E_Variable); if Present (Subt) then Analyze (Subt); @@ -1658,6 +1657,11 @@ Preanalyze_Range (Iter_Name); + -- Set the kind of the loop variable, which is not visible within + -- the iterator name. + + Set_Ekind (Def_Id, E_Variable); + -- If the domain of iteration is an expression, create a declaration for -- it, so that finalization actions are introduced outside of the loop. -- The declaration must be a renaming because the body of the loop may @@ -1679,6 +1683,13 @@ begin Typ := Etype (Iter_Name); +-- Protect against malformed iterator. + +if Typ = Any_Type then + Error_Msg_N (invalid expression in loop iterator, Iter_Name); + return; +end if; + -- The name in the renaming declaration may be a function call. -- Indicate that it does not come from source, to suppress -- spurious warnings on renamings of parameterless functions,
[Ada] Restrict propagation of atomicity from objects to types
The front-end uses a trick to accept a pragma Atomic on objects whose type isn't directly suitable for the pragma: if the type is declared in the same unit as the object, the front-end propagates under the hood the atomicity from the object to the type. This can have unwanted effects, most notably if the type is elementary, the object a simple component within a record, and both are in a spec: every object of this type in the entire program will be treated as atomic, thus incurring a potentially costly synchronization operation for every access. The change restricts the propagation to composite types. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Eric Botcazou ebotca...@adacore.com * sem_prag.adb (Process_Atomic_Shared_Volatile): Propagate atomicity from an object to its underlying type only if it is composite. Index: sem_prag.adb === --- sem_prag.adb(revision 187523) +++ sem_prag.adb(working copy) @@ -3022,16 +3022,29 @@ Set_Has_Delayed_Freeze (E); end if; - -- An interesting improvement here. If an object of type X is - -- declared atomic, and the type X is not atomic, that's a + -- An interesting improvement here. If an object of composite + -- type X is declared atomic, and the type X isn't, that's a -- pity, since it may not have appropriate alignment etc. We -- can rescue this in the special case where the object and -- type are in the same unit by just setting the type as -- atomic, so that the back end will process it as atomic. + -- Note: we used to do this for elementary types as well, + -- but that turns out to be a bad idea and can have unwanted + -- effects, most notably if the type is elementary, the object + -- a simple component within a record, and both are in a spec: + -- every object of this type in the entire program will be + -- treated as atomic, thus incurring a potentially costly + -- synchronization operation for every access. + + -- Of course it would be best if the back end could just adjust + -- the alignment etc for the specific object, but that's not + -- something we are capable of doing at this point. + Utyp := Underlying_Type (Etype (E)); if Present (Utyp) + and then Is_Composite_Type (Utyp) and then Sloc (E) No_Location and then Sloc (Utyp) No_Location and then
[PATCH][1/n] Improve vectorization in PR53355
This is the first patch to make the generated code for the testcase in PR53355 better. It teaches VRP about LSHIFT_EXPRs (albeit only of a very simple form). Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2012-05-15 Richard Guenther rguent...@suse.de PR tree-optimization/53355 * tree-vrp.c (extract_range_from_binary_expr_1): Handle LSHIFT_EXPRs by constants. * gcc.dg/tree-ssa/vrp67.c: New testcase. Index: gcc/tree-vrp.c === *** gcc/tree-vrp.c (revision 187503) --- gcc/tree-vrp.c (working copy) *** extract_range_from_binary_expr_1 (value_ *** 2403,2408 --- 2403,2409 code != ROUND_DIV_EXPR code != TRUNC_MOD_EXPR code != RSHIFT_EXPR +code != LSHIFT_EXPR code != MIN_EXPR code != MAX_EXPR code != BIT_AND_EXPR *** extract_range_from_binary_expr_1 (value_ *** 2596,2601 --- 2597,2636 extract_range_from_multiplicative_op_1 (vr, code, vr0, vr1); return; } + else if (code == LSHIFT_EXPR) + { + /* If we have a LSHIFT_EXPR with any shift values outside [0..prec-1], +then drop to VR_VARYING. Outside of this range we get undefined +behavior from the shift operation. We cannot even trust +SHIFT_COUNT_TRUNCATED at this stage, because that applies to rtl +shifts, and the operation at the tree level may be widened. */ + if (vr1.type != VR_RANGE + || !value_range_nonnegative_p (vr1) + || TREE_CODE (vr1.max) != INTEGER_CST + || compare_tree_int (vr1.max, TYPE_PRECISION (expr_type) - 1) == 1) + { + set_value_range_to_varying (vr); + return; + } + + /* We can map shifts by constants to MULT_EXPR handling. */ + if (range_int_cst_singleton_p (vr1)) + { + value_range_t vr1p = { VR_RANGE, NULL_TREE, NULL_TREE, NULL }; + vr1p.min + = double_int_to_tree (expr_type, + double_int_lshift (double_int_one, +TREE_INT_CST_LOW (vr1.min), +TYPE_PRECISION (expr_type), +false)); + vr1p.max = vr1p.min; + extract_range_from_multiplicative_op_1 (vr, MULT_EXPR, vr0, vr1p); + return; + } + + set_value_range_to_varying (vr); + return; + } else if (code == TRUNC_DIV_EXPR || code == FLOOR_DIV_EXPR || code == CEIL_DIV_EXPR Index: gcc/testsuite/gcc.dg/tree-ssa/vrp67.c === *** gcc/testsuite/gcc.dg/tree-ssa/vrp67.c (revision 0) --- gcc/testsuite/gcc.dg/tree-ssa/vrp67.c (revision 0) *** *** 0 --- 1,38 + /* { dg-do compile } */ + /* { dg-options -O2 -fdump-tree-vrp1 } */ + + unsigned foo (unsigned i) + { + if (i == 2) + { + i = i 2; + if (i != 8) + link_error (); + } + return i; + } + unsigned bar (unsigned i) + { + if (i == 1 (sizeof (unsigned) * 8 - 1)) + { + i = i 1; + if (i != 0) + link_error (); + } + return i; + } + unsigned baz (unsigned i) + { + i = i 15; + if (i == 0) + return 0; + i = 1000 - i; + i = 1; + i = 1; + if (i == 0) + link_error (); + return i; + } + + /* { dg-final { scan-tree-dump-times Folding predicate 3 vrp1 } } */ + /* { dg-final { cleanup-tree-dump vrp1 } } */
find_movable_pseudos vs. split moves (was Re: rx-elf fails after r187015)
DJ Delorie d...@redhat.com writes: After r187015 (Mar 31), gcc builds for rx-elf are failing with: make[3]: Entering directory `/greed/dj/m32c/gcc/rx-elf-head/rx-elf/64-bit-double/libgcc' # If this is the top-level multilib, build all the other # multilibs. /greed/dj/m32c/gcc/rx-elf-head/./gcc/xgcc -B/greed/dj/m32c/gcc/rx-elf-head/./gcc/ -B/greed/dj/m32c/install/rx-elf/bin/ -B/greed/dj/m32c/install/rx-elf/lib/ -isystem /greed/dj/m32c/install/rx-elf/include -isystem /greed/dj/m32c/install/rx-elf/sys-include-g -O2 -m64bit-doubles -O2 -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc -I. -I. -I../../.././gcc -I../../../../gcc/libgcc -I../../../../gcc/libgcc/. -I../../../../gcc/libgcc/../gcc -I../../../../gcc/libgcc/../include -DHAVE_CC_TLS -DUSE_EMUTLS -o _mulvdi3.o -MT _mulvdi3.o -MD -MP -MF _mulvdi3.dep -DL_mulvdi3 -c ../../../../gcc/libgcc/libgcc2.c ../../../../gcc/libgcc/libgcc2.c: In function '__mulvdi3': ../../../../gcc/libgcc/libgcc2.c:397:1: internal compiler error: in subreg_get_info, at rtlanal.c:3308 } ^ Can anyone else confirm this? I can well believe that that patch exposed the problem, but the bug seems to be in IRA. find_moveable_pseudos tries to redirect a DImode multiplication to a new register, then copies the new register to the original one before the first use. The problem here is that rx has no DImode move pattern, so we end up splitting the DImode move into two SImode moves and a clobber. When allocation fails for the new register, move_unallocated_pseudos deletes one of these three instructions, but the other two are left around. reload then gets confused because we have a subreg of a pseudo that isn't allocated and has no stack slot. One fix would be to check whether the backend has a move pattern. I don't particularly like that though, since I don't think targets like rx should be punished for not defining a DImode move. The fact that the first lower-subreg pass is so early in the rtl pipeline suggests that having unitary multiword moves shouldn't be important these days. This patch instead deletes all instructions that set the new register. One advantage is that IRA no longer needs to track the move specially. Tested by making sure that rx-elf build again and that the new code deletes all three instructions generated by gen_move_insn. Also bootstrapped regression-tested on x86_64-linux-gnu. OK to install? Richard gcc/ * ira.c (pseudo_move_insn): Delete. (find_moveable_pseudos): Don't set it. (move_unallocated_pseudos): Use DF_REG_DEF_CHAIN to find the definitions of the original pseudo. Delete all of them. Index: gcc/ira.c === --- gcc/ira.c 2012-05-15 10:47:19.0 +0100 +++ gcc/ira.c 2012-05-15 11:04:50.888126216 +0100 @@ -3621,9 +3621,6 @@ insn_dominated_by_p (rtx i1, rtx i2, int first_moveable_pseudo. */ /* The original home register. */ static VEC (rtx, heap) *pseudo_replaced_reg; -/* The move instruction we added to move the value to its original home - register. */ -static VEC (rtx, heap) *pseudo_move_insn; /* Look for instances where we have an instruction that is known to increase register pressure, and whose result is not used immediately. If it is @@ -3667,9 +3664,7 @@ find_moveable_pseudos (void) bitmap_initialize (interesting, 0); first_moveable_pseudo = max_regs; - VEC_free (rtx, heap, pseudo_move_insn); VEC_free (rtx, heap, pseudo_replaced_reg); - VEC_safe_grow (rtx, heap, pseudo_move_insn, max_regs); VEC_safe_grow (rtx, heap, pseudo_replaced_reg, max_regs); df_analyze (); @@ -3964,10 +3959,8 @@ find_moveable_pseudos (void) if (validate_change (def_insn, DF_REF_LOC (def), newreg, 0)) { unsigned nregno = REGNO (newreg); - rtx move = emit_insn_before (gen_move_insn (def_reg, newreg), - use_insn); + emit_insn_before (gen_move_insn (def_reg, newreg), use_insn); nregno -= max_regs; - VEC_replace (rtx, pseudo_move_insn, nregno, move); VEC_replace (rtx, pseudo_replaced_reg, nregno, def_reg); } } @@ -4010,27 +4003,32 @@ move_unallocated_pseudos (void) for (i = first_moveable_pseudo; i last_moveable_pseudo; i++) if (reg_renumber[i] 0) { - df_ref def = DF_REG_DEF_CHAIN (i); int idx = i - first_moveable_pseudo; rtx other_reg = VEC_index (rtx, pseudo_replaced_reg, idx); - rtx def_insn = DF_REF_INSN (def); - rtx move_insn = VEC_index (rtx, pseudo_move_insn, idx); - rtx set; + rtx def_insn = DF_REF_INSN (DF_REG_DEF_CHAIN (i)); + /* The use must follow all
Re: [C++ Patch] PR 11586
OK. Jason
Re: [PATCH preprocessor, diagnostics] PR preprocessor/53229 - Fix diagnostics location when pasting tokens
On 05/15/2012 07:18 AM, Dodji Seketeli wrote: +paste_tokens (cpp_reader *pfile, source_location lhs_location, If in the long run we want the location passed in to be the ## location, let's drop the lhs from the parameter name. - const cpp_token *result = cpp_get_token (pfile); + const cpp_token *result = cpp_get_token_with_location (pfile, NULL); I find the difference between these two functions confusing, since you aren't passing in a pointer for the location to go into. I see that cpp_get_token_with_location sets pfile-set_invocation_location, which is documented to mean /* When expanding a macro at top-level, this is the location of the macro invocation. */ source_location invocation_location; /* True if this call to cpp_get_token should consider setting invocation_location. */ bool set_invocation_location; But presumably get_token_no_padding isn't only called when we're starting to expand a top-level macro. And as far as I can tell the value of invocation_location is only used when we aren't tracking virtual locations anyway. So why does the change above fix the testcase? Jason
Re: [PATCH] Another fix for TARGET_READ_MODIFY_WRITE i386 peepholes (PR target/53358)
On Tue, May 15, 2012 at 1:47 PM, Jakub Jelinek ja...@redhat.com wrote: This is a similar problem as PR52086, but back then when looking at whether other peepholes might need similar treatment I didn't think about the possibility that addqi_1 pattern would allow non-q constraint register. Apparently it does in some of the alternatives, the insn is then emitted widened as addl etc., but for addqi_2 it isn't possible (it adds to memory). Fixed thusly, bootstrapped/regtested on i686-linux, ok for trunk/4.7? 2012-05-15 Jakub Jelinek ja...@redhat.com PR target/53358 * config/i386/i386.md (*addqi_2 peephole with QImode addition): Check that operands[2] is either immediate, or q_regs_operand. * gcc.dg/pr53358.c: New test. OK. Thanks, Uros.
Re: [RFC] PR 51712 -Wtype-limits should not trigger for enum constants
On Tue, May 15, 2012 at 4:06 AM, Richard Guenther richard.guent...@gmail.com wrote: On Mon, May 14, 2012 at 8:47 PM, Joseph S. Myers jos...@codesourcery.com wrote: On Mon, 14 May 2012, Manuel López-Ibáñez wrote: PING: http://gcc.gnu.org/ml/gcc-patches/2012-05/msg00383.html The general idea of checking this information in shorten_compare seems reasonable. (shorten_compare's optimization function is one that really ought to be done in generic code, but the warning function is reasonable enough.) And on a general note, what is the opinion of the C/C++ maintainers about tracking the original source code more faithfully than currently done? I consider it a good idea to do so - moving more to an explicit lowering step / conversion from front-end to middle-end internal representation. There are some places where c_fully_fold is called to avoid false positive warnings. A first approach for eliminating those would be to make the internal representation contain relevant information such as this is an implicit conversion so that the warnings can be generated later in c_fully_fold when it has the extra information from folding operands. Another possibility would be to have IR that says give this warning, if this condition can occur, and options to evaluate the condition early (with predictability but false positives) or late (fewer false positives, less predictability). Or you could lower as needed but carry around both lowered and unlowered versions of an expression (so front-end IR would include a pointer to lowered IR if lowering has taken place on-demand). I suppose it would be possible to use a new CONST_EXPR with two operands - the fully folded result (and thus constant) and the original expression which is unfolded. At the time we lower to GENERIC we can simply drop CONST_EXPR in favor of its constant operand. Note however that certain expressions are deemed constant only for the purpose of static initialization, not because they really are values -- they may still remain expressions. Address constants are prime examples. -- Gaby
[PATCH][5/n] Remove mark_symbols_for_renaming
This tackles thunks. Easiest would be to not claim we are in SSA form (we are not) and just go into SSA ... but well. This makes us use helpers properly. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2012-05-15 Richard Guenther rguent...@suse.de * cgraphunit.c (thunk_adjust): Use make_rename_temp. (assemble_thunk): Likewise. Manually rename and register function arguments. Index: gcc/cgraphunit.c === *** gcc/cgraphunit.c(revision 187503) --- gcc/cgraphunit.c(working copy) *** thunk_adjust (gimple_stmt_iterator * bsi *** 1264,1288 } vtabletmp = ! create_tmp_var (build_pointer_type ! (build_pointer_type (vtable_entry_type)), vptr); /* The vptr is always at offset zero in the object. */ stmt = gimple_build_assign (vtabletmp, build1 (NOP_EXPR, TREE_TYPE (vtabletmp), ptr)); gsi_insert_after (bsi, stmt, GSI_NEW_STMT); - mark_symbols_for_renaming (stmt); - find_referenced_vars_in (stmt); /* Form the vtable address. */ ! vtabletmp2 = create_tmp_var (TREE_TYPE (TREE_TYPE (vtabletmp)), ! vtableaddr); stmt = gimple_build_assign (vtabletmp2, build_simple_mem_ref (vtabletmp)); gsi_insert_after (bsi, stmt, GSI_NEW_STMT); - mark_symbols_for_renaming (stmt); - find_referenced_vars_in (stmt); /* Find the entry with the vcall offset. */ stmt = gimple_build_assign (vtabletmp2, --- 1264,1284 } vtabletmp = ! make_rename_temp (build_pointer_type ! (build_pointer_type (vtable_entry_type)), vptr); /* The vptr is always at offset zero in the object. */ stmt = gimple_build_assign (vtabletmp, build1 (NOP_EXPR, TREE_TYPE (vtabletmp), ptr)); gsi_insert_after (bsi, stmt, GSI_NEW_STMT); /* Form the vtable address. */ ! vtabletmp2 = make_rename_temp (TREE_TYPE (TREE_TYPE (vtabletmp)), !vtableaddr); stmt = gimple_build_assign (vtabletmp2, build_simple_mem_ref (vtabletmp)); gsi_insert_after (bsi, stmt, GSI_NEW_STMT); /* Find the entry with the vcall offset. */ stmt = gimple_build_assign (vtabletmp2, *** thunk_adjust (gimple_stmt_iterator * bsi *** 1292,1304 gsi_insert_after (bsi, stmt, GSI_NEW_STMT); /* Get the offset itself. */ ! vtabletmp3 = create_tmp_var (TREE_TYPE (TREE_TYPE (vtabletmp2)), ! vcalloffset); stmt = gimple_build_assign (vtabletmp3, build_simple_mem_ref (vtabletmp2)); gsi_insert_after (bsi, stmt, GSI_NEW_STMT); - mark_symbols_for_renaming (stmt); - find_referenced_vars_in (stmt); /* Adjust the `this' pointer. */ ptr = fold_build_pointer_plus_loc (input_location, ptr, vtabletmp3); --- 1288,1298 gsi_insert_after (bsi, stmt, GSI_NEW_STMT); /* Get the offset itself. */ ! vtabletmp3 = make_rename_temp (TREE_TYPE (TREE_TYPE (vtabletmp2)), !vcalloffset); stmt = gimple_build_assign (vtabletmp3, build_simple_mem_ref (vtabletmp2)); gsi_insert_after (bsi, stmt, GSI_NEW_STMT); /* Adjust the `this' pointer. */ ptr = fold_build_pointer_plus_loc (input_location, ptr, vtabletmp3); *** thunk_adjust (gimple_stmt_iterator * bsi *** 1316,1336 ptrtmp = ptr; else { ! ptrtmp = create_tmp_var (TREE_TYPE (ptr), ptr); stmt = gimple_build_assign (ptrtmp, ptr); gsi_insert_after (bsi, stmt, GSI_NEW_STMT); - mark_symbols_for_renaming (stmt); - find_referenced_vars_in (stmt); } ptr = fold_build_pointer_plus_hwi_loc (input_location, ptrtmp, fixed_offset); } /* Emit the statement and gimplify the adjustment expression. */ ! ret = create_tmp_var (TREE_TYPE (ptr), adjusted_this); stmt = gimple_build_assign (ret, ptr); - mark_symbols_for_renaming (stmt); - find_referenced_vars_in (stmt); gsi_insert_after (bsi, stmt, GSI_NEW_STMT); return ret; --- 1310,1326 ptrtmp = ptr; else { ! ptrtmp = make_rename_temp (TREE_TYPE (ptr), ptr); stmt = gimple_build_assign (ptrtmp, ptr); gsi_insert_after (bsi, stmt, GSI_NEW_STMT); } ptr = fold_build_pointer_plus_hwi_loc (input_location,
Re: [RFC] PR 51712 -Wtype-limits should not trigger for enum constants
On Tue, May 15, 2012 at 4:49 AM, Manuel López-Ibáñez lopeziba...@gmail.com wrote: On 15 May 2012 11:06, Richard Guenther richard.guent...@gmail.com wrote: On Mon, May 14, 2012 at 8:47 PM, Joseph S. Myers jos...@codesourcery.com wrote: On Mon, 14 May 2012, Manuel López-Ibáñez wrote: PING: http://gcc.gnu.org/ml/gcc-patches/2012-05/msg00383.html The general idea of checking this information in shorten_compare seems reasonable. (shorten_compare's optimization function is one that really ought to be done in generic code, but the warning function is reasonable enough.) And on a general note, what is the opinion of the C/C++ maintainers about tracking the original source code more faithfully than currently done? I consider it a good idea to do so - moving more to an explicit lowering step / conversion from front-end to middle-end internal representation. There are some places where c_fully_fold is called to avoid false positive warnings. A first approach for eliminating those would be to make the internal representation contain relevant information such as this is an implicit conversion so that the warnings can be generated later in c_fully_fold when it has the extra information from folding operands. Another possibility would be to have IR that says give this warning, if this condition can occur, and options to evaluate the condition early (with predictability but false positives) or late (fewer false positives, less predictability). Or you could lower as needed but carry around both lowered and unlowered versions of an expression (so front-end IR would include a pointer to lowered IR if lowering has taken place on-demand). I suppose it would be possible to use a new CONST_EXPR with two operands - the fully folded result (and thus constant) and the original expression which is unfolded. At the time we lower to GENERIC we can simply drop CONST_EXPR in favor of its constant operand. I think that would be probably the best for the long term. But it will also require a lot of work. More work than I can dedicate to this. This seems a chicken and egg dilemma. Current full-time contributors don't have interest or time for this kind of infrastructure work. The disjunctive is slamming two different things in the same bucket, and that should not be. When I was implementing constexpr, I occasionally ran in frustration with the compiler because it did not explicitly represent certain concepts (e.g. lvalueness, implicit conversions, etc.) systematically. Certainly the desire was there; only the time needed to get them in the release time schedule wasn't there. Well, eventually, the definition of constexpr evolved and those matters became less pressing, not that they were no longer needed. I seem to remember having discussed the idea of using a bit flag to represent expressions we know for sure are constant expressions, but I believe Jason felt otherwise at the time. So, we ended up with a predicate which was the compromised solution. -- Gaby
Re: remove TARGET_E500 and factorize SPE defaults computation in powerpc ports
Hello David, Back on this one after Alan's correction and extra testing of the patch on my side. On May 7, 2012, at 18:59 , David Edelsohn wrote: http://gcc.gnu.org/ml/gcc-patches/2010-08/msg01667.html Yes, exactly. If we can work through the fallout, this is exactly the type of cleanup I envisioned. Attached is a slightly modified version, with a bug fix regarding the ISEL deactivation. The original patch kept the logic of the test but mistakenly just extracted out of an outer else conditional branch, so doing it for e500 targets as well. In this version, the test is moved in the default: part of the case statement introduced to isolate e500 specific operations, replacing the previous if/else construct. This version builds and regtests fine for default languages on powerpc-eabisim on an x86_64-linux host. It also bootstraps and regtests fine for languages=all,ada on powerpc-generic-linux-gnu. OK to commit ? With Kind Regards, Olivier 2012-05-15 Olivier Hainque hain...@adacore.com config/rs6000: * rs6000-opts.h (enum processor_type): Add PROCESSOR_PPC8548. * rs6000-cpus.def: Reference it for cpu=8548. * rs6000.md (cpu attribute definition): Add ppc8548. * 8540.md: indicate that the units/patterns apply to ppc8548 as well. * rs6000.c (rs6000_option_override_internal): Rename default_cpu into implicit_cpu, conveying what --with-cpu was passed at configure time. Treat implicit_cpu as have_cpu. Pick defaults for SPE related flags, check that what is queried is supported by the selected configuration. Rework the single/double_float and MASK_STRING resets to hit for all the E500 cores (854x + E500MC variants). Select the ppc8540 costs for PROCESSOR_PPC8548 as well. (rs6000_issue_rate): case CPU_PPC8548 together with CPU_PPC8540. (rs6000_use_sched_lookahead): Likewise, rewriting function as a case statement instead of a sequence of ifs. * rs6000.h (TARGET_E500): Remove. (TARGET_NO_LWSYNC): Adjust accordingly. * e500.h (TARGET_E500): Remove. (CHECK_E500_OPTIONS): Adjust accordingly. * eabispe.h (SUBSUBTARGET_OVERRIDE_OPTIONS): Remove. (TARGET_DEFAULT): Reformat definition to match the one in linuxspe.h. * linuxspe.h: Likewise. * vxworks.h: Remove bogus TARGET_E500 overrides and superfluous comments. * e500-double.h: Remove. gcc: * config.gcc (pick a default with_cpu): For powerpc*-*-*spe*, default to with_cpu=8548 if --enable-e500-double, and to 8540 otherwise. (set misc flags section): For powerpc*|rs6000*, remove inclusion of e500-double.h for --enable-e500-double. e500-2.diff Description: Binary data
Re: Use sed -n … instead of sed s/…/p -e d in s-header-vars
Hello Hans, On May 15, 2012, at 05:22 , Hans-Peter Nilsson wrote: * Makefile.in (s-header-vars): Resort to -n instead of trailing -e d in sed invocation. Random non-maintainer comments: I'd suggest adding a nearby comment to avoid a future edit changing it back. Sure. The attachment with the patch had the mime-type Video/X-DV, maybe indicating an issue with your mail-client setup mismatching the .dif filename suffix. Ah, right. I have added a comment, regenerated the patch with a .diff extension and will take the opportunity to ping. Thanks for your comments, With Kind Regards, Olivier
Re: [PATCH preprocessor, diagnostics] PR preprocessor/53229 - Fix diagnostics location when pasting tokens
Jason Merrill ja...@redhat.com writes: On 05/15/2012 07:18 AM, Dodji Seketeli wrote: +paste_tokens (cpp_reader *pfile, source_location lhs_location, If in the long run we want the location passed in to be the ## location, let's drop the lhs from the parameter name. Dropped. - const cpp_token *result = cpp_get_token (pfile); + const cpp_token *result = cpp_get_token_with_location (pfile, NULL); I find the difference between these two functions confusing, since you aren't passing in a pointer for the location to go into. I see that cpp_get_token_with_location sets pfile-set_invocation_location, which is documented to mean /* When expanding a macro at top-level, this is the location of the macro invocation. */ source_location invocation_location; /* True if this call to cpp_get_token should consider setting invocation_location. */ bool set_invocation_location; But presumably get_token_no_padding isn't only called when we're starting to expand a top-level macro. And as far as I can tell the value of invocation_location is only used when we aren't tracking virtual locations anyway. So why does the change above fix the testcase? It fixes the test case gcc.dg/cpp/paste12.c because that test case runs with -ftrack-macro-expansion turned off. Otherwise, you are right that the issue exists only when we aren't tracking virtual locations. FWIW, here is the updated patch I have. libcpp/ PR preprocessor/53229 * directives.c (get_token_no_padding): Allow use of virtual locations in diagnostics emitted by the processor when handling directives. Update comments. This fixes gcc.dg/cpp/paste12.c. * macro.c (paste_tokens): Take a virtual location parameter for the LHS of the pasting operator. Use it in diagnostics. Update comments. (paste_all_tokens): Tighten the assert. Propagate the location of the expansion point when no virtual locations are available. Pass the virtual location to paste_tokens. gcc/testsuite/ PR preprocessor/53229 * gcc.dg/cpp/paste6.c: Force to run without -ftrack-macro-expansion. * gcc.dg/cpp/paste8.c: Likewise. * gcc.dg/cpp/paste8-2.c: New test, like paste8.c but run with -ftrack-macro-expansion. * gcc.dg/cpp/paste12.c: Force to run without -ftrack-macro-expansion. * gcc.dg/cpp/paste12-2.c: New test, like paste12.c but run with -ftrack-macro-expansion. * gcc.dg/cpp/paste13.c: Likewise. * gcc.dg/cpp/paste14.c: Likewise. * gcc.dg/cpp/paste14-2.c: New test, like paste14.c but run with -ftrack-macro-expansion. * gcc.dg/cpp/paste18.c: New test. --- gcc/testsuite/gcc.dg/cpp/paste12-2.c | 11 +++ gcc/testsuite/gcc.dg/cpp/paste12.c |5 - gcc/testsuite/gcc.dg/cpp/paste13.c |5 - gcc/testsuite/gcc.dg/cpp/paste14-2.c | 11 +++ gcc/testsuite/gcc.dg/cpp/paste14.c |5 - gcc/testsuite/gcc.dg/cpp/paste18.c | 16 gcc/testsuite/gcc.dg/cpp/paste6.c|5 - gcc/testsuite/gcc.dg/cpp/paste8-2.c | 15 +++ gcc/testsuite/gcc.dg/cpp/paste8.c|2 +- libcpp/directives.c |7 +-- libcpp/macro.c | 25 + 11 files changed, 92 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/cpp/paste12-2.c create mode 100644 gcc/testsuite/gcc.dg/cpp/paste14-2.c create mode 100644 gcc/testsuite/gcc.dg/cpp/paste18.c create mode 100644 gcc/testsuite/gcc.dg/cpp/paste8-2.c diff --git a/gcc/testsuite/gcc.dg/cpp/paste12-2.c b/gcc/testsuite/gcc.dg/cpp/paste12-2.c new file mode 100644 index 000..6e2e4f1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/paste12-2.c @@ -0,0 +1,11 @@ +/* + { dg-options -ftrack-macro-expansion=2 } + { dg-do preprocess } + */ + +/* Test correct diagnostics when pasting in #include. + Source: PR preprocessor/6780. */ + +#define inc2(a,b) ##a.b /* { dg-error pasting \\ and \stdio\ does not } */ +#define INC(X) inc2(X,h) +#include INC(stdio) diff --git a/gcc/testsuite/gcc.dg/cpp/paste12.c b/gcc/testsuite/gcc.dg/cpp/paste12.c index e61ec51..3e0f7b9 100644 --- a/gcc/testsuite/gcc.dg/cpp/paste12.c +++ b/gcc/testsuite/gcc.dg/cpp/paste12.c @@ -1,4 +1,7 @@ -/* { dg-do preprocess } */ +/* + { dg-options -ftrack-macro-expansion=0 } + { dg-do preprocess } +*/ /* Test correct diagnostics when pasting in #include. Source: PR preprocessor/6780. */ diff --git a/gcc/testsuite/gcc.dg/cpp/paste13.c b/gcc/testsuite/gcc.dg/cpp/paste13.c index 62c72d4..f0f4fd8 100644 --- a/gcc/testsuite/gcc.dg/cpp/paste13.c +++ b/gcc/testsuite/gcc.dg/cpp/paste13.c @@ -1,6 +1,9 @@ /* Copyright (C) 2000 Free Software Foundation, Inc. */ -/* { dg-do preprocess } */ +/* + { dg-options -ftrack-macro-expansion=0 } + { dg-do preprocess } +*/ /* This used to be recognized as a
ping: Use sed -n … instead of sed s/…/p -e d in s-header-vars
Hello, Ping for http://gcc.gnu.org/ml/gcc-patches/2012-04/msg01896.html New patch attached. Following Hans suggestion, I have added a comment to prevent going back to the original scheme and problem in the future. Thanks in advance for your feedback, With Kind Regards, Olivier On Apr 30, 2012, at 18:55 , Olivier Hainque wrote: sed s/…/p -e d as used in s-header-vars doesn't work on at least ia64-hpux, where s/.../p only prints out if -n was requested as well. ... * Makefile.in (s-header-vars): Resort to -n instead of trailing -e d in sed invocation. sed-n.diff Description: Binary data
PING: Re: [PR tree-optimization/52558]: RFC: questions on store data race
PING. Hi. Sorry for the delay. There were various tricky hiccups along the way to bootstrappability and regression cleanliness... On 04/26/12 04:51, Richard Guenther wrote: On Wed, 25 Apr 2012, Aldy Hernandez wrote: On 04/25/12 06:45, Richard Guenther wrote: On Tue, Apr 24, 2012 at 7:43 PM, Aldy Hernandezal...@redhat.com wrote: On 04/13/12 03:46, Richard Guenther wrote: On Fri, Apr 13, 2012 at 12:11 AM, Aldy Hernandezal...@redhat.com wrote: Speak of loads, I am keeping the information as an additional bitmap in `memory_accesses', as -refs_in_loop was set for stores as well, so I couldn't depend on it. Let me know if you have another idea. Hmm, refs_in_loop ~all_refs_stored_in_loop, so instead of + bitmap reads = VEC_index (bitmap, memory_accesses.reads_in_loop, + loop-num); + ref_read_in_loop_p = bitmap_bit_p (reads, ref-id); ref_read_in_loop_p = bitmap_bit_p (refs, ref-id) !bitmap_bit_p (stores, ref-id); ? But maybe that doesn't work if a ref is both read and stored to. Btw, rather than adding a bitmap to memory_accesses I'd rather add a mark_ref_loaded corresponding to mark_ref_stored (or rather merge both into one) and a bitmap to struct mem_ref. I have done so as mark_ref_loaded(). I first tried to merge both into a generic mark_ref(), to avoid iterating twice, but I was concerned with the early loop exit of !bitmap_bit_p(ref-stored, loop-num), not knowing if I should exit the loop altogether in the merged case or what. In either case, the code was somewhat convoluted, so I opted for a separate clean function. In scanning the gimple stream for the loads I noticed that instances of two component refs (say foo.bar) were not pointer comparable, so I am asking the alias oracle with refs_may_alias_p. It also seemed to make more sense wrt memory chunks that may alias. What do you think? This patch is far more robust and fully tested. Two wrenches to complicate things though... First, while inserting the code writing the _LSM_ temporary writes into the original variables, I found a handful of tests where the order of the writes mattered (aliased locations, inlined code, etc, IIRC). [This is in loops where multiple stores are moved.] So iterating and inserting on the exit edges caused the stores to be saved in reverse. I am now saving the edges and threading the code, so they happen in the correct order: if (foo_flag_lsm) foo = foo_lsm; if (foo2_flag_lsm) foo2 = foo2_lsm; actual_exit: This required some edge redirection so we didn't jump to the original actual exit prematurely when handling multiple moved stores. The dominator tree needed to be updated, and there is one instance where I couldn't find a clever way of saving the order without jumping through an inordinate amount of hoops. It seemed easier to call recompute_dominator. Second, avoiding the load, unless it happens in the loop like you have suggested, brought about some bogus unused warnings with the LSM temporaries. What happens is that compute_ssa() creates uses of the LSM temporaries that are not yet defined, so we end up with PHI nodes with a definition entry (D). Since we are sure the eventual uses will be gated by their corresponding flag, I created phi nodes with an initial value of 0 in the preheader of the loops in which they are used. This solved the problem. I also played with initializing to 0 at the entry block, but that seemed a bit too invasive. Andrew suggested the correct fix was to add a new pass that was able to do some ?? flow sensitive data flow analysis ?? that could discover these unreachable paths and insert the 0 phis at the start of the blocks automatically. But that seemed like far too much work, considering how long it's taken me to get this far ;-). Bootstraped and fully tested with multi_threaded_model_p=true hard-coded. This is the revision I'd like to contribute, sans the hardcoded value. What do you think?
[Patch] Use CAN_HAVE_LOCATION_P in EXPR_LOCATION
Hi, this is something I noticed when looking into more EXPR_LOC_OR_HERE uses in the C++ front-end: I don't think we want to crash if EXPR_LOC_OR_HERE is passed a NULL_TREE. Tested x86_64-linux. Thanks, Paolo. /// 2012-05-15 Paolo Carlini paolo.carl...@oracle.com * tree.h (EXPR_LOCATION): Use CAN_HAVE_LOCATION_P. Index: tree.h === --- tree.h (revision 187501) +++ tree.h (working copy) @@ -1684,7 +1684,7 @@ struct GTY(()) tree_constructor { decls and constants can be shared among multiple locations, so return nothing. */ #define EXPR_LOCATION(NODE) \ - (EXPR_P ((NODE)) ? (NODE)-exp.locus : UNKNOWN_LOCATION) + (CAN_HAVE_LOCATION_P ((NODE)) ? (NODE)-exp.locus : UNKNOWN_LOCATION) #define SET_EXPR_LOCATION(NODE, LOCUS) EXPR_CHECK ((NODE))-exp.locus = (LOCUS) #define EXPR_HAS_LOCATION(NODE) (EXPR_LOCATION (NODE) != UNKNOWN_LOCATION) #define EXPR_LOC_OR_HERE(NODE) (EXPR_HAS_LOCATION (NODE) ? (NODE)-exp.locus : input_location)
Re: PING: PATCH: Backport x32 support to libtool
On 05/11/2012 12:50 PM, H.J. Lu wrote: On Mon, Apr 16, 2012 at 10:47 AM, H.J. Lu hjl.to...@gmail.com wrote: On Tue, Apr 3, 2012 at 7:49 AM, H.J. Lu hjl.to...@gmail.com wrote: On Thu, Mar 29, 2012 at 7:34 AM, H.J. Lu hjl.to...@gmail.com wrote: On Sat, Mar 3, 2012 at 9:54 AM, H.J. Lu hongjiu...@intel.com wrote: Hi, This patch backports x32 support to libtool: http://git.savannah.gnu.org/cgit/libtool.git/commit/?id=88992fe6771ec3258bde1b03314ce579da0ac2d5 OK to install? Thanks. H.J. --- ommit 0d8c092cac25c3bce5dbfc1981b84df91b3f6086 Author: H.J. Lu hjl.to...@gmail.com Date: Mon Dec 12 13:03:14 2011 -0800 Add x32 support to libtool.m4 2011-12-12 H.J. Lu hongjiu...@intel.com * libtool.m4 (_LT_ENABLE_LOCK): Support x32. diff --git a/ChangeLog.x32 b/ChangeLog.x32 new file mode 100644 index 000..b6e01ee --- /dev/null +++ b/ChangeLog.x32 @@ -0,0 +1,3 @@ +2011-12-12 H.J. Lu hongjiu...@intel.com + + * libtool.m4 (_LT_ENABLE_LOCK): Support x32. diff --git a/libtool.m4 b/libtool.m4 index 67321a7..a7f99ac 100644 --- a/libtool.m4 +++ b/libtool.m4 @@ -1232,7 +1232,14 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) LD=${LD-ld} -m elf_i386_fbsd ;; x86_64-*linux*) - LD=${LD-ld} -m elf_i386 + case `/usr/bin/file conftest.o` in + *x86-64*) + LD=${LD-ld} -m elf32_x86_64 + ;; + *) + LD=${LD-ld} -m elf_i386 + ;; + esac ;; ppc64-*linux*|powerpc64-*linux*) LD=${LD-ld} -m elf32ppclinux Hi Ralf, Can you review this patch? Thanks. PING. PING. PING. I'm not Ralf, and I don't fully understand the details of what's going on here, but here's my review question: you seem to be relying on the format of the output of 'file' containing the exact string x86-64. Is this the right string to look for? Standard libtool seems to look for the phrase 64-bit or 32-bit in the output of 'file'.
Re: PING: PATCH: Backport x32 support to libtool
On Tue, May 15, 2012 at 8:06 AM, Nathanael Nerode (GCC) ncn_gc...@fastmail.fm wrote: On 05/11/2012 12:50 PM, H.J. Lu wrote: On Mon, Apr 16, 2012 at 10:47 AM, H.J. Lu hjl.to...@gmail.com wrote: On Tue, Apr 3, 2012 at 7:49 AM, H.J. Lu hjl.to...@gmail.com wrote: On Thu, Mar 29, 2012 at 7:34 AM, H.J. Lu hjl.to...@gmail.com wrote: On Sat, Mar 3, 2012 at 9:54 AM, H.J. Lu hongjiu...@intel.com wrote: Hi, This patch backports x32 support to libtool: http://git.savannah.gnu.org/cgit/libtool.git/commit/?id=88992fe6771ec3258bde1b03314ce579da0ac2d5 OK to install? Thanks. H.J. --- ommit 0d8c092cac25c3bce5dbfc1981b84df91b3f6086 Author: H.J. Lu hjl.to...@gmail.com Date: Mon Dec 12 13:03:14 2011 -0800 Add x32 support to libtool.m4 2011-12-12 H.J. Lu hongjiu...@intel.com * libtool.m4 (_LT_ENABLE_LOCK): Support x32. diff --git a/ChangeLog.x32 b/ChangeLog.x32 new file mode 100644 index 000..b6e01ee --- /dev/null +++ b/ChangeLog.x32 @@ -0,0 +1,3 @@ +2011-12-12 H.J. Lu hongjiu...@intel.com + + * libtool.m4 (_LT_ENABLE_LOCK): Support x32. diff --git a/libtool.m4 b/libtool.m4 index 67321a7..a7f99ac 100644 --- a/libtool.m4 +++ b/libtool.m4 @@ -1232,7 +1232,14 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) LD=${LD-ld} -m elf_i386_fbsd ;; x86_64-*linux*) - LD=${LD-ld} -m elf_i386 + case `/usr/bin/file conftest.o` in + *x86-64*) + LD=${LD-ld} -m elf32_x86_64 + ;; + *) + LD=${LD-ld} -m elf_i386 + ;; + esac ;; ppc64-*linux*|powerpc64-*linux*) LD=${LD-ld} -m elf32ppclinux Hi Ralf, Can you review this patch? Thanks. PING. PING. PING. I'm not Ralf, and I don't fully understand the details of what's going on here, but here's my review question: you seem to be relying on the format of the output of 'file' containing the exact string x86-64. Is this the right string to look for? Standard libtool seems to look for the phrase 64-bit or 32-bit in the output of 'file'. Here is the original libtool.m4 case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD=${LD-ld} -m elf_i386_fbsd ;; x86_64-*linux*) LD=${LD-ld} -m elf_i386 ;; In case of *32-bit, we want LD=${LD-ld} -m elf32_x86_64 if `file' also displays x86-64. Is my patch OK? Thanks. -- H.J.
Re: PING: PATCH: Backport x32 support to libtool
On 05/15/2012 11:32 AM, H.J. Lu wrote: On Tue, May 15, 2012 at 8:06 AM, Nathanael Nerode (GCC) ncn_gc...@fastmail.fm wrote: On 05/11/2012 12:50 PM, H.J. Lu wrote: On Mon, Apr 16, 2012 at 10:47 AM, H.J. Lu hjl.to...@gmail.com wrote: On Tue, Apr 3, 2012 at 7:49 AM, H.J. Lu hjl.to...@gmail.com wrote: On Thu, Mar 29, 2012 at 7:34 AM, H.J. Lu hjl.to...@gmail.com wrote: On Sat, Mar 3, 2012 at 9:54 AM, H.J. Lu hongjiu...@intel.com wrote: Hi, This patch backports x32 support to libtool: http://git.savannah.gnu.org/cgit/libtool.git/commit/?id=88992fe6771ec3258bde1b03314ce579da0ac2d5 OK to install? Thanks. H.J. --- ommit 0d8c092cac25c3bce5dbfc1981b84df91b3f6086 Author: H.J. Lu hjl.to...@gmail.com Date: Mon Dec 12 13:03:14 2011 -0800 Add x32 support to libtool.m4 2011-12-12 H.J. Lu hongjiu...@intel.com * libtool.m4 (_LT_ENABLE_LOCK): Support x32. diff --git a/ChangeLog.x32 b/ChangeLog.x32 new file mode 100644 index 000..b6e01ee --- /dev/null +++ b/ChangeLog.x32 @@ -0,0 +1,3 @@ +2011-12-12 H.J. Lu hongjiu...@intel.com + + * libtool.m4 (_LT_ENABLE_LOCK): Support x32. diff --git a/libtool.m4 b/libtool.m4 index 67321a7..a7f99ac 100644 --- a/libtool.m4 +++ b/libtool.m4 @@ -1232,7 +1232,14 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) LD=${LD-ld} -m elf_i386_fbsd ;; x86_64-*linux*) - LD=${LD-ld} -m elf_i386 + case `/usr/bin/file conftest.o` in + *x86-64*) + LD=${LD-ld} -m elf32_x86_64 + ;; + *) + LD=${LD-ld} -m elf_i386 + ;; + esac ;; ppc64-*linux*|powerpc64-*linux*) LD=${LD-ld} -m elf32ppclinux Hi Ralf, Can you review this patch? Thanks. PING. PING. PING. I'm not Ralf, and I don't fully understand the details of what's going on here, but here's my review question: you seem to be relying on the format of the output of 'file' containing the exact string x86-64. Is this the right string to look for? Standard libtool seems to look for the phrase 64-bit or 32-bit in the output of 'file'. Here is the original libtool.m4 case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD=${LD-ld} -m elf_i386_fbsd ;; x86_64-*linux*) LD=${LD-ld} -m elf_i386 ;; In case of *32-bit, we want LD=${LD-ld} -m elf32_x86_64 if `file' also displays x86-64. Is my patch OK? Thanks. Yeah, approved. I simply wonder whether we can trust the output of 'file' to keep using 'x86-64' (rather than AMD64, or EM64T, or whatever). It all seems very fragile.
Re: gnu-tm: Dont allow assigning transaction_unsafe functions to transaction_safe function pointers (issue6198054)
On Tue, 2012-05-08 at 18:02 -0500, Dave Boutcher wrote: Without this patch it is perfectly fine to assign non-transaction_safe functions to function pointers marked as transaction_safe. Unpleasantness happens at run time. e.g. __attribute__((transaction_safe)) long (*compare)(int, int); compare = my_funky_random_function; gcc/c-typeck.c |7 +++ 1 file changed, 7 insertions(+) diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index fc01a79..69687d6 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -5608,6 +5608,13 @@ convert_for_assignment (location_t location, tree type, tree rhs, } } + /* Check for assignment to transaction safe */ + if (is_tm_safe(type) !is_tm_safe_or_pure (rhs)) { I don't think that assigning a tm_pure function to tm_safe works. There will be no instrumented version of it. I don't think we generate an alias or sth like that yet. When contributing patches, please submit testcases along with it. For example, regarding this particular problem, I would believe that there are more cases that we don't check properly yet. Also, did you do the FSF copyright assignment paperwork yet? Torvald
Merge from gcc-4_7-branch to gccgo branch
I have merged gcc-4_7-branch revision 187489 to the gccgo branch. Ian
Turn check macros into functions. (issue6188088)
The gcc source uses several constructs that GDB does not understand. This patch corrects some of them. It affects only compilers built with ENABLE_TREE_CHECKING, and hence release compilers are unaffected. In particular, I change the implementation of CHECK macros using __extension__ into macros calling template inline functions. I do not change the accessor macros themselves. The effect is that it now possible to get useful responses to gdb command like (gdb) print DECL_FUNCTION_CODE (decl) To make the feature work, you must define two macros within gdb. (gdb) macro define __FILE__ gdb (gdb) macro define __LINE__ 1 The reason for these definitions is that gdb does not expand the magic preprocessor macros, and then cannot find what it thinks is a regular symbol. (There is now a gdb issue for this problem.) I added these definitions to gdbinit.in. The inline functions would normally introduce additional lines in a sequence of gdb 'step' commands. To prevent that behavior, I have added the new 'skip' command for the tree.h file to gdbinit.in. The 'skip' command works with gdb 7.4 and later. (The better solution to the stepping behavior is a new gdb command. See http://sourceware.org/bugzilla/show_bug.cgi?id=12940.) Tested on x86-64. Index: gcc/ChangeLog.cxx-conversion 2012-05-15 Lawrence Crowl cr...@google.com * tree.h (tree_check): New. (TREE_CHECK): Use inline function above instead of __extension__. (tree_not_check): New. (TREE_NOT_CHECK): Use inline function above instead of __extension__. (tree_check2): New. (TREE_CHECK2): Use inline function above instead of __extension__. (tree_not_check2): New. (TREE_NOT_CHECK2): Use inline function above instead of __extension__. (tree_check3): New. (TREE_CHECK3): Use inline function above instead of __extension__. (tree_not_check3): New. (TREE_NOT_CHECK3): Use inline function above instead of __extension__. (tree_check4): New. (TREE_CHECK4): Use inline function above instead of __extension__. (tree_not_check4): New. (TREE_NOT_CHECK4): Use inline function above instead of __extension__. (tree_check5): New. (TREE_CHECK5): Use inline function above instead of __extension__. (tree_not_check5): New. (TREE_NOT_CHECK5): Use inline function above instead of __extension__. (contains_struct_check): New. (CONTAINS_STRUCT_CHECK): Use inline function above instead of __extension__. (tree_class_check): New. (TREE_CLASS_CHECK): Use inline function above instead of __extension__. (tree_range_check): New. (TREE_RANGE_CHECK): Use inline function above instead of __extension__. (omp_clause_subcode_check): New. (OMP_CLAUSE_SUBCODE_CHECK): Use inline function above instead of __extension__. (omp_clause_range_check): New. (OMP_CLAUSE_RANGE_CHECK): Use inline function above instead of __extension__. (expr_check): New. (EXPR_CHECK): Use inline function above instead of __extension__. (non_type_check): New. (NON_TYPE_CHECK): Use inline function above instead of __extension__. (tree_vec_elt_check): New. (TREE_VEC_ELT_CHECK): Use inline function above instead of __extension__. (omp_clause_elt_check): New. (OMP_CLAUSE_ELT_CHECK): Use inline function above instead of __extension__. (tree_operand_check): New. (TREE_OPERAND_CHECK): Use inline function above instead of __extension__. (tree_operand_check_code): New. (TREE_OPERAND_CHECK_CODE): Use inline function above instead of __extension__. (TREE_CHAIN): Simplify implementation. (TREE_TYPE): Simplify implementation. (tree_operand_length): Move for compilation dependences. * gdbinit.in: (macro define __FILE__): New. (macro define __LINE__): New. (skip tree.h): New. Index: gcc/tree.h === --- gcc/tree.h (revision 187477) +++ gcc/tree.h (working copy) @@ -727,195 +727,80 @@ enum tree_node_structure_enum { is accessed incorrectly. The macros die with a fatal error. */ #if defined ENABLE_TREE_CHECKING (GCC_VERSION = 2007) -#define TREE_CHECK(T, CODE) __extension__ \ -({ __typeof (T) const __t = (T); \ -if (TREE_CODE (__t) != (CODE)) \ - tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,\ -(CODE), 0);\ -__t; }) +#define TREE_CHECK(T, CODE) \ +(tree_check ((T), __FILE__, __LINE__, __FUNCTION__, (CODE))) -#define TREE_NOT_CHECK(T, CODE) __extension__ \ -({ __typeof (T) const __t = (T);
Re: Turn check macros into functions. (issue6188088)
On Tue, May 15, 2012 at 7:19 PM, Lawrence Crowl cr...@google.com wrote: The gcc source uses several constructs that GDB does not understand. This patch corrects some of them. It affects only compilers built with ENABLE_TREE_CHECKING, and hence release compilers are unaffected. Index: gcc/ChangeLog.cxx-conversion (...) 2012-05-15 Lawrence Crowl cr...@google.com Is this something you could do for the mainline instead? If not, then I hope it will land there some day. I now usually build my debug compilers with checking disabled to work around this issue... Ciao! Steven
Re: [PATCH] PR preprocessor/7263 - Avoid pedantic warnings on system headers macro tokens
OK. Jason
Re: [PATCH preprocessor, diagnostics] PR preprocessor/53229 - Fix diagnostics location when pasting tokens
Dodji == Dodji Seketeli do...@redhat.com writes: Dodji To properly fix this, I think libcpp should keep the token of the Dodji pasting operator '##', instead of representing it with flag on the LHS Dodji operand's token. That way, it could use its location. Originally I had thought that a pasted token should have a special virtual location, pointing to the locations of its source tokens. This would let later code undo the paste, if need be. I don't know any more if this idea makes sense or not. Tom
Re: [C++ Patch] PR 44516
On 05/14/2012 07:17 PM, Paolo Carlini wrote: @@ -5670,7 +5672,8 @@ build_x_compound_expr_from_list (tree list, expr_l return error_mark_node; for (list = TREE_CHAIN (list); list; list = TREE_CHAIN (list)) - expr = build_x_compound_expr (expr, TREE_VALUE (list), + expr = build_x_compound_expr (EXPR_LOC_OR_HERE (expr), expr, + TREE_VALUE (list), complain); For a COMPOUND_EXPR, I think the relevant location is that of the comma, and since we don't have that location I think the location of the second expression is a closer approximation. Note that when copying the location from one expression to another, EXPR_LOC_OR_HERE will change UNKNOWN_LOCATION to input_location, whereas EXPR_LOCATION will leave it alone. Jason
Re: Build problem with libgo runtime
William J. Schmidt wschm...@linux.vnet.ibm.com writes: I'm investigating another build failure for Fedora 17 (based on 4.7). The failing compile from the build log is as follows: /bin/sh ./libtool --tag=CC --mode=compile /builddir/build/BUILD/gcc-4.7.0-20120504/obj-ppc64-redhat-linux/./gcc/xgcc -B/builddir/build/BUILD/gcc-4.7.0-20120504/obj-ppc64-redhat-linux/./gcc/ -B/usr/ppc64-redhat-linux/bin/ -B/usr/ppc64-redhat-linux/lib/ -isystem /usr/ppc64-redhat-linux/include -isystem /usr/ppc64-redhat-linux/sys-include -DHAVE_CONFIG_H -I. -I../../../libgo -I ../../../libgo/runtime -I../../../libgo/../libffi/include -I../libffi/include -pthread -fexceptions -fplan9-extensions -Wall -Wextra -Wwrite-strings -Wcast-qual -Werror -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I ../../../libgo/../libgcc -I ../../gcc/include -O2 -O3 -mtune=power7 -mcpu=power7 -g -fsigned-char -MT proc.lo -MD -MP -MF .deps/proc.Tpo -c -o proc.lo `test -f 'runtime/proc.c' || echo '../../../libgo/'`runtime/proc.c The reported failure: ../../../libgo/runtime/proc.c: In function ‘__go_go’: ../../../libgo/runtime/proc.c:1323:8: error: variable ‘sp’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered] ../../../libgo/runtime/proc.c:1324:9: error: variable ‘spsize’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered] cc1: all warnings being treated as errors The declarations in question are: byte *sp; size_t spsize; G * volatile newg; // volatile to avoid longjmp warning What's interesting here is that I don't see a problem when compiling for a 32-bit target. However, it's also apparent that making newg volatile was deemed sufficient up till now, so I am wondering if there is something about our build options/environment that could cause the problem. I can work around the problem with the following patch, but would appreciate any insights into whether this should be necessary, and if not, what we're doing wrong. I don't know why you are seeing this when I am not. However, the warning is essentially correct. It's not useful, because as it happens nothing will ever call setcontext in such a way that the getcontext call will return a second time, but the compiler can't know that. And if it did happen, the warning would be valid. So I committed this variant of your patch to prevent the warning. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch. Ian diff -r efd2462cb004 libgo/runtime/proc.c --- a/libgo/runtime/proc.c Mon May 14 14:57:59 2012 -0700 +++ b/libgo/runtime/proc.c Tue May 15 11:54:04 2012 -0700 @@ -1322,7 +1322,7 @@ { byte *sp; size_t spsize; - G * volatile newg; // volatile to avoid longjmp warning + G *newg; schedlock(); @@ -1363,19 +1363,26 @@ if(sp == nil) runtime_throw(nil g-stack0); - getcontext(newg-context); - newg-context.uc_stack.ss_sp = sp; + { + // Avoid warnings about variables clobbered by + // longjmp. + byte * volatile vsp = sp; + size_t volatile vspsize = spsize; + G * volatile vnewg = newg; + + getcontext(vnewg-context); + vnewg-context.uc_stack.ss_sp = vsp; #ifdef MAKECONTEXT_STACK_TOP - newg-context.uc_stack.ss_sp += spsize; + vnewg-context.uc_stack.ss_sp += vspsize; #endif - newg-context.uc_stack.ss_size = spsize; - makecontext(newg-context, kickoff, 0); + vnewg-context.uc_stack.ss_size = vspsize; + makecontext(vnewg-context, kickoff, 0); - newprocreadylocked(newg); - schedunlock(); + newprocreadylocked(vnewg); + schedunlock(); - return newg; -//printf( goid=%d\n, newg-goid); + return vnewg; + } } // Put on gfree list. Sched must be locked.
Re: Turn check macros into functions. (issue6188088)
On 12-05-15 14:23 , Steven Bosscher wrote: On Tue, May 15, 2012 at 7:19 PM, Lawrence Crowlcr...@google.com wrote: The gcc source uses several constructs that GDB does not understand. This patch corrects some of them. It affects only compilers built with ENABLE_TREE_CHECKING, and hence release compilers are unaffected. Index: gcc/ChangeLog.cxx-conversion (...) 2012-05-15 Lawrence Crowlcr...@google.com Is this something you could do for the mainline instead? The same patch applies to mainline. However, the patch makes use of template functions. So we can't put it in mainline until after mainline switches to C++. This will happen at some point in stage 1, but we agreed to have vec.[ch] converted before that happened. I'm working on the vec conversion, which I hope to have completed soon. Diego.
Re: [Patch] Use CAN_HAVE_LOCATION_P in EXPR_LOCATION
OK. Jason
Re: [PATCH, Android] Stack protector enabling for Android target
On 12/05/2012, at 9:03 AM, Igor Zamyatin wrote: Hi! Please look at the modified patch in the attachment. ChangeLog remains the same. Tested in android environment(x86_64-*-linux-android), also bootstrapped on x86_64-unknown-linux-gnu. I also started regtesting on linux. Is it ok after successfull regtesting? diff --git a/gcc/configure.ac b/gcc/configure.ac index 2c17736..43e760b 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -4545,7 +4545,7 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library, gcc_cv_libc_provides_ssp, [gcc_cv_libc_provides_ssp=no case $target in - *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu) + *-*-linux* | *-android* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu) You should not need this change. Android target triplets are of form *-*-linux-android*, which matches *-*-linux*. [# glibc 2.4 and later provides __stack_chk_fail and # either __stack_chk_guard, or TLS access to stack guard canary. if test -f $target_header_dir/features.h \ @@ -4566,6 +4566,11 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library, $target_header_dir/bits/uClibc_config.h /dev/null; then gcc_cv_libc_provides_ssp=yes fi + # all versions of Bionic support stack protector + elif test -f $target_header_dir/sys/cdefs.h \ + $EGREP '^[ ]*#[]*define[ ]+__BIONIC__[ ]+1' \ + $target_header_dir/sys/cdefs.h /dev/null; then + gcc_cv_libc_provides_ssp=yes fi] ;; *-*-gnu*) The patch is OK provided successful regtest and either dropping the first hunk or explaining why it is necessary. Thanks! -- Maxim Kuvyrkov CodeSourcery / Mentor Graphics
[PATCH] PR rtl-optimization/53352
Hi All, As reported in PR rtl-optimization/53352 CSE currently trips up on a paradoxical subreg case. When compiling for ARM GNU/Linux with -O3 the expanded RTL of interest looks like: (insn 12 11 13 3 (set (reg:SI 140) (lshiftrt:SI (reg/v:SI 135 [ tmp1 ]) (const_int 16 [0x10]))) (nil)) (insn 13 12 14 3 (set (reg:QI 141) (subreg:QI (reg:SI 140) 0)) (nil)) (insn 14 13 15 3 (set (reg:SI 142) (subreg:SI (reg:QI 141) 0)) (nil)) (insn 15 14 16 3 (set (reg:SI 134 [ tmp1$2 ]) (and:SI (reg:SI 142) (const_int 255 [0xff]))) (nil)) ... (insn 29 28 30 3 (set (reg:SI 0 r0) (const_int 0 [0])) (nil)) after cse1 things look like: (insn 12 11 13 2 (set (reg:SI 140) (const_int 65280 [0xff00])) (nil)) (insn 13 12 14 2 (set (reg:QI 141) (subreg:QI (reg:SI 140) 0)) (expr_list:REG_EQUAL (const_int 0 [0]) (nil))) ;; This is *not* equal to zero because the upper ;; two bytes are undefined. (insn 14 13 15 2 (set (reg:SI 142) (subreg:SI (reg:QI 141) 0)) (expr_list:REG_EQUAL (const_int 0 [0]) (nil))) (insn 15 14 16 2 (set (reg:SI 134 [ tmp1$2 ]) (reg:SI 142)) (expr_list:REG_EQUAL (const_int 0 [0]) (nil))) ... (insn 29 28 30 2 (set (reg:SI 0 r0) (reg:SI 142)) (expr_list:REG_EQUAL (const_int 0 [0]) (nil))) I believe the REG_EQUAL note on the set involving a paradoxical subreg is incorrect. It eventually causes 0xFF00 to be passed to the function 'foo'. The attached patch fixes the issue by skipping the paradoxical subreg in 'equiv_constant'. Compiler bootstrapped for i686-pc-linux-gnu and full GCC test runs for i686-pc-linux-gnu and arm-none-linux-gnueabi (no regressions). OK? (If this is OK, then can someone commit for me. I don't have write access). gcc/ 2012-05-15 Meador Inge mead...@codesourcery.com PR rtl-optimization/53352 * cse.c (equiv_constant): Ignore paradoxical subregs. gcc/testsuite/ 2012-05-15 Meador Inge mead...@codesourcery.com PR rtl-optimization/53352 * gcc.dg/pr53352.c: New test. -- Meador Inge CodeSourcery / Mentor Embedded http://www.mentor.com/embedded-software Index: gcc/testsuite/gcc.dg/pr53352.c === --- gcc/testsuite/gcc.dg/pr53352.c (revision 0) +++ gcc/testsuite/gcc.dg/pr53352.c (revision 0) @@ -0,0 +1,41 @@ +/* { dg-do run } */ +/* { dg-options -O1 } */ + +#include stdlib.h + +typedef union +{ + struct + { +unsigned char a; +unsigned char b; +unsigned char c; +unsigned char d; + } parts; + unsigned long whole; +} T; + +T *g_t; + +void bar (unsigned long x) +{ + if (x != 0) +abort (); +} + +int main () +{ + T one; + T two; + T tmp1, tmp2; + + one.whole = 0xFFE0E0E0; + two.whole = 0xFF00; + tmp1.parts = two.parts; + tmp2.parts = one.parts; + tmp2.parts.c = tmp1.parts.c; + one.parts = tmp2.parts; + + g_t = one; + bar (0); +} Index: gcc/cse.c === --- gcc/cse.c (revision 187470) +++ gcc/cse.c (working copy) @@ -3786,8 +3786,11 @@ equiv_constant (rtx x) } } - /* Otherwise see if we already have a constant for the inner REG. */ + /* Otherwise see if we already have a constant for the inner REG. + Don't bother with paradoxical subregs because we have no way + of knowing what the upper bytes are. */ if (REG_P (SUBREG_REG (x)) + (GET_MODE_SIZE (mode) = GET_MODE_SIZE (imode)) (new_rtx = equiv_constant (SUBREG_REG (x))) != 0) return simplify_subreg (mode, new_rtx, imode, SUBREG_BYTE (x));
[google/gcc-4_7] Allow static const floats unless -pedantic is passed (issue6212051)
To be applied to google/gcc-4_7. Allow static const floats unless -pedantic is passed. This patch allows us to migrate to C++11 more incrementally, since we can leave the static const float initializations in place, flip the switch, and then change it to use constexpr. This is a forward port of r180638 from google/gcc-4_6 (despite the fact that that revision says to NOT forward-port this). Minor additional fixups have been applied. 2012-05-15 Ollie Wild a...@google.com * gcc/cp/decl.c (check_static_variable_definition): Only generate a constexpr warning when -pedantic is enabled. * gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C: Replace -fpermissive with -pedantic. * gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C: New test. * gcc/testsuite/g++.old-deja/g++.ext/memconst.C: Compile with -pedantic -pedantic-errors to work around test failures with -std=gnu++11. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index bb26d15..d2fe731 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7861,9 +7861,18 @@ check_static_variable_definition (tree decl, tree type) error (in-class initialization of static data member %q#D of incomplete type, decl); else if (literal_type_p (type)) - permerror (input_location, - %constexpr% needed for in-class initialization of - static data member %q#D of non-integral type, decl); + { + /* FIXME google: This local modification allows us to + transition from C++98 to C++11 without moving static + const floats out of the class during the transition. It + should not be forward-ported to a 4.8 branch, since by + then we should be able to just fix the code to use + constexpr. */ + pedwarn (input_location, OPT_pedantic, + %constexpr% needed for in-class initialization of + static data member %q#D of non-integral type, decl); + return 0; + } else error (in-class initialization of static data member %q#D of non-literal type, decl); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C index 7c84cf8..658a458 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C @@ -1,5 +1,5 @@ // PR c++/50258 -// { dg-options -std=c++0x -fpermissive } +// { dg-options -std=c++0x -pedantic } struct Foo { static const double d = 3.14; // { dg-warning constexpr } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C new file mode 100644 index 000..28d34a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C @@ -0,0 +1,7 @@ +// PR c++/50258 +// { dg-options -std=c++0x } + +struct Foo { + static const double d = 3.14; // no warning +}; +const double Foo::d; diff --git a/gcc/testsuite/g++.old-deja/g++.ext/memconst.C b/gcc/testsuite/g++.old-deja/g++.ext/memconst.C index d934763..7e86156 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/memconst.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/memconst.C @@ -1,5 +1,5 @@ // { dg-do assemble } -// { dg-options } +// { dg-options -pedantic -pedantic-errors } // From: ove.ewer...@syscon.uu.se (Ove Ewerlid) // Subject: ss-940630:cc1plus: internal error // Date: Sat, 2 Jul 1994 05:07:20 +0200 -- This patch is available for review at http://codereview.appspot.com/6212051
Go patch committed: Don't try to address of a constant
This patch changes the Go frontend to avoid trying to directly take the address of a constant when generating GENERIC. That actually mostly works--unless the DECL_INITIAL of the constant is another constant. This patch changes the code to use a temporary variable instead. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch. Ian diff -r b66431f97fa7 go/expressions.cc --- a/go/expressions.cc Tue May 15 11:56:03 2012 -0700 +++ b/go/expressions.cc Tue May 15 12:58:22 2012 -0700 @@ -4044,7 +4044,7 @@ if (this-create_temp_ !TREE_ADDRESSABLE(TREE_TYPE(expr)) - !DECL_P(expr) + (TREE_CODE(expr) == CONST_DECL || !DECL_P(expr)) TREE_CODE(expr) != INDIRECT_REF TREE_CODE(expr) != COMPONENT_REF) { @@ -6194,7 +6194,9 @@ make_tmp = NULL_TREE; arg = right_tree; } - else if (TREE_ADDRESSABLE(TREE_TYPE(right_tree)) || DECL_P(right_tree)) + else if (TREE_ADDRESSABLE(TREE_TYPE(right_tree)) + || (TREE_CODE(right_tree) != CONST_DECL + DECL_P(right_tree))) { make_tmp = NULL_TREE; arg = build_fold_addr_expr_loc(location.gcc_location(), right_tree);
Re: [Ada] Restrict propagation of atomicity from objects to types
Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Eric Botcazou ebotca...@adacore.com * sem_prag.adb (Process_Atomic_Shared_Volatile): Propagate atomicity from an object to its underlying type only if it is composite. Backported to the 4.7 branch after testing on x86/ and PowerPC/Linux. -- Eric Botcazou
Merge from gcc-4_7-branch to gccgo branch
I've merged gcc 4.7 branch revision 187554 to the gccgo branch. Ian
[Fortran, patch] PR 48831 - Constant expression (PARAMETER array element) rejected as nonconstant
Hi All, in attachment there's a patch for PR 48831, it also includes a new test case suggested by Tobias Burnus. The patch is bootstrapped and tested on x86_64-unknown-linux-gnu. Regards. Alessandro Fanfarillo patch.diff Description: Binary data
Re: patch for PR53125
On 05/15/2012 07:59 AM, Steven Bosscher wrote: On Fri, May 11, 2012 at 8:42 PM, Steven Bosscherstevenb@gmail.com wrote: Now with patch On Fri, May 11, 2012 at 8:42 PM, Steven Bosscherstevenb@gmail.com wrote: 2012-05-10 Vladimir Makarovvmaka...@redhat.com PR rtl-optimization/53125 * ira.c (ira): Call find_moveable_pseudos and move_unallocated_pseudos if only ira_conflicts_p is true. And the attached patch fixes the reginfo slowness. The reginfo pass was doing: for each bb: for each insn in bb, from BB_END(bb) to BB_HEAD(bb): for each reg that died between BB_END(bb) and insn: // i.e. register is live at insn REG_LIVE_LENGTH(reg)++ With very large basic blocks, and the kind of code for the test case of the PR results in many live registers for SPARC (for x86_64 there are far fewer live registers). For SPARC, there are O(1e5) insns and O(1e4) registers live for most of the basic block. That is effectively almost quadratic behavior in the number of insns per basic block. But the above loop is a bit silly. It is much easier and computationally cheaper to just remember at what insn reg died (last used), and add to REG_LIVE_LENGTH the distance from the insn that sets reg to the insn that used reg. It turns out that (before or after the patch) partial or conditional sets never kill a register, so that REG_LIVE_LENGTH for registers set by partial or conditional stores is not very accurate. I have a few ideas for how to improve that situation a bit, but I'm not sure if it's worth the trouble. I also think that the computation of REG_FREQ and REG_FREQ_CALLS_CROSSED has been wrong for some time. The maximum REG_FREQ is REG_FREQ_MAX (see regs.h) but regstat.c just accumulates REG_FREQ_FROM_BB. I've added a few lines to limit the REG_FREQ to REG_FREQ_MAX, e.g.: REG_FREQ (dregno) += REG_FREQ_FROM_BB (bb); + REG_FREQ (dregno) = + MIN (REG_FREQ (dregno), REG_FREQ_MAX); With this patch, the reginfo pass disappears from the time report for the test case attached to PR53125, compiled at -O0. Bootstrapped and tested on x86_64-unknown-linux-gnu, and I verified for a few simple test cases that the computed REG_LIVE_LENGHTs are unchanged. OK for trunk? Sorry, Steven. I believe that regstat.c is a part of DF-infrastructure. At least, it was introduced by this work. Therefore I did not respond to your email and probably can not have a right to approve the patch. May be Kenny or Paolo (as the most active reviewers of DF-infrastructure these days) can help you with the approval.
Re: find_movable_pseudos vs. split moves (was Re: rx-elf fails after r187015)
On 05/15/2012 09:08 AM, Richard Sandiford wrote: DJ Deloried...@redhat.com writes: After r187015 (Mar 31), gcc builds for rx-elf are failing with: make[3]: Entering directory `/greed/dj/m32c/gcc/rx-elf-head/rx-elf/64-bit-double/libgcc' # If this is the top-level multilib, build all the other # multilibs. /greed/dj/m32c/gcc/rx-elf-head/./gcc/xgcc -B/greed/dj/m32c/gcc/rx-elf-head/./gcc/ -B/greed/dj/m32c/install/rx-elf/bin/ -B/greed/dj/m32c/install/rx-elf/lib/ -isystem /greed/dj/m32c/install/rx-elf/include -isystem /greed/dj/m32c/install/rx-elf/sys-include-g -O2 -m64bit-doubles -O2 -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc -I. -I. -I../../.././gcc -I../../../../gcc/libgcc -I../../../../gcc/libgcc/. -I../../../../gcc/libgcc/../gcc -I../../../../gcc/libgcc/../include -DHAVE_CC_TLS -DUSE_EMUTLS -o _mulvdi3.o -MT _mulvdi3.o -MD -MP -MF _mulvdi3.dep -DL_mulvdi3 -c ../../../../gcc/libgcc/libgcc2.c ../../../../gcc/libgcc/libgcc2.c: In function '__mulvdi3': ../../../../gcc/libgcc/libgcc2.c:397:1: internal compiler error: in subreg_get_info, at rtlanal.c:3308 } ^ Can anyone else confirm this? I can well believe that that patch exposed the problem, but the bug seems to be in IRA. find_moveable_pseudos tries to redirect a DImode multiplication to a new register, then copies the new register to the original one before the first use. The problem here is that rx has no DImode move pattern, so we end up splitting the DImode move into two SImode moves and a clobber. When allocation fails for the new register, move_unallocated_pseudos deletes one of these three instructions, but the other two are left around. reload then gets confused because we have a subreg of a pseudo that isn't allocated and has no stack slot. One fix would be to check whether the backend has a move pattern. I don't particularly like that though, since I don't think targets like rx should be punished for not defining a DImode move. The fact that the first lower-subreg pass is so early in the rtl pipeline suggests that having unitary multiword moves shouldn't be important these days. This patch instead deletes all instructions that set the new register. One advantage is that IRA no longer needs to track the move specially. Tested by making sure that rx-elf build again and that the new code deletes all three instructions generated by gen_move_insn. Also bootstrapped regression-tested on x86_64-linux-gnu. OK to install? Richard gcc/ * ira.c (pseudo_move_insn): Delete. (find_moveable_pseudos): Don't set it. (move_unallocated_pseudos): Use DF_REG_DEF_CHAIN to find the definitions of the original pseudo. Delete all of them. Ok. Thanks for working on this problem, Richard.
Re: [C++ Patch] PR 11586
On 05/15/2012 03:14 PM, Jason Merrill wrote: OK. Thanks. I applied the patch. However, I just noticed that I somehow missed a small issue in the testsuite (sorry): we have a testcase which is now failing because in templates we don't warn anymore (the warning is produced by warn_for_div_by_zero which also uses c_inhibit_evaluation_warnings). Is the attached tweak Ok or we want something more sophisticated? Thanks, Paolo. Index: crash10.C === --- crash10.C (revision 187551) +++ crash10.C (working copy) @@ -3,7 +3,7 @@ templateint M, int N class GCD { public: - enum { val = (N == 0) ? M : GCDN, M % N::val }; // { dg-warning division division } + enum { val = (N == 0) ? M : GCDN, M % N::val }; // { dg-error constant expression valid { target *-*-* } 6 } // { dg-message template argument valid { target *-*-* } 6 } };
Re: [C++ Patch] PR 44516
Hi, On 05/15/2012 08:53 PM, Jason Merrill wrote: On 05/14/2012 07:17 PM, Paolo Carlini wrote: @@ -5670,7 +5672,8 @@ build_x_compound_expr_from_list (tree list, expr_l return error_mark_node; for (list = TREE_CHAIN (list); list; list = TREE_CHAIN (list)) -expr = build_x_compound_expr (expr, TREE_VALUE (list), +expr = build_x_compound_expr (EXPR_LOC_OR_HERE (expr), expr, + TREE_VALUE (list), complain); For a COMPOUND_EXPR, I think the relevant location is that of the comma, and since we don't have that location I think the location of the second expression is a closer approximation. Ok, should be fixed now. I think I got the location of the comma right in the parser, but then was indeed unsure about the best thing to do here. Should have asked explicitly. Note that when copying the location from one expression to another, EXPR_LOC_OR_HERE will change UNKNOWN_LOCATION to input_location, whereas EXPR_LOCATION will leave it alone. Thanks for the useful clarification. I'm trying to put it to good use in the new patch below, which additionally takes care of build_min_non_dep: if I understand correctly, for all the uses of those, similarly to the build_x_compound_expr callers above, when copying the location we want EXPR_LOCATION (indeed, in my experiments, the source expr turns out to not have a location quite a few times and trying to use EXPR_LOC_OR_HERE leads to diagnostic regressions: concrete example, build_x_binary_op vs libstdc++-v3/testsuite/20_util/bind/ref_neg.cc) Tested x86_64-linux. Thanks! Paolo. / gcc/cp 2012-05-15 Paolo Carlini paolo.carl...@oracle.com PR c++/44516 * typeck.c (build_x_array_ref, build_x_conditional_expr, build_x_compound_expr, build_x_modify_expr): Add location_t parameter. (finish_class_member_access_expr, build_x_indirect_ref, build_x_binary_op, build_x_compound_expr_from_list, build_x_compound_expr_from_vec): Adjust callers. * tree.c (build_min_nt_loc, build_min_non_dep_loc): New. (build_min_nt, build_min_non_dep): Remove. * typeck2.c (build_x_arrow): Adjust callers. * pt.c (tsubst_qualified_id, tsubst_omp_for_iterator, tsubst_copy_and_build): Likewise. * semantics.c (finish_mem_initializers, handle_omp_for_class_iterator, finish_omp_atomic): Likewise. * decl2.c (grok_array_decl, build_anon_union_vars): Adjust. * parser.c (cp_parser_question_colon_clause, cp_parser_assignment_expression, cp_parser_expression, cp_parser_template_id, cp_parser_omp_for_loop): Likewise. * cp-tree.h: Update. gcc/testsuite 2012-05-15 Paolo Carlini paolo.carl...@oracle.com PR c++/44516 * g++.dg/parse/error48.C: New. * g++.dg/template/crash89.C: Adjust dg-error line numbers. libstdc++ 2012-05-15 Paolo Carlini paolo.carl...@oracle.com PR c++/44516 * testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Adjust dg-error line number. Index: libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc === --- libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc (revision 187550) +++ libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc (working copy) @@ -2,7 +2,7 @@ // { dg-options -std=gnu++0x } // { dg-require-cstdint } -// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation +// Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -51,5 +51,5 @@ test04() // { dg-error required from here { target *-*-* } 46 } // { dg-error denominator cannot be zero { target *-*-* } 265 } // { dg-error out of range { target *-*-* } 266 } -// { dg-error overflow in constant expression { target *-*-* } 61 } +// { dg-error overflow in constant expression { target *-*-* } 62 } // { dg-prune-output not a member } Index: gcc/testsuite/g++.dg/parse/error48.C === --- gcc/testsuite/g++.dg/parse/error48.C(revision 0) +++ gcc/testsuite/g++.dg/parse/error48.C(revision 0) @@ -0,0 +1,10 @@ +// PR c++/44516 + +struct WebService { }; +struct Server { }; + +void addHTTPService(Server const server, + WebService const *http) +{ + server += http; // { dg-error 10:no match for 'operator\\+=' } +} Index: gcc/testsuite/g++.dg/template/crash89.C === --- gcc/testsuite/g++.dg/template/crash89.C (revision 187551) +++ gcc/testsuite/g++.dg/template/crash89.C (working copy) @@ -1,8 +1,8 @@ // PR c++/34397 -templatetypename T, int = T()[0] struct A +templatetypename T, int =
Re: find_movable_pseudos vs. split moves (was Re: rx-elf fails after r187015)
gcc/ * ira.c (pseudo_move_insn): Delete. (find_moveable_pseudos): Don't set it. (move_unallocated_pseudos): Use DF_REG_DEF_CHAIN to find the definitions of the original pseudo. Delete all of them. I can build with this. Thanks!
Re: Turn check macros into functions. (issue6188088)
On May 15, 2012, at 11:23 AM, Steven Bosscher wrote: On Tue, May 15, 2012 at 7:19 PM, Lawrence Crowl cr...@google.com wrote: The gcc source uses several constructs that GDB does not understand. This patch corrects some of them. It affects only compilers built with ENABLE_TREE_CHECKING, and hence release compilers are unaffected. Index: gcc/ChangeLog.cxx-conversion (...) 2012-05-15 Lawrence Crowl cr...@google.com Is this something you could do for the mainline instead? If not, then I hope it will land there some day. I now usually build my debug compilers with checking disabled to work around this issue.. Gosh, we compile with -g3, and use: macro define TREE_CHECK(T, CODE) (T) macro define TREE_NOT_CHECK(T, CODE) (T) macro define TREE_CHECK2(T, CODE1, CODE2) (T) macro define TREE_NOT_CHECK2(T, CODE1, CODE2) (T) macro define TREE_CHECK3(T, CODE1, CODE2, CODE3) (T) macro define TREE_NOT_CHECK3(T, CODE1, CODE2, CODE3) (T) macro define TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) (T) macro define NON_TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) (T) macro define TREE_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) (T) macro define TREE_NOT_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) (T) macro define CONTAINS_STRUCT_CHECK(T, STRUCT) (T) macro define TREE_CLASS_CHECK(T, CLASS) (T) macro define TREE_RANGE_CHECK(T, CODE1, CODE2) (T) macro define OMP_CLAUSE_SUBCODE_CHECK(T, CODE) (T) macro define OMP_CLAUSE_RANGE_CHECK(T, CODE1, CODE2) (T) macro define EXPR_CHECK(T) (T) macro define NON_TYPE_CHECK(T) (T) macro define TREE_VEC_ELT_CHECK(T, I) ((T)-vec.a[I]) macro define OMP_CLAUSE_ELT_CHECK(T, I) ((T)-omp_clause.ops[I]) macro define TREE_OPERAND_CHECK(T, I) ((T)-exp.operands[I]) macro define TREE_OPERAND_CHECK_CODE(T, CODE, I) ((T)-exp.operands[I]) macro define TREE_CHAIN(T) ((T)-common.chain) macro define TREE_TYPE(T) ((T)-common.type) macro define RTL_FLAG_CHECK1(N, R, C1) (R) macro define RTL_FLAG_CHECK2(N, R, C1, C2) (R) macro define RTL_FLAG_CHECK3(N, R, C1, C2, C3) (R) macro define RTL_FLAG_CHECK4(N, R, C1, C2, C3, C4) (R) macro define RTL_FLAG_CHECK5(N, R, C1, C2, C3, C4, C5) (R) macro define RTL_FLAG_CHECK6(N, R, C1, C2, C3, C4, C5, C6) (R) macro define RTL_FLAG_CHECK7(N, R, C1, C2, C3, C4, C5, C6, C7) (R) macro define RTL_FLAG_CHECK8(N, R, C1, C2, C3, C4, C5, C6, C7, C8) (R) in gdbinit.in. This gets you 99% of the way there. The -g3 is annoying, as the sizes are large, fast machines, nice filesystems and ssd disks or better and help lesson the cost. This gives up checking during gdb usage, I've not found that to be a problem yet. I think this is fine for release branches and older software. For trunk, I do like a _better_ solution, like the first patch in this thread when it can go in. :-)
Re: gnu-tm: Dont allow assigning transaction_unsafe functions to transaction_safe function pointers (issue6198054)
Follow-up of Dave's patch. I would prefer to see such checks in trans-mem.c as follows. In a transaction, a function pointer can be declared and assigned but there is no check that the function pointer is transaction_safe. So at runtime, if the function was unsafe, libitm stops on assert because the clone is not found. Tested on i686. Is the patch ok? Thanks. BTW, Should we generate a warning or an error? -- 2012-05-15 Patrick Marlier patrick.marl...@gmail.com * trans-mem.c (diagnose_tm_1_op): Warn about assignment of transaction unsafe function to safe function pointer. testsuite/ 2012-05-15 Patrick Marlier patrick.marl...@gmail.com * c-c++-common/tm/indirect-1.c: New test. On 05/15/2012 12:23 PM, Torvald Riegel wrote: On Tue, 2012-05-08 at 18:02 -0500, Dave Boutcher wrote: Without this patch it is perfectly fine to assign non-transaction_safe functions to function pointers marked as transaction_safe. Unpleasantness happens at run time. e.g. __attribute__((transaction_safe)) long (*compare)(int, int); compare = my_funky_random_function; gcc/c-typeck.c |7 +++ 1 file changed, 7 insertions(+) diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index fc01a79..69687d6 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -5608,6 +5608,13 @@ convert_for_assignment (location_t location, tree type, tree rhs, } } + /* Check for assignment to transaction safe */ + if (is_tm_safe(type) !is_tm_safe_or_pure (rhs)) { I don't think that assigning a tm_pure function to tm_safe works. There will be no instrumented version of it. I don't think we generate an alias or sth like that yet. When contributing patches, please submit testcases along with it. For example, regarding this particular problem, I would believe that there are more cases that we don't check properly yet. Also, did you do the FSF copyright assignment paperwork yet? Torvald Index: trans-mem.c === --- trans-mem.c (revision 187371) +++ trans-mem.c (working copy) @@ -572,6 +572,16 @@ diagnose_tm_1_op (tree *tp, int *walk_subtrees ATT *tp); } + if (code == VAR_DECL + TREE_CODE (TREE_TYPE (*tp)) == POINTER_TYPE + ((d-block_flags (DIAG_TM_SAFE | DIAG_TM_RELAXED)) + || (d-func_flags DIAG_TM_SAFE)) + is_gimple_assign (d-stmt) + is_tm_safe (*tp) + !is_tm_safe (gimple_assign_rhs1 (d-stmt))) +warning_at (gimple_location (d-stmt), 0, Assigning unsafe function to + transaction_safe function pointer); + return NULL_TREE; } Index: testsuite/c-c++-common/tm/indirect-1.c === --- testsuite/c-c++-common/tm/indirect-1.c (revision 0) +++ testsuite/c-c++-common/tm/indirect-1.c (revision 0) @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options -fgnu-tm } */ + +__attribute__((transaction_safe)) void (*func_ptr)(void); + +void bar(void); + +__attribute__((transaction_safe)) +void foo1(void) +{ + func_ptr = bar; /* { dg-warning Assigning unsafe function to transaction_safe } */ +} + +void foo2(void) +{ + func_ptr = bar; +} + +void foo3(void) +{ + __transaction_atomic { +func_ptr = bar; /* { dg-warning Assigning unsafe function to transaction_safe } */ + } +} +
Re: [google/gcc-4_7] Allow static const floats unless -pedantic is passed (issue6212051)
Looks good to me. Yay for kicking the can down the road. ;) On Tue, May 15, 2012 at 12:57 PM, Ollie Wild a...@google.com wrote: To be applied to google/gcc-4_7. Allow static const floats unless -pedantic is passed. This patch allows us to migrate to C++11 more incrementally, since we can leave the static const float initializations in place, flip the switch, and then change it to use constexpr. This is a forward port of r180638 from google/gcc-4_6 (despite the fact that that revision says to NOT forward-port this). Minor additional fixups have been applied. 2012-05-15 Ollie Wild a...@google.com * gcc/cp/decl.c (check_static_variable_definition): Only generate a constexpr warning when -pedantic is enabled. * gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C: Replace -fpermissive with -pedantic. * gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C: New test. * gcc/testsuite/g++.old-deja/g++.ext/memconst.C: Compile with -pedantic -pedantic-errors to work around test failures with -std=gnu++11. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index bb26d15..d2fe731 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7861,9 +7861,18 @@ check_static_variable_definition (tree decl, tree type) error (in-class initialization of static data member %q#D of incomplete type, decl); else if (literal_type_p (type)) - permerror (input_location, - %constexpr% needed for in-class initialization of - static data member %q#D of non-integral type, decl); + { + /* FIXME google: This local modification allows us to + transition from C++98 to C++11 without moving static + const floats out of the class during the transition. It + should not be forward-ported to a 4.8 branch, since by + then we should be able to just fix the code to use + constexpr. */ + pedwarn (input_location, OPT_pedantic, + %constexpr% needed for in-class initialization of + static data member %q#D of non-integral type, decl); + return 0; + } else error (in-class initialization of static data member %q#D of non-literal type, decl); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C index 7c84cf8..658a458 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C @@ -1,5 +1,5 @@ // PR c++/50258 -// { dg-options -std=c++0x -fpermissive } +// { dg-options -std=c++0x -pedantic } struct Foo { static const double d = 3.14; // { dg-warning constexpr } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C new file mode 100644 index 000..28d34a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C @@ -0,0 +1,7 @@ +// PR c++/50258 +// { dg-options -std=c++0x } + +struct Foo { + static const double d = 3.14; // no warning +}; +const double Foo::d; diff --git a/gcc/testsuite/g++.old-deja/g++.ext/memconst.C b/gcc/testsuite/g++.old-deja/g++.ext/memconst.C index d934763..7e86156 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/memconst.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/memconst.C @@ -1,5 +1,5 @@ // { dg-do assemble } -// { dg-options } +// { dg-options -pedantic -pedantic-errors } // From: ove.ewer...@syscon.uu.se (Ove Ewerlid) // Subject: ss-940630:cc1plus: internal error // Date: Sat, 2 Jul 1994 05:07:20 +0200 -- This patch is available for review at http://codereview.appspot.com/6212051
Re: trans-mem: functions making indirect calls are not transformed (issue6194061)
Follow-up of Dave's patch with a testcase. Functions with indirect calls must be transactified (transformed). Tested on i686. Ok for trunk? -- Patrick 2012-05-15 Dave Boutcher daveboutc...@gmail.com Patrick Marlier patrick.marl...@gmail.com * trans-mem.c (ipa_tm_transform_clone): Transform functions with indirect calls. 2012-05-15 Patrick Marlier patrick.marl...@gmail.com * gcc.dg/tm/indirect-2.c: New test. On 05/08/2012 06:40 PM, Dave Boutcher wrote: gcc/trans-mem.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index 2badf25..24073fa 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -4721,7 +4721,7 @@ ipa_tm_transform_clone (struct cgraph_node *node) /* If this function makes no calls and has no irrevocable blocks, then there's nothing to do. */ /* ??? Remove non-aborting top-level transactions. */ - if (!node-callees !d-irrevocable_blocks_clone) + if (!node-callees !node-indirect_calls !d-irrevocable_blocks_clone) return; current_function_decl = d-clone-decl; Index: testsuite/gcc.dg/tm/indirect-2.c === --- testsuite/gcc.dg/tm/indirect-2.c (revision 0) +++ testsuite/gcc.dg/tm/indirect-2.c (revision 0) @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options -fgnu-tm } */ + +void __attribute__((transaction_safe)) +foo(void); + +void __attribute__((transaction_safe)) +set_fn(void) +{ + void __attribute__((transaction_safe)) (*fn)(void); + fn = foo; + fn(); +} + +/* { dg-final { scan-assembler _ITM_getTMCloneSafe } } */ Index: trans-mem.c === --- trans-mem.c (revision 187371) +++ trans-mem.c (working copy) @@ -4732,7 +4732,7 @@ ipa_tm_transform_clone (struct cgraph_node *node) /* If this function makes no calls and has no irrevocable blocks, then there's nothing to do. */ /* ??? Remove non-aborting top-level transactions. */ - if (!node-callees !d-irrevocable_blocks_clone) + if (!node-callees !node-indirect_calls !d-irrevocable_blocks_clone) return; current_function_decl = d-clone-symbol.decl;
Re: [C++ Patch] PR 44516
On 05/15/2012 04:56 PM, Paolo Carlini wrote: @@ -2753,7 +2754,8 @@ build_x_indirect_ref (location_t loc, tree expr, r rval = cp_build_indirect_ref (expr, errorstring, complain); if (processing_template_decl rval != error_mark_node) -return build_min_non_dep (INDIRECT_REF, rval, orig_expr); +return build_min_non_dep_loc (EXPR_LOCATION (rval), INDIRECT_REF, Shouldn't this use loc? If rval comes from cp_build_indirect_ref, it might not have the right location. @@ -3621,15 +3623,16 @@ build_x_binary_op (location_t loc, enum tree_code warn_about_parentheses (code, arg1_code, orig_arg1, arg2_code, orig_arg2); if (processing_template_decl expr != error_mark_node) -return build_min_non_dep (code, expr, orig_arg1, orig_arg2); - +return build_min_non_dep_loc (EXPR_LOCATION (expr), code, expr, Likewise. Similarly in build_x_array_ref, build_x_unary_op, build_x_conditional_expr, build_x_compound_expr. I still see a lot of EXPR_LOC_OR_HERE in the patch, is that deliberate? Jason
Re: [C++ Patch] PR 11586
On 05/15/2012 04:40 PM, Paolo Carlini wrote: However, I just noticed that I somehow missed a small issue in the testsuite (sorry): we have a testcase which is now failing because in templates we don't warn anymore (the warning is produced by warn_for_div_by_zero which also uses c_inhibit_evaluation_warnings). Is the attached tweak Ok or we want something more sophisticated? The tweak is OK. Jason
Re: [google/google-main] Fix regression - SUBTARGET_EXTRA_SPECS overridden by LINUX_GRTE_EXTRA_SPECS (issue 6016047)
I suspect this patch would change specs of non-i386 platform. For example, LINUX_GRTE_EXTRA_SPECS is not part of SUBTARGET_EXTRA_SPECS for darwin. Can you tell where SUBTARGET_EXTRA_SPECS is firstly defined for chromeos toolchain? On 2012/05/14 18:32:17, shenhan wrote: On 2012/04/12 21:14:29, shenhan wrote: Hi, the newest chrome gcc (from google-main) fails to linking anything, by looking into specs file, it seems that 'link_emulation' section is missing in specs. The problem I found is that SUBTARGET_EXTRA_SPECS, which is not empty for chromeos, is overridden by LINUX_GRTE_EXTRA_SPECS. Please review the proposed a patch. (Tested by buildit bootstrap). -Han Hi Jing and Rong, could you take a look at this? Thanks, -Han http://codereview.appspot.com/6016047/
Go patch committed: Sort array constructors by index
This patch to the Go frontend sorts array constructors by index. That is what the middle-end expects. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch. Ian diff -r b4118d35075b go/expressions.cc --- a/go/expressions.cc Tue May 15 12:58:54 2012 -0700 +++ b/go/expressions.cc Tue May 15 15:28:14 2012 -0700 @@ -11794,8 +11794,7 @@ if (this-indexes() == NULL) max_index = this-vals()-size() - 1; else - max_index = *std::max_element(this-indexes()-begin(), - this-indexes()-end()); + max_index = this-indexes()-back(); tree max_tree = size_int(max_index); tree constructor_type = build_array_type(element_type_tree, build_index_type(max_tree)); @@ -12546,6 +12545,17 @@ return ret; } +// Used to sort an index/value array. + +class Index_value_compare +{ + public: + bool + operator()(const std::pairunsigned long, Expression* a, + const std::pairunsigned long, Expression* b) + { return a.first b.first; } +}; + // Lower an array composite literal. Expression* @@ -12557,6 +12567,7 @@ std::vectorunsigned long* indexes = new std::vectorunsigned long; indexes-reserve(this-vals_-size()); + bool indexes_out_of_order = false; Expression_list* vals = new Expression_list(); vals-reserve(this-vals_-size()); unsigned long index = 0; @@ -12627,6 +12638,9 @@ return Expression::make_error(location); } + if (!indexes-empty() index indexes-back()) + indexes_out_of_order = true; + indexes-push_back(index); } @@ -12641,6 +12655,34 @@ indexes = NULL; } + if (indexes_out_of_order) +{ + typedef std::vectorstd::pairunsigned long, Expression* V; + + V v; + v.reserve(indexes-size()); + std::vectorunsigned long::const_iterator pi = indexes-begin(); + for (Expression_list::const_iterator pe = vals-begin(); + pe != vals-end(); + ++pe, ++pi) + v.push_back(std::make_pair(*pi, *pe)); + + std::sort(v.begin(), v.end(), Index_value_compare()); + + delete indexes; + delete vals; + indexes = new std::vectorunsigned long(); + indexes-reserve(v.size()); + vals = new Expression_list(); + vals-reserve(v.size()); + + for (V::const_iterator p = v.begin(); p != v.end(); ++p) + { + indexes-push_back(p-first); + vals-push_back(p-second); + } +} + return this-make_array(type, indexes, vals); } @@ -12661,7 +12703,9 @@ size_t size; if (vals == NULL) size = 0; - else if (indexes == NULL) + else if (indexes != NULL) + size = indexes-back() + 1; + else { size = vals-size(); Integer_type* it = Type::lookup_integer_type(int)-integer_type(); @@ -12672,11 +12716,6 @@ return Expression::make_error(location); } } - else - { - size = *std::max_element(indexes-begin(), indexes-end()); - ++size; - } mpz_t vlen; mpz_init_set_ui(vlen, size); @@ -12704,8 +12743,7 @@ } else { - unsigned long max = *std::max_element(indexes-begin(), - indexes-end()); + unsigned long max = indexes-back(); if (max = val) { error_at(location,
Fix PR ada/52494
Andris Pavenis devised this patch to fix the build for targets which use the s-taprop-dummy.adb package. Applied on mainline and 4.7 branch. 2012-05-15 Andris Pavenis andris.pave...@iki.fi PR ada/52494 * s-taprop-dummy.adb (Specific): New package. -- Eric Botcazou --- s-taprop-dummy.adb~ 2012-03-04 16:40:49.677874262 +0100 +++ s-taprop-dummy.adb 2012-03-05 21:11:44.270307016 +0100 @@ -46,6 +46,28 @@ pragma Warnings (Off); -- Turn off warnings since so many unreferenced parameters + + -- Local Packages -- + + + package Specific is + + procedure Set (Self_Id : Task_Id); + pragma Inline (Set); + -- Set the self id for the current task + + end Specific; + + package body Specific is + + procedure Set (Self_Id : Task_Id) is + begin + null; + end Set; + + end Specific; + -- The body of this package is target specific + -- -- ATCB allocation/deallocation -- --
Re: [C++ Patch] PR 44516
Hi, On 05/16/2012 12:11 AM, Jason Merrill wrote: On 05/15/2012 04:56 PM, Paolo Carlini wrote: @@ -2753,7 +2754,8 @@ build_x_indirect_ref (location_t loc, tree expr, r rval = cp_build_indirect_ref (expr, errorstring, complain); if (processing_template_decl rval != error_mark_node) -return build_min_non_dep (INDIRECT_REF, rval, orig_expr); +return build_min_non_dep_loc (EXPR_LOCATION (rval), INDIRECT_REF, Shouldn't this use loc? If rval comes from cp_build_indirect_ref, it might not have the right location. @@ -3621,15 +3623,16 @@ build_x_binary_op (location_t loc, enum tree_code warn_about_parentheses (code, arg1_code, orig_arg1, arg2_code, orig_arg2); if (processing_template_decl expr != error_mark_node) -return build_min_non_dep (code, expr, orig_arg1, orig_arg2); - +return build_min_non_dep_loc (EXPR_LOCATION (expr), code, expr, Likewise. Similarly in build_x_array_ref, build_x_unary_op, build_x_conditional_expr, build_x_compound_expr. I can't change the build_min_non_dep_loc call in build_x_binary_op to simply use loc, that causes the diagnostic regression I mentioned before. Sorry, I wasn't clear in my previous message, it happens when one naturally just passes loc, not the EXPR_LOCATION from the intermediate expr. Indeed, in all the calls you mentioned I naturally passed a couple of days ago loc in my local tree, then when I saw that library testcase with the wrong location in some error messages I stopped. Today, I fooled myself into believing that I should have passes the location via EXPR_LOCATION from the intermediate expr and tried quickly to prepare something. This requires more analysis. Is it Ok with you if we return to a patch only touching the build_min_nt_locs? I still see a lot of EXPR_LOC_OR_HERE in the patch, is that deliberate? Now that you are asking, I can re-analyze those which I added a couple of days ago. Paolo.
Go patch committed: Fix taking address of constant outside function
This patch to the Go frontend extends the code I committed earlier today for taking the address of a constant to work outside of a function. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch. Ian diff -r f37debbb3806 go/expressions.cc --- a/go/expressions.cc Tue May 15 15:29:37 2012 -0700 +++ b/go/expressions.cc Tue May 15 15:45:22 2012 -0700 @@ -4048,15 +4048,46 @@ TREE_CODE(expr) != INDIRECT_REF TREE_CODE(expr) != COMPONENT_REF) { - tree tmp = create_tmp_var(TREE_TYPE(expr), get_name(expr)); - DECL_IGNORED_P(tmp) = 1; - DECL_INITIAL(tmp) = expr; - TREE_ADDRESSABLE(tmp) = 1; - return build2_loc(loc.gcc_location(), COMPOUND_EXPR, - build_pointer_type(TREE_TYPE(expr)), - build1_loc(loc.gcc_location(), DECL_EXPR, - void_type_node, tmp), - build_fold_addr_expr_loc(loc.gcc_location(), tmp)); + if (current_function_decl != NULL) + { + tree tmp = create_tmp_var(TREE_TYPE(expr), get_name(expr)); + DECL_IGNORED_P(tmp) = 1; + DECL_INITIAL(tmp) = expr; + TREE_ADDRESSABLE(tmp) = 1; + return build2_loc(loc.gcc_location(), COMPOUND_EXPR, +build_pointer_type(TREE_TYPE(expr)), +build1_loc(loc.gcc_location(), DECL_EXPR, + void_type_node, tmp), +build_fold_addr_expr_loc(loc.gcc_location(), + tmp)); + } + else + { + tree tmp = build_decl(loc.gcc_location(), VAR_DECL, +create_tmp_var_name(A), TREE_TYPE(expr)); + DECL_EXTERNAL(tmp) = 0; + TREE_PUBLIC(tmp) = 0; + TREE_STATIC(tmp) = 1; + DECL_ARTIFICIAL(tmp) = 1; + TREE_ADDRESSABLE(tmp) = 1; + tree make_tmp; + if (!TREE_CONSTANT(expr)) + make_tmp = fold_build2_loc(loc.gcc_location(), INIT_EXPR, + void_type_node, tmp, expr); + else + { + TREE_READONLY(tmp) = 1; + TREE_CONSTANT(tmp) = 1; + DECL_INITIAL(tmp) = expr; + make_tmp = NULL_TREE; + } + rest_of_decl_compilation(tmp, 1, 0); + tree addr = build_fold_addr_expr_loc(loc.gcc_location(), tmp); + if (make_tmp == NULL_TREE) + return addr; + return build2_loc(loc.gcc_location(), COMPOUND_EXPR, +TREE_TYPE(addr), make_tmp, addr); + } } return build_fold_addr_expr_loc(loc.gcc_location(), expr);
Merge from gcc-4_7-branch to gccgo branch
I have done yet another merge from gcc-4_7-branch to gccgo branch, this time from revision 187566. Ian
Re: Turn check macros into functions. (issue6188088)
On 12-05-15 13:19 , Lawrence Crowl wrote: The gcc source uses several constructs that GDB does not understand. This patch corrects some of them. It affects only compilers built with ENABLE_TREE_CHECKING, and hence release compilers are unaffected. In particular, I change the implementation of CHECK macros using __extension__ into macros calling template inline functions. I do not change the accessor macros themselves. I was going to ask you about effects on code size, but I had a clean build tree around so I could do some comparisons. Your patch reduces code size by about 1%. Before the patch: textdata bss dec hex filename 14,576,887 43008 1438432 16058327 f507d7 cc1 15,121,560 52048 1443504 16617112 fd8e98 f951 13,896,410 43760 1434640 15374810 ea99da jc1 13,673,077 42216 1435680 15150973 e72f7d lto1 After the patch: $ size *1 | grep -v libgcc textdata bss dec hex filename 14,390,489 43008 1438432 15871929 f22fb9 cc1 (-1.28%) 14,940,242 52048 1443504 16435794 faca52 f951 (-1.20%) 13,716,108 43760 1434640 15194508 e7d98c jc1 (-1.30%) 13,490,551 42216 1435680 14968447 e4667f lto1 (-1.33%) Clearly, this will only affect binaries built with --enable-checking. But this is a good result anyway. Thanks. Diego.
Re: [C++ Patch] PR 44516
On 05/15/2012 06:44 PM, Paolo Carlini wrote: I can't change the build_min_non_dep_loc call in build_x_binary_op to simply use loc, that causes the diagnostic regression I mentioned before. Sorry, I wasn't clear in my previous message, it happens when one naturally just passes loc, not the EXPR_LOCATION from the intermediate expr. Because loc is wrong? Is it Ok with you if we return to a patch only touching the build_min_nt_locs? It seems like as long as we're messing with this area we ought to finish the job, but if you want to split up the patch that's fine. Jason
Re: [Patch / RFC] PR 39681
OK. Jason