Fix ICE due to commit for PR88834
Hi All, As pointed to me by Jeff, after committing patch to fix PR88834, some tests are failing for target rx-elf. This is because in preferred_mem_scale_factor we end up with mem_mode which is BLKmode and hence GET_MODE_UNIT_SIZE returns zero. I have fixed this by checking for BLKmode. I believe this is the only way we can have GET_MODE_UNIT_SIZE of 0. Otherwise, we can check for GET_MODE_UNIT_SIZE of zero. Bootstrapped and regression tested attached patch on x86_64-linux-gnu with no new regressions. Is this OK for trunk? Thanks, Kugan gcc/ChangeLog: 2019-06-17 Kugan Vivekanandarajah * tree-ssa-address.c (preferred_mem_scale_factor): Handle when mem_mode is BLKmode. From 5cd4ac35ce8006a6c407a2386175382f053dcdd3 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Sun, 16 Jun 2019 21:02:59 +1000 Subject: [PATCH] Fix ICE for rx-elf Change-Id: I503b6b8316e7d11d63ec7749ff44dbc641078539 --- gcc/tree-ssa-address.c | 4 1 file changed, 4 insertions(+) diff --git a/gcc/tree-ssa-address.c b/gcc/tree-ssa-address.c index cdd432a..1dca779 100644 --- a/gcc/tree-ssa-address.c +++ b/gcc/tree-ssa-address.c @@ -1138,6 +1138,10 @@ preferred_mem_scale_factor (tree base, machine_mode mem_mode, addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (base)); unsigned int fact = GET_MODE_UNIT_SIZE (mem_mode); + /* for BLKmode, we cant do anything so return 1. */ + if (mem_mode == BLKmode) +return 1; + /* Addressing mode "base + index". */ parts.index = integer_one_node; parts.base = integer_one_node; -- 2.7.4
Re: [PATCH v4 2/3] Add predict_doloop_p target hook
Hi Segher and Bill, Thanks a lot for your review comments! I've updated the patch accordingly. The updated one attached. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 91fafc4e766..6667cd03042 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1909,6 +1909,9 @@ static const struct attribute_spec rs6000_attribute_table[] = #undef TARGET_CAN_USE_DOLOOP_P #define TARGET_CAN_USE_DOLOOP_P can_use_doloop_if_innermost +#undef TARGET_PREDICT_DOLOOP_P +#define TARGET_PREDICT_DOLOOP_P rs6000_predict_doloop_p + #undef TARGET_ATOMIC_ASSIGN_EXPAND_FENV #define TARGET_ATOMIC_ASSIGN_EXPAND_FENV rs6000_atomic_assign_expand_fenv @@ -39413,7 +39416,27 @@ rs6000_mangle_decl_assembler_name (tree decl, tree id) return id; } - +/* Predict whether the given loop in gimple will be transformed in the RTL + doloop_optimize pass. */ + +static bool +rs6000_predict_doloop_p (struct loop *loop) +{ + gcc_assert (loop); + + /* On rs6000, targetm.can_use_doloop_p is actually + can_use_doloop_if_innermost. Just ensure the loop is innermost. */ + if (loop->inner != NULL) +{ + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "Predict doloop failure due to" + " loop nesting.\n"); + return false; +} + + return true; +} + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-rs6000.h" diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 622e8cf240f..c2aa4d04777 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -11610,6 +11610,14 @@ function version at run-time for a given set of function versions. body must be generated. @end deftypefn +@deftypefn {Target Hook} bool TARGET_PREDICT_DOLOOP_P (struct loop *@var{loop}) +Return true if we can predict it is possible to use a low-overhead loop +for a particular loop. The parameter @var{loop} is a pointer to the loop. +This target hook is required only when the target supports low-overhead +loops, and will help ivopts to make some decisions. +The default version of this hook returns false. +@end deftypefn + @deftypefn {Target Hook} bool TARGET_CAN_USE_DOLOOP_P (const widest_int @var{}, const widest_int @var{_max}, unsigned int @var{loop_depth}, bool @var{entered_at_top}) Return true if it is possible to use low-overhead loops (@code{doloop_end} and @code{doloop_begin}) for a particular loop. @var{iterations} gives the diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 17560fce6b7..b4d57b86e2f 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -7944,6 +7944,8 @@ to by @var{ce_info}. @hook TARGET_GENERATE_VERSION_DISPATCHER_BODY +@hook TARGET_PREDICT_DOLOOP_P + @hook TARGET_CAN_USE_DOLOOP_P @hook TARGET_INVALID_WITHIN_DOLOOP diff --git a/gcc/target.def b/gcc/target.def index 7d52102c815..71b69723b75 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -4236,6 +4236,15 @@ DEFHOOK rtx, (machine_mode mode, rtx result, rtx val, rtx failval), default_speculation_safe_value) +DEFHOOK +(predict_doloop_p, + "Return true if we can predict it is possible to use a low-overhead loop\n\ +for a particular loop. The parameter @var{loop} is a pointer to the loop.\n\ +This target hook is required only when the target supports low-overhead\n\ +loops, and will help ivopts to make some decisions.\n\ +The default version of this hook returns false.", + bool, (struct loop *loop), + default_predict_doloop_p) DEFHOOK (can_use_doloop_p, diff --git a/gcc/targhooks.c b/gcc/targhooks.c index b27111639f4..0da885ec152 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -643,6 +643,19 @@ default_has_ifunc_p (void) return HAVE_GNU_INDIRECT_FUNCTION; } +/* Return true if we predict the loop LOOP will be transformed to a + low-overhead loop, otherwise return false. + + By default, false is returned, as this hook's applicability should be + verified for each target. Target maintainers should re-define the hook + if the target can take advantage of it. */ + +bool +default_predict_doloop_p (struct loop *loop ATTRIBUTE_UNUSED) +{ + return false; +} + /* NULL if INSN insn is valid within a low-overhead loop, otherwise returns an error message. diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 229aacd7b65..50b03ce3aa0 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -85,6 +85,7 @@ extern bool default_fixed_point_supported_p (void); extern bool default_has_ifunc_p (void); +extern bool default_predict_doloop_p (struct loop *); extern const char * default_invalid_within_doloop (const rtx_insn *); extern tree default_builtin_vectorized_function (unsigned int, tree, tree); diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 890f9b788b4..530ea4ae343 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -3712,6 +3712,63 @@ prepare_decl_rtl (tree *expr_p, int *ws, void *data) return NULL_TREE; } +/* Predict whether the given loop will be
RE: [PATCH] improve ifcvt optimization (PR rtl-optimization/89430)
Hi, May I know any feedback comments to this patch? Thanks, -Jiangning From: Kyrill Tkachov Sent: Friday, May 24, 2019 10:55 PM To: JiangNing OS ; gcc-patches@gcc.gnu.org Cc: ebotca...@adacore.com; ste...@gcc.gnu.org; l...@redhat.com Subject: Re: [PATCH] improve ifcvt optimization (PR rtl-optimization/89430) Hi Jiangning On 3/15/19 4:46 AM, JiangNing OS wrote: This patch is to fix a missing ifcvt opportunity in back-end. For the simple case below, if (...) x = a; /* x is memory */ /* no else */ We can generate conditional move and remove the branch as below if the target cost is acceptable. r1 = x r2 = a cmp ... csel r3, r1, r2, cond x = r3 This could be safe if x is a stack variable, and there isn't any address taken in current function, so the store speculation can be avoided. In practice, this optimization can improve a real application performance by %4 on aarch64. Now that GCC 10 development is open, this should appropriate for considering. I've cc'ed folks who are either listed maintainers in this area or have reviewed patches in this area in my recent memory. Thanks, Kyrill Thanks, -Jiangning
[PATCH, PR d/90603] Committed fix for ICE in functionParameters
Hi, This patch merges the dmd frontend implementation with upstream dmd 792f0fdf2. Backports semantic pass refactoring, fixing a number of ICEs in handling forward or recursively referenced declarations. Bootstrapped and regression tested on x86_64-linux-gnu. Committed to trunk as r272366 -- Iain --- diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 0620a5ba556..d208aea3717 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -6e44734ccbeb78252a52e129a67fefb313679948 +792f0fdf249b21531dc91690024827f4f9ecbb97 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/dclass.c b/gcc/d/dmd/dclass.c index 572b3e24387..bbe2f8a9d72 100644 --- a/gcc/d/dmd/dclass.c +++ b/gcc/d/dmd/dclass.c @@ -481,7 +481,7 @@ void ClassDeclaration::semantic(Scope *sc) baseClass = tc->sym; b->sym = baseClass; -if (tc->sym->_scope && tc->sym->baseok < BASEOKdone) +if (tc->sym->baseok < BASEOKdone) resolveBase(this, sc, scx, tc->sym); // Try to resolve forward reference if (tc->sym->baseok < BASEOKdone) { @@ -533,7 +533,7 @@ void ClassDeclaration::semantic(Scope *sc) b->sym = tc->sym; -if (tc->sym->_scope && tc->sym->baseok < BASEOKdone) +if (tc->sym->baseok < BASEOKdone) resolveBase(this, sc, scx, tc->sym); // Try to resolve forward reference if (tc->sym->baseok < BASEOKdone) { @@ -918,10 +918,10 @@ bool ClassDeclaration::isBaseOf(ClassDeclaration *cd, int *poffset) { /* cd->baseClass might not be set if cd is forward referenced. */ -if (!cd->baseClass && cd->_scope && !cd->isInterfaceDeclaration()) +if (!cd->baseClass && cd->semanticRun < PASSsemanticdone && !cd->isInterfaceDeclaration()) { cd->semantic(NULL); -if (!cd->baseClass && cd->_scope) +if (!cd->baseClass && cd->semanticRun < PASSsemanticdone) cd->error("base class is forward referenced by %s", toChars()); } @@ -1574,7 +1574,7 @@ void InterfaceDeclaration::semantic(Scope *sc) b->sym = tc->sym; -if (tc->sym->_scope && tc->sym->baseok < BASEOKdone) +if (tc->sym->baseok < BASEOKdone) resolveBase(this, sc, scx, tc->sym); // Try to resolve forward reference if (tc->sym->baseok < BASEOKdone) { diff --git a/gcc/d/dmd/declaration.c b/gcc/d/dmd/declaration.c index 2a054306347..0018d9501f0 100644 --- a/gcc/d/dmd/declaration.c +++ b/gcc/d/dmd/declaration.c @@ -865,6 +865,11 @@ void VarDeclaration::semantic(Scope *sc) _scope = NULL; } +if (!sc) +return; + +semanticRun = PASSsemantic; + /* Pick up storage classes from context, but except synchronized, * override, abstract, and final. */ @@ -1038,6 +1043,7 @@ void VarDeclaration::semantic(Scope *sc) else if (isAliasThisTuple(e)) { VarDeclaration *v = copyToTemp(0, "__tup", e); +v->semantic(sc); VarExp *ve = new VarExp(loc, v); ve->type = e->type; @@ -1439,7 +1445,7 @@ Lnomatch: if (!e) { error("is not a static and cannot have static initializer"); -return; +e = new ErrorExp(); } } ei = new ExpInitializer(_init->loc, e); diff --git a/gcc/d/dmd/denum.c b/gcc/d/dmd/denum.c index fbca54b7dae..ff261bc0ad0 100644 --- a/gcc/d/dmd/denum.c +++ b/gcc/d/dmd/denum.c @@ -110,6 +110,9 @@ void EnumDeclaration::semantic(Scope *sc) _scope = NULL; } +if (!sc) +return; + parent = sc->parent; type = type->semantic(loc, sc); diff --git a/gcc/d/dmd/dimport.c b/gcc/d/dmd/dimport.c index 3d899f09b52..5f7d7fdc09e 100644 --- a/gcc/d/dmd/dimport.c +++ b/gcc/d/dmd/dimport.c @@ -197,12 +197,18 @@ void Import::importAll(Scope *sc) void Import::semantic(Scope *sc) { //printf("Import::semantic('%s') %s\n", toPrettyChars(), id->toChars()); +if (semanticRun > PASSinit) +return; if (_scope) { sc = _scope; _scope = NULL; } +if (!sc) +return; + +semanticRun = PASSsemantic; // Load if not already done so if (!mod) @@ -291,6 +297,8 @@ void Import::semantic(Scope *sc) sc = sc->pop(); } +semanticRun = PASSsemanticdone; + // object self-imports itself, so skip that (Bugzilla 7547) // don't list pseudo modules __entrypoint.d, __main.d (Bugzilla 7, 11164) if (global.params.moduleDeps != NULL && diff --git a/gcc/d/dmd/dinterpret.c b/gcc/d/dmd/dinterpret.c index 0749c7f487d..a1658bbd051
[committed][nvptx] Fix some missing mode warnings in nvptx.md
Hi, Fix these warnings: ... gcc/config/nvptx/nvptx.md:748:1: warning: operand 0 missing mode? gcc/config/nvptx/nvptx.md:757:1: warning: operand 1 missing mode? gcc/config/nvptx/nvptx.md:1514:1: warning: source missing a mode? ... Build and reg-tested on x86_64 with nvptx accelerator. Committed to trunk. Thanks, - Tom [nvptx] Fix some missing mode warnings in nvptx.md 2019-06-17 Tom de Vries * config/nvptx/nvptx.md (define_insn "call_insn"): Rename to ... (define_insn "call_insn_"): ... this. Use P iterator on match_operand 0. (define_insn "call_value_insn"): Rename to ... (define_insn "call_value_insn_"): this. Use P iterator on match_operand 0. (define_insn "nvptx_red_partition"): Set unspec_volatile result mode to DI. --- gcc/config/nvptx/nvptx.md | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md index 1a090a47a32..3ed5296db96 100644 --- a/gcc/config/nvptx/nvptx.md +++ b/gcc/config/nvptx/nvptx.md @@ -745,19 +745,19 @@ ;; Calls -(define_insn "call_insn" +(define_insn "call_insn_" [(match_parallel 2 "call_operation" -[(call (mem:QI (match_operand 0 "call_insn_operand" "Rs")) +[(call (mem:QI (match_operand:P 0 "call_insn_operand" "Rs")) (match_operand 1))])] "" { return nvptx_output_call_insn (insn, NULL_RTX, operands[0]); }) -(define_insn "call_value_insn" +(define_insn "call_value_insn_" [(match_parallel 3 "call_operation" [(set (match_operand 0 "nvptx_register_operand" "=R") - (call (mem:QI (match_operand 1 "call_insn_operand" "Rs")) + (call (mem:QI (match_operand:P 1 "call_insn_operand" "Rs")) (match_operand 2)))])] "" { @@ -1513,7 +1513,7 @@ (define_insn "nvptx_red_partition" [(set (match_operand:DI 0 "nonimmediate_operand" "=R") - (unspec_volatile [(match_operand:DI 1 "const_int_operand")] + (unspec_volatile:DI [(match_operand:DI 1 "const_int_operand")] UNSPECV_RED_PART))] "" {
Re: [PATCH][MSP430][4/4] Implement 64-bit shifts in assembly code
On Thu, 6 Jun 2019 11:32:49 -0600 Jeff Law wrote: > On 6/6/19 6:42 AM, Jozef Lawrynowicz wrote: > > On Wed, 5 Jun 2019 16:35:14 -0600 > > Jeff Law wrote: > > > >> On 6/4/19 7:17 AM, Jozef Lawrynowicz wrote: > >>> libgcc/ChangeLog > >>> > >>> 2019-06-04 Jozef Lawrynowicz > >>> > >>> * config/msp430/slli.S (__mspabi_s): New library function for > >>> performing a logical left shift of a 64-bit value. > >>> (__mspabi_srall): New library function for > >>> performing a arithmetic right shift of a 64-bit value. > >>> (__mspabi_srlll): New library function for > >>> performing a logical right shift of a 64-bit value. > >>> > >> Going to assume your assembly routines are correct :-) > >> > >> OK > >> jeff > > I assume I implemented them correctly based on the clean regtest of > > GCC/G++ testsuites. But in case there might be a gap in the coverage > > somewhere, how about the attached new torture test to explicitly check > > 64-bit > > shifts work as expected? > > Passes for x86_64-linux-gnu and msp430-elf. > I suspect this needs to be conditional on 64bit integer support (check > either at runtime with sizeof or via dejagnu effective target stuff). > With that fixed this is OK. > > jeff Since it seems that the use of long long when a 64-bit type is required is much more prevalent in the testsuite that __INT64_TYPE__ (which may not be supported on all systems), I changed the types to use long long, and made the test require the longlong64 effective target keyword. Committed. Thanks, Jozef
[committed] pa: Fix nonlocal_goto and builtin_longjmp expanders
The attached change fixes PR middle-end/64242 on hppa. The nonlocal_goto and builtin_longjmp expanders are reworked to restore the frame pointer last. Clobbers and a blockage are added to ensure the restored frame pointer is not used to restore the stack pointer and the branch address. Tested on hppa-unknown-linux-gnu and hppa2.0w-hp-hpux11.11. Committed to trunk. Dave -- John David Anglin dave.ang...@bell.net 2019-06-16 John David Anglin PR middle-end/64242 * config/pa/pa.md (nonlocal_goto): Restore frame pointer last. Add frame clobbers and schedule block. (builtin_longjmp): Likewise. Index: config/pa/pa.md === --- config/pa/pa.md (revision 272327) +++ config/pa/pa.md (working copy) @@ -6904,21 +6904,24 @@ rtx stack = operands[2]; rtx fp = operands[3]; - lab = copy_to_reg (lab); - emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode))); emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx)); - /* Restore the frame pointer. The virtual_stack_vars_rtx is saved - instead of the hard_frame_pointer_rtx in the save area. As a - result, an extra instruction is needed to adjust for the offset + lab = copy_to_reg (lab); + + /* Restore the stack and frame pointers. The virtual_stack_vars_rtx + is saved instead of the hard_frame_pointer_rtx in the save area. + As a result, an extra instruction is needed to adjust for the offset of the virtual stack variables and the hard frame pointer. */ - if (GET_CODE (fp) != REG) -fp = force_reg (Pmode, fp); + fp = copy_to_reg (fp); + emit_stack_restore (SAVE_NONLOCAL, stack); + + /* Ensure the frame pointer move is not optimized. */ + emit_insn (gen_blockage ()); + emit_clobber (hard_frame_pointer_rtx); + emit_clobber (frame_pointer_rtx); emit_move_insn (hard_frame_pointer_rtx, plus_constant (Pmode, fp, -8)); - emit_stack_restore (SAVE_NONLOCAL, stack); - emit_use (hard_frame_pointer_rtx); emit_use (stack_pointer_rtx); @@ -8695,23 +8698,26 @@ emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode))); emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx)); - /* Restore the frame pointer. The virtual_stack_vars_rtx is saved - instead of the hard_frame_pointer_rtx in the save area. We need - to adjust for the offset between these two values. */ - if (GET_CODE (fp) != REG) -fp = force_reg (Pmode, fp); + /* Load the label we are jumping through into r1 so that we know + where to look for it when we get back to setjmp's function for + restoring the gp. */ + emit_move_insn (pv, lab); + + /* Restore the stack and frame pointers. The virtual_stack_vars_rtx + is saved instead of the hard_frame_pointer_rtx in the save area. + We need to adjust for the offset between these two values. */ + fp = copy_to_reg (fp); + emit_stack_restore (SAVE_NONLOCAL, stack); + + /* Ensure the frame pointer move is not optimized. */ + emit_insn (gen_blockage ()); + emit_clobber (hard_frame_pointer_rtx); + emit_clobber (frame_pointer_rtx); emit_move_insn (hard_frame_pointer_rtx, plus_constant (Pmode, fp, -8)); - /* This bit is the same as expand_builtin_longjmp. */ - emit_stack_restore (SAVE_NONLOCAL, stack); emit_use (hard_frame_pointer_rtx); emit_use (stack_pointer_rtx); - /* Load the label we are jumping through into r1 so that we know - where to look for it when we get back to setjmp's function for - restoring the gp. */ - emit_move_insn (pv, lab); - /* Prevent the insns above from being scheduled into the delay slot of the interspace jump because the space register could change. */ emit_insn (gen_blockage ());
Re: Use ODR for canonical types construction in LTO
Hi, here is patch that adds TYPE_ODR_P to determine type that comply C++ ODR rules (i.e. ODR types themselves or structures/unions derived from them). I have decided to use STRING_FLAG which have meaning only for integers and arrays which forced me to add type checks on places where we check STRING_FLAG on other types. The patch also let me to verify that all types we consider to have linkage actually are created by C++ FE which turned out to not be the case for Ada which I fixed in needs_assembler_name_p. Bootstrapped/regtested x86_64-linux, OK? * ipa-utils.h (type_with_linkage_p): Verify that type is CXX_ODR_P. (odr_type_p): Remove extra return. * lto-streamer-out.c (hash_tree): Hash TYPE_CXX_ODR_P; hash STRING_FLAG only for arrays and integers. * tree-stremaer-in.c (unpack_ts_type_common_value_fields): Update analogously. * tree-streamer-out.c (pack_ts_type_common_value_fields): Likewise. * print-tree.c (print_node): Print cxx-odr-p and string-flag. * tree.c (need_assembler_name_p): Also check that type is CXX_ODR_TYPE_P (verify_type_variant): Update verification of SRING_FLAG; also check CXX_ODR_P. * tree.h (ARRAY_OR_INTEGER_TYPE_CHECK): New macro. (TYPE_STRING_FLAG): Use it. (TYPE_CXX_ODR_P): New macro. * lto-common.c (compare_tree_sccs_1): Compare CXX_ODR_P; compare STRING_FLAG only for arrays and integers. * gcc-interface/decl.c (gnat_to_gnu_entity): Check that type is array or integer prior checking string flag. * gcc-interface/gigi.h (gnat_signed_type_for, maybe_character_value): Likewise. * c-common.c (braced_lists_to_strings): Check that type is array or integer prior checking string flag. * lex.c (cxx_make_type): Set TYPE_CXX_ODR_P. * dwarf2out.c (gen_array_type_die): First check that type is an array and then test string flag. * trans-expr.c (gfc_conv_substring): Check that type is array or integer prior checking string flag. (gfc_conv_string_parameter): Likewise. * trans-openmp.c (gfc_omp_scalar_p): Likewise. * trans.c (gfc_build_array_ref): Likewise. Index: ada/gcc-interface/decl.c === --- ada/gcc-interface/decl.c(revision 272353) +++ ada/gcc-interface/decl.c(working copy) @@ -1855,7 +1855,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entit = Has_Biased_Representation (gnat_entity); /* Do the same processing for Character subtypes as for types. */ - if (TYPE_STRING_FLAG (TREE_TYPE (gnu_type))) + if ((TREE_CODE (TREE_TYPE (gnu_type)) == INTEGER_TYPE + || TREE_CODE (TREE_TYPE (gnu_type)) == ARRAY_TYPE) + && TYPE_STRING_FLAG (TREE_TYPE (gnu_type))) { TYPE_NAME (gnu_type) = gnu_entity_name; TYPE_STRING_FLAG (gnu_type) = 1; Index: ada/gcc-interface/gigi.h === --- ada/gcc-interface/gigi.h(revision 272353) +++ ada/gcc-interface/gigi.h(working copy) @@ -1138,7 +1138,8 @@ gnat_signed_type_for (tree type_node) static inline tree maybe_character_type (tree type) { - if (TYPE_STRING_FLAG (type) && !TYPE_UNSIGNED (type)) + if (TREE_CODE (type) == INTEGER_TYPE + && TYPE_STRING_FLAG (type) && !TYPE_UNSIGNED (type)) type = gnat_unsigned_type_for (type); return type; @@ -1151,7 +1152,8 @@ maybe_character_value (tree expr) { tree type = TREE_TYPE (expr); - if (TYPE_STRING_FLAG (type) && !TYPE_UNSIGNED (type)) + if (TREE_CODE (type) == INTEGER_TYPE + && TYPE_STRING_FLAG (type) && !TYPE_UNSIGNED (type)) { type = gnat_unsigned_type_for (type); expr = convert (type, expr); Index: c-family/c-common.c === --- c-family/c-common.c (revision 272353) +++ c-family/c-common.c (working copy) @@ -8847,7 +8847,8 @@ braced_lists_to_strings (tree type, tree else return ctor; - if (TYPE_STRING_FLAG (ttp)) + if ((TREE_CODE (ttp) == ARRAY_TYPE || TREE_CODE (ttp) == INTEGER_TYPE) + && TYPE_STRING_FLAG (ttp)) return braced_list_to_string (type, ctor); code = TREE_CODE (ttp); Index: cp/lex.c === --- cp/lex.c(revision 272353) +++ cp/lex.c(working copy) @@ -884,6 +884,9 @@ cxx_make_type (enum tree_code code MEM_S CLASSTYPE_INTERFACE_ONLY (t) = finfo->interface_only; } + if (code == RECORD_TYPE || code == UNION_TYPE) +TYPE_CXX_ODR_P (t) = 1; + return t; } Index: dwarf2out.c === --- dwarf2out.c (revision 272353) +++ dwarf2out.c (working copy) @@ -21850,8 +21850,8 @@ gen_array_type_die (tree type, dw_die_re /* Emit DW_TAG_string_type for Fortran
[PATCH] Fix for c++/90816, c++/90809, Fixes -finstrument-functions-exclude-function-list namespace and comma handling
Patch fixes following PRs: c++/90816 - -finstrument-functions-exclude-function-list improperly handles namespace/class definitions c++/90809 - -finstrument-functions-exclude-function-list mishandles comma escaping Fixes as follows: At flag_instrument_functions_exclude_p [gimplify.c] Using lang_hooks.decl_printable_name (fndecl, 1) to get namespace / class information as part of printable name to allow for inclusion of namespace / class specification when passing symbols to -finstrument-functions-exclude-function-list. Was previously lang_hooks.decl_printable_name (fndecl, 0). At add_comma_separated_to_vector [opts.c] Added writing of a null character to w after primary loop finishes, to account for offset between r and w when r reaches end of passed string. from Oliver Browne PR c++/90816 PR c++/90809 * gimplify.c (flag_instrument_functions_exclude_p): include namespace information as part of decl name * opts.c (add_comma_separated_to_vector): add null character to correct position in last token added to token vector Index: gimplify.c === --- gimplify.c 2019-06-12 19:07:26.872077000 +0100 +++ gimplify.c 2019-06-12 18:55:10.609255000 +0100 @@ -13987,11 +13987,17 @@ flag_instrument_functions_exclude_p (tre { const char *name; - int i; + unsigned int i; char *s; - name = lang_hooks.decl_printable_name (fndecl, 0); - FOR_EACH_VEC_ELT (*v, i, s) + name = lang_hooks.decl_printable_name (fndecl, 1); + for(i = 0; i < v->length(); i++){ + s = (*v)[i]; + if(strstr(name, s) != NULL){ + return(true); + } + } +/* FOR_EACH_VEC_ELT (*v, i, s) if (strstr (name, s) != NULL) - return true; + return true;*/ } @@ -14278,3 +14284,3 @@ gimplify_hasher::equal (const elt_t *p1, return true; -} \ No newline at end of file +} Index: opts.c === --- opts.c 2019-06-12 19:10:04.354612000 +0100 +++ opts.c 2019-06-12 18:53:43.675852000 +0100 @@ -263,7 +263,8 @@ add_comma_separated_to_vector (void **pv *w++ = *r++; } - if (*token_start != '\0') + *w = '\0'; + if (*token_start != '\0'){ v->safe_push (token_start); - + } *pvec = v; } @@ -3151,3 +3152,3 @@ option_name (diagnostic_context *context else return NULL; -} \ No newline at end of file +}
Re: [PATCH] libgfortran: Use __builtin_mul_overflow in xmallocarray
On Sat, Jun 15, 2019 at 2:23 AM Steve Kargl wrote: > > On Fri, Jun 14, 2019 at 08:07:36AM -0700, Steve Kargl wrote: > > On Fri, Jun 14, 2019 at 01:08:48PM +0300, Janne Blomqvist wrote: > > > As GCC now provides builtins for doing integer overflow checking, lets > > > use it when checking for overflow in xmallocarray. > > > > > > Regtested on x86_64-pc-linux-gnu, Ok for trunk? > > > > > > > OK > > > > Just found > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65921 > > I assume that you close the PR. Oh, I had completely forgotten that I filed that one! (I won't close it yet as the frontend part is still to be done) -- Janne Blomqvist
C++ PATCH for c++/83820 - excessive attribute arguments not detected
While messing with [[noreturn]] I also found out that we don't detect the case when an attribute specifier that takes no arguments contains an attribute-argument-clause. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2019-06-16 Marek Polacek PR c++/83820 - excessive attribute arguments not detected. * parser.c (cp_parser_std_attribute): Detect excessive arguments. * g++.dg/cpp0x/gen-attrs-67.C: New test. diff --git gcc/cp/parser.c gcc/cp/parser.c index 8f5ae84670a..871bc45da63 100644 --- gcc/cp/parser.c +++ gcc/cp/parser.c @@ -26149,6 +26149,20 @@ cp_parser_std_attribute (cp_parser *parser, tree attr_ns) vec *vec; int attr_flag = normal_attr; +/* Maybe we don't expect to see any arguments for this attribute. */ +const attribute_spec *as + = lookup_attribute_spec (TREE_PURPOSE (attribute)); +if (as && as->max_length == 0) + { + error_at (token->location, "attribute %qE does not take any arguments", + attr_id); + cp_parser_skip_to_closing_parenthesis (parser, + /*recovering=*/true, + /*or_comma=*/false, + /*consume_paren=*/true); + return error_mark_node; + } + if (attr_ns == gnu_identifier && attribute_takes_identifier_p (attr_id)) /* A GNU attribute that takes an identifier in parameter. */ diff --git gcc/testsuite/g++.dg/cpp0x/gen-attrs-67.C gcc/testsuite/g++.dg/cpp0x/gen-attrs-67.C new file mode 100644 index 000..bbbedd0240a --- /dev/null +++ gcc/testsuite/g++.dg/cpp0x/gen-attrs-67.C @@ -0,0 +1,11 @@ +// PR c++/83820 - excessive attribute arguments not detected. +// { dg-do compile { target c++11 } } + +[[noreturn()]] void f0 (); // { dg-error "attribute .noreturn. does not take any arguments" } +[[noreturn(1)]] void f1 (); // { dg-error "attribute .noreturn. does not take any arguments" } +[[noreturn(1, 2)]] void f2 (); // { dg-error "attribute .noreturn. does not take any arguments" } +[[maybe_unused()]] int f3(); // { dg-error "attribute .maybe_unused. does not take any arguments" } +[[nodiscard()]] int f4(); // { dg-error "attribute .nodiscard. does not take any arguments" } +[[gnu::noinline()]] int f5(); // { dg-error "attribute .noinline. does not take any arguments" } +[[gnu::constructor]] int f6(); +[[gnu::constructor(101)]] int f7();
Re: [PATCH, sanitizer] Wrap rethrow_primary_exception (PR 87880).
On Sun, Jun 16, 2019 at 07:54:42PM +0100, Iain Sandoe wrote: > So, I guess, unless Jonathan has plans to add __cxa_rethrow_primary_exception > during the 10 time-frame, it’s correct to exclude the symbol anyway and we > should > bump the so version and apply trunk. I don't understand why they've added it, it should be called std::rethrow_exception and that is how it is called in libstdc++. > Actually, because the way in which interposing works for Darwin is different, > the only > symbol change in the library on Darwin is removing an "undefined dynamic > lookup". > So, for back-ports, I can could up with some Darwin-specific Makefike change > that > only adds the ASAN_HAS_CXA_RETHROW_PRIMARY_EXCEPTION=0 for Darwin. > > So - OK for trunk with a bumped soname? Yes. > (and a TODO to figure a Darwin-only backport) Yeah. Jakub
Re: [PATCH, sanitizer] Wrap rethrow_primary_exception (PR 87880).
Hi Jakub, > On 14 Jun 2019, at 15:47, Jakub Jelinek wrote: > > On Fri, Jun 14, 2019 at 03:38:05PM +0100, Iain Sandoe wrote: >> For some Darwin versions the absence of the rethrow_primary_exception >> symbol causes almost all sanitizer tests to fail. >> >> The following patch wraps it as suggested by Jakub in the PR trail, such that >> if the gate is not defined, it’s assumed to be available. > > I wonder if we shouldn't bump libasan soname because of this, as this change > is removing an exported symbol from it. > > Otherwise LGTM (but bumping soname would mean it is not backportable). So, I guess, unless Jonathan has plans to add __cxa_rethrow_primary_exception during the 10 time-frame, it’s correct to exclude the symbol anyway and we should bump the so version and apply trunk. Actually, because the way in which interposing works for Darwin is different, the only symbol change in the library on Darwin is removing an "undefined dynamic lookup". So, for back-ports, I can could up with some Darwin-specific Makefike change that only adds the ASAN_HAS_CXA_RETHROW_PRIMARY_EXCEPTION=0 for Darwin. So - OK for trunk with a bumped soname? (and a TODO to figure a Darwin-only backport) thanks Iain > >> 2019-06-14 Iain Sandoe >> >> PR libsanitizer/87880 >> * asan/asan_interceptors.h: >> (ASAN_INTERCEPT___CXA_RETHROW_PRIMARY_EXCEPTION): New. >> * asan/Makefile.am (DEFS): Add >> ASAN_HAS_CXA_RETHROW_PRIMARY_EXCEPTION, defined to 0. >> * asan/Makefile.in: Regenerated. > > Jakub
[Darwin, committed] The need for picsym stubs is dependent on linker used, not OS rev.
This is one in a series of changes to make the operation of the Darwin back- end, depend on configuration-determined data, rather than guessing on the basis of the OS version we are generating code for. For very old toolchains, the compiler generated pic symbol stubs that provide indirections for external symbols. We no longer need this (since xcode 3 era) and it's more efficient for the linker to make one stub when it knows a symbol is needed that for us to emit them speculatively in every object. Our current codegen is making the assumption that a specific OS version uses a specific linker version - and therefore the presence of support could be based on the target OS rev. Of course, that's way too simplistic (most likely bogus for cross-toolchains) and we want to make things explicit. Since we have detection of the linker version, we can use that directly (A config test for support for stub-less linking might also be feasible but much more involved). Finally, should the user wish to generate code that caters for export to use in an environment with an older toolchain, the generation of stubs can be forced from the command line. In addition to the points above, branch islanding and a long branch opt for PowerPC Darwin has become conflated with the emission of these stubs (which is confusing, and will be rectified in a following patch). 2019-06-16 Iain Sandoe * config/darwin.c (machopic_indirect_call_target): Use renamed darwin_picsymbol_stubs to decide on output. (darwin_override_options): Handle darwin_picsymbol_stubs. * config/darwin.h (MIN_LD64_OMIT_STUBS): New. (LD64_VERSION): Revise default. * config/darwin.opt: (mpic-symbol-stubs): New option. (darwin_picsymbol_stubs): New variable. * config/i386/darwin.h (TARGET_MACHO_BRANCH_ISLANDS): rename to TARGET_MACHO_PICSYM_STUBS. * config/i386/i386.c (output_pic_addr_const): Likewise. * config/i386/i386.h Likewise. * config/rs6000/darwin.h: Likewise. * config/rs6000/rs6000.c (rs6000_call_darwin_1): Use renamed darwin_picsymbol_stubs. diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 17e1801d2e..00fa65278c 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -78,12 +78,6 @@ along with GCC; see the file COPYING3. If not see of MACHO_SYMBOL_STATIC for the code that handles @code{static} symbol indirection. */ -/* For darwin >= 9 (OSX 10.5) the linker is capable of making the necessary - branch islands and we no longer need to emit darwin stubs. - However, if we are generating code for earlier systems (or for use in the - kernel) the stubs might still be required, and this will be set true. */ -int darwin_emit_branch_islands = false; - typedef struct GTY(()) cdtor_record { rtx symbol; int priority;/* [con/de]structor priority */ @@ -790,7 +784,7 @@ machopic_indirect_data_reference (rtx orig, rtx reg) rtx machopic_indirect_call_target (rtx target) { - if (! darwin_emit_branch_islands) + if (! darwin_picsymbol_stubs) return target; if (GET_CODE (target) != MEM) @@ -3235,7 +3229,7 @@ darwin_override_options (void) flag_unwind_tables = 0; flag_asynchronous_unwind_tables = 0; /* We still need to emit branch islands for kernel context. */ - darwin_emit_branch_islands = true; + darwin_picsymbol_stubs = true; } if (flag_var_tracking_uninit == 0 @@ -3259,11 +3253,31 @@ darwin_override_options (void) flag_pic = 2; } - /* It is assumed that branch island stubs are needed for earlier systems. */ - if (generating_for_darwin_version < 9) -darwin_emit_branch_islands = true; - else -emit_aligned_common = true; /* Later systems can support aligned common. */ + /* Linkers >= ld64-62.1 (at least) are capable of making the necessary PIC + indirections and we no longer need to emit pic symbol stubs. + However, if we are generating code for earlier ones (or for use in the + kernel) the stubs might still be required, and this will be set true. + If the user sets it on or off - then that takes precedence. */ + + if (!global_options_set.x_darwin_picsymbol_stubs) +{ + if (darwin_target_linker) { + if (strverscmp (darwin_target_linker, MIN_LD64_OMIT_STUBS) < 0) + darwin_picsymbol_stubs = true; + } else if (generating_for_darwin_version < 9) + /* We know no better than to assume the use of an earlier linker. */ + darwin_picsymbol_stubs = true; +} + else if (DARWIN_X86 && darwin_picsymbol_stubs && TARGET_64BIT) +{ + inform (input_location, + "%<-mpic-symbol-stubs%> is not required for 64b code (ignored)"); + darwin_picsymbol_stubs = false; +} + + if (generating_for_darwin_version >= 9) +/* Later systems can support aligned common. */ +emit_aligned_common = true; /* The c_dialect...() macros are not available to
[Darwin, committed, opts] Add RejectNegative for cases with explict inverses.
These cases specify the negative option specifically, so we should not accept a regular -no- for them. tested on x86_64-darwin16, applied to mainline, thanks Iain 2019-06-16 Iain Sandoe * config/darwin.opt (prebind, noprebind, seglinkedit, noseglinkedit): Add RejectNegative. diff --git a/gcc/config/darwin.opt b/gcc/config/darwin.opt index 0b16b03..3f04375 100644 --- a/gcc/config/darwin.opt +++ b/gcc/config/darwin.opt @@ -237,11 +237,11 @@ Driver RejectNegative (Obsolete after 10.4) Set MH_NOMULTIDEFS in an umbrella framework. noprebind -Driver Negative(prebind) +Driver RejectNegative Negative(prebind) (Obsolete) LD_PREBIND is no longer supported. noseglinkedit -Driver Negative(seglinkedit) +Driver RejectNegative Negative(seglinkedit) (Obsolete) This is the default. object @@ -252,7 +252,7 @@ Driver RejectNegative Separate -pagezero_size sizeAllows setting the page 0 size to 4kb for certain special cases. prebind -Driver Negative(noprebind) +Driver RejectNegative Negative(noprebind) (Obsolete) LD_PREBIND is no longer supported. prebind_all_twolevel_modules @@ -317,7 +317,7 @@ Driver RejectNegative Separate Args(3) (Obsolete, ld_classic only) -sectcreate segname sectname file seglinkedit -Driver Negative(noseglinkedit) +Driver RejectNegative Negative(noseglinkedit) (Obsolete) Object files with LINKEDIT sections are no longer supported. segprot
Fix aliasing_component_refs WRT trailing arrays of size 0
Hi, while enabling bit more of alias oracle I have noticed that the size comparsion in aliasing_component_refs_p may lead to false negatives when struct contain trailing array of size 0. In that case the size of a an element of that array is bigger then size of the struct. This is fixed by the following patch: while walking the access path we look for component refs of arrays size 0 or NULL and if they are at the end of struct we record them. I added check that there is at most one in the path passing array_at_struct_end_p. Leter the size compares is used for following decisions 1) whether walk path1 or path2. Here we want to take into account the size of path1/2 may actually increase, so in addition to compare type1 and type2 we want to compare with the element size of trailing array. 2) when looking for type match we still want to compare type1/type2 because there is no way to bypass the outer structure. However we do not want to give up too early deciding that type in question is too small. 3) When deciding whether one path can continue by another, we can actually use the bigger size. Note that we do not need to bother about zero sized array reference in the path continuation since memory access of ref type will not write/read into the array. I can only construct exaple when the outer types does not match (becuase then we do conservative offset/max_size decision) and thus the extra union but I think the testcase is still valid C. Bootstrapped/regtested x86_64-linux, comitted. * gcc.dg/tree-ssa/alias-access-path-4.c: New testcase. * gcc.dg/tree-ssa/alias-access-path-5.c: New testcase. * tree-ssa-alias.c (aliasing_component_refs_p): Watch for arrays at the end of structures. Index: tree-ssa-alias.c === --- tree-ssa-alias.c(revision 272354) +++ tree-ssa-alias.c(working copy) @@ -877,22 +877,62 @@ aliasing_component_refs_p (tree ref1, tree *refp; int same_p1 = 0, same_p2 = 0; bool maybe_match = false; + tree end_struct_ref1 = NULL, end_struct_ref2 = NULL; /* Choose bases and base types to search for. */ base1 = ref1; while (handled_component_p (base1)) -base1 = TREE_OPERAND (base1, 0); +{ + /* Generally access paths are monotous in the size of object. The +exception are trailing arrays of structures. I.e. + struct a {int array[0];}; +or + struct a {int array1[0]; int array[];}; +Such struct has size 0 but accesses to a.array may have non-zero size. +In this case the size of TREE_TYPE (base1) is smaller than +size of TREE_TYPE (TREE_OPERNAD (base1, 0)). + +Because we compare sizes of arrays just by sizes of their elements, +we only need to care about zero sized array fields here. */ + if (TREE_CODE (base1) == COMPONENT_REF + && TREE_CODE (TREE_TYPE (TREE_OPERAND (base1, 1))) == ARRAY_TYPE + && (!TYPE_SIZE (TREE_TYPE (TREE_OPERAND (base1, 1))) + || integer_zerop (TYPE_SIZE (TREE_TYPE (TREE_OPERAND (base1, 1) + && array_at_struct_end_p (base1)) + { + gcc_checking_assert (!end_struct_ref1); + end_struct_ref1 = base1; + } + base1 = TREE_OPERAND (base1, 0); +} type1 = TREE_TYPE (base1); base2 = ref2; while (handled_component_p (base2)) -base2 = TREE_OPERAND (base2, 0); +{ + if (TREE_CODE (base2) == COMPONENT_REF + && TREE_CODE (TREE_TYPE (TREE_OPERAND (base2, 1))) == ARRAY_TYPE + && (!TYPE_SIZE (TREE_TYPE (TREE_OPERAND (base2, 1))) + || integer_zerop (TYPE_SIZE (TREE_TYPE (TREE_OPERAND (base2, 1) + && array_at_struct_end_p (base2)) + { + gcc_checking_assert (!end_struct_ref2); + end_struct_ref2 = base2; + } + base2 = TREE_OPERAND (base2, 0); +} type2 = TREE_TYPE (base2); /* Now search for the type1 in the access path of ref2. This would be a common base for doing offset based disambiguation on. This however only makes sense if type2 is big enough to hold type1. */ int cmp_outer = compare_type_sizes (type2, type1); - if (cmp_outer >= 0) + + /* If type2 is big enough to contain type1 walk its access path. + We also need to care of arrays at the end of structs that may extend + beyond the end of structure. */ + if (cmp_outer >= 0 + || (end_struct_ref2 + && compare_type_sizes (TREE_TYPE (end_struct_ref2), type1) >= 0)) { refp = while (true) @@ -900,7 +940,11 @@ aliasing_component_refs_p (tree ref1, /* We walk from inner type to the outer types. If type we see is already too large to be part of type1, terminate the search. */ int cmp = compare_type_sizes (type1, TREE_TYPE (*refp)); - if (cmp < 0) + + if (cmp < 0 + && (!end_struct_ref1 +
Re: C++ PATCH for c++/60364 - noreturn after first decl not diagnosed (v3)
On Sun, Jun 16, 2019 at 06:18:56PM +0200, Jakub Jelinek wrote: > On Sun, Jun 16, 2019 at 12:10:37PM -0400, Marek Polacek wrote: > > > Guess I will really have to make the changes to treat [[noreturn]] > > > similarly > > > to e.g. [[nodiscard]], so that cxx11_attribute_p works. > > > > Thus. Changes I've made: > > * don't treat [[noreturn]] as an equivalent to __attribute__((noreturn)); > > * for that I had to adjust decl_attributes, it wasn't preserving the > > C++11 form (a list in another list); fix shadowing while at it; > > * the above turned up two spots that were wrongly accessing TREE_PURPOSE > > directly instead of using get_attribute_name; > > * give error only for [[noreturn]] but not for __attribute__((noreturn)) > > or [[gnu::noreturn]]. > > > > Bootstrapped/regtested on x86_64-linux, ok for trunk? > > I'd prefer to defer review of this to Jason, just want to note that I don't > see any testsuite coverage on mixing declarations with different forms of > attributes ([[noreturn]] on one decl and __attribute__((noreturn)) or > [[gnu::noreturn]] on another one or vice versa. Added now. I suppose it should compile fine, which it does. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2019-06-16 Marek Polacek PR c++/60364 - noreturn after first decl not diagnosed. * attribs.c (get_attribute_namespace): No longer static. (decl_attributes): Avoid shadowing. Preserve the C++11 form for C++11 attributes. * attribs.h (get_attribute_namespace): Declare. * tree-inline.c (function_attribute_inlinable_p): Use get_attribute_name. * c-attribs.c (handle_noreturn_attribute): No longer static. * c-common.h (handle_noreturn_attribute): Declare. * c-format.c (check_function_format): Use get_attribute_name. * decl.c (duplicate_decls): Give an error when a function is declared [[noreturn]] after its first declaration. * parser.c (cp_parser_std_attribute): Don't treat C++11 noreturn attribute as equivalent to GNU's. * tree.c (std_attribute_table): Add noreturn. * g++.dg/warn/noreturn-8.C: New test. * g++.dg/warn/noreturn-9.C: New test. diff --git gcc/attribs.c gcc/attribs.c index 4441922543f..8e540165597 100644 --- gcc/attribs.c +++ gcc/attribs.c @@ -340,7 +340,7 @@ lookup_attribute_spec (const_tree name) Please read the comments of cxx11_attribute_p to understand the format of attributes. */ -static tree +tree get_attribute_namespace (const_tree attr) { if (cxx11_attribute_p (attr)) @@ -469,7 +469,6 @@ tree decl_attributes (tree *node, tree attributes, int flags, tree last_decl /* = NULL_TREE */) { - tree a; tree returned_attrs = NULL_TREE; if (TREE_TYPE (*node) == error_mark_node || attributes == error_mark_node) @@ -548,22 +547,23 @@ decl_attributes (tree *node, tree attributes, int flags, /* Note that attributes on the same declaration are not necessarily in the same order as in the source. */ - for (a = attributes; a; a = TREE_CHAIN (a)) + for (tree attr = attributes; attr; attr = TREE_CHAIN (attr)) { - tree ns = get_attribute_namespace (a); - tree name = get_attribute_name (a); - tree args = TREE_VALUE (a); + tree ns = get_attribute_namespace (attr); + tree name = get_attribute_name (attr); + tree args = TREE_VALUE (attr); tree *anode = node; const struct attribute_spec *spec = lookup_scoped_attribute_spec (ns, name); int fn_ptr_quals = 0; tree fn_ptr_tmp = NULL_TREE; + const bool cxx11_attr_p = cxx11_attribute_p (attr); if (spec == NULL) { if (!(flags & (int) ATTR_FLAG_BUILT_IN)) { - if (ns == NULL_TREE || !cxx11_attribute_p (a)) + if (ns == NULL_TREE || !cxx11_attr_p) warning (OPT_Wattributes, "%qE attribute directive ignored", name); else @@ -584,7 +584,7 @@ decl_attributes (tree *node, tree attributes, int flags, gcc_assert (is_attribute_p (spec->name, name)); if (TYPE_P (*node) - && cxx11_attribute_p (a) + && cxx11_attr_p && !(flags & ATTR_FLAG_TYPE_IN_PLACE)) { /* This is a c++11 attribute that appertains to a @@ -707,8 +707,7 @@ decl_attributes (tree *node, tree attributes, int flags, if (spec->handler != NULL) { - int cxx11_flag = - cxx11_attribute_p (a) ? ATTR_FLAG_CXX11 : 0; + int cxx11_flag = (cxx11_attr_p ? ATTR_FLAG_CXX11 : 0); /* Pass in an array of the current declaration followed by the last pushed/merged declaration if one exists. @@ -756,17 +755,23 @@ decl_attributes (tree *node, tree attributes, int flags, if (a == NULL_TREE) { /* This attribute isn't already in the list. */ + tree r; + /* Preserve
Re: C++ PATCH for c++/60364 - noreturn after first decl not diagnosed (v2)
On Sun, Jun 16, 2019 at 12:10:37PM -0400, Marek Polacek wrote: > > Guess I will really have to make the changes to treat [[noreturn]] similarly > > to e.g. [[nodiscard]], so that cxx11_attribute_p works. > > Thus. Changes I've made: > * don't treat [[noreturn]] as an equivalent to __attribute__((noreturn)); > * for that I had to adjust decl_attributes, it wasn't preserving the > C++11 form (a list in another list); fix shadowing while at it; > * the above turned up two spots that were wrongly accessing TREE_PURPOSE > directly instead of using get_attribute_name; > * give error only for [[noreturn]] but not for __attribute__((noreturn)) > or [[gnu::noreturn]]. > > Bootstrapped/regtested on x86_64-linux, ok for trunk? I'd prefer to defer review of this to Jason, just want to note that I don't see any testsuite coverage on mixing declarations with different forms of attributes ([[noreturn]] on one decl and __attribute__((noreturn)) or [[gnu::noreturn]] on another one or vice versa. Jakub
Re: C++ PATCH for c++/60364 - noreturn after first decl not diagnosed (v2)
On Sat, Jun 15, 2019 at 10:39:13AM -0400, Marek Polacek wrote: > On Sat, Jun 15, 2019 at 04:33:26PM +0200, Jakub Jelinek wrote: > > On Sat, Jun 15, 2019 at 10:29:17AM -0400, Marek Polacek wrote: > > > [dcl.attr.noreturn] says "The first declaration of a function shall > > > specify the > > > noreturn attribute if any declaration of that function specifies the > > > noreturn > > > attribute" meaning that we should diagnose > > > > > > void func (); > > > void func [[noreturn]] (); > > > > > > but we do not. I'd been meaning to issue a hard error for [[noreturn]] > > > and > > > only a warning for __attribute__((noreturn)) but then I found out that we > > > treat [[noreturn]] exactly as the GNU attribute, and so cxx11_attribute_p > > > returns false for it, so I decided to make it a pedwarn for all the cases. > > > A pedwarn counts as a diagnostic, so we'd be conforming still. > > > > > > Bootstrapped/regtested on x86_64-linux, ok for trunk? > > > > IMHO we should treat __attribute__((noreturn)) as before without any > > warnings, just [[noreturn]] that way. There is nothing wrong on declaring > > it just on second or following declaration, it is an optimization attribute. > > That's a complication then; currently [[noreturn]], [[gnu::noreturn]], and > __attribute__((noreturn)) are not distinguishable. :( > > Guess I will really have to make the changes to treat [[noreturn]] similarly > to e.g. [[nodiscard]], so that cxx11_attribute_p works. Thus. Changes I've made: * don't treat [[noreturn]] as an equivalent to __attribute__((noreturn)); * for that I had to adjust decl_attributes, it wasn't preserving the C++11 form (a list in another list); fix shadowing while at it; * the above turned up two spots that were wrongly accessing TREE_PURPOSE directly instead of using get_attribute_name; * give error only for [[noreturn]] but not for __attribute__((noreturn)) or [[gnu::noreturn]]. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2019-06-16 Marek Polacek PR c++/60364 - noreturn after first decl not diagnosed. * attribs.c (get_attribute_namespace): No longer static. (decl_attributes): Avoid shadowing. Preserve the C++11 form for C++11 attributes. * attribs.h (get_attribute_namespace): Declare. * tree-inline.c (function_attribute_inlinable_p): Use get_attribute_name. * c-attribs.c (handle_noreturn_attribute): No longer static. * c-common.h (handle_noreturn_attribute): Declare. * c-format.c (check_function_format): Use get_attribute_name. * decl.c (duplicate_decls): Give an error when a function is declared [[noreturn]] after its first declaration. * parser.c (cp_parser_std_attribute): Don't treat C++11 noreturn attribute as equivalent to GNU's. * tree.c (std_attribute_table): Add noreturn. * g++.dg/warn/noreturn-8.C: New test. diff --git gcc/attribs.c gcc/attribs.c index 4441922543f..8e540165597 100644 --- gcc/attribs.c +++ gcc/attribs.c @@ -340,7 +340,7 @@ lookup_attribute_spec (const_tree name) Please read the comments of cxx11_attribute_p to understand the format of attributes. */ -static tree +tree get_attribute_namespace (const_tree attr) { if (cxx11_attribute_p (attr)) @@ -469,7 +469,6 @@ tree decl_attributes (tree *node, tree attributes, int flags, tree last_decl /* = NULL_TREE */) { - tree a; tree returned_attrs = NULL_TREE; if (TREE_TYPE (*node) == error_mark_node || attributes == error_mark_node) @@ -548,22 +547,23 @@ decl_attributes (tree *node, tree attributes, int flags, /* Note that attributes on the same declaration are not necessarily in the same order as in the source. */ - for (a = attributes; a; a = TREE_CHAIN (a)) + for (tree attr = attributes; attr; attr = TREE_CHAIN (attr)) { - tree ns = get_attribute_namespace (a); - tree name = get_attribute_name (a); - tree args = TREE_VALUE (a); + tree ns = get_attribute_namespace (attr); + tree name = get_attribute_name (attr); + tree args = TREE_VALUE (attr); tree *anode = node; const struct attribute_spec *spec = lookup_scoped_attribute_spec (ns, name); int fn_ptr_quals = 0; tree fn_ptr_tmp = NULL_TREE; + const bool cxx11_attr_p = cxx11_attribute_p (attr); if (spec == NULL) { if (!(flags & (int) ATTR_FLAG_BUILT_IN)) { - if (ns == NULL_TREE || !cxx11_attribute_p (a)) + if (ns == NULL_TREE || !cxx11_attr_p) warning (OPT_Wattributes, "%qE attribute directive ignored", name); else @@ -584,7 +584,7 @@ decl_attributes (tree *node, tree attributes, int flags, gcc_assert (is_attribute_p (spec->name, name)); if (TYPE_P (*node) - && cxx11_attribute_p (a) + && cxx11_attr_p && !(flags &
Re: Remove nonoverlapping_component_refs_of_decl_p
Hi, my patch had a typo - I forgot to update the second call of truncate. This fixes it. Bootstrapped/regtested with all languages on x86_64-linux and comitted. This unbreaks non-lto Ada bootstrap failure. * tree-ssa-alias.c (nonoverlapping_component_refs_p): Fix pasto in my previous patch. Index: tree-ssa-alias.c === --- tree-ssa-alias.c(revision 272353) +++ tree-ssa-alias.c(working copy) @@ -1230,7 +1230,7 @@ nonoverlapping_component_refs_p (const_t fieldsy.safe_push (TREE_OPERAND (y, 1)); } else if (TREE_CODE (y) == VIEW_CONVERT_EXPR) - fieldsx.truncate (0); + fieldsy.truncate (0); y = TREE_OPERAND (y, 0); } if (fieldsy.length () == 0)
[patch, fortran, committed] Improve internal compiler debugging
Hi, I just committed the attached patch as obvious ans simple. No impact on user code, just to make internal debugging easier. Regards Thomas 2019-06-16 Thomas Koenig * dump_parse_tree (debug): Add verison for formal arglist. Do not crash when a gfc_expr is NULL. Index: dump-parse-tree.c === --- dump-parse-tree.c (Revision 271945) +++ dump-parse-tree.c (Arbeitskopie) @@ -66,6 +66,19 @@ dumpfile = tmp; } +void debug (gfc_formal_arglist *formal) +{ + FILE *tmp = dumpfile; + dumpfile = stderr; + for (; formal; formal = formal->next) +{ + fputc ('\n', dumpfile); + show_symbol (formal->sym); +} + fputc ('\n', dumpfile); + dumpfile = tmp; +} + void debug (symbol_attribute attr) { debug (); @@ -75,9 +88,15 @@ { FILE *tmp = dumpfile; dumpfile = stderr; - show_expr (e); - fputc (' ', dumpfile); - show_typespec (>ts); + if (e != NULL) +{ + show_expr (e); + fputc (' ', dumpfile); + show_typespec (>ts); +} + else +fputs ("() ", dumpfile); + fputc ('\n', dumpfile); dumpfile = tmp; }
[PATCH, d] Committed merge with upstream dmd 6e44734cc
Hi, This patch merges the dmd frontend implementation with upstream dmd 6e44734cc, and the libdruntime sub-directory with upstream druntime cb1583b4. The patch has been split up into separate commits, so that all PRs fixed are individually referenced with the part of the patch that addresses that issue. Listing the PRs in numerical order. PR d/90559 (r272351) PR d/90560 (r272348) PR d/90650 (r272344) PR d/90651 (r272345) PR d/90602 (r272342) PR d/90604 (r272343) PR d/90651 (r272340) PR d/90660 (r272339) PR d/90661 (r272341) PR d/90761 (r272346) PR d/90762 (r272347) PR d/90863 (r272352) Bootstrapped and regression tested on x86_64-linux-gnu. Committed to trunk. -- Iain --- 2019-06-16 Iain Buclaw gcc/d/ChangeLog: PR d/90559 * d-target.cc (Target::_init): Reduce max static data size to INT_MAX. PR d/90651 * typeinfo.cc (object_module): New variable. (make_frontend_typeinfo): Update signature. Set temporary on generated TypeInfo classes. (create_tinfo_types): Set object_module. Move generation of front-end typeinfo into ... (create_frontend_tinfo_types): ... New function. (layout_typeinfo): Call create_frontend_tinfo_types. (layout_classinfo): Likewise. (layout_cpp_typeinfo): Likewise. (create_typeinfo): Likewise. gcc/testsuite/ChangeLog: PR d/90650 * gdc.dg/pr90650a.d: New test. * gdc.dg/pr90650b.d: New test. --- commit b5e4c44129acca5d6958c06b0ad6754f8a3763fc git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272352 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 4111fc97044..0620a5ba556 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -7afcc60c30554e452eacdfbefc4951ebf601fccd +6e44734ccbeb78252a52e129a67fefb313679948 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/blockexit.c b/gcc/d/dmd/blockexit.c index e9d3f105429..c3b60b88216 100644 --- a/gcc/d/dmd/blockexit.c +++ b/gcc/d/dmd/blockexit.c @@ -496,6 +496,8 @@ int blockExit(Statement *s, FuncDeclaration *func, bool mustNotThrow) } }; +if (!s) +return BEfallthru; BlockExit be(func, mustNotThrow); s->accept(); return be.result; diff --git a/gcc/d/dmd/statementsem.c b/gcc/d/dmd/statementsem.c index 167836c0478..143864dc666 100644 --- a/gcc/d/dmd/statementsem.c +++ b/gcc/d/dmd/statementsem.c @@ -2035,7 +2035,7 @@ public: ss->_body = semantic(ss->_body, sc); sc->noctor--; -if (conditionError || ss->_body->isErrorStatement()) +if (conditionError || (ss->_body && ss->_body->isErrorStatement())) goto Lerror; // Resolve any goto case's with exp @@ -2111,7 +2111,7 @@ public: { ss->hasNoDefault = 1; -if (!ss->isFinal && !ss->_body->isErrorStatement()) +if (!ss->isFinal && (!ss->_body || !ss->_body->isErrorStatement())) ss->error("switch statement without a default; use 'final switch' or add 'default: assert(0);' or add 'default: break;'"); // Generate runtime error if the default is hit diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail19955.d b/gcc/testsuite/gdc.test/fail_compilation/fail19955.d new file mode 100644 index 000..7cdce2c676a --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/fail19955.d @@ -0,0 +1,8 @@ +// PERMUTE_ARGS: +/* +TEST_OUTPUT: +--- +fail_compilation/fail19955.d(8): Error: `switch` statement without a `default`; use `final switch` or add `default: assert(0);` or add `default: break;` +--- +*/ +void f() { switch(1) static assert(1); } commit 960d7913321bce56e4cb16c38500f6c8b1291853 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272351 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/d/d-target.cc b/gcc/d/d-target.cc index e0cfbafe0b9..8d85534f054 100644 --- a/gcc/d/d-target.cc +++ b/gcc/d/d-target.cc @@ -140,8 +140,9 @@ Target::_init (void) /* Size of run-time TypeInfo object. */ Target::classinfosize = 19 * Target::ptrsize; - /* Allow data sizes up to half of the address space. */ - Target::maxStaticDataSize = tree_to_shwi (TYPE_MAX_VALUE (ptrdiff_type_node)); + /* Much of the dmd front-end uses ints for sizes and offsets, and cannot + handle any larger data type without some pervasive rework. */ + Target::maxStaticDataSize = tree_to_shwi (TYPE_MAX_VALUE (integer_type_node)); /* Define what type to use for size_t, ptrdiff_t. */ if (POINTER_SIZE == 64) diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 01c8cb0325d..4111fc97044 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -f8e38c001b9d7bd6586ee5b3dab7f7f199a69be7 +7afcc60c30554e452eacdfbefc4951ebf601fccd The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository.
[committed][openacc] Fix SIGSEGV in oacc_entry_exit_ok_1
Hi, When compiling the test-case with r268755, we run into a SIGSEGV in oacc_entry_exit_ok_1 when trying to dereference a NULL red: ... struct reduction_info *red; red = reduction_phi (reduction_list, use_stmt); tree val = PHI_RESULT (red->keep_res); ... Fix this by handling ref == NULL. Bootstrapped and reg-tested on x86_64. Build and reg-tested on x86_64 with nvptx accelerator. Committed to trunk. Thanks, - Tom [openacc] Fix SIGSEGV in oacc_entry_exit_ok_1 2019-06-16 Tom de Vries PR tree-optimization/89376 * tree-parloops.c (oacc_entry_exit_ok_1): Handle red == NULL. * testsuite/libgomp.oacc-c-c++-common/pr89376.c: New test. --- gcc/tree-parloops.c | 6 +++--- libgomp/testsuite/libgomp.oacc-c-c++-common/pr89376.c | 15 +++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index 9de154e722f..6b8c8cd5b75 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -3052,11 +3052,11 @@ oacc_entry_exit_ok_1 (bitmap in_loop_bbs, vec region_bbs, { use_operand_p use_p; gimple *use_stmt; + struct reduction_info *red; single_imm_use (lhs, _p, _stmt); - if (gimple_code (use_stmt) == GIMPLE_PHI) + if (gimple_code (use_stmt) == GIMPLE_PHI + && (red = reduction_phi (reduction_list, use_stmt))) { - struct reduction_info *red; - red = reduction_phi (reduction_list, use_stmt); tree val = PHI_RESULT (red->keep_res); if (has_single_use (val)) { diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/pr89376.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr89376.c new file mode 100644 index 000..7f6c83254d5 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr89376.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fno-tree-ch -fno-tree-dce -fno-tree-vrp" } */ + +int +main (void) +{ + int fa; + + #pragma acc kernels + for (int rw = 0; rw < 1; ++rw) +fa = 0; + + return 0; +} +