Re: [lra] spilling general class pseudos into SSE regs instead of memory (a target hooks driven implementation)
On Wed, Mar 28, 2012 at 1:07 AM, Vladimir Makarov vmaka...@redhat.com wrote: The following patch implements general spilling one class pseudos into another class hard registers *instead of memory* in LRA. Can't find the patch itself - Joey
Re: [PATCH, i386]: FIX PR 52698, reload failure with complex address
On Tue, Mar 27, 2012 at 7:20 PM, Richard Henderson r...@redhat.com wrote: On 03/27/12 09:37, Uros Bizjak wrote: Now, in this particular case, there might be another option to avoid this hassle completely: I understand that this UNSPEC is simply a magic marker to make the address use the fs: or gs: segment override, right? Now that GCC supports address spaces, it might be possible to model fs:/gs: relative addresses instead by using a non-standard address space ... This is an interesting idea, I will look into it. Generallized segment overrides via non-standard address spaces has been on my to-do list for quite a while... What about release branches? While this issue didn't trigger there yet, it can be triggered by some bad RA decision, and the fixup is missing. Uros.
Re: [PATCH] Bug fix in store_bit_field_1 for big endian targets (issue 51893)
On Tue, 27 Mar 2012, Eric Botcazou wrote: Changelog: * expmed.c (store_bit_field_1): Fix wordnum value for big endian targets The author line was missing so I put: 2012-03-27 Aurelien Buhrig aurelien.buhrig@gmail.com PR middle-end/51893 * expmed.c (store_bit_field_1): Fix wordnum value for big-endian targets. Will this fix be backported to 4.6 branch for next release? The policy is to put only fixes for regressions on release branches, and this is obviously not a regression. I think we might want to put it on the 4.7 branch though, because it's early in the release cycle and we fixed a twin bug on that branch (PR middle-end/50325). But it's up to the RMs, now CCed. Yes, it's ok for the 4.7 branch. Richard.
Re: Fix PR rtl-optimization/52629
On Tue, 27 Mar 2012, Eric Botcazou wrote: Bootstrapped/regtested on x86_64-suse-linux, applied on mainline. Should it be applied to the release branches as well? 2012-03-26 Eric Botcazou ebotca...@adacore.com PR rtl-optimization/52629 * reload1.c (count_pseudo): Short-circuit common case. (count_spilled_pseudo): Return early for pseudos without hard regs. Assert that the pseudo has got a hard reg before manipulating it. RMs, what's your decision? What's the impact of this bug? If it is a wrong-code or ice-on-valid bug then it's ok for the 4.7 branch. Richard.
Re: [patch, fortran-dev] Use fixed variable sizes for stride calculations
On Sat, Mar 24, 2012 at 16:13, Thomas Koenig tkoe...@netcologne.de wrote: Hello world, this patch uses division by known sizes (which can usually be replaced by a simple shift because intrinsics have sizes of power of two) instead of division by the size extracted from the array descriptor itself. This should save about 20 cycles for a single calculation. I'll go through the rest of the library to identify other possibilities for this. Regression-tested, no new failures. OK for the branch? Index: libgfortran.h === --- libgfortran.h (Revision 185261) +++ libgfortran.h (Arbeitskopie) @@ -364,6 +364,11 @@ #define GFC_DESCRIPTOR_TYPE(desc) (((desc)-dtype GFC_DTYPE_TYPE_MASK) \ GFC_DTYPE_TYPE_SHIFT) #define GFC_DESCRIPTOR_SIZE(desc) ((desc)-dtype GFC_DTYPE_SIZE_SHIFT) + +/* This is for getting the size of a descriptor when the type of the +descriptor is known at compile-time. Do not use for string types. */ + +#define GFC_DESCRIPTOR_SIZE_TYPEKNOWN(desc) (sizeof((desc)-base_addr[0])) #define GFC_DESCRIPTOR_DATA(desc) ((desc)-base_addr) #define GFC_DESCRIPTOR_DTYPE(desc) ((desc)-dtype) The comment should say size of a type rather than size of a descriptor. Otherwise Ok. Though I think that longer term, maybe we should do the address calculations in bytes directly? Now we have (on the branch) the stride in bytes, which we convert to elements by dividing with the element size, and then the compiler again converts it to bytes by multiplying with the element size when we calculate the address of an array element. So maybe instead we should have the address of the current element as a variable of type char*, and then only when operating on that element we cast it to the correct type? -- Janne Blomqvist
Re: [PATCH] GCC 4.7 and 4.8 PowerPC RTEMS
On 03/27/2012 05:42 PM, Andreas Schwab wrote: Sebastian Hubersebastian.hu...@embedded-brains.de writes: What is the purpose of the ctrbegin.o and crtend.o? The same as crtbeginS.o and crtendS.o, except for non-shared linking. Ok, so if I add additional files here: extra_parts=$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o it will do no harm since eventually the specs file will decide which one is used? *startfile: %{!qrtems: %(old_startfile)} \ %{!nostdlib: %{qrtems: ecrti%O%s rtems_crti%O%s crtbegin.o%s start.o%s}} *endfile: %{!qrtems: %(old_endfile)} %{qrtems: crtend.o%s ecrtn.o%s} -- Sebastian Huber, embedded brains GmbH Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany Phone : +49 89 18 90 80 79-6 Fax : +49 89 18 90 80 79-9 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
Re: Fix PR rtl-optimization/52629
What's the impact of this bug? If it is a wrong-code or ice-on-valid bug then it's ok for the 4.7 branch. Neither, it's an out-of-bounds memory access in reload1.c with apparently no visible effects as it has been introduced with IRA (4.4 series). -- Eric Botcazou
Re: [lra] spilling general class pseudos into SSE regs instead of memory (a target hooks driven implementation)
Vladimir Makarov vmaka...@redhat.com writes: The following patch implements general spilling one class pseudos into another class hard registers *instead of memory* in LRA. Nice. Just double checking: would it automatically disable itself with -mno-sse2 for code that does not support the FPU? -Andi -- a...@linux.intel.com -- Speaking for myself only
Re: [RFC ivopts] ARM - Make ivopts take into account whether pre and post increments are actually supported on targets.
On Tue, Mar 27, 2012 at 3:17 PM, Ramana Radhakrishnan ramana.radhakrish...@linaro.org wrote: And the patch is now attached This does not look like it would compile on any other target. Richard. Ramana
Re: [RFC ivopts] ARM - Make ivopts take into account whether pre and post increments are actually supported on targets.
On Wed, Mar 28, 2012 at 11:57 AM, Richard Guenther richard.guent...@gmail.com wrote: On Tue, Mar 27, 2012 at 3:17 PM, Ramana Radhakrishnan ramana.radhakrish...@linaro.org wrote: And the patch is now attached This does not look like it would compile on any other target. Looks like the macros are pre-existing in rtl.h. With that the ivopts change is ok. I'll let arm folks decide over the arm specific bits. Thanks, Richard. Richard. Ramana
Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2
On Tue, Mar 27, 2012 at 7:48 PM, H.J. Lu hongjiu...@intel.com wrote: OPTION_MASK_ISA_64BIT 32bit x86-64 code or 64bit x86-64 code OPTION_MASK_ISA_X86_64 64bit x86-64 code OPTION_MASK_ISA_X32 32bit x86-64 code How annoying, the first one doesn't mean what it says. OPTION_MASK_ISA_64BIT should be renamed to OPTION_MASK_ARCH_X86_64, then it makes sense. For consistency, I'd say: OPTION_MASK_ISA_64BIT - OPTION_MASK_ARCH_X86_64 OPTION_MASK_ISA_X86_64 - OPTION_MASK_ISA_64 OPTION_MASK_ISA_X32 - stays the same. and i386.opt becomes -m64: Turn on OPTION_MASK_ISA_X86_64 -mx32: Turn on OPTION_MASK_ISA_X32 -m32: Turn off OPTION_MASK_ISA_64BIT Both OPTION_MASK_ISA_X32 and OPTION_MASK_ISA_X86_64 imply OPTION_MASK_ISA_64BIT. OPTION_MASK_ISA_X32 clears OPTION_MASK_ISA_X86_64 and vice versa. With a renamed macros, the above make sense. -#define TARGET_LP64 (TARGET_64BIT !TARGET_X32) +#define TARGET_LP64 TARGET_X86_64 You don't need new define, just use OPTION_MASK_ISA_64. Uros.
[avr,backported,4.7] PR52692, 52737
Backported from trunk to 4.7: PR52737 - -mtiny-stack shall not influence multilib selection http://gcc.gnu.org/viewcvs?root=gccview=revrev=185908 PR52692 - Add support for avr-specific built-ins + LTO http://gcc.gnu.org/viewcvs?root=gccview=revrev=185911
[avr,revert,4.6]: PR52741 (revert PR51002 changes)
http://gcc.gnu.org/viewcvs?root=gccview=revrev=185912 Reverts the changes for PR51002 - SP_H register used even on targets without SP_H PR51002 has been re-scheduled for 4.7
[libgo] Handle Solaris 11 Update 1 zone_net_addr_t
When I first tried to build mainline on Solaris 11 Update 1, the libgo build failed. In gen-sysinfo.go, I have type _zone_net_addr_t struct { zna_family uint16; zna_plen uint16; zna_addru struct { znau_addr6 _in6_addr; }; } type _zone_net_data_t struct { zn_type int; zn_linkid uint32; zn_naddrs uint32; zn_addrs [0+1]_zone_net_addr_t; } but the former is filtered out due to its use of _in6_addr, so we're left with a reference to an undefined type. The following patch fixes this and allowed the bootstrap to complete, but I wonder if it wouldn't be better to globally do a sed -e 's/_in6_addr/[16]byte/' instead of the current special-casing of _in6_addr in a couple of places. Rainer 2012-03-22 Rainer Orth r...@cebitec.uni-bielefeld.de * mksysinfo.sh (_zone_net_addr_t): Handle _in6_addr. # HG changeset patch # Parent fb5daa5b2c139aa02220feb898ac29bbafb1cb00 Handle Solaris 11 Update 1 zone_net_addr_t diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh @@ -1065,4 +1065,9 @@ grep '^type _ipv6_member_t ' gen-sysinfo egrep '^const _(MIB2|EXPER)_' gen-sysinfo.go | \ sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' ${OUT} +# The Solaris 11 Update 1 _zone_net_addr_t struct. +grep '^type _zone_net_addr_t ' gen-sysinfo.go | \ +sed -e 's/_in6_addr/[16]byte/' \ + ${OUT} + exit $? -- - Rainer Orth, Center for Biotechnology, Bielefeld University
[PATCH] Fix tree-vect-generic.c BIT_FIELD_REF creation (PR middle-end/52750)
Hi! The attached testcase shows that already for 32x signed char vector shuffles using the index element type for computing BIT_FIELD_REF positions is wrong - bytes 16 and above in the vector are bits 128 and above, and if idx has signed char type, that overflows. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.7? 2012-03-28 Jakub Jelinek ja...@redhat.com PR middle-end/52750 * tree-vect-generic.c (vector_element): Perform multiplication for pos in bitsizetype type instead of idx type. * gcc.c-torture/compile/pr52750.c: New test. --- gcc/tree-vect-generic.c.jj 2012-03-20 08:51:32.0 +0100 +++ gcc/tree-vect-generic.c 2012-03-28 11:20:16.715685934 +0200 @@ -567,8 +567,9 @@ vector_element (gimple_stmt_iterator *gs else { tree size = TYPE_SIZE (vect_elt_type); - tree pos = fold_build2 (MULT_EXPR, TREE_TYPE (idx), idx, size); - return fold_build3 (BIT_FIELD_REF, vect_elt_type, vect, size, pos); + tree pos = fold_build2 (MULT_EXPR, bitsizetype, + fold_convert (bitsizetype, idx), size); + return fold_build3 (BIT_FIELD_REF, vect_elt_type, vect, size, pos); } } --- gcc/testsuite/gcc.c-torture/compile/pr52750.c.jj2012-03-28 11:51:12.110286829 +0200 +++ gcc/testsuite/gcc.c-torture/compile/pr52750.c 2012-03-28 11:49:44.0 +0200 @@ -0,0 +1,11 @@ +/* PR middle-end/52750 */ + +typedef signed char V __attribute__((vector_size (32))); + +void +foo (V *x) +{ + V m = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; + *x = __builtin_shuffle (*x, m); +} Jakub
Re: [PATCH] Fix PR18589
On Tue, Mar 6, 2012 at 9:49 PM, William J. Schmidt wschm...@linux.vnet.ibm.com wrote: Hi, This is a re-post of the patch I posted for comments in January to address http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18589. The patch modifies reassociation to expose repeated factors from __builtin_pow* calls, optimally reassociate repeated factors, and possibly reconstitute __builtin_powi calls from the results of reassociation. Bootstrapped and passes regression tests for powerpc64-linux-gnu. I expect there may need to be some small changes, but I am targeting this for trunk approval. Thanks very much for the review, Hmm. How much work would it be to extend the reassoc 'IL' to allow a repeat factor per op? I realize what you do is all within what reassoc already does though ideally we would not require any GIMPLE IL changes for building up / optimizing the reassoc IL but only do so when we commit changes. Thanks, Richard. Bill gcc: 2012-03-06 Bill Schmidt wschm...@linux.vnet.ibm.com * tree-pass.h: Replace pass_reassoc with pass_early_reassoc and pass_late_reassoc. * passes.c (init_optimization_passes): Change pass_reassoc calls to pass_early_reassoc and pass_late_reassoc. * tree-ssa-reassoc.c (reassociate_stats): Add two fields. (early_reassoc): New static var. (MAX_POW_EXPAND): New #define'd constant. (linear_expand_pow_common): New function. (linear_expand_powi): Likewise. (linear_expand_pow): Likewise. (break_up_subtract_bb): Attempt to expand __builtin_pow[i]. (repeat_factor_d): New struct and associated typedefs. (repeat_factor_vec): New static vector variable. (compare_repeat_factors): New function. (get_reassoc_pow_ssa_name): Likewise. (attempt_builtin_powi): Likewise. (reassociate_bb): Attempt to reconstitute __builtin_powi calls, and multiply their results by any leftover reassociated factors. (fini_reassoc): Two new calls to statistics_counter_event. (execute_early_reassoc): New function. (execute_late_reassoc): Likewise. (pass_early_reassoc): Replace pass_reassoc, renamed to reassoc1, call execute_early_reassoc. (pass_late_reassoc): New gimple_opt_pass named reassoc2 that calls execute_late_reassoc. gcc/testsuite: 2012-03-06 Bill Schmidt wschm...@linux.vnet.ibm.com * gcc.dg/pr46309.c: Change -fdump-tree-reassoc-details to -fdump-tree-reassoc[12]-details. * gcc.dg/tree-ssa/pr18589-1.c: New test. * gcc.dg/tree-ssa/pr18589-2.c: Likewise. * gcc.dg/tree-ssa/pr18589-3.c: Likewise. * gcc.dg/tree-ssa/pr18589-4.c: Likewise. * gcc.dg/tree-ssa/pr18589-5.c: Likewise. * gcc.dg/tree-ssa/pr18589-6.c: Likewise. * gcc.dg/tree-ssa/pr18589-7.c: Likewise. * gcc.dg/tree-ssa/pr18589-8.c: Likewise. Index: gcc/tree-pass.h === --- gcc/tree-pass.h (revision 184997) +++ gcc/tree-pass.h (working copy) @@ -440,7 +440,8 @@ extern struct gimple_opt_pass pass_copy_prop; extern struct gimple_opt_pass pass_vrp; extern struct gimple_opt_pass pass_uncprop; extern struct gimple_opt_pass pass_return_slot; -extern struct gimple_opt_pass pass_reassoc; +extern struct gimple_opt_pass pass_early_reassoc; +extern struct gimple_opt_pass pass_late_reassoc; extern struct gimple_opt_pass pass_rebuild_cgraph_edges; extern struct gimple_opt_pass pass_remove_cgraph_callee_edges; extern struct gimple_opt_pass pass_build_cgraph_edges; Index: gcc/testsuite/gcc.dg/pr46309.c === --- gcc/testsuite/gcc.dg/pr46309.c (revision 184997) +++ gcc/testsuite/gcc.dg/pr46309.c (working copy) @@ -1,6 +1,6 @@ /* PR tree-optimization/46309 */ /* { dg-do compile } */ -/* { dg-options -O2 -fdump-tree-reassoc-details } */ +/* { dg-options -O2 -fdump-tree-reassoc1-details -fdump-tree-reassoc2-details } */ /* The transformation depends on BRANCH_COST being greater than 1 (see the notes in the PR), so try to force that. */ /* { dg-additional-options -mtune=octeon2 { target mips*-*-* } } */ Index: gcc/testsuite/gcc.dg/tree-ssa/pr18589-4.c === --- gcc/testsuite/gcc.dg/tree-ssa/pr18589-4.c (revision 0) +++ gcc/testsuite/gcc.dg/tree-ssa/pr18589-4.c (revision 0) @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options -O3 -ffast-math -fdump-tree-optimized } */ + +double baz (double x, double y, double z, double u) +{ + return x * x * y * y * y * z * z * z * z * u; +} + +/* { dg-final { scan-tree-dump-times \\* 7 optimized } } */ +/* { dg-final { cleanup-tree-dump optimized } } */ Index: gcc/testsuite/gcc.dg/tree-ssa/pr18589-5.c ===
[PATCH] Restore __builtin_va_start - __builtin_next_arg folding (PR middle-end/52691)
Hi! The builtin_decl_explicit_p changes broke the __builtin_va_start - __builtin_next_arg folding, previously it was testing that built_in_decls[BUILT_IN_NEXT_ARG] == NULL (and giving up in that case), so the conversion missed !. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.7? 2012-03-28 Jakub Jelinek ja...@redhat.com PR middle-end/52691 * tree-ssa-ccp.c (optimize_stdarg_builtin): Optimize __builtin_va_start to __builtin_next_arg if the latter is builtin_decl_explicit_p rather than when it is not. * gcc.dg/pr52691.c: New test. --- gcc/tree-ssa-ccp.c.jj 2012-01-13 21:47:35.0 +0100 +++ gcc/tree-ssa-ccp.c 2012-03-28 12:48:44.358615418 +0200 @@ -2288,7 +2288,7 @@ optimize_stdarg_builtin (gimple call) case BUILT_IN_VA_START: if (!va_list_simple_ptr || targetm.expand_builtin_va_start != NULL - || builtin_decl_explicit_p (BUILT_IN_NEXT_ARG)) + || !builtin_decl_explicit_p (BUILT_IN_NEXT_ARG)) return NULL_TREE; if (gimple_call_num_args (call) != 2) --- gcc/testsuite/gcc.dg/pr52691.c.jj 2012-03-28 12:57:34.555364325 +0200 +++ gcc/testsuite/gcc.dg/pr52691.c 2012-03-28 13:11:16.020328633 +0200 @@ -0,0 +1,24 @@ +/* PR middle-end/52691 */ +/* { dg-do compile } */ +/* { dg-options -O2 -fdump-tree-optimized } */ + +#include stdarg.h + +int +foo (int a, ...) +{ + int b = 0, c = 0; + va_list ap; + va_start (ap, a); + if (a 1) +b = va_arg (ap, double); + if (a 2) +c = va_arg (ap, long long); + va_end (ap); + return a + b + c; +} + +/* { dg-final { scan-tree-dump __builtin_next_arg optimized { target { { i?86-*-* x86_64-*-* } ia32 } } } } */ +/* { dg-final { scan-tree-dump __builtin_next_arg optimized { target { powerpc*-*-darwin* powerpc*-*-aix* } } } } */ +/* { dg-final { scan-tree-dump __builtin_next_arg optimized { target { powerpc*-*-linux* lp64 } } } } */ +/* { dg-final { cleanup-tree-dump optimized } } */ Jakub
Re: [lra] spilling general class pseudos into SSE regs instead of memory (a target hooks driven implementation)
On 03/28/2012 02:39 AM, Ye Joey wrote: On Wed, Mar 28, 2012 at 1:07 AM, Vladimir Makarovvmaka...@redhat.com wrote: The following patch implements general spilling one class pseudos into another class hard registers *instead of memory* in LRA. Can't find the patch itself Sorry, my bad. Here is the patch. Index: lra-int.h === --- lra-int.h (revision 185724) +++ lra-int.h (working copy) @@ -239,6 +239,8 @@ typedef struct lra_insn_recog_data *lra_ extern FILE *lra_dump_file; +extern bool lra_reg_spill_p; + extern HARD_REG_SET lra_no_alloc_regs; extern bitmap_head lra_constraint_insn_stack_bitmap; Index: lra-spills.c === --- lra-spills.c (revision 185724) +++ lra-spills.c (working copy) @@ -41,12 +41,17 @@ along with GCC; see the file COPYING3. #include timevar.h #include target.h #include lra-int.h +#include ira.h #include df.h /* Max regno at the start of the pass. */ static int regs_num; +/* Map spilled regno - hard regno used instead of memory for + spilling. */ +static rtx *spill_hard_reg; + /* The structure describes stack slot of a spilled pseudo. */ struct pseudo_slot { @@ -67,10 +72,12 @@ struct slot { /* First pseudo with given stack slot. */ int regno; + /* Hard reg into which the slot pseudos are spilled. */ + int hard_regno; /* Memory representing the all stack slot. It can be different from memory representing a pseudo belonging to give stack slot because - pseudo can be placed in a part of the corresponding stack - slot. */ + pseudo can be placed in a part of the corresponding stack slot. + The value is NULL for pseudos spilled into a hard reg. */ rtx mem; /* Combined live ranges of all pseudos belonging to give slot. It is used to define can a new spilled pseudo use given stack @@ -87,7 +94,7 @@ static int slots_num; /* Set up memory of the spilled pseudo I. The function can allocate the corresponding stack slot if it is not done yet. */ static void -assign_slot (int i) +assign_mem_slot (int i) { rtx x = NULL_RTX; enum machine_mode mode = GET_MODE (regno_reg_rtx[i]); @@ -200,63 +207,161 @@ pseudo_reg_slot_compare (const void *v1p return regno1 - regno2; } -/* Assign stack slot number to them pseudo-register numbers in array - PSEUDO_REGNOS of length N. Sort them for subsequent assigning - stack slots. */ +static int +assign_spill_hard_regs (int *pseudo_regnos, int n) +{ + int i, k, p, regno, res, spill_class_size, hard_regno, nr; + enum reg_class rclass, spill_class; + enum machine_mode mode; + lra_live_range_t r; + rtx insn, set; + basic_block bb; + HARD_REG_SET conflict_hard_regs; + bitmap_head ok_insn_bitmap; + bitmap set_jump_crosses = regstat_get_setjmp_crosses (); + /* Hard registers which can not be used for any purpose at given + program point because they are unallocatable or already allocated + for other pseudos. */ + HARD_REG_SET *reserved_hard_regs; + + if (! lra_reg_spill_p) +return n; + /* Set up reserved hard regs for every program point. */ + reserved_hard_regs = (HARD_REG_SET *) xmalloc (sizeof (HARD_REG_SET) + * lra_live_max_point); + for (p = 0; p lra_live_max_point; p++) +COPY_HARD_REG_SET (reserved_hard_regs[p], lra_no_alloc_regs); + for (i = FIRST_PSEUDO_REGISTER; i regs_num; i++) +if (lra_reg_info[i].nrefs != 0 + (hard_regno = lra_get_regno_hard_regno (i)) = 0) + for (r = lra_reg_info[i].live_ranges; r != NULL; r = r-next) + for (p = r-start; p = r-finish; p++) + lra_add_hard_reg_set (hard_regno, lra_reg_info[i].biggest_mode, +reserved_hard_regs[p]); + bitmap_initialize (ok_insn_bitmap, reg_obstack); + FOR_EACH_BB (bb) +FOR_BB_INSNS (bb, insn) + if (DEBUG_INSN_P (insn) + || ((set = single_set (insn)) != NULL_RTX + REG_P (SET_SRC (set)) REG_P (SET_DEST (set + bitmap_set_bit (ok_insn_bitmap, INSN_UID (insn)); + for (res = i = 0; i n; i++) +{ + regno = pseudo_regnos[i]; + rclass = lra_get_allocno_class (regno); + if (bitmap_bit_p (set_jump_crosses, regno) + || (spill_class = targetm.spill_class (rclass)) == NO_REGS + || (targetm.spill_class_mode (rclass, spill_class, + PSEUDO_REGNO_MODE (regno)) + != PSEUDO_REGNO_MODE (regno)) + || bitmap_intersect_compl_p (lra_reg_info[regno].insn_bitmap, + ok_insn_bitmap)) + { + pseudo_regnos[res++] = regno; + continue; + } + COPY_HARD_REG_SET (conflict_hard_regs, + lra_reg_info[regno].conflict_hard_regs); + for (r = lra_reg_info[regno].live_ranges; r != NULL; r = r-next) + for (p = r-start; p = r-finish; p++) + IOR_HARD_REG_SET (conflict_hard_regs, reserved_hard_regs[p]); + spill_class = targetm.spill_class (lra_get_allocno_class (regno)); + gcc_assert (spill_class != NO_REGS); + spill_class_size =
[PATCH][C++] Deal with non-sign-extended unsigned sizetype for arrays of size zero
For arrays of size zero the C++ frontend generates a TYPE_DOMAIN using build_index_type (which is hardcoded to unsigned sizetype) passing it -1 (in ssizetype ...) as the maximum index (build_index_type will use size_zero_node as minimum index). That works all well as long as sizetype constants are signextended, but process_init_constructor_array does: tree domain = TYPE_DOMAIN (type); if (domain) ! len = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain)) ! - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain)) ! + 1); so if that -1 is not sign-extended and sizetype is 32bits on a 64bit host (where TREE_INT_CST_LOW is 64bit) then the above computes a non-sensical value, 0x1, that is. The C frontend (now) avoids this by using a [0, ] TYPE_DOMAIN for the extension of zero-size arrays but I see that size can be the result of template expansion in C++ (and maybe other places in the C++ frontend assume taht TYPE_MAX_VALUE of TYPE_DOMAIN is never NULL). I know that simply using a range type with ssizetype does not work (yeah, we should make that work I guess ...), so the fix for the above code is to properly do twos-complement arithmetic and truncate/extend the HOST_WIDE_INT value. Another fix would be to use a [1, 0] domain - not sure what that would break though. Like with the following patch (heh, C++ operator overloading would make dealing with double-ints so much nicer to look at ...). Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. This cures the last non-Ada failure I have with the patchset that makes TYPE_UNSIGNED sizetype constants no longer sign-extended. Ok for trunk? Thanks, Richard. 2012-03-28 Richard Guenther rguent...@suse.de cp/ * typeck2.c (process_init_constructor_array): Use the proper type for computing the array length. Index: gcc/cp/typeck2.c === *** gcc/cp/typeck2.c(revision 185911) --- gcc/cp/typeck2.c(working copy) *** process_init_constructor_array (tree typ *** 1054,1062 { tree domain = TYPE_DOMAIN (type); if (domain) ! len = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain)) ! - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain)) ! + 1); else unbounded = true; /* Take as many as there are. */ } --- 1054,1067 { tree domain = TYPE_DOMAIN (type); if (domain) ! len = double_int_ext ! (double_int_add ! (double_int_sub ! (tree_to_double_int (TYPE_MAX_VALUE (domain)), !tree_to_double_int (TYPE_MIN_VALUE (domain))), ! double_int_one), ! TYPE_PRECISION (TREE_TYPE (domain)), ! TYPE_UNSIGNED (TREE_TYPE (domain))).low; else unbounded = true; /* Take as many as there are. */ }
Re: [PATCH] Restore __builtin_va_start - __builtin_next_arg folding (PR middle-end/52691)
On Wed, Mar 28, 2012 at 4:00 PM, Jakub Jelinek ja...@redhat.com wrote: Hi! The builtin_decl_explicit_p changes broke the __builtin_va_start - __builtin_next_arg folding, previously it was testing that built_in_decls[BUILT_IN_NEXT_ARG] == NULL (and giving up in that case), so the conversion missed !. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.7? Ok. Thanks, Richard. 2012-03-28 Jakub Jelinek ja...@redhat.com PR middle-end/52691 * tree-ssa-ccp.c (optimize_stdarg_builtin): Optimize __builtin_va_start to __builtin_next_arg if the latter is builtin_decl_explicit_p rather than when it is not. * gcc.dg/pr52691.c: New test. --- gcc/tree-ssa-ccp.c.jj 2012-01-13 21:47:35.0 +0100 +++ gcc/tree-ssa-ccp.c 2012-03-28 12:48:44.358615418 +0200 @@ -2288,7 +2288,7 @@ optimize_stdarg_builtin (gimple call) case BUILT_IN_VA_START: if (!va_list_simple_ptr || targetm.expand_builtin_va_start != NULL - || builtin_decl_explicit_p (BUILT_IN_NEXT_ARG)) + || !builtin_decl_explicit_p (BUILT_IN_NEXT_ARG)) return NULL_TREE; if (gimple_call_num_args (call) != 2) --- gcc/testsuite/gcc.dg/pr52691.c.jj 2012-03-28 12:57:34.555364325 +0200 +++ gcc/testsuite/gcc.dg/pr52691.c 2012-03-28 13:11:16.020328633 +0200 @@ -0,0 +1,24 @@ +/* PR middle-end/52691 */ +/* { dg-do compile } */ +/* { dg-options -O2 -fdump-tree-optimized } */ + +#include stdarg.h + +int +foo (int a, ...) +{ + int b = 0, c = 0; + va_list ap; + va_start (ap, a); + if (a 1) + b = va_arg (ap, double); + if (a 2) + c = va_arg (ap, long long); + va_end (ap); + return a + b + c; +} + +/* { dg-final { scan-tree-dump __builtin_next_arg optimized { target { { i?86-*-* x86_64-*-* } ia32 } } } } */ +/* { dg-final { scan-tree-dump __builtin_next_arg optimized { target { powerpc*-*-darwin* powerpc*-*-aix* } } } } */ +/* { dg-final { scan-tree-dump __builtin_next_arg optimized { target { powerpc*-*-linux* lp64 } } } } */ +/* { dg-final { cleanup-tree-dump optimized } } */ Jakub
[PATCH] Fix PR50708
I am testing the following patch to remove the endless recursion between rshift_double and lshift_double trying to make their signed count argument positive by simple negation. I opted to make rshift_double private because it is the deprecated interface and is no longer used. Bootstrap and regtest running on x86_64-unknown-linux-gnu. Richard. 2012-03-28 Richard Guenther rguent...@suse.de PR middle-end/50708 * double-int.h (rshift_double): Remove. * double-int.c (lshift_double): Use absu_hwi to make count positive. (rshift_double): Make static, take unsigned count argument, remove handling of negative count argument. (double_int_rshift): Dispatch to lshift_double. Index: gcc/double-int.c === *** gcc/double-int.c(revision 185911) --- gcc/double-int.c(working copy) *** mul_double_with_sign (unsigned HOST_WIDE *** 186,209 return (*hv 0 ? ~(toplow tophigh) : toplow | tophigh) != 0; } ! /* Shift the doubleword integer in L1, H1 left by COUNT places !keeping only PREC bits of result. !Shift right if COUNT is negative. !ARITH nonzero specifies arithmetic shifting; otherwise use logical shift. Store the value as two `HOST_WIDE_INT' pieces in *LV and *HV. */ ! void ! lshift_double (unsigned HOST_WIDE_INT l1, HOST_WIDE_INT h1, ! HOST_WIDE_INT count, unsigned int prec, ! unsigned HOST_WIDE_INT *lv, HOST_WIDE_INT *hv, bool arith) { unsigned HOST_WIDE_INT signmask; ! if (count 0) ! { ! rshift_double (l1, h1, -count, prec, lv, hv, arith); ! return; ! } if (SHIFT_COUNT_TRUNCATED) count %= prec; --- 186,207 return (*hv 0 ? ~(toplow tophigh) : toplow | tophigh) != 0; } ! /* Shift the doubleword integer in L1, H1 right by COUNT places !keeping only PREC bits of result. ARITH nonzero specifies !arithmetic shifting; otherwise use logical shift. Store the value as two `HOST_WIDE_INT' pieces in *LV and *HV. */ ! static void ! rshift_double (unsigned HOST_WIDE_INT l1, HOST_WIDE_INT h1, ! unsigned HOST_WIDE_INT count, unsigned int prec, ! unsigned HOST_WIDE_INT *lv, HOST_WIDE_INT *hv, ! bool arith) { unsigned HOST_WIDE_INT signmask; ! signmask = (arith ! ? -((unsigned HOST_WIDE_INT) h1 (HOST_BITS_PER_WIDE_INT - 1)) ! : 0); if (SHIFT_COUNT_TRUNCATED) count %= prec; *** lshift_double (unsigned HOST_WIDE_INT l1 *** 217,277 } else if (count = HOST_BITS_PER_WIDE_INT) { ! *hv = l1 (count - HOST_BITS_PER_WIDE_INT); ! *lv = 0; } else { ! *hv = (((unsigned HOST_WIDE_INT) h1 count) !| (l1 (HOST_BITS_PER_WIDE_INT - count - 1) 1)); ! *lv = l1 count; } ! /* Sign extend all bits that are beyond the precision. */ ! ! signmask = -((prec HOST_BITS_PER_WIDE_INT ! ? ((unsigned HOST_WIDE_INT) *hv ! (prec - HOST_BITS_PER_WIDE_INT - 1)) ! : (*lv (prec - 1))) 1); ! if (prec = 2 * HOST_BITS_PER_WIDE_INT) ; ! else if (prec = HOST_BITS_PER_WIDE_INT) { ! *hv = ~((HOST_WIDE_INT) (-1) (prec - HOST_BITS_PER_WIDE_INT)); ! *hv |= signmask (prec - HOST_BITS_PER_WIDE_INT); } else { *hv = signmask; ! *lv = ~((unsigned HOST_WIDE_INT) (-1) prec); ! *lv |= signmask prec; } } ! /* Shift the doubleword integer in L1, H1 right by COUNT places !keeping only PREC bits of result. Shift left if COUNT is negative. ARITH nonzero specifies arithmetic shifting; otherwise use logical shift. Store the value as two `HOST_WIDE_INT' pieces in *LV and *HV. */ void ! rshift_double (unsigned HOST_WIDE_INT l1, HOST_WIDE_INT h1, HOST_WIDE_INT count, unsigned int prec, ! unsigned HOST_WIDE_INT *lv, HOST_WIDE_INT *hv, ! bool arith) { unsigned HOST_WIDE_INT signmask; if (count 0) { ! lshift_double (l1, h1, -count, prec, lv, hv, arith); return; } - signmask = (arith - ? -((unsigned HOST_WIDE_INT) h1 (HOST_BITS_PER_WIDE_INT - 1)) - : 0); - if (SHIFT_COUNT_TRUNCATED) count %= prec; --- 215,272 } else if (count = HOST_BITS_PER_WIDE_INT) { ! *hv = 0; ! *lv = (unsigned HOST_WIDE_INT) h1 (count - HOST_BITS_PER_WIDE_INT); } else { ! *hv = (unsigned HOST_WIDE_INT) h1 count; ! *lv = ((l1 count) !| ((unsigned HOST_WIDE_INT) h1 !(HOST_BITS_PER_WIDE_INT - count - 1) 1)); } ! /* Zero / sign extend all bits that are beyond the precision. */ ! if (count = (HOST_WIDE_INT)prec) ! { ! *hv = signmask; ! *lv = signmask; ! } ! else if
[patch] Fix ICE during inlining with SJLJ
Hi, this is a regression present on the mainline and 4.7 branch for platforms using SJLJ exceptions, e.g. the ARM. The scenario is as follows: the main procedure calls My_Iterators.Current which has a pragma Inline on it. The procedure also has exceptions handlers so there is an abnormal edge from the BB containing the call to My_Iterators.Current (which is therefore the last statement in the BB) to the setjmp dispatcher. The local-pure-const pass computes that My_Iterators.Current is pure and may not terminate (DECL_PURE_P DECL_LOOPING_CONST_OR_PURE_P) because it is pure and contains a call to gnat_check, which is no-return, and state_from_flags (call_state, call_looping, flags, ((flags (ECF_NORETURN | ECF_NOTHROW)) == (ECF_NORETURN | ECF_NOTHROW)) || (!flag_exceptions (flags ECF_NORETURN))); considers that, with !flag_exceptions, a no-return function call can really never return, including by exceptional means. The early SRA pass then inserts a statement in the procedure right after the call to My_Iterators.Current, so at the end of the BB, because stmt_ends_bb_p has returned false on the call, in turn because the statement is ECF_PURE and is_ctrl_altering_stmt has /* A non-pure/const call alters flow control if the current function has nonlocal labels. */ if (!(flags (ECF_CONST | ECF_PURE | ECF_LEAF)) cfun-has_nonlocal_label) return true; i.e. doesn't return true if ECF_PURE. As a consequence, the abnormal edge from the BB to the setjmp receiver is deleted. When My_Iterators.Current gets inlined into P, the call to gnat_check is copied into it and, since stmt_can_make_abnormal_goto returns true on it, a new abnormal edge to the setjmp dispatcher is created. The compiler aborts in update_ssa_across_abnormal_edges because it cannot find the original abnormal edge that it needs to use in order to complete the new one. The cause is the discrepancy between local-pure-const, is_ctrl_altering_stmt and stmt_can_make_abnormal_goto (the latter two themselves disagreeing) as to when a call can return exceptionally/make an abnormal goto. It's clear that (!flag_exceptions (flags ECF_NORETURN)) overlooks the __builtin_setjmp/__builtin_longjmp constructs so is optimistic at best. But we cannot really do better in local-pure-const, short of removing the condition entirely. The interesting thing is that stmt_can_make_abnormal_goto, unlike the related is_ctrl_altering_stmt, doesn't consider that a mere ECF_PURE can change the property of a call wrt control flow: bool stmt_can_make_abnormal_goto (gimple t) { if (computed_goto_p (t)) return true; if (is_gimple_call (t)) return (gimple_has_side_effects (t) cfun-has_nonlocal_label !(gimple_call_flags (t) ECF_LEAF)); return false; } because it tests gimple_has_side_effects, which is still true if the call may not return: if (is_gimple_call (s)) { int flags = gimple_call_flags (s); /* An infinite loop is considered a side effect. */ if (!(flags (ECF_CONST | ECF_PURE)) || (flags ECF_LOOPING_CONST_OR_PURE)) return true; return false; } So, in the end, a reasonable fix might be to unify the condition used by is_ctrl_altering_stmt and stmt_can_make_abnormal_goto, by using the most conservative one (the latter), which happens to also cover the optimistic semantics used by local-pure-const. Tested on x86_64-suse-linux, OK for mainline and 4.7 branch? 2012-03-28 Eric Botcazou ebotca...@adacore.com * tree-cfg.c (call_can_make_abnormal_goto): New predicate. (stmt_can_make_abnormal_goto): Use it. (is_ctrl_altering_stmt): Likewise. 2012-03-28 Eric Botcazou ebotca...@adacore.com * gnat.dg/controlled6.adb: New test. * gnat.dg/controlled6_pkg.ads: New helper. * gnat.dg/controlled6_pkg-iterators.ad[sb]: Likewise. -- Eric Botcazou Index: tree-cfg.c === --- tree-cfg.c (revision 185857) +++ tree-cfg.c (working copy) @@ -2273,6 +2273,43 @@ gimple_cfg2vcg (FILE *file) Miscellaneous helpers ---*/ +/* Return true if T, a GIMPLE_CALL, can make an abnormal transfer of control + flow. Transfers of control flow associated with EH are excluded. */ + +static bool +call_can_make_abnormal_goto (gimple t) +{ + /* If the function has no non-local labels, then a call cannot make an + abnormal transfer of control. */ + if (!cfun-has_nonlocal_label) + return false; + + /* Likewise if the call has no side effects. */ + if (!gimple_has_side_effects (t)) +return false; + + /* Likewise if the called function is leaf. */ + if (gimple_call_flags (t) ECF_LEAF) +return false; + + return true; +} + + +/* Return true
Re: [PATCH][C++] Deal with non-sign-extended unsigned sizetype for arrays of size zero
OK. Jason
[patch] Add support for FP bit fields in varasm.c
Hi, another kind of bit fields supported in Ada are floating-point bit fields. They work fine, except that varasm.c rejects static constants (CONSTRUCTORs) containing them. The attached patch plugs this hole. Tested on x86_64-suse-linux, OK for mainline? 2012-03-28 Eric Botcazou ebotca...@adacore.com * varasm.c (initializer_constant_valid_for_bitfield_p): Return true for REAL_CST as well. (output_constructor): Use RECORD_OR_UNION_TYPE_P predicate. In the bitfield case, if the value is a REAL_CST, convert it first to an INTEGER_CST. 2012-03-28 Eric Botcazou ebotca...@adacore.com * gnat.dg/specs/aggr5.ads: New test. -- Eric Botcazou Index: varasm.c === --- varasm.c (revision 185857) +++ varasm.c (working copy) @@ -4420,6 +4420,7 @@ initializer_constant_valid_for_bitfield_ } case INTEGER_CST: +case REAL_CST: return true; case VIEW_CONVERT_EXPR: @@ -5075,10 +5076,7 @@ output_constructor (tree exp, unsigned H /* The element in a union constructor specifies the proper field or index. */ - if ((TREE_CODE (local.type) == RECORD_TYPE - || TREE_CODE (local.type) == UNION_TYPE - || TREE_CODE (local.type) == QUAL_UNION_TYPE) - ce-index != NULL_TREE) + if (RECORD_OR_UNION_TYPE_P (local.type) ce-index != NULL_TREE) local.field = ce-index; else if (TREE_CODE (local.type) == ARRAY_TYPE) @@ -5110,9 +5108,17 @@ output_constructor (tree exp, unsigned H || !CONSTRUCTOR_BITFIELD_P (local.field))) output_constructor_regular_field (local); - /* For a true bitfield or part of an outer one. */ + /* For a true bitfield or part of an outer one. Only INTEGER_CSTs are + supported for scalar fields, so we may need to convert first. */ else - output_constructor_bitfield (local, outer); +{ + if (TREE_CODE (local.val) == REAL_CST) + local.val = fold_build1 (VIEW_CONVERT_EXPR, + make_signed_type + (TYPE_PRECISION (TREE_TYPE (local.val))), + local.val); + output_constructor_bitfield (local, outer); + } } /* If we are not at toplevel, save the pending data for our caller. -- { dg-do compile } pragma Restrictions (No_Elaboration_Code); package Aggr5 is type R is record C : Character; F : Float; end record; for R use record C at 0 range 0 .. 7; F at 1 range 0 .. 31; end record; My_R : R := (C = 'A', F = 1.0); end Aggr5;
Re: [PATCH] PR c++/50852 - Revisit dependant template parameter
Jason Merrill ja...@redhat.com writes: + /* This can happen for template parms of a template template +parameter, e.g: + +templatetemplateclass T, class U class TT struct S; + +Consider the level of the parms of TT; T and U both have +level 2; TT has no template parm of level 1. So in this case +the first element of full_template_args is NULL_TREE. If we +leave it like this TMPL_ARG_DEPTH on args returns 1 instead +of 2. This will make tsubst wrongly consider that T and U +have level 1. Instead, let's create a dummy vector as the +first element of full_template_args so that TMPL_ARG_DEPTH +returns the correct depth for args. */ Hmm, it seems odd that the parms wouldn't have level 1. Finally, thinking about this a little more, this situation does not seem completely crazy to me. For: templateclass T, templateclass U, T class TT struct S; the parms of TT do have a level 1 that contains the parm T. It seems to me that we need T and U to have different levels here, so both cannot have level 1. I wonder if changing that would also avoid needing to use structural equality for template template parameters. What do you mean exactly by changing that? I am getting confused now. -- Dodji
Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors
Hi again, On 03/26/2012 09:31 PM, Jason Merrill wrote: On 03/26/2012 07:22 AM, Paolo Carlini wrote: My basic idea so far is very simple: --- class.c (revision 185792) +++ class.c (working copy) @@ -1001,6 +1001,10 @@ add_method (tree type, tree method, tree using_dec destructor, type); } + else if (cxx_dialect = cxx0x + !TYPE_RAISES_EXCEPTIONS (TREE_TYPE (method))) + TREE_TYPE (method) = build_exception_variant (TREE_TYPE (method), + noexcept_true_spec); } That would implement N1366, but implementing N3204 is a bit more involved. You need to copy TYPE_RAISES_EXCEPTIONS from the result of implicitly_declare_fn; see defaulted_late_check for something similar. Also, this is too early, since we can't know what the eh specification of the implicit declaration would be until the closing brace of the class. I think I understand your explanation and the below appears already to work pretty well. Is it on the right track? What about the check_redeclaration_exception_specification bits? Thanks in advance for any further feedback, Paolo. Index: class.c === --- class.c (revision 185911) +++ class.c (working copy) @@ -4321,6 +4321,37 @@ clone_constructors_and_destructors (tree t) clone_function_decl (OVL_CURRENT (fns), /*update_method_vec_p=*/1); } +/* For each destructor in T, deduce noexcept per: + + 12.4/3: A declaration of a destructor that does not have an + exception-specification is implicitly considered to have the + same exception-specification as an implicit declaration (15.4). */ + +static void +deduce_noexcept_on_destructors (tree t) +{ + tree fns; + + /* If for some reason we don't have a CLASSTYPE_METHOD_VEC, we bail + out now. */ + if (!CLASSTYPE_METHOD_VEC (t)) +return; + + for (fns = CLASSTYPE_DESTRUCTORS (t); fns; fns = OVL_NEXT (fns)) +{ + tree fn = OVL_CURRENT (fns); + if (!TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn))) + { + tree ctx = DECL_CONTEXT (fn); + tree implicit_fn = implicitly_declare_fn (sfk_destructor, ctx, + /*const_p=*/false); + tree eh_spec = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (implicit_fn)); + + TREE_TYPE (fn) = build_exception_variant (TREE_TYPE (fn), eh_spec); + } +} +} + /* Subroutine of set_one_vmethod_tm_attributes. Search base classes of TYPE for virtual functions which FNDECL overrides. Return a mask of the tm attributes found therein. */ @@ -5129,6 +5160,10 @@ check_bases_and_members (tree t) do anything with non-static member functions. */ finalize_literal_type_property (t); + /* Deduce noexcept. */ + if (cxx_dialect = cxx0x) +deduce_noexcept_on_destructors (t); + /* Create the in-charge and not-in-charge variants of constructors and destructors. */ clone_constructors_and_destructors (t); Index: decl.c === --- decl.c (revision 185911) +++ decl.c (working copy) @@ -1144,7 +1144,13 @@ check_redeclaration_exception_specification (tree if ((pedantic || ! DECL_IN_SYSTEM_HEADER (old_decl)) ! DECL_IS_BUILTIN (old_decl) flag_exceptions - !comp_except_specs (new_exceptions, old_exceptions, ce_normal)) + !comp_except_specs (new_exceptions, old_exceptions, ce_normal) + /* Special case in C++11: noexcept has been deduced as true for +the declaration and there is no exception-specification on the +definition. */ + !(DECL_DESTRUCTOR_P (new_decl) + cxx_dialect = cxx0x + !new_exceptions TYPE_NOEXCEPT_P (old_type))) { error (declaration of %qF has a different exception specifier, new_decl); Index: method.c === --- method.c(revision 185911) +++ method.c(working copy) @@ -1444,7 +1444,7 @@ explain_implicit_non_constexpr (tree decl) reference argument or a non-const reference. Returns the FUNCTION_DECL for the implicitly declared function. */ -static tree +tree implicitly_declare_fn (special_function_kind kind, tree type, bool const_p) { tree fn; Index: cp-tree.h === --- cp-tree.h (revision 185911) +++ cp-tree.h (working copy) @@ -5264,6 +5264,8 @@ extern tree get_copy_assign (tree); extern tree get_default_ctor (tree); extern tree get_dtor (tree, tsubst_flags_t); extern tree locate_ctor(tree); +extern tree implicitly_declare_fn (special_function_kind, tree, +bool); /* In optimize.c */ extern bool maybe_clone_body (tree);
RE: [PATCH H8300] Add function_vector attribute
Hi Jeff, Thank you for replying to the post. How is this different than the function vector support that is already in GCC for the H8/300 series processors? Current H8/300 implementation of function vector seems inappropriate. This patch fixes following problems from it. 1. Attribute syntax: The function vector attribute is expected to accept one argument i.e. vector number. Ref: http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#index- calling-functions-through-the-function-vector-on-H8_002f300_002c- M16C_002c-M32C-and-SH2A-processors-2525 However, with H8/300 target, it does not accept any argument and test case compilation fails with an error message: error: wrong number of arguments specified for function_vector attribute This patch fixes this problem. 2. Addressing mode support: Currently, even for function vectors, GCC generates instruction 'jsr' in absolute addressing mode which is incorrect. Instead of that, it should be generating 'jsr' in indirect memory addressing mode (@@aa:8). This patch fixes this problem as well. Thanks Regards, Ajinkya Dhobale KPIT Cummins Infosystems Ltd, Pune (INDIA)
Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors
On 03/28/2012 11:02 AM, Paolo Carlini wrote: + !comp_except_specs (new_exceptions, old_exceptions, ce_normal) + /* Special case in C++11: noexcept has been deduced as true for +the declaration and there is no exception-specification on the +definition. */ + !(DECL_DESTRUCTOR_P (new_decl) + cxx_dialect= cxx0x + !new_exceptions TYPE_NOEXCEPT_P (old_type))) TYPE_NOEXCEPT_P is the wrong test; the implicit declaration might have an exception-specification that allows some or all exceptions. I think the most straightforward thing would be to add the implicit exception-specification immediately when declaring a destructor outside the class, so that by the time we get to check_redeclaration_exception_specification the EH specs will match. Jason
Re: [PATCH] PR c++/50852 - Revisit dependant template parameter
On 03/28/2012 11:02 AM, Dodji Seketeli wrote: For: templateclass T, templateclass U, T class TT struct S; the parms of TT do have a level 1 that contains the parm T. It seems to me that we need T and U to have different levels here, so both cannot have level 1. Why do we need them to have different levels? They are parameters of different templates. Jason
Re: C++ PATCH to add auto return type deduction with -std=c++1y
On Sun, 25 Mar 2012, Marc Glisse wrote: - a first goal is simple functions, with a single return statement (which may even often be the only statement). After playing with it a bit, I am not sure how to use it in the simple forwarding case: T f(int); auto g(int i){return f(i);} If T is a reference, this does a copy. auto g(int i){return f(i);} Now if T is not a reference, this returns a reference to a destroyed temporary. So I am back to writing the following, which is precisely what we never want to write: auto g(int i)-decltype(f(i)){return f(i);} Maybe having just auto (no auto const, auto and others) without stripping cv-ref from it would work better in this case? It would have drawbacks in other cases... I guess the discussion should happen on a different forum once the proposal is published... -- Marc Glisse
Re: [PATCH] Fix PR18589
On Wed, 2012-03-28 at 15:57 +0200, Richard Guenther wrote: On Tue, Mar 6, 2012 at 9:49 PM, William J. Schmidt wschm...@linux.vnet.ibm.com wrote: Hi, This is a re-post of the patch I posted for comments in January to address http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18589. The patch modifies reassociation to expose repeated factors from __builtin_pow* calls, optimally reassociate repeated factors, and possibly reconstitute __builtin_powi calls from the results of reassociation. Bootstrapped and passes regression tests for powerpc64-linux-gnu. I expect there may need to be some small changes, but I am targeting this for trunk approval. Thanks very much for the review, Hmm. How much work would it be to extend the reassoc 'IL' to allow a repeat factor per op? I realize what you do is all within what reassoc already does though ideally we would not require any GIMPLE IL changes for building up / optimizing the reassoc IL but only do so when we commit changes. Ah, I take your point. I will look into it. We still need the additional data structures to allow sorting by factor repeat counts, but perhaps expanding the builtins can be avoided until it's proven necessary. The patch as submitted may be slightly easier to implement and understand, but I agree it would be better to avoid changing GIMPLE unnecessarily if possible. I'll get back to you shortly. Thanks, Bill Thanks, Richard.
Re: [PATCH] PR c++/50852 - Revisit dependant template parameter
Jason Merrill ja...@redhat.com writes: On 03/28/2012 11:02 AM, Dodji Seketeli wrote: For: templateclass T, templateclass U, T class TT struct S; the parms of TT do have a level 1 that contains the parm T. It seems to me that we need T and U to have different levels here, so both cannot have level 1. Why do we need them to have different levels? They are parameters of different templates. Then, if U and T have the same level, how do we represent the full set of template parms up to U for instance? I mean if that TREE_LIST of parms still has two entries - one for level 1 that contains T and one for level N (which you say should be 1 as well) that contains U - would the TREE_PURPOSEs of both entries have a 1 as their level number? I agree there are parameters of different templates at play here, but it seems like there are cases when we need to tie them together, like what lookup_template_class_1 does when the relevant template is a template template parameter. What am I missing? -- Dodji
[PATCH] Remove bogus assert from CCP's insert_clobbers_for_var
Hi, when testing a different patch of mine I hit the assert in insert_clobbers_for_var which is there to make sure that there is a call to builtin_stack_save in a BB with or dominating a call to builtin_alloca_with_align. In my case that was not true because the DOM pass duplicated the call to builtin_stack_save and put it onto two different paths to the same BB. On IRC I've been told that is OK and the that CCP cannot make such assumtions. Since it is only a missed-optimization if the call to the builtin is not found and processed (basically PR 51491 again but only in cases like these), I thought it best to just remove the assert by the following simple patch, bootstrapped and tested on x86_64-linux. OK for trunk? Thanks, Martin 2012-03-28 Martin Jambor mjam...@suse.cz * tree-ssa-ccp.c (insert_clobbers_for_var): Do not assert that there is a builtin_stack_save in a dominating BB. Index: src/gcc/tree-ssa-ccp.c === --- src.orig/gcc/tree-ssa-ccp.c +++ src/gcc/tree-ssa-ccp.c @@ -1769,18 +1769,16 @@ gsi_prev_dom_bb_nondebug (gimple_stmt_it static void insert_clobbers_for_var (gimple_stmt_iterator i, tree var) { - bool save_found; gimple stmt; tree saved_val; htab_t visited = NULL; - for (save_found = false; !gsi_end_p (i); gsi_prev_dom_bb_nondebug (i)) + for (; !gsi_end_p (i); gsi_prev_dom_bb_nondebug (i)) { stmt = gsi_stmt (i); if (!gimple_call_builtin_p (stmt, BUILT_IN_STACK_SAVE)) continue; - save_found = true; saved_val = gimple_call_lhs (stmt); if (saved_val == NULL_TREE) @@ -1792,7 +1790,6 @@ insert_clobbers_for_var (gimple_stmt_ite if (visited != NULL) htab_delete (visited); - gcc_assert (save_found); } /* Detects a __builtin_alloca_with_align with constant size argument. Declares
Re: C++ PATCH to add auto return type deduction with -std=c++1y
On Wed, 28 Mar 2012, Gabriel Dos Reis wrote: On Wed, Mar 28, 2012 at 10:51 AM, Marc Glisse marc.gli...@inria.fr wrote: On Sun, 25 Mar 2012, Marc Glisse wrote: - a first goal is simple functions, with a single return statement (which may even often be the only statement). After playing with it a bit, I am not sure how to use it in the simple forwarding case: T f(int); auto g(int i){return f(i);} function call or return value is equivalent to initialization. So, the deduction works (as it should) as if you wrote auto x = f(i); I agree that it works like initialization, and like lambdas, so that ship has sailed. I assume there were good reasons for that, even if they are not obvious, I know things can be trickier than they appear. However, I can't help thinking that there is something wrong with having to write: auto g(int i) - decltype(f(i)) { return f(i); } (and even worse with noexcept(noexcept(f(i))), but that's another issue) for a simple macro-like forwarding function. Now fixing that isn't the goal of Jason's proposal and this is fine. -- Marc Glisse
Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2
On Wed, Mar 28, 2012 at 3:17 AM, Uros Bizjak ubiz...@gmail.com wrote: On Tue, Mar 27, 2012 at 7:48 PM, H.J. Lu hongjiu...@intel.com wrote: OPTION_MASK_ISA_64BIT 32bit x86-64 code or 64bit x86-64 code OPTION_MASK_ISA_X86_64 64bit x86-64 code OPTION_MASK_ISA_X32 32bit x86-64 code How annoying, the first one doesn't mean what it says. OPTION_MASK_ISA_64BIT should be renamed to OPTION_MASK_ARCH_X86_64, then it makes sense. For consistency, I'd say: OPTION_MASK_ISA_64BIT - OPTION_MASK_ARCH_X86_64 OPTION_MASK_ISA_X86_64 - OPTION_MASK_ISA_64 OPTION_MASK_ISA_X32 - stays the same. and i386.opt becomes -m64: Turn on OPTION_MASK_ISA_X86_64 -mx32: Turn on OPTION_MASK_ISA_X32 -m32: Turn off OPTION_MASK_ISA_64BIT Both OPTION_MASK_ISA_X32 and OPTION_MASK_ISA_X86_64 imply OPTION_MASK_ISA_64BIT. OPTION_MASK_ISA_X32 clears OPTION_MASK_ISA_X86_64 and vice versa. With a renamed macros, the above make sense. -#define TARGET_LP64 (TARGET_64BIT !TARGET_X32) +#define TARGET_LP64 TARGET_X86_64 You don't need new define, just use OPTION_MASK_ISA_64. What do we do with TARGET_64BIT and TARGET_64BIT_DEFAULT? They are used to indicate 64bit ISA like: collect2.c:/* TARGET_64BIT may be defined to use driver specific functionality. */ collect2.c:#undef TARGET_64BIT collect2.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT reg-stack.c: if ((flag_pic !TARGET_64BIT) tlink.c:/* TARGET_64BIT may be defined to use driver specific functionality. */ tlink.c:#undef TARGET_64BIT tlink.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT xcoffout.c: if (lno 0 (TARGET_64BIT || lno = (int)USHRT_MAX)) \ config/darwin.c:TARGET_64BIT config/darwin.c:TARGET_64BIT config/darwin.c:: (TARGET_64BIT ? 2 config/darwin.c: if (TARGET_64BIT global_options.x_flag_objc_abi 2) config/darwin.c: if (!TARGET_64BIT global_options.x_flag_objc_abi = 2) config/darwin.c: !TARGET_64BIT) config/darwin.c: if (!TARGET_64BIT)\ config/darwin.c: if (!TARGET_64BIT \ config/darwin.h:flag_next_runtime !TARGET_64BIT; \ config/sol2-bi.h:#define WCHAR_TYPE (TARGET_64BIT ? int : long int) config/sol2-bi.h:#define WINT_TYPE (TARGET_64BIT ? int : long int) Should we keep them? Right now I have #define TARGET_64BITOPTION_ARCH_X86_64 and #define TARGET_64BIT_DEFAULT (OPTION_MASK_ARCH_X86_64 | OPTION_MASK_ISA_64) Should we go with OPTION_MASK_ISA_64BIT - stays the same OPTION_MASK_ISA_X86_64 - OPTION_MASK_ABI_64 OPTION_MASK_ISA_X32 - OPTION_MASK_ABI_X32 instead? -- H.J.
Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2
On Wed, 28 Mar 2012, H.J. Lu wrote: collect2.c:/* TARGET_64BIT may be defined to use driver specific functionality. */ collect2.c:#undef TARGET_64BIT collect2.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT As previously discussed, this use is a bug; TARGET_64BIT should be considered private to back ends and collect2.c should use better-defined target macros or hooks that aren't private to the back end. (I don't know what target macro is being used in collect2 that may be using TARGET_64BIT_DEFAULT indirectly.) reg-stack.c: if ((flag_pic !TARGET_64BIT) Logically part of the x86 back end. We should set things up so that architecture-specific passes can actually go in gcc/config/. tlink.c:/* TARGET_64BIT may be defined to use driver specific functionality. */ tlink.c:#undef TARGET_64BIT tlink.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT Part of collect2. xcoffout.c: if (lno 0 (TARGET_64BIT || lno = (int)USHRT_MAX)) \ Logically part of the rs6000 back end (specifically, for AIX). You can ignore it. config/darwin.c: TARGET_64BIT config/darwin.c: TARGET_64BIT config/darwin.c: : (TARGET_64BIT ? 2 config/darwin.c: if (TARGET_64BIT global_options.x_flag_objc_abi 2) config/darwin.c: if (!TARGET_64BIT global_options.x_flag_objc_abi = 2) config/darwin.c: !TARGET_64BIT) config/darwin.c: if (!TARGET_64BIT) \ config/darwin.c: if (!TARGET_64BIT \ config/darwin.h: flag_next_runtime !TARGET_64BIT; \ config/sol2-bi.h:#define WCHAR_TYPE (TARGET_64BIT ? int : long int) config/sol2-bi.h:#define WINT_TYPE (TARGET_64BIT ? int : long int) I don't know exactly what TARGET_64BIT is intended to mean, architecture-independently, for Darwin and Solaris. -- Joseph S. Myers jos...@codesourcery.com
Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2
On Wed, Mar 28, 2012 at 9:33 PM, H.J. Lu hjl.to...@gmail.com wrote: What do we do with TARGET_64BIT and TARGET_64BIT_DEFAULT? They are used to indicate 64bit ISA like: collect2.c:/* TARGET_64BIT may be defined to use driver specific functionality. */ collect2.c:#undef TARGET_64BIT collect2.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT reg-stack.c: if ((flag_pic !TARGET_64BIT) tlink.c:/* TARGET_64BIT may be defined to use driver specific functionality. */ tlink.c:#undef TARGET_64BIT tlink.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT xcoffout.c: if (lno 0 (TARGET_64BIT || lno = (int)USHRT_MAX)) \ config/darwin.c: TARGET_64BIT config/darwin.c: TARGET_64BIT config/darwin.c: : (TARGET_64BIT ? 2 config/darwin.c: if (TARGET_64BIT global_options.x_flag_objc_abi 2) config/darwin.c: if (!TARGET_64BIT global_options.x_flag_objc_abi = 2) config/darwin.c: !TARGET_64BIT) config/darwin.c: if (!TARGET_64BIT) \ config/darwin.c: if (!TARGET_64BIT \ config/darwin.h: flag_next_runtime !TARGET_64BIT; \ config/sol2-bi.h:#define WCHAR_TYPE (TARGET_64BIT ? int : long int) config/sol2-bi.h:#define WINT_TYPE (TARGET_64BIT ? int : long int) Should we keep them? Right now I have #define TARGET_64BIT OPTION_ARCH_X86_64 and #define TARGET_64BIT_DEFAULT (OPTION_MASK_ARCH_X86_64 | OPTION_MASK_ISA_64) Should we go with OPTION_MASK_ISA_64BIT - stays the same OPTION_MASK_ISA_X86_64 - OPTION_MASK_ABI_64 OPTION_MASK_ISA_X32 - OPTION_MASK_ABI_X32 Yes, the above is IMO much better. We have to separate ABI and ISA defines in some meaningful way. Uros.
Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2
On Wed, Mar 28, 2012 at 12:51 PM, Uros Bizjak ubiz...@gmail.com wrote: On Wed, Mar 28, 2012 at 9:33 PM, H.J. Lu hjl.to...@gmail.com wrote: What do we do with TARGET_64BIT and TARGET_64BIT_DEFAULT? They are used to indicate 64bit ISA like: collect2.c:/* TARGET_64BIT may be defined to use driver specific functionality. */ collect2.c:#undef TARGET_64BIT collect2.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT reg-stack.c: if ((flag_pic !TARGET_64BIT) tlink.c:/* TARGET_64BIT may be defined to use driver specific functionality. */ tlink.c:#undef TARGET_64BIT tlink.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT xcoffout.c: if (lno 0 (TARGET_64BIT || lno = (int)USHRT_MAX)) \ config/darwin.c: TARGET_64BIT config/darwin.c: TARGET_64BIT config/darwin.c: : (TARGET_64BIT ? 2 config/darwin.c: if (TARGET_64BIT global_options.x_flag_objc_abi 2) config/darwin.c: if (!TARGET_64BIT global_options.x_flag_objc_abi = 2) config/darwin.c: !TARGET_64BIT) config/darwin.c: if (!TARGET_64BIT) \ config/darwin.c: if (!TARGET_64BIT \ config/darwin.h: flag_next_runtime !TARGET_64BIT; \ config/sol2-bi.h:#define WCHAR_TYPE (TARGET_64BIT ? int : long int) config/sol2-bi.h:#define WINT_TYPE (TARGET_64BIT ? int : long int) Should we keep them? Right now I have #define TARGET_64BIT OPTION_ARCH_X86_64 and #define TARGET_64BIT_DEFAULT (OPTION_MASK_ARCH_X86_64 | OPTION_MASK_ISA_64) Should we go with OPTION_MASK_ISA_64BIT - stays the same OPTION_MASK_ISA_X86_64 - OPTION_MASK_ABI_64 OPTION_MASK_ISA_X32 - OPTION_MASK_ABI_X32 Yes, the above is IMO much better. We have to separate ABI and ISA defines in some meaningful way. Uros. Here is the new patch. OK for trunk if there are no regressions on Linux/ia32 and Linux/x86-64? Thanks. -- H.J. -- 2012-03-28 H.J. Lu hongjiu...@intel.com * config/i386/biarch64.h (TARGET_64BIT_DEFAULT): Add OPTION_MASK_ABI_64. * config/i386/gnu-user64.h (SPEC_64): Support TARGET_BI_ARCH == 2. (SPEC_X32): Likewise. (MULTILIB_DEFAULTS): Likewise. * config/i386/i386.c (isa_opts): Replace OPTION_MASK_ISA_64BIT with OPTION_MASK_ABI_64 for -m64. (ix86_option_override_internal): Properly set OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32 as well as handle -m32, -m64 and -mx32. * config/i386/i386.h (TARGET_X32): Replace OPTION_ISA_X32 with OPTION_ABI_X32. (TARGET_LP64): Changed to OPTION_ABI_64. * config/i386/i386.opt (m64): Replace ISA_64BIT with ABI_64. (mx32): Replace ISA_X32 with ABI_X32. 2012-03-28 H.J. Lu hongjiu...@intel.com * config/i386/biarch64.h (TARGET_64BIT_DEFAULT): Add OPTION_MASK_ABI_64. * config/i386/gnu-user64.h (SPEC_64): Support TARGET_BI_ARCH == 2. (SPEC_X32): Likewise. (MULTILIB_DEFAULTS): Likewise. * config/i386/i386.c (isa_opts): Replace OPTION_MASK_ISA_64BIT with OPTION_MASK_ABI_64 for -m64. (ix86_option_override_internal): Properly set OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32 as well as handle -m32, -m64 and -mx32. * config/i386/i386.h (TARGET_X32): Replace OPTION_ISA_X32 with OPTION_ABI_X32. (TARGET_LP64): Changed to OPTION_ABI_64. * config/i386/i386.opt (m64): Replace ISA_64BIT with ABI_64. (mx32): Replace ISA_X32 with ABI_X32. diff --git a/gcc/config/i386/biarch64.h b/gcc/config/i386/biarch64.h index 629ec98..0c3811e 100644 --- a/gcc/config/i386/biarch64.h +++ b/gcc/config/i386/biarch64.h @@ -25,5 +25,5 @@ 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/. */ -#define TARGET_64BIT_DEFAULT OPTION_MASK_ISA_64BIT +#define TARGET_64BIT_DEFAULT (OPTION_MASK_ISA_64BIT | OPTION_MASK_ABI_64) #define TARGET_BI_ARCH 1 diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h index 954f3b2..6f7b5de 100644 --- a/gcc/config/i386/gnu-user64.h +++ b/gcc/config/i386/gnu-user64.h @@ -58,8 +58,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #if TARGET_64BIT_DEFAULT #define SPEC_32 m32 +#if TARGET_BI_ARCH == 2 +#define SPEC_64 m64 +#define SPEC_X32 m32|m64:; +#else #define SPEC_64 m32|mx32:; #define SPEC_X32 mx32 +#endif #else #define SPEC_32 m64|mx32:; #define SPEC_64 m64 @@ -95,7 +100,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s #if TARGET_64BIT_DEFAULT +#if TARGET_BI_ARCH == 2 +#define MULTILIB_DEFAULTS { mx32 } +#else #define MULTILIB_DEFAULTS { m64 } +#endif #else #define MULTILIB_DEFAULTS { m32 } #endif diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 18172a1..b11602b 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2657,7
Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2
On Mar 28, 2012, at 12:44 PM, Joseph S. Myers wrote: config/darwin.c: TARGET_64BIT config/darwin.c: TARGET_64BIT config/darwin.c: : (TARGET_64BIT ? 2 config/darwin.c: if (TARGET_64BIT global_options.x_flag_objc_abi 2) config/darwin.c: if (!TARGET_64BIT global_options.x_flag_objc_abi = 2) config/darwin.c: !TARGET_64BIT) config/darwin.c: if (!TARGET_64BIT) \ config/darwin.c: if (!TARGET_64BIT \ config/darwin.h: flag_next_runtime !TARGET_64BIT; \ I don't know exactly what TARGET_64BIT is intended to mean, architecture-independently, for Darwin and Solaris. For darwin, it means: #define TARGET_64BITOPTION_ISA_64BIT from i386.h for darwin on x86, and on ppc, it means the same thing that TARGET_64BIT means in rs6000.h. The rough idea, we are going to generate code for a 64-bit target. (-m64 for example, on x86, that would be x86_64 and on ppc that would be powerpc64).
Re: [PATCH] PR c++/50852 - Revisit dependant template parameter
On 03/28/2012 12:08 PM, Dodji Seketeli wrote: On 03/28/2012 11:02 AM, Dodji Seketeli wrote: templateclass T, templateclass U, T class TT struct S; Then, if U and T have the same level, how do we represent the full set of template parms up to U for instance? I mean if that TREE_LIST of parms still has two entries - one for level 1 that contains T and one for level N (which you say should be 1 as well) that contains U - would the TREE_PURPOSEs of both entries have a 1 as their level number? Hmm, no, I guess you're right; T is an enclosing parameter of TT. Never mind. Jason
[Patch, fortran] PR52652 - call to gfc_match_asynchronous for allocatable at parse.c line 164
Committed as trivial/obvious in revision 185924. Thanks to Brian Ames for spotting the error! 2012-03-28 Paul Thomas pa...@gcc.gnu.org Tobias Burnus bur...@gcc.gnu.org PR fortran/52652 * match.c (gfc_match_allocate, gfc_match_deallocate): Change not.. or to neither.. nor. * parse.c (decode_specification_statement): Correct error in chpice of matching function for allocatable. 2012-03-28 Paul Thomas pa...@gcc.gnu.org Tobias Burnus bur...@gcc.gnu.org PR fortran/52652 * gfortran.dg/allocate_class_1.f90 : Change error test. * gfortran.dg/allocate_with_typespec_4.f90 : Change error test. * gfortran.dg/allocate_alloc_opt_1.f90 : Change error test. * gfortran.dg/deallocate_alloc_opt_1.f90 : Change error test. Cheers Paul
Re: [PATCH] rs6000: Extend TARGET_NO_LWSYNC to cover more processors
On Tue, Mar 27, 2012 at 5:21 PM, Meador Inge mead...@codesourcery.com wrote: Hi All, This patch fixes an issue reported by one of our customers where an instruction exception gets raised when using '__sync_fetch_and_add' on a PowerPC 440 processor. The instruction causing the exception is 'lwsync'. Luckily Joseph laid the groundwork when solving a similar issue for e500 cores [1] by adding a new macro ('TARGET_NO_LWSYNC') for controlling whether 'lwsync' is available . This patch extends the 'TARGET_NO_LWSYNC' macro to include the PowerPC 440 and 603 processors. The 440 because that is what the problem was reported against and the 603 because problems have been reported elsewhere [4] about that. It doesn't seem like 'lwsync' is supported on 603 processors anyway. I looked at the IBM [2] and Freescale [3] manuals and both use the heavyweight implementation of 'sync' (i.e. the 'sync' bit L=0). Meador, Something does not make sense about this patch. Other than unique issues with e500, lwsync should be accepted everywhere. On older processors, the L bit is ignored and it is treated as hwsync. So I do not understand the need for explicit TARGET_NO_LWSYNC on PPC440 or PPC603. Is this some sort of PPC440 errata for the specific 440 being used by Mentor's customer? Thanks, David
Re: C++ PATCH to add auto return type deduction with -std=c++1y
On 03/28/2012 03:20 PM, Marc Glisse wrote: I agree that it works like initialization, and like lambdas, so that ship has sailed. I assume there were good reasons for that, even if they are not obvious, I know things can be trickier than they appear. However, I can't help thinking that there is something wrong with having to write: auto g(int i) - decltype(f(i)) { return f(i); } I agree that this is a serious problem; decltype has the semantics we want, and so new functionality that does something different may not actually be very useful. Unfortunately, making auto functions different from auto variables and lambdas isn't very appealing, either. Jason
Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2
On Wed, Mar 28, 2012 at 2:10 PM, Uros Bizjak ubiz...@gmail.com wrote: On Wed, Mar 28, 2012 at 10:13 PM, H.J. Lu hjl.to...@gmail.com wrote: On Wed, Mar 28, 2012 at 12:51 PM, Uros Bizjak ubiz...@gmail.com wrote: On Wed, Mar 28, 2012 at 9:33 PM, H.J. Lu hjl.to...@gmail.com wrote: What do we do with TARGET_64BIT and TARGET_64BIT_DEFAULT? They are used to indicate 64bit ISA like: collect2.c:/* TARGET_64BIT may be defined to use driver specific functionality. */ collect2.c:#undef TARGET_64BIT collect2.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT reg-stack.c: if ((flag_pic !TARGET_64BIT) tlink.c:/* TARGET_64BIT may be defined to use driver specific functionality. */ tlink.c:#undef TARGET_64BIT tlink.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT xcoffout.c: if (lno 0 (TARGET_64BIT || lno = (int)USHRT_MAX)) \ config/darwin.c: TARGET_64BIT config/darwin.c: TARGET_64BIT config/darwin.c: : (TARGET_64BIT ? 2 config/darwin.c: if (TARGET_64BIT global_options.x_flag_objc_abi 2) config/darwin.c: if (!TARGET_64BIT global_options.x_flag_objc_abi = 2) config/darwin.c: !TARGET_64BIT) config/darwin.c: if (!TARGET_64BIT) \ config/darwin.c: if (!TARGET_64BIT \ config/darwin.h: flag_next_runtime !TARGET_64BIT; \ config/sol2-bi.h:#define WCHAR_TYPE (TARGET_64BIT ? int : long int) config/sol2-bi.h:#define WINT_TYPE (TARGET_64BIT ? int : long int) Should we keep them? Right now I have #define TARGET_64BIT OPTION_ARCH_X86_64 and #define TARGET_64BIT_DEFAULT (OPTION_MASK_ARCH_X86_64 | OPTION_MASK_ISA_64) Should we go with OPTION_MASK_ISA_64BIT - stays the same OPTION_MASK_ISA_X86_64 - OPTION_MASK_ABI_64 OPTION_MASK_ISA_X32 - OPTION_MASK_ABI_X32 Yes, the above is IMO much better. We have to separate ABI and ISA defines in some meaningful way. Uros. Here is the new patch. OK for trunk if there are no regressions on Linux/ia32 and Linux/x86-64? @@ -2657,7 +2657,7 @@ ix86_target_string (HOST_WIDE_INT isa, int flags, const char *arch, preceding options while match those first. */ static struct ix86_target_opts isa_opts[] = { - { -m64, OPTION_MASK_ISA_64BIT }, + { -m64, OPTION_MASK_ABI_64 }, { -mfma4, OPTION_MASK_ISA_FMA4 }, Please add -mx32 here. Probably also -m32. I will add -mx32. Adding -m32 is hard since clearing the OPTION_MASK_ISA_64BIT bit isn't supported here. Can I try { !-m32, OPTION_MASK_ISA_64BIT }, #define TARGET_64BIT OPTION_ISA_64BIT -#define TARGET_X32 OPTION_ISA_X32 +#define TARGET_X32 OPTION_ABI_X32 #define TARGET_MMX OPTION_ISA_MMX #define TARGET_3DNOW OPTION_ISA_3DNOW #define TARGET_3DNOW_A OPTION_ISA_3DNOW_A @@ -77,7 +77,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define TARGET_F16C OPTION_ISA_F16C #define TARGET_RTM OPTION_ISA_RTM -#define TARGET_LP64 (TARGET_64BIT !TARGET_X32) +#define TARGET_LP64 OPTION_ABI_64 Please group new OPTION_ABI_xxx defines together, after ISA defines. Will do. The patch is OK, but please also get approval from Joseph (options maintainer). Thanks. -- H.J.
Re: [PATCH] rs6000: Extend TARGET_NO_LWSYNC to cover more processors
On 03/28/2012 03:59 PM, David Edelsohn wrote: On Tue, Mar 27, 2012 at 5:21 PM, Meador Inge mead...@codesourcery.com wrote: Hi All, This patch fixes an issue reported by one of our customers where an instruction exception gets raised when using '__sync_fetch_and_add' on a PowerPC 440 processor. The instruction causing the exception is 'lwsync'. Luckily Joseph laid the groundwork when solving a similar issue for e500 cores [1] by adding a new macro ('TARGET_NO_LWSYNC') for controlling whether 'lwsync' is available . This patch extends the 'TARGET_NO_LWSYNC' macro to include the PowerPC 440 and 603 processors. The 440 because that is what the problem was reported against and the 603 because problems have been reported elsewhere [4] about that. It doesn't seem like 'lwsync' is supported on 603 processors anyway. I looked at the IBM [2] and Freescale [3] manuals and both use the heavyweight implementation of 'sync' (i.e. the 'sync' bit L=0). Meador, Something does not make sense about this patch. Other than unique issues with e500, lwsync should be accepted everywhere. On older processors, the L bit is ignored and it is treated as hwsync. So I do not understand the need for explicit TARGET_NO_LWSYNC on PPC440 or PPC603. Is this some sort of PPC440 errata for the specific 440 being used by Mentor's customer? David, I am still working on getting the specific processor information. Thanks for the lwsync info and review feedback. If I can't get the processor specifics, then I will just drop the patch. Thanks again, -- Meador Inge CodeSourcery / Mentor Embedded http://www.mentor.com/embedded-software
Go patch committed: Fix crashes
This patch from Rémy Oudompheng fixes a couple of compiler crashes. The compiler would crash on: if true || x, y := 1, 2 {} and var s string s = append(s, hello) Bootstrapped on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch. Ian diff -r f18209760e98 go/expressions.cc --- a/go/expressions.cc Wed Mar 28 14:25:57 2012 -0700 +++ b/go/expressions.cc Wed Mar 28 14:32:00 2012 -0700 @@ -7441,6 +7441,8 @@ void Builtin_call_expression::do_check_types(Gogo*) { + if (this-is_error_expression()) +return; switch (this-code_) { case BUILTIN_INVALID: diff -r f18209760e98 go/parse.cc --- a/go/parse.cc Wed Mar 28 14:25:57 2012 -0700 +++ b/go/parse.cc Wed Mar 28 14:32:00 2012 -0700 @@ -3971,7 +3971,7 @@ bool saw_simple_stat = false; Expression* cond = NULL; - bool saw_send_stmt; + bool saw_send_stmt = false; if (this-simple_stat_may_start_here()) { cond = this-simple_stat(false, saw_send_stmt, NULL, NULL);
[PATCH, i386]: Add AVX modes to ix86_modes_tieable_p
Hello! Attached patch adds AVX modes to ix86_modes_tieable_p, in the same way as other SSE and MMX modes. Additionally, the patch removes unneeded gen_lowpart calls from ix86_expand_vector_move_misalign. The mode function argument just duplicates the mode of operands for convenience. 2012-03-28 Uros Bizjak ubiz...@gmail.com * config/i386/i386.c (ix86_modes_tieable_p): Handle 32bit AVX modes. (ix86_expand_vector_move_misalign): Remove un-needed gen_lowpart calls. Tested on x86_64-pc-linux-gnu {,-m32} with and without -mfpmath=avx. Committed. Uros. Index: i386.c === --- i386.c (revision 185918) +++ i386.c (working copy) @@ -15831,17 +15831,18 @@ ix86_expand_vector_move_misalign (enum machine_mod switch (GET_MODE_SIZE (mode)) { case 16: - /* If we're optimizing for size, movups is the smallest. */ if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL) { op0 = gen_lowpart (V4SFmode, op0); op1 = gen_lowpart (V4SFmode, op1); emit_insn (gen_sse_movups (op0, op1)); - return; } - op0 = gen_lowpart (V16QImode, op0); - op1 = gen_lowpart (V16QImode, op1); - emit_insn (gen_sse2_movdqu (op0, op1)); + else + { + op0 = gen_lowpart (V16QImode, op0); + op1 = gen_lowpart (V16QImode, op1); + emit_insn (gen_sse2_movdqu (op0, op1)); + } break; case 32: op0 = gen_lowpart (V32QImode, op0); @@ -15853,27 +15854,22 @@ ix86_expand_vector_move_misalign (enum machine_mod } break; case MODE_VECTOR_FLOAT: - op0 = gen_lowpart (mode, op0); - op1 = gen_lowpart (mode, op1); - switch (mode) { case V4SFmode: emit_insn (gen_sse_movups (op0, op1)); break; - case V8SFmode: - ix86_avx256_split_vector_move_misalign (op0, op1); - break; case V2DFmode: if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL) { op0 = gen_lowpart (V4SFmode, op0); op1 = gen_lowpart (V4SFmode, op1); emit_insn (gen_sse_movups (op0, op1)); - return; } - emit_insn (gen_sse2_movupd (op0, op1)); + else + emit_insn (gen_sse2_movupd (op0, op1)); break; + case V8SFmode: case V4DFmode: ix86_avx256_split_vector_move_misalign (op0, op1); break; @@ -15918,8 +15914,6 @@ ix86_expand_vector_move_misalign (enum machine_mod if (TARGET_SSE_UNALIGNED_LOAD_OPTIMAL) { - op0 = gen_lowpart (V2DFmode, op0); - op1 = gen_lowpart (V2DFmode, op1); emit_insn (gen_sse2_movupd (op0, op1)); return; } @@ -15984,8 +15978,8 @@ ix86_expand_vector_move_misalign (enum machine_mod return; } - /* ??? Similar to above, only less clear because of quote -typeless stores unquote. */ + /* ??? Similar to above, only less clear +because of typeless stores. */ if (TARGET_SSE2 !TARGET_SSE_TYPELESS_STORES GET_MODE_CLASS (mode) == MODE_VECTOR_INT) { @@ -15998,11 +15992,7 @@ ix86_expand_vector_move_misalign (enum machine_mod if (TARGET_SSE2 mode == V2DFmode) { if (TARGET_SSE_UNALIGNED_STORE_OPTIMAL) - { - op0 = gen_lowpart (V2DFmode, op0); - op1 = gen_lowpart (V2DFmode, op1); - emit_insn (gen_sse2_movupd (op0, op1)); - } + emit_insn (gen_sse2_movupd (op0, op1)); else { m = adjust_address (op0, DFmode, 0); @@ -31399,6 +31389,10 @@ ix86_modes_tieable_p (enum machine_mode mode1, enu /* If MODE2 is only appropriate for an SSE register, then tie with any other mode acceptable to SSE registers. */ + if (GET_MODE_SIZE (mode2) == 32 + ix86_hard_regno_mode_ok (FIRST_SSE_REG, mode2)) +return (GET_MODE_SIZE (mode1) == 32 +ix86_hard_regno_mode_ok (FIRST_SSE_REG, mode1)); if (GET_MODE_SIZE (mode2) == 16 ix86_hard_regno_mode_ok (FIRST_SSE_REG, mode2)) return (GET_MODE_SIZE (mode1) == 16
Fix fallout of VECTOR_CST change
Vector support has been seriously damaged in Ada since the re-implementation of the VECTOR_CST node. This fixes crashes. Tested on i586-suse-linux, applied on the mainline as obvious. 2012-03-28 Eric Botcazou ebotca...@adacore.com * tree.c (tree_size) VECTOR_CST: New case. 2012-03-28 Eric Botcazou ebotca...@adacore.com * gnat.dg/vect7.ad[sb]: New test. -- Eric Botcazou Index: tree.c === --- tree.c (revision 185857) +++ tree.c (working copy) @@ -724,6 +724,10 @@ tree_size (const_tree node) return (sizeof (struct tree_vec) + (TREE_VEC_LENGTH (node) - 1) * sizeof (tree)); +case VECTOR_CST: + return (sizeof (struct tree_vector) + + (TYPE_VECTOR_SUBPARTS (TREE_TYPE (node)) - 1) * sizeof (tree)); + case STRING_CST: return TREE_STRING_LENGTH (node) + offsetof (struct tree_string, str) + 1; -- { dg-do compile } package body Vect7 is procedure Assign is v1 : constant v4sf := (-1.0, -2.0, -3.0, -4.0); v2 : v4sf := v1; v3 : v4sf; begin v3 := vzero; v3 := vconst; v3 := v1; v3 := v2; v3 := (1.0, -2.0, 3.0, -4.0); v3 := (1.0, -2.0, 3.0, F); v2 := vzero; end; end Vect7; package Vect7 is type v4sf is array (1 .. 4) of Float; for v4sf'Alignment use 16; pragma Machine_Attribute (v4sf, vector_type); vzero : constant v4sf := (0.0, 0.0, 0.0, 0.0); vconst : constant v4sf := (1.0, 2.0, 3.0, 4.0); vvar : v4sf := vconst; F : Float := 5.0; procedure Assign; end Vect7;
Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2
On Wed, Mar 28, 2012 at 2:17 PM, H.J. Lu hjl.to...@gmail.com wrote: On Wed, Mar 28, 2012 at 2:10 PM, Uros Bizjak ubiz...@gmail.com wrote: On Wed, Mar 28, 2012 at 10:13 PM, H.J. Lu hjl.to...@gmail.com wrote: On Wed, Mar 28, 2012 at 12:51 PM, Uros Bizjak ubiz...@gmail.com wrote: On Wed, Mar 28, 2012 at 9:33 PM, H.J. Lu hjl.to...@gmail.com wrote: What do we do with TARGET_64BIT and TARGET_64BIT_DEFAULT? They are used to indicate 64bit ISA like: collect2.c:/* TARGET_64BIT may be defined to use driver specific functionality. */ collect2.c:#undef TARGET_64BIT collect2.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT reg-stack.c: if ((flag_pic !TARGET_64BIT) tlink.c:/* TARGET_64BIT may be defined to use driver specific functionality. */ tlink.c:#undef TARGET_64BIT tlink.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT xcoffout.c: if (lno 0 (TARGET_64BIT || lno = (int)USHRT_MAX)) \ config/darwin.c: TARGET_64BIT config/darwin.c: TARGET_64BIT config/darwin.c: : (TARGET_64BIT ? 2 config/darwin.c: if (TARGET_64BIT global_options.x_flag_objc_abi 2) config/darwin.c: if (!TARGET_64BIT global_options.x_flag_objc_abi = 2) config/darwin.c: !TARGET_64BIT) config/darwin.c: if (!TARGET_64BIT) \ config/darwin.c: if (!TARGET_64BIT \ config/darwin.h: flag_next_runtime !TARGET_64BIT; \ config/sol2-bi.h:#define WCHAR_TYPE (TARGET_64BIT ? int : long int) config/sol2-bi.h:#define WINT_TYPE (TARGET_64BIT ? int : long int) Should we keep them? Right now I have #define TARGET_64BIT OPTION_ARCH_X86_64 and #define TARGET_64BIT_DEFAULT (OPTION_MASK_ARCH_X86_64 | OPTION_MASK_ISA_64) Should we go with OPTION_MASK_ISA_64BIT - stays the same OPTION_MASK_ISA_X86_64 - OPTION_MASK_ABI_64 OPTION_MASK_ISA_X32 - OPTION_MASK_ABI_X32 Yes, the above is IMO much better. We have to separate ABI and ISA defines in some meaningful way. Uros. Here is the new patch. OK for trunk if there are no regressions on Linux/ia32 and Linux/x86-64? @@ -2657,7 +2657,7 @@ ix86_target_string (HOST_WIDE_INT isa, int flags, const char *arch, preceding options while match those first. */ static struct ix86_target_opts isa_opts[] = { - { -m64, OPTION_MASK_ISA_64BIT }, + { -m64, OPTION_MASK_ABI_64 }, { -mfma4, OPTION_MASK_ISA_FMA4 }, Please add -mx32 here. Probably also -m32. I will add -mx32. Adding -m32 is hard since clearing the OPTION_MASK_ISA_64BIT bit isn't supported here. Can I try { !-m32, OPTION_MASK_ISA_64BIT }, It turns out I can just remove -m64 and handle -m32/-m64/-mx32 together. #define TARGET_64BIT OPTION_ISA_64BIT -#define TARGET_X32 OPTION_ISA_X32 +#define TARGET_X32 OPTION_ABI_X32 #define TARGET_MMX OPTION_ISA_MMX #define TARGET_3DNOW OPTION_ISA_3DNOW #define TARGET_3DNOW_A OPTION_ISA_3DNOW_A @@ -77,7 +77,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define TARGET_F16C OPTION_ISA_F16C #define TARGET_RTM OPTION_ISA_RTM -#define TARGET_LP64 (TARGET_64BIT !TARGET_X32) +#define TARGET_LP64 OPTION_ABI_64 Please group new OPTION_ABI_xxx defines together, after ISA defines. Will do. The patch is OK, but please also get approval from Joseph (options maintainer). Here is the updated patch. I will wait for OK from Joseph. Thanks, -- H.J. 2012-03-28 H.J. Lu hongjiu...@intel.com * config/i386/biarch64.h (TARGET_64BIT_DEFAULT): Add OPTION_MASK_ABI_64. * config/i386/gnu-user64.h (SPEC_64): Support TARGET_BI_ARCH == 2. (SPEC_X32): Likewise. (MULTILIB_DEFAULTS): Likewise. * config/i386/i386.c (isa_opts): Remove -m64. (ix86_target_string): Properly handle -m32/-m64/-mx32. (ix86_option_override_internal): Properly set OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32 as well as handle -m32, -m64 and -mx32. * config/i386/i386.h (TARGET_X32): Replace OPTION_ISA_X32 with OPTION_ABI_X32. Moved after TARGET_LP64. (TARGET_LP64): Changed to OPTION_ABI_64. * config/i386/i386.opt (m64): Replace ISA_64BIT with ABI_64. (mx32): Replace ISA_X32 with ABI_X32. diff --git a/gcc/config/i386/biarch64.h b/gcc/config/i386/biarch64.h index 629ec98..0c3811e 100644 --- a/gcc/config/i386/biarch64.h +++ b/gcc/config/i386/biarch64.h @@ -25,5 +25,5 @@ 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/. */ -#define TARGET_64BIT_DEFAULT OPTION_MASK_ISA_64BIT +#define TARGET_64BIT_DEFAULT (OPTION_MASK_ISA_64BIT | OPTION_MASK_ABI_64) #define TARGET_BI_ARCH 1 diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h index 954f3b2..6f7b5de 100644 --- a/gcc/config/i386/gnu-user64.h +++ b/gcc/config/i386/gnu-user64.h @@ -58,8 +58,13
Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2
On Wed, 28 Mar 2012, H.J. Lu wrote: Here is the updated patch. I will wait for OK from Joseph. I have no comments on this patch. -- Joseph S. Myers jos...@codesourcery.com
Go patch committed: Avoid compiler crash
This patch from Rémy Oudompheng avoids a Go frontend crash on the valid Go code package p var v struct{ I } type I interface{} Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch. Ian diff -r 652c8036e264 go/gogo.cc --- a/go/gogo.cc Wed Mar 28 14:32:28 2012 -0700 +++ b/go/gogo.cc Wed Mar 28 15:12:54 2012 -0700 @@ -1653,8 +1653,12 @@ } case Type::TYPE_STRUCT: + // Traverse the field types first in case there is an embedded + // field with methods that the struct should inherit. + if (t-struct_type()-traverse_field_types(this) == TRAVERSE_EXIT) + return TRAVERSE_EXIT; t-struct_type()-finalize_methods(this-gogo_); - break; + return TRAVERSE_SKIP_COMPONENTS; default: break;
Go patch committed: Avoid ICE on invalid
This patch from Rémy Oudompheng avoids an ICE on invalid in the Go frontend. Bootstrapped on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch. Ian diff -r c1a1b9b5894b go/expressions.cc --- a/go/expressions.cc Wed Mar 28 15:20:12 2012 -0700 +++ b/go/expressions.cc Wed Mar 28 15:24:08 2012 -0700 @@ -10577,7 +10577,8 @@ tree Interface_field_reference_expression::do_get_tree(Translate_context*) { - go_unreachable(); + error_at(this-location(), reference to method other than calling it); + return error_mark_node; } // Dump ast representation for an interface field reference.
Go patch committed: Avoid ICE on invalid len call
This Go frontend patch from Rémy Oudompheng avoids an ICE on an invalid call to the builtin len function. Bootstrapped on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch. Ian diff -r 5b52b07a8cf4 go/expressions.cc --- a/go/expressions.cc Wed Mar 28 15:24:30 2012 -0700 +++ b/go/expressions.cc Wed Mar 28 15:29:03 2012 -0700 @@ -6609,7 +6609,7 @@ if (this-code_ == BUILTIN_LEN || this-code_ == BUILTIN_CAP) { Expression* arg = this-one_arg(); - if (!arg-is_constant()) + if (arg != NULL !arg-is_constant()) { Find_call_expression find_call; Expression::traverse(arg, find_call); @@ -6929,7 +6929,7 @@ Builtin_call_expression::one_arg() const { const Expression_list* args = this-args(); - if (args-size() != 1) + if (args == NULL || args-size() != 1) return NULL; return args-front(); }
Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2
On Wed, Mar 28, 2012 at 3:07 PM, Joseph S. Myers jos...@codesourcery.com wrote: On Wed, 28 Mar 2012, H.J. Lu wrote: Here is the updated patch. I will wait for OK from Joseph. I have no comments on this patch. Given that my patch doesn't change any command line options, I am checking it in. Please let me know if there are any issues. Thanks. -- H.J.
Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors
Hi, On 03/28/2012 11:02 AM, Paolo Carlini wrote: + !comp_except_specs (new_exceptions, old_exceptions, ce_normal) + /* Special case in C++11: noexcept has been deduced as true for + the declaration and there is no exception-specification on the + definition. */ + !(DECL_DESTRUCTOR_P (new_decl) + cxx_dialect= cxx0x + !new_exceptions TYPE_NOEXCEPT_P (old_type))) TYPE_NOEXCEPT_P is the wrong test; the implicit declaration might have an exception-specification that allows some or all exceptions. I think the most straightforward thing would be to add the implicit exception-specification immediately when declaring a destructor outside the class, so that by the time we get to check_redeclaration_exception_specification the EH specs will match. Agreed. The below is another iteration (which passes boot test, library included modulo the already mentioned expected failures in C++11 mode), I'm trying to get to the point you by and large like the code proper, thus I can start adjusting the testcases, etc. Anyway, some notes about bits new wrt the previous iterations and not totally obvious given your indications: 1- Turns out the check_bases_and_members change has to happen earlier, because we want to fixup the exceptions before check_bases, otherwise we reject things like (in the C++ library and elsewhere): struct True2 { virtual ~True2() noexcept; }; template typename Base struct C : Base { ~C(); }; 2- The new register_specialization bits are needed to cope with (also in the C++ library and elsewhere): templatetypename T struct A { ~A(); }; template Aint::~A(); template Aint::~A() { } As a matter of fact, though, there is one more path in register_specialization which leads to a duplicate_decls call, I'm not 100% sure we can leave it alone. 3- Names of the new functions, files to which belong, I'm just guessing. Thanks, Paolo. / Index: class.c === --- class.c (revision 185920) +++ class.c (working copy) @@ -4321,6 +4321,40 @@ clone_constructors_and_destructors (tree t) clone_function_decl (OVL_CURRENT (fns), /*update_method_vec_p=*/1); } +/* Deduce noexcept for a destructor DTOR. */ +void +deduce_noexcept_on_destructor (tree dtor) +{ + if (!TYPE_RAISES_EXCEPTIONS (TREE_TYPE (dtor))) +{ + tree ctx = DECL_CONTEXT (dtor); + tree implicit_fn = implicitly_declare_fn (sfk_destructor, ctx, + /*const_p=*/false); + tree eh_spec = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (implicit_fn)); + TREE_TYPE (dtor) = build_exception_variant (TREE_TYPE (dtor), eh_spec); +} +} + +/* For each destructor in T, deduce noexcept: + + 12.4/3: A declaration of a destructor that does not have an + exception-specification is implicitly considered to have the + same exception-specification as an implicit declaration (15.4). */ + +static void +deduce_noexcept_on_destructors (tree t) +{ + tree fns; + + /* If for some reason we don't have a CLASSTYPE_METHOD_VEC, we bail + out now. */ + if (!CLASSTYPE_METHOD_VEC (t)) +return; + + for (fns = CLASSTYPE_DESTRUCTORS (t); fns; fns = OVL_NEXT (fns)) +deduce_noexcept_on_destructor (OVL_CURRENT (fns)); +} + /* Subroutine of set_one_vmethod_tm_attributes. Search base classes of TYPE for virtual functions which FNDECL overrides. Return a mask of the tm attributes found therein. */ @@ -4994,6 +5028,10 @@ check_bases_and_members (tree t) cant_have_const_ctor = 0; no_const_asn_ref = 0; + /* Deduce noexcept on destructors. */ + if (cxx_dialect = cxx0x) +deduce_noexcept_on_destructors (t); + /* Check all the base-classes. */ check_bases (t, cant_have_const_ctor, no_const_asn_ref); Index: decl.c === --- decl.c (revision 185920) +++ decl.c (working copy) @@ -7528,6 +7528,12 @@ grokfndecl (tree ctype, if (TREE_CODE (decl) == TEMPLATE_DECL) decl = DECL_TEMPLATE_RESULT (decl); + /* 12.4/3 */ + if (cxx_dialect = cxx0x + DECL_DESTRUCTOR_P (decl) + TYPE_RAISES_EXCEPTIONS (TREE_TYPE (old_decl))) + deduce_noexcept_on_destructor (decl); + /* Attempt to merge the declarations. This can fail, in the case of some invalid specialization declarations. */ pushed_scope = push_scope (ctype); Index: method.c === --- method.c(revision 185920) +++ method.c(working copy) @@ -1444,7 +1444,7 @@ explain_implicit_non_constexpr (tree decl) reference argument or a non-const reference. Returns the FUNCTION_DECL for the implicitly declared function. */ -static tree +tree implicitly_declare_fn (special_function_kind kind, tree type, bool const_p) { tree fn; Index: pt.c
Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors
Oops... 1- Turns out the check_bases_and_members change has to happen earlier, because we want to fixup the exceptions before check_bases, otherwise we reject things like (in the C++ library and elsewhere): struct True2 { virtual ~True2() noexcept; }; template typename Base struct C : Base { ~C(); }; Last line of the snippet missing: CTrue2 c; Paolo.
Re: [PATCH, i386, Android] -mandroid support for i386 target
This patch looks good for Android toolchain. But I am not a maintainer. Can any x86 backend maintainer help to review the patch? Thanks, Jing On Tue, Mar 27, 2012 at 6:55 AM, Ilya Enkovich enkovich@gmail.com wrote: Ping 13 марта 2012 г. 15:13 пользователь Ilya Enkovich enkovich@gmail.com написал: Ping 27 февраля 2012 г. 6:41 пользователь Ilya Enkovich enkovich@gmail.com написал: You should keep those *_SPEC and define them with new GNU_*_SPEC in gnu-user.h since gnu-user.h is also used by other non-linux targets. In linux.h, you undef *_SPEC before defining them. -- H.J. Thanks for the note. Here is fixed version. Is it OK now? Thanks, Ilya -- 2012-02-27 Enkovich Ilya ilya.enkov...@intel.com * gcc/config/i386/gnu-user.h (GNU_USER_TARGET_CC1_SPEC): New. (CC1_SPEC): Use GNU_USER_TARGET_CC1_SPEC. (GNU_USER_TARGET_LINK_SPEC): New. (LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC. (GNU_USER_TARGET_MATHFILE_SPEC): New. (ENDFILE_SPEC): Use GNU_USER_TARGET_MATHFILE_SPEC. * gcc/config/i386/linux.h (CC1_SPEC): New. (LINK_SPEC): New. (LIB_SPEC): New. (STARTFILE_SPEC): New. (ENDFILE_SPEC): New. diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h index 98d0a25..33ceab7 100644 --- a/gcc/config/i386/gnu-user.h +++ b/gcc/config/i386/gnu-user.h @@ -77,8 +77,11 @@ along with GCC; see the file COPYING3. If not see #undef CPP_SPEC #define CPP_SPEC %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT} +#undef GNU_USER_TARGET_CC1_SPEC +#define GNU_USER_TARGET_CC1_SPEC %(cc1_cpu) %{profile:-p} + #undef CC1_SPEC -#define CC1_SPEC %(cc1_cpu) %{profile:-p} +#define CC1_SPEC GNU_USER_TARGET_CC1_SPEC /* Provide a LINK_SPEC appropriate for GNU userspace. Here we provide support for the special GCC options -static and -shared, which allow us to @@ -97,22 +100,28 @@ along with GCC; see the file COPYING3. If not see { link_emulation, GNU_USER_LINK_EMULATION },\ { dynamic_linker, GNU_USER_DYNAMIC_LINKER } -#undef LINK_SPEC -#define LINK_SPEC -m %(link_emulation) %{shared:-shared} \ +#define GNU_USER_TARGET_LINK_SPEC \ + -m %(link_emulation) %{shared:-shared} \ %{!shared: \ %{!static: \ %{rdynamic:-export-dynamic} \ -dynamic-linker %(dynamic_linker)} \ %{static:-static}} +#undef LINK_SPEC +#define LINK_SPEC GNU_USER_TARGET_LINK_SPEC + /* Similar to standard GNU userspace, but adding -ffast-math support. */ -#undef ENDFILE_SPEC -#define ENDFILE_SPEC \ +#define GNU_USER_TARGET_MATHFILE_SPEC \ %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ %{mpc32:crtprec32.o%s} \ %{mpc64:crtprec64.o%s} \ - %{mpc80:crtprec80.o%s} \ - %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s + %{mpc80:crtprec80.o%s} + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + GNU_USER_TARGET_MATHFILE_SPEC \ + GNU_USER_TARGET_ENDFILE_SPEC /* A C statement (sans semicolon) to output to the stdio stream FILE the assembler definition of uninitialized global DECL named diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h index 73681fe..a832ddc 100644 --- a/gcc/config/i386/linux.h +++ b/gcc/config/i386/linux.h @@ -22,3 +22,30 @@ along with GCC; see the file COPYING3. If not see #define GNU_USER_LINK_EMULATION elf_i386 #define GLIBC_DYNAMIC_LINKER /lib/ld-linux.so.2 + +#undef CC1_SPEC +#define CC1_SPEC \ + LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \ + GNU_USER_TARGET_CC1_SPEC ANDROID_CC1_SPEC) + +#undef LINK_SPEC +#define LINK_SPEC \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \ + GNU_USER_TARGET_LINK_SPEC ANDROID_LINK_SPEC) + +#undef LIB_SPEC +#define LIB_SPEC \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LIB_SPEC, \ + GNU_USER_TARGET_LIB_SPEC ANDROID_LIB_SPEC) + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, \ + ANDROID_STARTFILE_SPEC) + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC \ + GNU_USER_TARGET_ENDFILE_SPEC, \ + GNU_USER_TARGET_MATHFILE_SPEC \ + ANDROID_ENDFILE_SPEC)
Re: [PATCH, i386, Android] Enable __ANDROID__ macro for Android i386 target
This patch looks good for Android toolchain. But I am not a maintainer. Can any x86 backend maintainer help to review the patch? Thanks, Jing On Tue, Mar 27, 2012 at 6:56 AM, Ilya Enkovich enkovich@gmail.com wrote: Ping 13 марта 2012 г. 15:12 пользователь Ilya Enkovich enkovich@gmail.com написал: Ping 27 февраля 2012 г. 6:39 пользователь Ilya Enkovich enkovich@gmail.com написал: Undef TARGET_OS_CPP_BUILTINS and define TARGET_OS_CPP_BUILTINS in linux.h with GNU_USER_TARGET_OS_CPP_BUILTINS and ANDROID_TARGET_OS_CPP_BUILTINS. -- H.J. Hello, Here is a variant with linux.h modification. Does it look fine? Thanks, Ilya -- 2012-02-27 Enkovich Ilya ilya.enkov...@intel.com * gcc/config/i386/linux.h (TARGET_OS_CPP_BUILTINS): New. diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h index 73681fe..03c7b29 100644 --- a/gcc/config/i386/linux.h +++ b/gcc/config/i386/linux.h @@ -22,3 +22,12 @@ along with GCC; see the file COPYING3. If not see #define GNU_USER_LINK_EMULATION elf_i386 #define GLIBC_DYNAMIC_LINKER /lib/ld-linux.so.2 + +#undef TARGET_OS_CPP_BUILTINS +#define TARGET_OS_CPP_BUILTINS() \ + do \ + { \ + GNU_USER_TARGET_OS_CPP_BUILTINS(); \ + ANDROID_TARGET_OS_CPP_BUILTINS(); \ + } \ + while (0)
Re: [libgo] Handle Solaris 11 Update 1 zone_net_addr_t
Rainer Orth r...@cebitec.uni-bielefeld.de writes: The following patch fixes this and allowed the bootstrap to complete, but I wonder if it wouldn't be better to globally do a sed -e 's/_in6_addr/[16]byte/' instead of the current special-casing of _in6_addr in a couple of places. Yeah, probably. 2012-03-22 Rainer Orth r...@cebitec.uni-bielefeld.de * mksysinfo.sh (_zone_net_addr_t): Handle _in6_addr. But for now I have committed your patch to mainline and 4.7 branch. Thanks. Ian
PATCH: Don't set TM_MULTILIB_CONFIG if --disable-multilib is used
Hi, When --disable-multilib is used on Linux/x86-64 target, we still set TM_MULTILIB_CONFIG=m64,m32 It isn't necessary and doesn't work if the default ABI is -mx32. This patch checks --with-multilib-list for x86-64 Linux targets only if multilib is enabled. OK for trunk? Thanks. H.J. --- 2012-03-28 H.J. Lu hongjiu...@intel.com * config.gcc: Check --with-multilib-list for x86-64 Linux targets only if multilib is enabled. diff --git a/gcc/config.gcc b/gcc/config.gcc index 1f2baee..86d12db 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1275,22 +1296,24 @@ x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu) ;; esac tmake_file=${tmake_file} i386/t-linux64 - x86_multilibs=${with_multilib_list} - if test $x86_multilibs = default; then - x86_multilibs=m64,m32 + if test x$enable_multilib = xyes; then + x86_multilibs=${with_multilib_list} + if test $x86_multilibs = default; then + x86_multilibs=m64,m32 + fi + x86_multilibs=`echo $x86_multilibs | sed -e 's/,/ /g'` + for x86_multilib in ${x86_multilibs}; do + case ${x86_multilib} in + m32 | m64 | mx32) + TM_MULTILIB_CONFIG=${TM_MULTILIB_CONFIG},${x86_multilib} + ;; + *) + echo --with-multilib-list=${x86_with_multilib} not supported. + exit 1 + esac + done + TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'` fi - x86_multilibs=`echo $x86_multilibs | sed -e 's/,/ /g'` - for x86_multilib in ${x86_multilibs}; do - case ${x86_multilib} in - m32 | m64 | mx32) - TM_MULTILIB_CONFIG=${TM_MULTILIB_CONFIG},${x86_multilib} - ;; - *) - echo --with-multilib-list=${x86_with_multilib} not supported. - exit 1 - esac - done - TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'` ;; i[34567]86-pc-msdosdjgpp*) xm_file=i386/xm-djgpp.h
[google] Refine static branch prediction (iv-compare heuristic)
Hi, This patch handles the comparison of iv against the loop iv initial value. Previously, we only handle the comparison of iv against its bound. Bootstrapped and passed all regression tests. Ok for google branches? Thanks, Dehao 2012-03-29 Dehao Chen de...@google.com * predict.c (predict_iv_comparison): Add the comparison of induction variable against its initial value. 2012-03-29 Dehao Chen de...@google.com * gcc.dg/predict-5.c: Check if LOOP_IV_COMPARE static predict heuristic is working properly. Index: gcc/testsuite/gcc.dg/predict-5.c === --- gcc/testsuite/gcc.dg/predict-5.c(revision 0) +++ gcc/testsuite/gcc.dg/predict-5.c(revision 0) @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options -O2 -fdump-tree-profile_estimate } */ + +extern int global; + +int bar(int); + +void foo (int base, int bound) +{ + int i, ret = 0; + for (i = base; i = bound; i++) +{ + if (i base + 2) + global += bar (i); + else +global += bar (i + 1); +} +} + +/* { dg-final { scan-tree-dump loop iv compare heuristics profile_estimate} } */ +/* { dg-final { cleanup-tree-dump profile_estimate } } */ Index: gcc/predict.c === --- gcc/predict.c (revision 185903) +++ gcc/predict.c (working copy) @@ -1185,8 +1185,7 @@ return; } - if (!expr_coherent_p (loop_bound_var, compare_var) - || loop_iv_base_var != compare_base) + if (loop_iv_base_var != compare_base) return; /* If loop bound, base and compare bound are all constents, we can @@ -1230,34 +1229,52 @@ return; } - if ((loop_bound_code == LT_EXPR || loop_bound_code == LE_EXPR) - (compare_code == LT_EXPR || compare_code == LE_EXPR)) -predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); - else if ((loop_bound_code == GT_EXPR || loop_bound_code == GE_EXPR) - (compare_code == GT_EXPR || compare_code == GE_EXPR)) -predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); - else if (loop_bound_code == NE_EXPR) -{ - /* If the loop backedge condition is (i != bound), we do -the comparison based on the step of IV: - * step 0 : backedge condition is like (i bound) - * step 0 : backedge condition is like (i bound) */ - gcc_assert (loop_bound_step != 0); + if (expr_coherent_p (loop_bound_var, compare_var)) +{ + if ((loop_bound_code == LT_EXPR || loop_bound_code == LE_EXPR) + (compare_code == LT_EXPR || compare_code == LE_EXPR)) + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); + else if ((loop_bound_code == GT_EXPR || loop_bound_code == GE_EXPR) + (compare_code == GT_EXPR || compare_code == GE_EXPR)) + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); + else if (loop_bound_code == NE_EXPR) + { + /* If the loop backedge condition is (i != bound), we do +the comparison based on the step of IV: +* step 0 : backedge condition is like (i bound) +* step 0 : backedge condition is like (i bound) */ + gcc_assert (loop_bound_step != 0); + if (loop_bound_step 0 + (compare_code == LT_EXPR + || compare_code == LE_EXPR)) + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); + else if (loop_bound_step 0 + (compare_code == GT_EXPR + || compare_code == GE_EXPR)) + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); + else + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN); + } + else + /* The branch is predicted not-taken if loop_bound_code is + opposite with compare_code. */ + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN); +} + else if (expr_coherent_p (loop_iv_base_var, compare_var)) +{ + /* For cases like: + for (i = s; i h; i++) +if (i s + 2) +The branch should be predicted taken. */ if (loop_bound_step 0 - (compare_code == LT_EXPR - || compare_code == LE_EXPR)) + (compare_code == GT_EXPR || compare_code == GE_EXPR)) predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); else if (loop_bound_step 0 - (compare_code == GT_EXPR - || compare_code == GE_EXPR)) + (compare_code == LT_EXPR || compare_code == LE_EXPR)) predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); else predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN); } - else -/* The branch is predicted not-taken if loop_bound_code is - opposite with compare_code. */ -predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN); } /* Predict edge probabilities by
Re: [google] Refine static branch prediction (iv-compare heuristic)
Can the test case be improved so that expected prediction results is checked (with the help of more dumping such as blah blah is predicted to be taken/not taken with probability xyz) ? Also the more test cases need to be added to cover more cases base, base +1, =base +2, base+1, =base+1 etc -- even though expression reassociation will normalize them ... Thanks, David On Wed, Mar 28, 2012 at 4:54 PM, Dehao Chen de...@google.com wrote: Hi, This patch handles the comparison of iv against the loop iv initial value. Previously, we only handle the comparison of iv against its bound. Bootstrapped and passed all regression tests. Ok for google branches? Thanks, Dehao 2012-03-29 Dehao Chen de...@google.com * predict.c (predict_iv_comparison): Add the comparison of induction variable against its initial value. 2012-03-29 Dehao Chen de...@google.com * gcc.dg/predict-5.c: Check if LOOP_IV_COMPARE static predict heuristic is working properly. Index: gcc/testsuite/gcc.dg/predict-5.c === --- gcc/testsuite/gcc.dg/predict-5.c (revision 0) +++ gcc/testsuite/gcc.dg/predict-5.c (revision 0) @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options -O2 -fdump-tree-profile_estimate } */ + +extern int global; + +int bar(int); + +void foo (int base, int bound) +{ + int i, ret = 0; + for (i = base; i = bound; i++) + { + if (i base + 2) + global += bar (i); + else + global += bar (i + 1); + } +} + +/* { dg-final { scan-tree-dump loop iv compare heuristics profile_estimate} } */ +/* { dg-final { cleanup-tree-dump profile_estimate } } */ Index: gcc/predict.c === --- gcc/predict.c (revision 185903) +++ gcc/predict.c (working copy) @@ -1185,8 +1185,7 @@ return; } - if (!expr_coherent_p (loop_bound_var, compare_var) - || loop_iv_base_var != compare_base) + if (loop_iv_base_var != compare_base) return; /* If loop bound, base and compare bound are all constents, we can @@ -1230,34 +1229,52 @@ return; } - if ((loop_bound_code == LT_EXPR || loop_bound_code == LE_EXPR) - (compare_code == LT_EXPR || compare_code == LE_EXPR)) - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); - else if ((loop_bound_code == GT_EXPR || loop_bound_code == GE_EXPR) - (compare_code == GT_EXPR || compare_code == GE_EXPR)) - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); - else if (loop_bound_code == NE_EXPR) - { - /* If the loop backedge condition is (i != bound), we do - the comparison based on the step of IV: - * step 0 : backedge condition is like (i bound) - * step 0 : backedge condition is like (i bound) */ - gcc_assert (loop_bound_step != 0); + if (expr_coherent_p (loop_bound_var, compare_var)) + { + if ((loop_bound_code == LT_EXPR || loop_bound_code == LE_EXPR) + (compare_code == LT_EXPR || compare_code == LE_EXPR)) + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); + else if ((loop_bound_code == GT_EXPR || loop_bound_code == GE_EXPR) + (compare_code == GT_EXPR || compare_code == GE_EXPR)) + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); + else if (loop_bound_code == NE_EXPR) + { + /* If the loop backedge condition is (i != bound), we do + the comparison based on the step of IV: + * step 0 : backedge condition is like (i bound) + * step 0 : backedge condition is like (i bound) */ + gcc_assert (loop_bound_step != 0); + if (loop_bound_step 0 + (compare_code == LT_EXPR + || compare_code == LE_EXPR)) + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); + else if (loop_bound_step 0 + (compare_code == GT_EXPR + || compare_code == GE_EXPR)) + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); + else + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN); + } + else + /* The branch is predicted not-taken if loop_bound_code is + opposite with compare_code. */ + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN); + } + else if (expr_coherent_p (loop_iv_base_var, compare_var)) + { + /* For cases like: + for (i = s; i h; i++) + if (i s + 2) + The branch should be predicted taken. */ if (loop_bound_step 0 - (compare_code == LT_EXPR - || compare_code == LE_EXPR)) + (compare_code == GT_EXPR || compare_code == GE_EXPR)) predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); else if
Re: PATCH: Don't set TM_MULTILIB_CONFIG if --disable-multilib is used
On Wed, Mar 28, 2012 at 4:43 PM, H.J. Lu hongjiu...@intel.com wrote: Hi, When --disable-multilib is used on Linux/x86-64 target, we still set TM_MULTILIB_CONFIG=m64,m32 It isn't necessary and doesn't work if the default ABI is -mx32. This patch checks --with-multilib-list for x86-64 Linux targets only if multilib is enabled. OK for trunk? TM_MULTILIB_CONFIG isn't used with --with-multilib-list. This patch is withdrawn. H.J.
Re: PATCH: Add --with-abi= support to x86_64-*-*
On Sun, Mar 25, 2012 at 2:27 PM, Nathanael Nerode (GCC) ncn_gc...@fastmail.fm wrote: Hi, Can any build maintainers review this patch? I don't feel comfortable reviewing this, because I don't fully comprehend the intricacy of the interactions in this area. It *looks* good, but I don't trust my review abilities here. If this has been tested *in each of the possible modes* on x86-64, then I would approve it, but there are an awful lot of combinations, and Tested on Linux/x32 does not tell me whether it works correctly on all of them. Perhaps someone else will be more able to review this by reading through the logic tree. Thanks. Since OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 have been added, the --with-abi= patch is much simpler. It just includes i386/biarchx32.h instead of i386/biarch64.h when --with-abi={x32|mx32} or --with-multilib-list=mx32 is used. OK for trunk? Thanks. -- H.J. --- 2012-03-28 H.J. Lu hongjiu...@intel.com * config.gcc: Use i386/biarchx32.h instead of i386/biarch64.h for --with-abi={x32|mx32} or --with-multilib-list=mx32. (supported_defaults): Add abi for i[34567]86-*-* and x86_64-*-*. * config/i386/biarchx32.h: New. 2012-03-28 H.J. Lu hongjiu...@intel.com * config.gcc: Use i386/biarchx32.h instead of i386/biarch64.h for --with-abi={x32|mx32} or --with-multilib-list=mx32. (supported_defaults): Add abi for i[34567]86-*-* and x86_64-*-*. * config/i386/biarchx32.h: New. diff --git a/gcc/config.gcc b/gcc/config.gcc index 1f2baee..5bce2c1 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -488,6 +488,10 @@ fi case ${target} in i[34567]86-*-*) + if test x$with_abi != x; then + echo This target does not support --with-abi. + exit 1 + fi if test x$enable_cld = xyes; then tm_defines=${tm_defines} USE_IX86_CLD=1 fi @@ -497,7 +501,24 @@ i[34567]86-*-*) tm_file=vxworks-dummy.h ${tm_file} ;; x86_64-*-*) - tm_file=i386/biarch64.h ${tm_file} + case ${with_abi} in + ) + if test x$with_multilib_list = xmx32; then + tm_file=i386/biarchx32.h ${tm_file} + else + tm_file=i386/biarch64.h ${tm_file} + fi + ;; + 64 | m64) + tm_file=i386/biarch64.h ${tm_file} + ;; + x32 | mx32) + tm_file=i386/biarchx32.h ${tm_file} + ;; + *) + echo Unknown ABI used in --with-abi=$with_abi + exit 1 + esac if test x$enable_cld = xyes; then tm_defines=${tm_defines} USE_IX86_CLD=1 fi @@ -3137,7 +3158,7 @@ case ${target} in ;; i[34567]86-*-* | x86_64-*-*) - supported_defaults=arch arch_32 arch_64 cpu cpu_32 cpu_64 tune tune_32 tune_64 + supported_defaults=abi arch arch_32 arch_64 cpu cpu_32 cpu_64 tune tune_32 tune_64 for which in arch arch_32 arch_64 cpu cpu_32 cpu_64 tune tune_32 tune_64; do eval val=\$with_$which case ${val} in diff --git a/gcc/config/i386/biarchx32.h b/gcc/config/i386/biarchx32.h new file mode 100644 index 000..69d6722 --- /dev/null +++ b/gcc/config/i386/biarchx32.h @@ -0,0 +1,28 @@ +/* Make configure files to produce biarch compiler defaulting to x32 mode. + This file must be included very first, while the OS specific file later + to overwrite otherwise wrong defaults. + Copyright (C) 2012 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +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/. */ + +#define TARGET_64BIT_DEFAULT (OPTION_MASK_ISA_64BIT | OPTION_MASK_ABI_X32) +#define TARGET_BI_ARCH 2
PATCH: Define x86_64_fallback_frame_state only for glibc
Hi, We shouldn't assume that we can define x86_64_fallback_frame_state for other x86-64 C libraries, like Bionic. OK for trunk? Thanks. H.J. --- 2012-03-27 H.J. Lu hongjiu...@intel.com * config/i386/linux-unwind.h (x86_64_fallback_frame_state): Define only for glibc. diff --git a/gcc/config/i386/linux-unwind.h b/gcc/config/i386/linux-unwind.h index c5f7ea0..61b4ebf 100644 --- a/libgcc/config/i386/linux-unwind.h +++ b/libgcc/config/i386/linux-unwind.h @@ -28,11 +28,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #ifndef inhibit_libc -#ifdef __x86_64__ +/* There's no sys/ucontext.h for glibc 2.0, so no + signal-turned-exceptions for them. There's also no configure-run for + the target, so we can't check on (e.g.) HAVE_SYS_UCONTEXT_H. Using the + target libc version macro should be enough. */ +#if defined __GLIBC__ !(__GLIBC__ == 2 __GLIBC_MINOR__ == 0) #include signal.h #include sys/ucontext.h +#ifdef __x86_64__ + #define MD_FALLBACK_FRAME_STATE_FOR x86_64_fallback_frame_state static _Unwind_Reason_Code @@ -102,15 +108,6 @@ x86_64_fallback_frame_state (struct _Unwind_Context *context, #else /* ifdef __x86_64__ */ -/* There's no sys/ucontext.h for glibc 2.0, so no - signal-turned-exceptions for them. There's also no configure-run for - the target, so we can't check on (e.g.) HAVE_SYS_UCONTEXT_H. Using the - target libc version macro should be enough. */ -#if defined __GLIBC__ !(__GLIBC__ == 2 __GLIBC_MINOR__ == 0) - -#include signal.h -#include sys/ucontext.h - #define MD_FALLBACK_FRAME_STATE_FOR x86_fallback_frame_state static _Unwind_Reason_Code @@ -191,6 +188,6 @@ x86_frob_update_context (struct _Unwind_Context *context, _Unwind_SetSignalFrame (context, 1); } -#endif /* not glibc 2.0 */ #endif /* ifdef __x86_64__ */ +#endif /* not glibc 2.0 */ #endif /* ifdef inhibit_libc */
C++ PATCH for c++/52746 (virtual destructors broken in templates)
In my fix for PR 48051 I failed to audit all the users of adjust_result_of_qualified_name_lookup to make sure it wasn't being called for non-qualified lookups as well; in this case we were calling it for an explicit destructor call, and now that we set BASELINK_QUALIFIED_P in that function, we were suppressing virtual calling semantics inappropriately. Tested x86_64-pc-linux-gnu, applying to trunk and 4.7. commit 1f230c968d34b5c48ad50f83e8774de52d04d653 Author: Jason Merrill ja...@redhat.com Date: Wed Mar 28 20:59:26 2012 -0400 PR c++/52746 * typeck.c (lookup_destructor): Clear BASELINK_QUALIFIED_P if we didn't get an explicit scope. * pt.c (tsubst_baselink): Likewise. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f128947..9b410a7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11814,6 +11814,7 @@ tsubst_baselink (tree baselink, tree object_type, tree optype; tree template_args = 0; bool template_id_p = false; +bool qualified = BASELINK_QUALIFIED_P (baselink); /* A baselink indicates a function from a base class. Both the BASELINK_ACCESS_BINFO and the base class referenced may @@ -11862,9 +11863,12 @@ tsubst_baselink (tree baselink, tree object_type, if (!object_type) object_type = current_class_type; -return adjust_result_of_qualified_name_lookup (baselink, - qualifying_scope, - object_type); + +if (qualified) + baselink = adjust_result_of_qualified_name_lookup (baselink, + qualifying_scope, + object_type); +return baselink; } /* Like tsubst_expr for a SCOPE_REF, given by QUALIFIED_ID. DONE is diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index b68de52..d2ed940 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2415,6 +2415,11 @@ lookup_destructor (tree object, tree scope, tree dtor_name) tf_warning_or_error); expr = (adjust_result_of_qualified_name_lookup (expr, dtor_type, object_type)); + if (scope == NULL_TREE) +/* We need to call adjust_result_of_qualified_name_lookup in case the + destructor names a base class, but we unset BASELINK_QUALIFIED_P so + that we still get virtual function binding. */ +BASELINK_QUALIFIED_P (expr) = false; return expr; } diff --git a/gcc/testsuite/g++.dg/overload/virtual2.C b/gcc/testsuite/g++.dg/overload/virtual2.C new file mode 100644 index 000..c93ba9e --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/virtual2.C @@ -0,0 +1,31 @@ +// PR c++/52746 +// { dg-do run } + +extern C int printf(const char*,...); +extern C void abort(); +bool db; + +struct A +{ + virtual ~A() {} +}; + +struct B : public A +{ + virtual ~B() { db = true; } +}; + +templateint void test() +{ + B * b = new B; + A * a = b; + a-~A(); + ::operator delete(b); +} + +int main() +{ + test0(); + if (!db) +abort(); +}
Re: [google] Refine static branch prediction (iv-compare heuristic)
Thanks, attached is the updated patch. Dehao Index: gcc/testsuite/gcc.dg/predict-3.c === --- gcc/testsuite/gcc.dg/predict-3.c(revision 185903) +++ gcc/testsuite/gcc.dg/predict-3.c(working copy) @@ -10,10 +10,16 @@ int i, ret = 0; for (i = 0; i = bound; i++) { + if (i bound - 2) + global += bar (i); + if (i = bound) + global += bar (i); + if (i + 1 bound) + global += bar (i); if (i != bound) global += bar (i); } } -/* { dg-final { scan-tree-dump loop iv compare heuristics profile_estimate} } */ +/* { dg-final { scan-tree-dump-times loop iv compare heuristics: 100.0% 4 profile_estimate} } */ /* { dg-final { cleanup-tree-dump profile_estimate } } */ Index: gcc/testsuite/gcc.dg/predict-4.c === --- gcc/testsuite/gcc.dg/predict-4.c(revision 185903) +++ gcc/testsuite/gcc.dg/predict-4.c(working copy) @@ -15,5 +15,5 @@ } } -/* { dg-final { scan-tree-dump loop iv compare heuristics profile_estimate} } */ +/* { dg-final { scan-tree-dump loop iv compare heuristics: 50.0% profile_estimate} } */ /* { dg-final { cleanup-tree-dump profile_estimate } } */ Index: gcc/testsuite/gcc.dg/predict-1.c === --- gcc/testsuite/gcc.dg/predict-1.c(revision 185903) +++ gcc/testsuite/gcc.dg/predict-1.c(working copy) @@ -10,10 +10,18 @@ int i, ret = 0; for (i = 0; i bound; i++) { + if (i bound) + global += bar (i); + if (i = bound + 2) + global += bar (i); if (i bound - 2) global += bar (i); + if (i + 2 bound) + global += bar (i); + if (i == 10) + global += bar (i); } } -/* { dg-final { scan-tree-dump loop iv compare heuristics profile_estimate} } */ +/* { dg-final { scan-tree-dump-times loop iv compare heuristics: 0.0% 5 profile_estimate} } */ /* { dg-final { cleanup-tree-dump profile_estimate } } */ Index: gcc/testsuite/gcc.dg/predict-5.c === --- gcc/testsuite/gcc.dg/predict-5.c(revision 0) +++ gcc/testsuite/gcc.dg/predict-5.c(revision 0) @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options -O2 -fdump-tree-profile_estimate } */ + +extern int global; + +int bar (int); + +void foo (int base, int bound) +{ + int i, ret = 0; + for (i = base; i = bound; i++) +{ + if (i base) + global += bar (i); + if (i base + 1) + global += bar (i); + if (i = base + 3) + global += bar (i); + if (i - 2 = base) + global += bar (i); +} +} + +/* { dg-final { scan-tree-dump-times loop iv compare heuristics: 100.0% 4 profile_estimate} } */ +/* { dg-final { cleanup-tree-dump profile_estimate } } */ Index: gcc/testsuite/gcc.dg/predict-2.c === --- gcc/testsuite/gcc.dg/predict-2.c(revision 185903) +++ gcc/testsuite/gcc.dg/predict-2.c(working copy) @@ -5,12 +5,20 @@ int bar(int); -void foo (int bound) +void foo (int base, int bound) { int i, ret = 0; - for (i = 0; i bound; i++) + for (i = base; i bound; i++) { - if (i bound * bound ) + if (i bound * bound) + global += bar (i); + if (i bound + 10) + global += bar (i); + if (i = bound + 10) + global += bar (i); + if (i base + 10) + global += bar (i); + if (i base - 10) global += bar (i); } } Index: gcc/testsuite/gcc.dg/predict-6.c === --- gcc/testsuite/gcc.dg/predict-6.c(revision 0) +++ gcc/testsuite/gcc.dg/predict-6.c(revision 0) @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options -O2 -fdump-tree-profile_estimate } */ + +extern int global; + +int bar (int); + +void foo (int base, int bound) +{ + int i, ret = 0; + for (i = base; i = bound; i++) +{ + if (i base) + global += bar (i); + if (i base + 1) + global += bar (i); + if (i = base + 3) + global += bar (i); + if (i - 1 base) + global += bar (i); +} +} + +/* { dg-final { scan-tree-dump-times loop iv compare heuristics: 0.0% 4 profile_estimate} } */ +/* { dg-final { cleanup-tree-dump profile_estimate } } */ Index: gcc/predict.c === --- gcc/predict.c (revision 185903) +++ gcc/predict.c (working copy) @@ -1070,6 +1070,8 @@ bound = get_base_value (bound); if (!bound) return false; + if (TREE_CODE (base) != INTEGER_CST) +base = get_base_value (base); *loop_invariant = bound; *compare_code = code; @@ -1185,8 +1187,7 @@ return; } - if (!expr_coherent_p (loop_bound_var, compare_var) - || loop_iv_base_var != compare_base) + if (!expr_coherent_p(loop_iv_base_var,
Re: [google] Refine static branch prediction (iv-compare heuristic)
Ok for google branches. thanks, David On Wed, Mar 28, 2012 at 7:55 PM, Dehao Chen de...@google.com wrote: Thanks, attached is the updated patch. Dehao Index: gcc/testsuite/gcc.dg/predict-3.c === --- gcc/testsuite/gcc.dg/predict-3.c (revision 185903) +++ gcc/testsuite/gcc.dg/predict-3.c (working copy) @@ -10,10 +10,16 @@ int i, ret = 0; for (i = 0; i = bound; i++) { + if (i bound - 2) + global += bar (i); + if (i = bound) + global += bar (i); + if (i + 1 bound) + global += bar (i); if (i != bound) global += bar (i); } } -/* { dg-final { scan-tree-dump loop iv compare heuristics profile_estimate} } */ +/* { dg-final { scan-tree-dump-times loop iv compare heuristics: 100.0% 4 profile_estimate} } */ /* { dg-final { cleanup-tree-dump profile_estimate } } */ Index: gcc/testsuite/gcc.dg/predict-4.c === --- gcc/testsuite/gcc.dg/predict-4.c (revision 185903) +++ gcc/testsuite/gcc.dg/predict-4.c (working copy) @@ -15,5 +15,5 @@ } } -/* { dg-final { scan-tree-dump loop iv compare heuristics profile_estimate} } */ +/* { dg-final { scan-tree-dump loop iv compare heuristics: 50.0% profile_estimate} } */ /* { dg-final { cleanup-tree-dump profile_estimate } } */ Index: gcc/testsuite/gcc.dg/predict-1.c === --- gcc/testsuite/gcc.dg/predict-1.c (revision 185903) +++ gcc/testsuite/gcc.dg/predict-1.c (working copy) @@ -10,10 +10,18 @@ int i, ret = 0; for (i = 0; i bound; i++) { + if (i bound) + global += bar (i); + if (i = bound + 2) + global += bar (i); if (i bound - 2) global += bar (i); + if (i + 2 bound) + global += bar (i); + if (i == 10) + global += bar (i); } } -/* { dg-final { scan-tree-dump loop iv compare heuristics profile_estimate} } */ +/* { dg-final { scan-tree-dump-times loop iv compare heuristics: 0.0% 5 profile_estimate} } */ /* { dg-final { cleanup-tree-dump profile_estimate } } */ Index: gcc/testsuite/gcc.dg/predict-5.c === --- gcc/testsuite/gcc.dg/predict-5.c (revision 0) +++ gcc/testsuite/gcc.dg/predict-5.c (revision 0) @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options -O2 -fdump-tree-profile_estimate } */ + +extern int global; + +int bar (int); + +void foo (int base, int bound) +{ + int i, ret = 0; + for (i = base; i = bound; i++) + { + if (i base) + global += bar (i); + if (i base + 1) + global += bar (i); + if (i = base + 3) + global += bar (i); + if (i - 2 = base) + global += bar (i); + } +} + +/* { dg-final { scan-tree-dump-times loop iv compare heuristics: 100.0% 4 profile_estimate} } */ +/* { dg-final { cleanup-tree-dump profile_estimate } } */ Index: gcc/testsuite/gcc.dg/predict-2.c === --- gcc/testsuite/gcc.dg/predict-2.c (revision 185903) +++ gcc/testsuite/gcc.dg/predict-2.c (working copy) @@ -5,12 +5,20 @@ int bar(int); -void foo (int bound) +void foo (int base, int bound) { int i, ret = 0; - for (i = 0; i bound; i++) + for (i = base; i bound; i++) { - if (i bound * bound ) + if (i bound * bound) + global += bar (i); + if (i bound + 10) + global += bar (i); + if (i = bound + 10) + global += bar (i); + if (i base + 10) + global += bar (i); + if (i base - 10) global += bar (i); } } Index: gcc/testsuite/gcc.dg/predict-6.c === --- gcc/testsuite/gcc.dg/predict-6.c (revision 0) +++ gcc/testsuite/gcc.dg/predict-6.c (revision 0) @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options -O2 -fdump-tree-profile_estimate } */ + +extern int global; + +int bar (int); + +void foo (int base, int bound) +{ + int i, ret = 0; + for (i = base; i = bound; i++) + { + if (i base) + global += bar (i); + if (i base + 1) + global += bar (i); + if (i = base + 3) + global += bar (i); + if (i - 1 base) + global += bar (i); + } +} + +/* { dg-final { scan-tree-dump-times loop iv compare heuristics: 0.0% 4 profile_estimate} } */ +/* { dg-final { cleanup-tree-dump profile_estimate } } */ Index: gcc/predict.c === --- gcc/predict.c (revision 185903) +++ gcc/predict.c (working copy) @@ -1070,6 +1070,8 @@ bound = get_base_value (bound); if (!bound) return false; + if (TREE_CODE (base) != INTEGER_CST) + base = get_base_value
Re: PATCH: Define x86_64_fallback_frame_state only for glibc
H.J. Lu hongjiu...@intel.com writes: 2012-03-27 H.J. Lu hongjiu...@intel.com * config/i386/linux-unwind.h (x86_64_fallback_frame_state): Define only for glibc. This is OK. Thanks. Ian
Go patch committed: Fix return type of unsafe functions
The functions unsafe.Sizeof, unsafe.Alignof, and unsafe.Offsetof are supported to return uintptr. The Go frontend was incorrectly having them return int. This patch fixes the problem. This uncovered a couple of problems in the gccgo-specific part of libgo, which are also fixed by this patch. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch. Ian diff -r 854ced9f1d72 go/expressions.cc --- a/go/expressions.cc Wed Mar 28 16:18:42 2012 -0700 +++ b/go/expressions.cc Wed Mar 28 20:50:30 2012 -0700 @@ -7091,7 +7091,8 @@ else go_unreachable(); - nc-set_unsigned_long(NULL, static_castunsigned long(ret)); + nc-set_unsigned_long(Type::lookup_integer_type(uintptr), + static_castunsigned long(ret)); return true; } else if (this-code_ == BUILTIN_OFFSETOF) @@ -7113,7 +7114,8 @@ farg-field_index(), offset)) return false; - nc-set_unsigned_long(NULL, static_castunsigned long(offset)); + nc-set_unsigned_long(Type::lookup_integer_type(uintptr), + static_castunsigned long(offset)); return true; } else if (this-code_ == BUILTIN_REAL || this-code_ == BUILTIN_IMAG) @@ -7246,10 +7248,12 @@ case BUILTIN_CAP: case BUILTIN_COPY: case BUILTIN_LEN: + return Type::lookup_integer_type(int); + case BUILTIN_ALIGNOF: case BUILTIN_OFFSETOF: case BUILTIN_SIZEOF: - return Type::lookup_integer_type(int); + return Type::lookup_integer_type(uintptr); case BUILTIN_CLOSE: case BUILTIN_DELETE: @@ -8078,8 +8082,8 @@ go_assert(saw_errors()); return error_mark_node; } - Type* int_type = Type::lookup_integer_type(int); - tree type = type_to_tree(int_type-get_backend(gogo)); + Type* uintptr_type = Type::lookup_integer_type(uintptr); + tree type = type_to_tree(uintptr_type-get_backend(gogo)); return build_int_cst(type, val); } diff -r 854ced9f1d72 go/unsafe.cc --- a/go/unsafe.cc Wed Mar 28 16:18:42 2012 -0700 +++ b/go/unsafe.cc Wed Mar 28 20:50:30 2012 -0700 @@ -57,11 +57,11 @@ if (add_to_globals) this-add_named_type(pointer_type); - Type* int_type = this-lookup_global(int)-type_value(); + Type* uintptr_type = Type::lookup_integer_type(uintptr); // Sizeof. Typed_identifier_list* results = new Typed_identifier_list; - results-push_back(Typed_identifier(, int_type, bloc)); + results-push_back(Typed_identifier(, uintptr_type, bloc)); Function_type* fntype = Type::make_function_type(NULL, NULL, results, bloc); fntype-set_is_builtin(); no = bindings-add_function_declaration(Sizeof, package, fntype, bloc); @@ -70,7 +70,7 @@ // Offsetof. results = new Typed_identifier_list; - results-push_back(Typed_identifier(, int_type, bloc)); + results-push_back(Typed_identifier(, uintptr_type, bloc)); fntype = Type::make_function_type(NULL, NULL, results, bloc); fntype-set_is_varargs(); fntype-set_is_builtin(); @@ -80,7 +80,7 @@ // Alignof. results = new Typed_identifier_list; - results-push_back(Typed_identifier(, int_type, bloc)); + results-push_back(Typed_identifier(, uintptr_type, bloc)); fntype = Type::make_function_type(NULL, NULL, results, bloc); fntype-set_is_varargs(); fntype-set_is_builtin(); diff -r 854ced9f1d72 libgo/go/os/dir.go --- a/libgo/go/os/dir.go Wed Mar 28 16:18:42 2012 -0700 +++ b/libgo/go/os/dir.go Wed Mar 28 20:50:30 2012 -0700 @@ -34,7 +34,7 @@ func (file *File) readdirnames(n int) (names []string, err error) { if elen == 0 { var dummy syscall.Dirent - elen = (unsafe.Offsetof(dummy.Name) + + elen = (int(unsafe.Offsetof(dummy.Name)) + libc_pathconf(syscall.StringBytePtr(file.name), syscall.PC_NAME_MAX) + 1) } diff -r 854ced9f1d72 libgo/go/syscall/libcall_posix.go --- a/libgo/go/syscall/libcall_posix.go Wed Mar 28 16:18:42 2012 -0700 +++ b/libgo/go/syscall/libcall_posix.go Wed Mar 28 20:50:30 2012 -0700 @@ -138,7 +138,7 @@ //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) //select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) int -const nfdbits = unsafe.Sizeof(fds_bits_type) * 8 +const nfdbits = int(unsafe.Sizeof(fds_bits_type) * 8) type FdSet struct { Bits [(FD_SETSIZE + nfdbits - 1) / nfdbits]fds_bits_type
Re: [PATCH, i386, Android] -mandroid support for i386 target
On 28/02/2012, at 3:41 AM, Ilya Enkovich wrote: You should keep those *_SPEC and define them with new GNU_*_SPEC in gnu-user.h since gnu-user.h is also used by other non-linux targets. In linux.h, you undef *_SPEC before defining them. -- H.J. Thanks for the note. Here is fixed version. Is it OK now? This version looks mostly OK, but still needs a bit of work and testing. How did you test this patch? You should have built before- and after-patch compilers for both Linux and Android and run regression testsuites at least for Linux, and make sure there are no new failures. As is, it appears this patch did not see much testing, I'm pretty sure it breaks building shared libraries and PIE executable for Linux. Thanks, Ilya -- 2012-02-27 Enkovich Ilya ilya.enkov...@intel.com * gcc/config/i386/gnu-user.h (GNU_USER_TARGET_CC1_SPEC): New. (CC1_SPEC): Use GNU_USER_TARGET_CC1_SPEC. (GNU_USER_TARGET_LINK_SPEC): New. (LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC. (GNU_USER_TARGET_MATHFILE_SPEC): New. (ENDFILE_SPEC): Use GNU_USER_TARGET_MATHFILE_SPEC. * gcc/config/i386/linux.h (CC1_SPEC): New. (LINK_SPEC): New. (LIB_SPEC): New. (STARTFILE_SPEC): New. (ENDFILE_SPEC): New. diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h index 98d0a25..33ceab7 100644 --- a/gcc/config/i386/gnu-user.h +++ b/gcc/config/i386/gnu-user.h @@ -77,8 +77,11 @@ along with GCC; see the file COPYING3. If not see #undef CPP_SPEC #define CPP_SPEC %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT} +#undef GNU_USER_TARGET_CC1_SPEC +#define GNU_USER_TARGET_CC1_SPEC %(cc1_cpu) %{profile:-p} Here and in other instances below you use GNU_USER_TARGET_ prefix. I would prefer using a shorter GNU_USER_ instead unless there is a good reason to add TARGET too. + #undef CC1_SPEC -#define CC1_SPEC %(cc1_cpu) %{profile:-p} +#define CC1_SPEC GNU_USER_TARGET_CC1_SPEC /* Provide a LINK_SPEC appropriate for GNU userspace. Here we provide support for the special GCC options -static and -shared, which allow us to @@ -97,22 +100,28 @@ along with GCC; see the file COPYING3. If not see { link_emulation, GNU_USER_LINK_EMULATION },\ { dynamic_linker, GNU_USER_DYNAMIC_LINKER } -#undef LINK_SPEC -#define LINK_SPEC -m %(link_emulation) %{shared:-shared} \ +#define GNU_USER_TARGET_LINK_SPEC \ + -m %(link_emulation) %{shared:-shared} \ %{!shared: \ %{!static: \ %{rdynamic:-export-dynamic} \ -dynamic-linker %(dynamic_linker)} \ %{static:-static}} +#undef LINK_SPEC +#define LINK_SPEC GNU_USER_TARGET_LINK_SPEC + /* Similar to standard GNU userspace, but adding -ffast-math support. */ -#undef ENDFILE_SPEC -#define ENDFILE_SPEC \ +#define GNU_USER_TARGET_MATHFILE_SPEC \ %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ %{mpc32:crtprec32.o%s} \ %{mpc64:crtprec64.o%s} \ - %{mpc80:crtprec80.o%s} \ - %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s + %{mpc80:crtprec80.o%s} + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + GNU_USER_TARGET_MATHFILE_SPEC \ + GNU_USER_TARGET_ENDFILE_SPEC Here you remove %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s. Presumably, you are moving that to GNU_USER[_TARGET]_ENDFILE_SPEC, but you never define it. /* A C statement (sans semicolon) to output to the stdio stream FILE the assembler definition of uninitialized global DECL named diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h index 73681fe..a832ddc 100644 --- a/gcc/config/i386/linux.h +++ b/gcc/config/i386/linux.h i386/linux.h is used only for simple x86 32-bit builds; i386/linux64.h is used for multilib-enabled x86 toolchains. Placing below definitions in i386/linux.h will not allow adding an Android as an additional multilib to -m32/-m64 x86 builds. I improve on this situation I suggest: - rename i386/linux.h to i386/linux32.h (with corresponding change to config.gcc), - put below definitions to new i386/linux.h (remember to add license notice header to the new file), - include i386/linux.h from both i386/linux32.h and i386/linux64.h. @@ -22,3 +22,30 @@ along with GCC; see the file COPYING3. If not see #define GNU_USER_LINK_EMULATION elf_i386 #define GLIBC_DYNAMIC_LINKER /lib/ld-linux.so.2 + +#undef CC1_SPEC +#define CC1_SPEC \ + LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \ +GNU_USER_TARGET_CC1_SPEC ANDROID_CC1_SPEC) + +#undef LINK_SPEC +#define LINK_SPEC \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \ +GNU_USER_TARGET_LINK_SPEC ANDROID_LINK_SPEC) + +#undef LIB_SPEC +#define LIB_SPEC \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LIB_SPEC, \ +GNU_USER_TARGET_LIB_SPEC ANDROID_LIB_SPEC) + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, \ +
Re: PATCH: Use crtbegin_so%O%s/crtend_so%O%s for -mandroid -shared
This is OK. I didn't encounter building shared libraries for Android when developed the original Android support. You can commit this under the obvious patch rule. [I've asked SC for reviewer privileges for Android support, so that I can approve more complex patches.] Thank you, -- Maxim Kuvyrkov CodeSourcery / Mentor Graphics On 15/12/2011, at 6:11 AM, H.J. Lu wrote: Hi, Android uses crtbegin_so.o and crtend_so.o to build shared library with -mshared. OK for trunk in stage 1? H.J. --- 2011-12-13 H.J. Lu hongjiu...@intel.com * config/linux-android.h (ANDROID_STARTFILE_SPEC): Use crtbegin_so%O%s for -shared. (ANDROID_ENDFILE_SPEC): Use crtend_so%O%s for -shared. --- gcc/ChangeLog.android |5 + gcc/config/linux-android.h |4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 gcc/ChangeLog.android diff --git a/gcc/ChangeLog.android b/gcc/ChangeLog.android new file mode 100644 index 000..fc54522 --- /dev/null +++ b/gcc/ChangeLog.android @@ -0,0 +1,5 @@ +2011-12-13 H.J. Lu hongjiu...@intel.com + + * config/linux-android.h (ANDROID_STARTFILE_SPEC): Use + crtbegin_so%O%s for -shared. + (ANDROID_ENDFILE_SPEC): Use crtend_so%O%s for -shared. diff --git a/gcc/config/linux-android.h b/gcc/config/linux-android.h index 94c5274..acbc662 100644 --- a/gcc/config/linux-android.h +++ b/gcc/config/linux-android.h @@ -53,8 +53,8 @@ %{!static: -ldl} #define ANDROID_STARTFILE_SPEC \ - %{!shared: \ + %{shared: crtbegin_so%O%s;: \ %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s}} #define ANDROID_ENDFILE_SPEC \ - %{!shared: crtend_android%O%s} + %{shared: crtend_so%O%s;: crtend_android%O%s} -- 1.7.6.4