diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4aa86f0bbe90..861f45a2a2c8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,76 @@ +2023-10-24 Mark Harmstone + + Backported from master: + 2023-10-24 Mark Harmstone + + * opts.cc (debug_type_names): Remove stabs and xcoff. + (df_set_names): Adjust. + +2023-10-23 Oleg Endo + + PR target/111001 + * config/sh/sh_treg_combine.cc (sh_treg_combine::record_set_of_reg): + Skip over nop move insns. + +2023-10-23 Kewen Lin + + Backported from master: + 2023-10-12 Kewen Lin + + PR target/111367 + * config/rs6000/rs6000.md (stack_protect_setsi): Support prefixed + instruction emission and incorporate to stack_protect_set. + (stack_protect_setdi): Rename to ... + (stack_protect_set): ... this, adjust constraint. + (stack_protect_testsi): Support prefixed instruction emission and + incorporate to stack_protect_test. + (stack_protect_testdi): Rename to ... + (stack_protect_test): ... this, adjust constraint. + +2023-10-20 Oleg Endo + + PR target/101177 + * config/sh/sh.md (unnamed split pattern): Fix comparison of + find_regno_note result. + +2023-10-18 Richard Sandiford + + Backported from master: + 2023-09-07 Richard Sandiford + + PR target/111528 + * lra-eliminations.cc (lra_eliminate_regs_1): Use simplify_gen_binary + rather than gen_rtx_PLUS. + +2023-10-17 liuhongt + + Backported from master: + 2023-07-06 liuhongt + + PR target/110170 + * config/i386/i386.md (movdf_internal): Disparage slightly for + 2 alternatives (r,v) and (v,r) by adding constraint modifier + '?'. + +2023-10-16 Kewen Lin + + Backported from master: + 2023-09-25 Kewen Lin + + PR target/111380 + * config/rs6000/rs6000.cc (rs6000_can_inline_p): Adopt + target_option_default_node when the callee has no option + attributes, also simplify the existing code accordingly. + +2023-10-16 Kewen Lin + + Backported from master: + 2023-09-25 Kewen Lin + + PR target/111366 + * config/rs6000/rs6000.cc (rs6000_update_ipa_fn_target_info): Skip + empty inline asm. + 2023-10-13 Andrew MacLeod PR tree-optimization/111622 diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 2638d56830af..8cc3c140cdf8 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20231016 +20231026 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 8c4ec45d7f6b..2d92bf206794 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,18 @@ +2023-10-20 Marek Polacek + + Backported from master: + 2023-10-20 Marek Polacek + + PR c/111884 + * c-common.cc (c_common_get_alias_set): Return -1 for char8_t only + in C++. + +2023-10-19 Lewis Hyatt + + PR c++/89038 + * c-pragma.cc (handle_pragma_diagnostic_impl): Handle + -Wunknown-pragmas during early processing. + 2023-07-27 Release Manager * GCC 13.2.0 released. diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 2b4c82facf7f..aae397ed755c 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -3806,12 +3806,13 @@ c_common_get_alias_set (tree t) if (!TYPE_P (t)) return -1; - /* Unlike char, char8_t doesn't alias. */ - if (flag_char8_t && t == char8_type_node) + /* Unlike char, char8_t doesn't alias in C++. (In C, char8_t is not + a distinct type.) */ + if (flag_char8_t && t == char8_type_node && c_dialect_cxx ()) return -1; /* The C standard guarantees that any object may be accessed via an - lvalue that has narrow character type (except char8_t). */ + lvalue that has narrow character type. */ if (t == char_type_node || t == signed_char_type_node || t == unsigned_char_type_node) diff --git a/gcc/c-family/c-pragma.cc b/gcc/c-family/c-pragma.cc index ae8790f3c666..4f8d9949ee13 100644 --- a/gcc/c-family/c-pragma.cc +++ b/gcc/c-family/c-pragma.cc @@ -1006,7 +1006,8 @@ handle_pragma_diagnostic_impl () /* option_string + 1 to skip the initial '-' */ unsigned int option_index = find_opt (data.option_str + 1, lang_mask); - if (early && !c_option_is_from_cpp_diagnostics (option_index)) + if (early && !(c_option_is_from_cpp_diagnostics (option_index) + || option_index == OPT_Wunknown_pragmas)) return; if (option_index == OPT_SPECIAL_unknown) diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index bd678190782e..d6e25db9d014 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -3744,9 +3744,9 @@ ;; Possible store forwarding (partial memory) stall in alternatives 4, 6 and 7. (define_insn "*movdf_internal" [(set (match_operand:DF 0 "nonimmediate_operand" - "=Yf*f,m ,Yf*f,?r ,!o,?*r ,!o,!o,?r,?m,?r,?r,v,v,v,m,*x,*x,*x,m ,r ,v,r ,o ,r ,m") + "=Yf*f,m ,Yf*f,?r ,!o,?*r ,!o,!o,?r,?m,?r,?r,v,v,v,m,*x,*x,*x,m ,?r,?v,r ,o ,r ,m") (match_operand:DF 1 "general_operand" - "Yf*fm,Yf*f,G ,roF,r ,*roF,*r,F ,rm,rC,C ,F ,C,v,m,v,C ,*x,m ,*x,v,r ,roF,rF,rmF,rC"))] + "Yf*fm,Yf*f,G ,roF,r ,*roF,*r,F ,rm,rC,C ,F ,C,v,m,v,C ,*x,m ,*x, v, r,roF,rF,rmF,rC"))] "!(MEM_P (operands[0]) && MEM_P (operands[1])) && (lra_in_progress || reload_completed || !CONST_DOUBLE_P (operands[1]) diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h index f81678756465..f0db67f8c7b8 100644 --- a/gcc/config/loongarch/loongarch.h +++ b/gcc/config/loongarch/loongarch.h @@ -1157,3 +1157,8 @@ struct GTY (()) machine_function (TARGET_HARD_FLOAT_ABI ? (TARGET_DOUBLE_FLOAT_ABI ? 8 : 4) : 0) #define FUNCTION_VALUE_REGNO_P(N) ((N) == GP_RETURN || (N) == FP_RETURN) + +/* LoongArch maintains ICache/DCache coherency by hardware, + we just need "ibar" to avoid instruction hazard here. */ +#undef CLEAR_INSN_CACHE +#define CLEAR_INSN_CACHE(beg, end) __builtin_loongarch_ibar (0) diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index 43c3578b6db4..830eaaea90e4 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -110,6 +110,7 @@ (define_constants [(RETURN_ADDR_REGNUM 1) + (TP_REGNUM 2) (T0_REGNUM 12) (T1_REGNUM 13) (S0_REGNUM 23) @@ -3446,6 +3447,12 @@ [(set_attr "length" "0") (set_attr "type" "ghost")]) +;; Named pattern for expanding thread pointer reference. +(define_expand "get_thread_pointer" + [(set (match_operand:P 0 "register_operand" "=r") + (reg:P TP_REGNUM))] + "HAVE_AS_TLS" + {}) (define_split [(match_operand 0 "small_data_pattern")] diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index b323d4132715..b54767867ef8 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -12354,33 +12354,26 @@ DONE; }) -(define_insn "stack_protect_setsi" - [(set (match_operand:SI 0 "memory_operand" "=m") - (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET)) - (set (match_scratch:SI 2 "=&r") (const_int 0))] - "TARGET_32BIT" - "lwz%U1%X1 %2,%1\;stw%U0%X0 %2,%0\;li %2,0" - [(set_attr "type" "three") - (set_attr "length" "12")]) - ;; We can't use the prefixed attribute here because there are two memory ;; instructions. We can't split the insn due to the fact that this operation ;; needs to be done in one piece. -(define_insn "stack_protect_setdi" - [(set (match_operand:DI 0 "memory_operand" "=Y") - (unspec:DI [(match_operand:DI 1 "memory_operand" "Y")] UNSPEC_SP_SET)) - (set (match_scratch:DI 2 "=&r") (const_int 0))] - "TARGET_64BIT" +(define_insn "stack_protect_set" + [(set (match_operand:P 0 "memory_operand" "=YZ") + (unspec:P [(match_operand:P 1 "memory_operand" "YZ")] UNSPEC_SP_SET)) + (set (match_scratch:P 2 "=&r") (const_int 0))] + "" { - if (prefixed_memory (operands[1], DImode)) - output_asm_insn ("pld %2,%1", operands); + if (prefixed_memory (operands[1], mode)) + /* Prefixed load only supports D-form but no update and X-form. */ + output_asm_insn ("p %2,%1", operands); else - output_asm_insn ("ld%U1%X1 %2,%1", operands); + output_asm_insn ("%U1%X1 %2,%1", operands); - if (prefixed_memory (operands[0], DImode)) - output_asm_insn ("pstd %2,%0", operands); + if (prefixed_memory (operands[0], mode)) + /* Prefixed store only supports D-form but no update and X-form. */ + output_asm_insn ("pst %2,%0", operands); else - output_asm_insn ("std%U0%X0 %2,%0", operands); + output_asm_insn ("st%U0%X0 %2,%0", operands); return "li %2,0"; } @@ -12426,45 +12419,33 @@ DONE; }) -(define_insn "stack_protect_testsi" - [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y") - (unspec:CCEQ [(match_operand:SI 1 "memory_operand" "m,m") - (match_operand:SI 2 "memory_operand" "m,m")] - UNSPEC_SP_TEST)) - (set (match_scratch:SI 4 "=r,r") (const_int 0)) - (clobber (match_scratch:SI 3 "=&r,&r"))] - "TARGET_32BIT" - "@ - lwz%U1%X1 %3,%1\;lwz%U2%X2 %4,%2\;xor. %3,%3,%4\;li %4,0 - lwz%U1%X1 %3,%1\;lwz%U2%X2 %4,%2\;cmplw %0,%3,%4\;li %3,0\;li %4,0" - [(set_attr "length" "16,20")]) - ;; We can't use the prefixed attribute here because there are two memory ;; instructions. We can't split the insn due to the fact that this operation ;; needs to be done in one piece. -(define_insn "stack_protect_testdi" +(define_insn "stack_protect_test" [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y") - (unspec:CCEQ [(match_operand:DI 1 "memory_operand" "Y,Y") - (match_operand:DI 2 "memory_operand" "Y,Y")] + (unspec:CCEQ [(match_operand:P 1 "memory_operand" "YZ,YZ") + (match_operand:P 2 "memory_operand" "YZ,YZ")] UNSPEC_SP_TEST)) - (set (match_scratch:DI 4 "=r,r") (const_int 0)) - (clobber (match_scratch:DI 3 "=&r,&r"))] - "TARGET_64BIT" + (set (match_scratch:P 4 "=r,r") (const_int 0)) + (clobber (match_scratch:P 3 "=&r,&r"))] + "" { - if (prefixed_memory (operands[1], DImode)) - output_asm_insn ("pld %3,%1", operands); + if (prefixed_memory (operands[1], mode)) + /* Prefixed load only supports D-form but no update and X-form. */ + output_asm_insn ("p %3,%1", operands); else - output_asm_insn ("ld%U1%X1 %3,%1", operands); + output_asm_insn ("%U1%X1 %3,%1", operands); - if (prefixed_memory (operands[2], DImode)) - output_asm_insn ("pld %4,%2", operands); + if (prefixed_memory (operands[2], mode)) + output_asm_insn ("p %4,%2", operands); else - output_asm_insn ("ld%U2%X2 %4,%2", operands); + output_asm_insn ("%U2%X2 %4,%2", operands); if (which_alternative == 0) output_asm_insn ("xor. %3,%3,%4", operands); else - output_asm_insn ("cmpld %0,%3,%4\;li %3,0", operands); + output_asm_insn ("cmpl %0,%3,%4\;li %3,0", operands); return "li %4,0"; } diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index 76e7774cef31..93374c65bfe1 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -842,7 +842,7 @@ if (SUBREG_P (reg)) reg = SUBREG_REG (reg); gcc_assert (REG_P (reg)); - if (find_regno_note (curr_insn, REG_DEAD, REGNO (reg)) != NULL_RTX) + if (find_regno_note (curr_insn, REG_DEAD, REGNO (reg)) == NULL_RTX) FAIL; /* FIXME: Maybe also search the predecessor basic blocks to catch diff --git a/gcc/config/sh/sh_treg_combine.cc b/gcc/config/sh/sh_treg_combine.cc index 9f6a89fa71fb..9b35960c8c2b 100644 --- a/gcc/config/sh/sh_treg_combine.cc +++ b/gcc/config/sh/sh_treg_combine.cc @@ -729,7 +729,14 @@ sh_treg_combine::record_set_of_reg (rtx reg, rtx_insn *start_insn, } else if (REG_P (new_entry.cstore.set_src ())) { - // If it's a reg-reg copy follow the copied reg. + // If it's a reg-reg copy follow the copied reg, but ignore + // nop copies of the reg onto itself. + if (REGNO (new_entry.cstore.set_src ()) == REGNO (reg)) + { + i = prev_nonnote_nondebug_insn_bb (i); + continue; + } + new_entry.cstore_reg_reg_copies.push_back (new_entry.cstore); reg = new_entry.cstore.set_src (); i = new_entry.cstore.insn; diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index d72228ae030f..f0eac95782b3 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -16333,6 +16333,11 @@ function you need to include @code{larchintrin.h}. void __break (imm0_32767) @end smallexample +Returns the value that is currently set in the @samp{tp} register. +@smallexample + void * __builtin_thread_pointer (void) +@end smallexample + @node MIPS DSP Built-in Functions @subsection MIPS DSP Built-in Functions diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e88bb3d78e20..db29631a5144 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2023-10-21 Harald Anlauf + + Backported from master: + 2023-10-17 Harald Anlauf + + PR fortran/111837 + * frontend-passes.cc (traverse_io_block): Dependency check of loop + nest shall be triangular, not banded. + 2023-10-04 Paul Thomas Backported from master: diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc index 904289820232..85ebca56a69f 100644 --- a/gcc/fortran/frontend-passes.cc +++ b/gcc/fortran/frontend-passes.cc @@ -1326,7 +1326,7 @@ traverse_io_block (gfc_code *code, bool *has_reached, gfc_code *prev) if (iters[i]) { gfc_expr *var = iters[i]->var; - for (int j = i - 1; j < i; j++) + for (int j = 0; j < i; j++) { if (iters[j] && (var_in_expr (var, iters[j]->start) diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc index 422063666690..c627dc5db6b7 100644 --- a/gcc/lra-eliminations.cc +++ b/gcc/lra-eliminations.cc @@ -397,8 +397,8 @@ lra_eliminate_regs_1 (rtx_insn *insn, rtx x, machine_mode mem_mode, rtx to = subst_p ? ep->to_rtx : ep->from_rtx; if (! update_p && ! full_p) - return gen_rtx_PLUS (Pmode, to, XEXP (x, 1)); - + return simplify_gen_binary (PLUS, Pmode, to, XEXP (x, 1)); + if (maybe_ne (update_sp_offset, 0)) offset = ep->to_rtx == stack_pointer_rtx ? update_sp_offset : 0; else diff --git a/gcc/m2/ChangeLog b/gcc/m2/ChangeLog index ea2d97cf5bcc..1fa98922af34 100644 --- a/gcc/m2/ChangeLog +++ b/gcc/m2/ChangeLog @@ -1,3 +1,49 @@ +2023-10-18 Gaius Mulley + + PR modula2/111756 + * Make-lang.in (CM2DEP): New define conditionally set if + ($(CXXDEPMODE),depmode=gcc3). + (m2/gm2-gcc/%.o): Ensure $(@D)/$(DEPDIR) is created. + Add $(CM2DEP) to the $(COMPILER) command and use $(POSTCOMPILE). + (m2/gm2-gcc/m2configure.o): Ditto. + (m2/gm2-lang.o): Ditto. + (m2/m2pp.o): Ditto. + (m2/gm2-gcc/rtegraph.o): Ditto. + (m2/mc-boot/$(SRC_PREFIX)%.o): Ditto. + (m2/mc-boot-ch/$(SRC_PREFIX)%.o): Ditto. + (m2/mc-boot-ch/$(SRC_PREFIX)%.o): Ditto. + (m2/mc-boot/main.o): Ditto. + (mcflex.o): Ditto. + (m2/gm2-libs-boot/M2RTS.o): Ditto. + (m2/gm2-libs-boot/%.o): Ditto. + (m2/gm2-libs-boot/%.o): Ditto. + (m2/gm2-libs-boot/RTcodummy.o): Ditto. + (m2/gm2-libs-boot/RTintdummy.o): Ditto. + (m2/gm2-libs-boot/wrapc.o): Ditto. + (m2/gm2-libs-boot/UnixArgs.o): Ditto. + (m2/gm2-libs-boot/choosetemp.o): Ditto. + (m2/gm2-libs-boot/errno.o): Ditto. + (m2/gm2-libs-boot/dtoa.o): Ditto. + (m2/gm2-libs-boot/ldtoa.o): Ditto. + (m2/gm2-libs-boot/termios.o): Ditto. + (m2/gm2-libs-boot/SysExceptions.o): Ditto. + (m2/gm2-libs-boot/SysStorage.o): Ditto. + (m2/gm2-compiler-boot/M2GCCDeclare.o): Ditto. + (m2/gm2-compiler-boot/M2Error.o): Ditto. + (m2/gm2-compiler-boot/%.o): Ditto. + (m2/gm2-compiler-boot/%.o): Ditto. + (m2/gm2-compiler-boot/m2flex.o): Ditto. + (m2/gm2-compiler/m2flex.o): Ditto. + (m2/gm2-libs/choosetemp.o): Ditto. + (m2/boot-bin/mklink$(exeext)): Ditto. + (m2/pge-boot/%.o): Ditto. + (m2/pge-boot/%.o): Ditto. + * README: Remove out of date info. + * gm2-compiler/M2Quads.mod (BuildStringAdrParam): Correct + procedure end name. + * gm2-compiler/SymbolTable.mod (GetVarPointerCheck): Add + default FALSE return value. + 2023-09-26 Gaius Mulley Backported from master: diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in index cf4f3c015115..0ae3e1839770 100644 --- a/gcc/m2/Make-lang.in +++ b/gcc/m2/Make-lang.in @@ -27,6 +27,13 @@ GM2_CROSS_NAME = `echo gm2|sed '$(program_transform_cross_name)'` M2_MAINTAINER = no +# CM2DEP must match the COMPILE and POSTCOMPILE defines in gcc/Make-lang.in +ifeq ($(CXXDEPMODE),depmode=gcc3) +CM2DEP=-MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo +else +CM2DEP= +endif + GM2_1 = ./gm2 -B./m2/stage1 -g -fm2-g GM2_FOR_TARGET = $(STAGE_CC_WRAPPER) ./gm2 -B./ -B$(build_tooldir)/bin/ -L$(objdir)/../ld $(TFLAGS) @@ -567,35 +574,40 @@ GCC_HEADER_DEPENDENCIES_FOR_M2 = $(BUILD-BOOT-H) $(TIMEVAR_H) m2/gm2config.h $(C $(generated_files) insn-attr-common.h m2/gm2-gcc/%.o: $(srcdir)/m2/gm2-gcc/%.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(COMPILER) -c -g $(ALL_COMPILERFLAGS) \ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(COMPILER) $(CM2DEP) -c -g $(ALL_COMPILERFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) + $(POSTCOMPILE) m2/gm2-gcc/m2configure.o: $(srcdir)/m2/gm2-gcc/m2configure.cc \ $(SYSTEM_H) $(GCC_H) $(CONFIG_H) \ m2/gm2config.h $(TARGET_H) $(PLUGIN_HEADERS) \ $(generated_files) $(C_TREE_H) insn-attr-common.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(COMPILER) $(CM2DEP) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ $(DRIVER_DEFINES) \ -DLIBSUBDIR=\"$(libsubdir)\" \ -DPREFIX=\"$(prefix)\" \ -c $(srcdir)/m2/gm2-gcc/m2configure.cc $(OUTPUT_OPTION) + $(POSTCOMPILE) m2/gm2-lang.o: $(srcdir)/m2/gm2-lang.cc gt-m2-gm2-lang.h $(GCC_HEADER_DEPENDENCIES_FOR_M2) - $(COMPILER) -c -g $(GM2GCC) $(ALL_COMPILERFLAGS) \ + $(COMPILER) $(CM2DEP) -c -g $(GM2GCC) $(ALL_COMPILERFLAGS) \ -DLIBSUBDIR=\"$(libsubdir)\" \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) + $(POSTCOMPILE) m2/m2pp.o : $(srcdir)/m2/m2pp.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) - $(COMPILER) -c -g -DGM2 $(ALL_COMPILERFLAGS) \ + $(COMPILER) $(CM2DEP) -c -g -DGM2 $(ALL_COMPILERFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) + $(POSTCOMPILE) m2/gm2-gcc/rtegraph.o: $(srcdir)/m2/gm2-gcc/rtegraph.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \ gt-m2-rtegraph.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(COMPILER) -c -g $(GM2GCC) $(ALL_COMPILERFLAGS) \ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(COMPILER) $(CM2DEP) -c -g $(GM2GCC) $(ALL_COMPILERFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) + $(POSTCOMPILE) m2/gm2-gcc/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-gcc/%.def $(MCDEPS) -test -d $(@D) || $(mkinstalldirs) $(@D) @@ -1373,126 +1385,150 @@ m2/boot-bin/mc$(exeext): $(BUILD-MC-BOOT-O) $(BUILD-MC-INTERFACE-O) \ mcflex.o m2/gm2-libs-boot/RTcodummy.o -lm m2/mc-boot/$(SRC_PREFIX)%.o: m2/mc-boot/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) $(CXXFLAGS) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) $(CXXFLAGS) $(GM2_PICFLAGS) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) $(CXXFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) $(CXXFLAGS) $(GM2_PICFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@ + $(POSTCOMPILE) m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h -test -d $(@D) || $(mkinstalldirs) $(@D) $(CXX) $(CXXFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@ m2/mc-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit - -test -d $(@D) || $(mkinstalldirs) $(@D) + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) unset CC ; $(M2LINK) -s --langc++ --exit --name m2/mc-boot/main.cc $(srcdir)/m2/init/mcinit - $(CXX) $(CXXFLAGS) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) m2/mc-boot/main.cc -o $@ + $(CXX) $(CM2DEP) $(CXXFLAGS) $(GM2_PICFLAGS) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) m2/mc-boot/main.cc -o $@ + $(POSTCOMPILE) mcflex.o: mcflex.c m2/gm2-libs/gm2-libs-host.h - $(CC) $(CFLAGS) -I$(srcdir)/m2/mc -g -c $< -o $@ # remember that mcReserved.h is copied into m2/mc + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CC) $(CM2DEP) $(CFLAGS) $(GM2_PICFLAGS) -I$(srcdir)/m2/mc -g -c $< -o $@ # remember that mcReserved.h is copied into m2/mc + $(POSTCOMPILE) mcflex.c: $(srcdir)/m2/mc/mc.flex flex -t $< > $@ m2/gm2-libs-boot/M2RTS.o: $(srcdir)/m2/gm2-libs/M2RTS.mod $(MCDEPS) $(BUILD-BOOT-H) - -test -d $(@D) || $(mkinstalldirs) $(@D) + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) $(MC) --suppress-noreturn -o=m2/gm2-libs-boot/M2RTS.c $(srcdir)/m2/gm2-libs/M2RTS.mod - $(COMPILER) -c -DIN_GCC $(CFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/M2RTS.c -o $@ + $(COMPILER) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/M2RTS.c -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H) - -test -d $(@D) || $(mkinstalldirs) $(@D) + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) $(MC) -o=m2/gm2-libs-boot/$*.c $(srcdir)/m2/gm2-libs-boot/$*.mod - $(COMPILER) -c -DIN_GCC $(CFLAGS) $(MCINCLUDES) m2/gm2-libs-boot/$*.c -o $@ + $(COMPILER) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) $(MCINCLUDES) m2/gm2-libs-boot/$*.c -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H) - -test -d $(@D) || $(mkinstalldirs) $(@D) + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) $(MC) -o=m2/gm2-libs-boot/$*.c $(srcdir)/m2/gm2-libs/$*.mod - $(COMPILER) -c -DIN_GCC $(CFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/$*.c -o $@ + $(COMPILER) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/$*.c -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS) -test -d $(@D) || $(mkinstalldirs) $(@D) $(MC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def m2/gm2-libs-boot/RTcodummy.o: $(srcdir)/m2/gm2-libs-ch/RTcodummy.c m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/RTintdummy.o: $(srcdir)/m2/gm2-libs-ch/RTintdummy.c m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/wrapc.o: $(srcdir)/m2/gm2-libs-ch/wrapc.c m2/gm2-libs-boot/$(SRC_PREFIX)wrapc.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -c -DHAVE_CONFIG_H $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/UnixArgs.o: $(srcdir)/m2/gm2-libs-ch/UnixArgs.cc m2/gm2-libs-boot/$(SRC_PREFIX)UnixArgs.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/choosetemp.o: m2/gm2-libs-ch/choosetemp.c m2/gm2-libiberty/Gchoosetemp.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/errno.o: $(srcdir)/m2/gm2-libs-ch/errno.c m2/gm2-libs-boot/$(SRC_PREFIX)errno.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/dtoa.o: $(srcdir)/m2/gm2-libs-ch/dtoa.cc m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/ldtoa.o: $(srcdir)/m2/gm2-libs-ch/ldtoa.cc m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/termios.o: $(srcdir)/m2/gm2-libs-ch/termios.c $(BUILD-LIBS-BOOT-H) m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/SysExceptions.o: $(srcdir)/m2/gm2-libs-ch/SysExceptions.c \ m2/gm2-libs-boot/$(SRC_PREFIX)SysExceptions.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/SysStorage.o: $(srcdir)/m2/gm2-libs/SysStorage.mod $(MCDEPS) $(BUILD-BOOT-H) - -test -d $(@D) || $(mkinstalldirs) $(@D) + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) $(MC) -o=m2/gm2-libs-boot/SysStorage.c $(srcdir)/m2/gm2-libs/SysStorage.mod - $(COMPILER) -DIN_GCC -c $(CFLAGS) \ - -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) \ - m2/gm2-libs-boot/SysStorage.c -o m2/gm2-libs-boot/SysStorage.o + $(COMPILER) $(CM2DEP) -DIN_GCC -c $(CFLAGS) $(GM2_PICFLAGS) \ + -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) \ + m2/gm2-libs-boot/SysStorage.c -o m2/gm2-libs-boot/SysStorage.o + $(POSTCOMPILE) m2/gm2-compiler-boot/M2GCCDeclare.o: $(srcdir)/m2/gm2-compiler/M2GCCDeclare.mod $(MCDEPS) $(BUILD-BOOT-H) - -test -d $(@D) || $(mkinstalldirs) $(@D) + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) $(MC) --extended-opaque -o=m2/gm2-compiler-boot/M2GCCDeclare.c $< - $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \ - -I. -I$(srcdir)/../include -I$(srcdir) \ - -I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot \ - -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/M2GCCDeclare.c -o $@ + $(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \ + -I. -I$(srcdir)/../include -I$(srcdir) \ + -I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot \ + -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/M2GCCDeclare.c -o $@ + $(POSTCOMPILE) m2/gm2-compiler-boot/M2Error.o: $(srcdir)/m2/gm2-compiler/M2Error.mod $(MCDEPS) $(BUILD-BOOT-H) - -test -d $(@D) || $(mkinstalldirs) $(@D) + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) $(MC) --extended-opaque -o=m2/gm2-compiler-boot/M2Error.c $< - $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \ - -I. -I$(srcdir)/../include -I$(srcdir) \ - -I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot \ - -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/M2Error.c -o $@ + $(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \ + -I. -I$(srcdir)/../include -I$(srcdir) \ + -I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot \ + -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/M2Error.c -o $@ + $(POSTCOMPILE) m2/gm2-compiler-boot/%.o: $(srcdir)/m2/gm2-compiler/%.mod $(BUILD-BOOT-H) $(MCDEPS) $(BUILD-BOOT-H) - -test -d $(@D) || $(mkinstalldirs) $(@D) + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) $(MC) -o=m2/gm2-compiler-boot/$*.c $(srcdir)/m2/gm2-compiler/$*.mod - $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \ - -I. -I$(srcdir)/../include -I$(srcdir) \ - -I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -Im2/gm2-libiberty \ - -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/$*.c -o $@ + + $(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \ + -I. -I$(srcdir)/../include -I$(srcdir) \ + -I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -Im2/gm2-libiberty \ + -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/$*.c -o $@ + $(POSTCOMPILE) m2/gm2-compiler-boot/%.o: m2/gm2-compiler-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H) - -test -d $(@D) || $(mkinstalldirs) $(@D) + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) $(MC) -o=m2/gm2-compiler-boot/$*.c m2/gm2-compiler-boot/$*.mod - $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \ - -I. -I$(srcdir)/../include -I$(srcdir) \ - -I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot \ - -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/$*.c -o $@ + $(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \ + -I. -I$(srcdir)/../include -I$(srcdir) \ + -I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot \ + -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/$*.c -o $@ + $(POSTCOMPILE) m2/gm2-compiler-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-compiler/%.def $(MCDEPS) -test -d $(@D) || $(mkinstalldirs) $(@D) @@ -1501,10 +1537,11 @@ m2/gm2-compiler-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-compiler/%.def $(MCDEPS) m2/gm2-compiler-boot/m2flex.o: m2/gm2-compiler/m2flex.c $(BUILD-BOOT-H) $(TIMEVAR_H) \ $(BUILD-LIBS-BOOT-H) m2/gm2-compiler-boot/$(SRC_PREFIX)NameKey.h \ $(CONFIG_H) m2/gm2config.h $(TARGET_H) $(PLUGIN_HEADERS) - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(COMPILER) -c -g $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(COMPILER) $(CM2DEP) -c -g $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ $(GM2GCC) $(INCLUDES) -I$(srcdir)/m2 \ -Im2 -Im2/gm2-compiler-boot -Im2/gm2-libs-boot $< -o $@ + $(POSTCOMPILE) m2/gm2-compiler/m2flex.c: $(srcdir)/m2/m2.flex $(TIMEVAR_H) insn-attr-common.h -test -d $(@D) || $(mkinstalldirs) $(@D) @@ -1521,23 +1558,24 @@ m2/gm2-compiler/%.o: $(srcdir)/m2/gm2-compiler/%.mod $(GM2_1) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@ m2/gm2-compiler/m2flex.o: m2/gm2-compiler/m2flex.c m2/gm2-libs/gm2-libs-host.h $(TIMEVAR_H) - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(COMPILER) -c -g $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ - $(GM2GCC) -Im2/gm2-compiler-boot -Im2/gm2-libs-boot $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(COMPILER) $(CM2DEP) -c -g $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(GM2GCC) -Im2/gm2-compiler-boot -Im2/gm2-libs-boot $< -o $@ + $(POSTCOMPILE) m2/gm2-compiler/%.o: m2/gm2-compiler/%.mod -test -d $(@D) || $(mkinstalldirs) $(@D) $(GM2_1) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@ m2/gm2-libs-iso/%.o: $(srcdir)/m2/gm2-libs-iso/%.c m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -DBUILD_GM2_LIBS_TARGET -DBUILD_GM2_LIBS -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -DBUILD_GM2_LIBS_TARGET -DBUILD_GM2_LIBS -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs-iso/%.o: $(srcdir)/m2/gm2-libs-iso/%.mod -test -d $(@D) || $(mkinstalldirs) $(@D) $(GM2_1) $(GM2_ISO_FLAGS) -c -B./ -Im2/gm2-libs-iso:$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs $< -o $@ - # We build the cc1gm2$(exeext) from the boot stage and then proceed to build it # again using itself. @@ -1632,16 +1670,19 @@ m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H) $(GM2_1) -c $(GM2_FLAGS) -Im2/gm2-libs -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso $< -o $@ m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs-ch/%.c m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -DBUILD_GM2_LIBS -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -DBUILD_GM2_LIBS -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs-ch/%.cc m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs/choosetemp.o: m2/gm2-libs-ch/choosetemp.c m2/gm2-libiberty/Gchoosetemp.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-libs-boot/libgm2.a: m2/boot-bin/mc$(exeext) $(BUILD-LIBS-BOOT) -test -d $(@D) || $(mkinstalldirs) $(@D) @@ -1660,8 +1701,9 @@ m2/gm2-compiler-boot/gm2.a: m2/boot-bin/mc$(exeext) m2/boot-bin/mklink$(exeext) m2/gm2-compiler-boot/gm2.a: m2/boot-bin/mc$(exeext) m2/boot-bin/mklink$(exeext): $(srcdir)/m2/tools-src/mklink.c - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) $(CFLAGS) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) $(CFLAGS) $(LDFLAGS) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) $< -o $@ + $(POSTCOMPILE) m2/gm2-compiler-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-compiler-boot/%.def $(MCDEPS) -test -d $(@D) || $(mkinstalldirs) $(@D) @@ -1740,12 +1782,14 @@ ifeq ($(M2_MAINTAINER),yes) include m2/Make-maintainer else m2/pge-boot/%.o: m2/pge-boot/%.c m2/gm2-libs/gm2-libs-host.h m2/gm2config.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) $(CFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) $(CFLAGS) $(GM2_PICFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@ + $(POSTCOMPILE) m2/pge-boot/%.o: m2/pge-boot/%.cc m2/gm2-libs/gm2-libs-host.h m2/gm2config.h - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(CXX) $(CXXFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@ + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) + $(CXX) $(CM2DEP) $(CXXFLAGS) $(GM2_PICFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@ + $(POSTCOMPILE) $(PGE): $(BUILD-PGE-O) +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PGE-O) -lm diff --git a/gcc/m2/README b/gcc/m2/README index 9de9e4fbf548..9cb87724d318 100644 --- a/gcc/m2/README +++ b/gcc/m2/README @@ -1,25 +1,4 @@ -Building GNU Modula-2 -===================== - -Please see the GCC documentation (gcc.texi) and section -(Installing GCC). - -Regression testing GM2 -====================== - - cd host-build ; make check-m2 - -runs all regression tests. - -Stress testing GM2 -================== - - cd host-build/gcc ; make gm2.paranoid - -builds gm2 using itself and then compiles each module with both -versions of gm2 comparing the emitted assembler code. - Contributing to GNU Modula-2 ============================ diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod index 9d4616ae6e64..7b5cd083b71a 100644 --- a/gcc/m2/gm2-compiler/M2Quads.mod +++ b/gcc/m2/gm2-compiler/M2Quads.mod @@ -2593,7 +2593,7 @@ BEGIN PushTtok (m2strnul, tok) ; PushT (1) ; BuildAdrFunction -END BuildAdrFunction ; +END BuildStringAdrParam ; (* diff --git a/gcc/m2/gm2-compiler/SymbolTable.mod b/gcc/m2/gm2-compiler/SymbolTable.mod index 891b29985b8b..85025e15bc0b 100644 --- a/gcc/m2/gm2-compiler/SymbolTable.mod +++ b/gcc/m2/gm2-compiler/SymbolTable.mod @@ -6713,7 +6713,8 @@ BEGIN WITH pSym^.Var DO RETURN( IsPointerCheck ) END - END + END ; + RETURN FALSE END GetVarPointerCheck ; diff --git a/gcc/opts.cc b/gcc/opts.cc index 74bd7d0ae7ce..2e1ddf000c45 100644 --- a/gcc/opts.cc +++ b/gcc/opts.cc @@ -49,7 +49,7 @@ static void set_Wstrict_aliasing (struct gcc_options *opts, int onoff); const char *const debug_type_names[] = { - "none", "stabs", "dwarf-2", "xcoff", "vms", "ctf", "btf" + "none", "dwarf-2", "vms", "ctf", "btf" }; /* Bitmasks of fundamental debug info formats indexed by enum @@ -64,7 +64,7 @@ static uint32_t debug_type_masks[] = /* Names of the set of debug formats requested by user. Updated and accessed via debug_set_names. */ -static char df_set_names[sizeof "none stabs dwarf-2 xcoff vms ctf btf"]; +static char df_set_names[sizeof "none dwarf-2 vms ctf btf"]; /* Get enum debug_info_type of the specified debug format, for error messages. Can be used only for individual debug format types. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 40f762f83941..746acf78a611 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,56 @@ +2023-10-23 Kewen Lin + + Backported from master: + 2023-10-12 Kewen Lin + + PR target/111367 + * g++.target/powerpc/pr111367.C: New test. + +2023-10-21 Harald Anlauf + + Backported from master: + 2023-10-17 Harald Anlauf + + PR fortran/111837 + * gfortran.dg/implied_do_io_8.f90: New test. + +2023-10-20 Marek Polacek + + Backported from master: + 2023-10-20 Marek Polacek + + PR c/111884 + * c-c++-common/alias-1.c: New test. + +2023-10-19 Lewis Hyatt + + PR c++/89038 + * c-c++-common/cpp/Wunknown-pragmas-1.c: New test. + +2023-10-17 liuhongt + + Backported from master: + 2023-07-06 liuhongt + + * gcc.target/i386/pr110170-3.c: New test. + +2023-10-16 Kewen Lin + + Backported from master: + 2023-09-25 Kewen Lin + + PR target/111380 + * gcc.target/powerpc/pr111380-1.c: New test. + * gcc.target/powerpc/pr111380-2.c: New test. + +2023-10-16 Kewen Lin + + Backported from master: + 2023-09-25 Kewen Lin + + PR target/111366 + * g++.target/powerpc/pr111366.C: New test. + 2023-10-11 Andrew MacLeod PR tree-optimization/111694 diff --git a/gcc/testsuite/c-c++-common/alias-1.c b/gcc/testsuite/c-c++-common/alias-1.c new file mode 100644 index 000000000000..d72fec47f760 --- /dev/null +++ b/gcc/testsuite/c-c++-common/alias-1.c @@ -0,0 +1,23 @@ +/* PR c/111884 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ +/* { dg-additional-options "-std=c++20" { target c++ } } */ +/* { dg-additional-options "-std=c2x" { target c } } */ + +int f(int i) +{ + int f = 1; + return i[(unsigned char *)&f]; +} + +int g(int i) +{ + int f = 1; + return i[(signed char *)&f]; +} + +int h(int i) +{ + int f = 1; + return i[(char *)&f]; +} diff --git a/gcc/testsuite/c-c++-common/cpp/Wunknown-pragmas-1.c b/gcc/testsuite/c-c++-common/cpp/Wunknown-pragmas-1.c new file mode 100644 index 000000000000..fb58739e2bce --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/Wunknown-pragmas-1.c @@ -0,0 +1,13 @@ +/* PR c++/89038 */ +/* { dg-additional-options "-Wunknown-pragmas" } */ + +#pragma oops /* { dg-warning "-:-Wunknown-pragmas" } */ +#pragma GGC diagnostic push /* { dg-warning "-:-Wunknown-pragmas" } */ +#pragma GCC diagnostics push /* { dg-warning "-:-Wunknown-pragmas" } */ + +/* Test we can disable the warnings. */ +#pragma GCC diagnostic ignored "-Wunknown-pragmas" + +#pragma oops /* { dg-bogus "-:-Wunknown-pragmas" } */ +#pragma GGC diagnostic push /* { dg-bogus "-:-Wunknown-pragmas" } */ +#pragma GCC diagnostics push /* { dg-bogus "-:-Wunknown-pragmas" } */ diff --git a/gcc/testsuite/g++.target/powerpc/pr111367.C b/gcc/testsuite/g++.target/powerpc/pr111367.C new file mode 100644 index 000000000000..8f9d4415672d --- /dev/null +++ b/gcc/testsuite/g++.target/powerpc/pr111367.C @@ -0,0 +1,22 @@ +/* { dg-do assemble } */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-mdejagnu-cpu=power10 -fstack-protector-strong" } */ + +/* Verify object file can be generated successfully. */ + +struct SortAscending +{ +}; + +typedef unsigned long long size_t; + +void VQSort (long long *, size_t, SortAscending); + +void +BenchAllColdSort () +{ + typedef long long T; + constexpr size_t kSize = 10 * 1000; + alignas (16) T items[kSize]; + VQSort (items, kSize, SortAscending ()); +} diff --git a/gcc/testsuite/gcc.target/i386/pr110170-3.c b/gcc/testsuite/gcc.target/i386/pr110170-3.c new file mode 100644 index 000000000000..70daa89e9aae --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr110170-3.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -fno-if-conversion -fno-if-conversion2" } */ +/* { dg-final { scan-assembler-not {(?n)movq.*r} } } */ + +void __cond_swap(double* __x, double* __y) { + _Bool __r = (*__x < *__y); + double __tmp = __r ? *__x : *__y; + *__y = __r ? *__y : *__x; + *__x = __tmp; +} + diff --git a/gcc/testsuite/gcc.target/loongarch/builtin_thread_pointer.c b/gcc/testsuite/gcc.target/loongarch/builtin_thread_pointer.c new file mode 100644 index 000000000000..541e3b143bd2 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/builtin_thread_pointer.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target tls_native } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler "or\t\\\$r4,\\\$r2,\\\$r0" } } */ + +void * +get_tp () +{ + return __builtin_thread_pointer (); +} diff --git a/gcc/testsuite/gfortran.dg/implied_do_io_8.f90 b/gcc/testsuite/gfortran.dg/implied_do_io_8.f90 new file mode 100644 index 000000000000..c66a0f6fde66 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/implied_do_io_8.f90 @@ -0,0 +1,18 @@ +! { dg-do run } +! { dg-additional-options "-fcheck=bounds" } +! PR fortran/111837 - out of bounds access with front-end optimization + +program implied_do_bug + implicit none + integer :: i,j,k + real :: arr(1,1,1) + integer :: ni(1) + ni(1) = 1 + arr = 1 + write(*,*) (((arr(i,j,k), i=1,ni(k)), k=1,1), j=1,1) + write(*,*) (((arr(i,j,k), i=1,ni(k)), j=1,1), k=1,1) + write(*,*) (((arr(k,i,j), i=1,ni(k)), k=1,1), j=1,1) + write(*,*) (((arr(k,i,j), i=1,ni(k)), j=1,1), k=1,1) + write(*,*) (((arr(j,k,i), i=1,ni(k)), k=1,1), j=1,1) + write(*,*) (((arr(j,k,i), i=1,ni(k)), j=1,1), k=1,1) +end diff --git a/libgcc/config/avr/libf7/ChangeLog b/libgcc/config/avr/libf7/ChangeLog index e78b9cb88692..8a1bba80127a 100644 --- a/libgcc/config/avr/libf7/ChangeLog +++ b/libgcc/config/avr/libf7/ChangeLog @@ -1,3 +1,22 @@ +2023-10-19 Georg-Johann Lay + + * libf7-asm.sx (mul_mant): Implement for devices without MUL. + * asm-defs.h (wmov) [!HAVE_MUL]: Fix regno computation. + * t-libf7 (F7_ASM_FLAGS): Add -g0. + +2023-10-17 Georg-Johann Lay + + * f7-renames.h: Re-renerate. + +2023-10-17 Georg-Johann Lay + + * libf7.h (F7_SIZEOF): New macro. + * libf7-asm.sx: Use F7_SIZEOF instead of magic number "10". + (F7MOD_D_fma_, __fma): New module and function. + (fma) [-mdouble=64]: Define as alias for __fma. + (fmal) [-mlong-double=64]: Define as alias for __fma. + * libf7-common.mk (F7_ASM_PARTS): Add D_fma. + 2023-10-12 Georg-Johann Lay * libf7.c (F7MOD_atan2_, f7_atan2): New module and function. diff --git a/libgcc/config/avr/libf7/asm-defs.h b/libgcc/config/avr/libf7/asm-defs.h index 4cfd3e61cbb8..a50260a162f2 100644 --- a/libgcc/config/avr/libf7/asm-defs.h +++ b/libgcc/config/avr/libf7/asm-defs.h @@ -134,14 +134,14 @@ ..regno = 0 .irp reg, \ - X, x, XL, xl, Xl, xL, x, x \ + X, x, XL, xl, Xl, xL, x, x, \ Y, y, YL, yl, Yl, yL, y, y, \ Z, z, ZL, zl, Zl, zL, z, z .ifc \reg,\dst - ..dst = (..regno / 8) + 26 + ..dst = 2 * (..regno / 8) + 26 .endif .ifc \reg,\src - ..src = (..regno / 8) + 26 + ..src = 2 * (..regno / 8) + 26 .endif ..regno = ..regno + 1 .endr diff --git a/libgcc/config/avr/libf7/f7-renames.h b/libgcc/config/avr/libf7/f7-renames.h index e4c0c0d8fc00..22370a1e699a 100644 --- a/libgcc/config/avr/libf7/f7-renames.h +++ b/libgcc/config/avr/libf7/f7-renames.h @@ -3,16 +3,16 @@ Generated by: f7renames.sh. Generated using: F7_PREFIX = __f7_ from t-libf7. - F7F, F7F_cst, F7F_asm from libf7-common.mk. - Included by: libf7.h. - Used by: libf7.c, libf7.h, libf7-asm.sx, f7-wraps.h. + F7F, F7F_cst, F7F_asm from libf7-common.mk. + Included by: libf7.h. + Used by: libf7.c, libf7.h, libf7-asm.sx, f7-wraps.h. */ #ifndef F7_RENAMES_H #define F7_RENAMES_H #define F7_(name) __f7_##name -#define F7P __f7_ +#define F7P __f7_ /* Renames for libf7.c, libf7.h. */ diff --git a/libgcc/config/avr/libf7/libf7-asm.sx b/libgcc/config/avr/libf7/libf7-asm.sx index 8fbd66bd2902..4505764c1263 100644 --- a/libgcc/config/avr/libf7/libf7-asm.sx +++ b/libgcc/config/avr/libf7/libf7-asm.sx @@ -283,8 +283,8 @@ DEFUN copy cp XL, ZL cpc XH, ZH breq 9f - adiw XL, 10 - adiw ZL, 10 + adiw XL, F7_SIZEOF + adiw ZL, F7_SIZEOF set bld ZERO, 1 bld ZERO, 3 ; ZERO = 0b1010 = 10. @@ -312,8 +312,8 @@ DEFUN copy_P st X+, TMP dec ZERO brne .Loop - sbiw X, 10 - sbiw Z, 10 + sbiw X, F7_SIZEOF + sbiw Z, F7_SIZEOF ret ENDF copy_P #endif /* F7MOD_copy_P_ */ @@ -1067,6 +1067,100 @@ DEFUN mul_mant ENDF mul_mant #endif /* F7MOD_mul_mant_ && MUL */ +#if defined F7MOD_mul_mant_ && ! defined (__AVR_HAVE_MUL__) + #define AA TMP + #define A0 13 + #define A1 A0+1 + #define A2 A0+2 + #define A3 A0+3 + #define A4 A0+4 + #define A5 r26 + #define A6 r27 + #define BB ZERO + #define Bits r29 + #define Bytes r28 + +DEFUN mul_mant + do_prologue_saves 7 + bst r18, 0 ; T = 1: Don't round. + ;; Save result address for later. + push r25 + push r24 + ;; Load 1st operand mantissa. + wmov r30, r22 + clr AA + LDD A0, Z+0+Off + LDD A1, Z+1+Off + LDD A2, Z+2+Off + LDD A3, Z+3+Off + LDD A4, Z+4+Off + LDD A5, Z+5+Off + LDD A6, Z+6+Off + ;; Let Z point one past .mant of the 2nd input operand. + wmov r30, r20 + adiw r30, Expo + + ;; Clear the result mantissa. + .global __clr_8 + XCALL __clr_8 + + ;; Loop over the bytes of B's mantissa from highest to lowest. + ;; "+1" because we jump into the loop. + ldi Bytes, 1 + F7_MANT_BYTES + + ;; Divide one operand by 2 so that the result mantissa won't overflow. + ;; This is accounted for by "Carry = 1" below. + ldi Bits, 1 + rjmp .Loop_entry + +.Loop_bytes: + ld BB, -Z + ;; Loop over the bits of B's mantissa from highest to lowest. + ldi Bits, 8 +.Loop_bits: + lsl BB + brcc .Lnext_bit + + ADD CA, AA + adc C0, A0 + adc C1, A1 + adc C2, A2 + adc C3, A3 + adc C4, A4 + adc C5, A5 + adc C6, A6 + +.Lnext_bit: +.Loop_entry: + LSR A6 + ror A5 + ror A4 + ror A3 + ror A2 + ror A1 + ror A0 + ror AA + + dec Bits + brne .Loop_bits + + dec Bytes + brne .Loop_bytes + + ;; Finally... + + pop ZL + pop ZH + + ;; The result has to be left-shifted by one (multiplied by 2) in order + ;; to undo the division by 2 of the 1st operand. + ldi Carry, 1 + F7call normalize.maybe_round.store_with_flags + + do_epilogue_restores 7 +ENDF mul_mant +#endif /* F7MOD_mul_mant_ && ! MUL */ + #if defined (F7MOD_div_) @@ -1328,6 +1422,58 @@ ENDF sqrt_approx #undef Carry +#ifdef F7MOD_D_fma_ +_DEFUN __fma + DALIAS fma + LALIAS fmal + +#define n_pushed 4 +#define n_frame (2 * F7_SIZEOF) + + do_prologue_saves n_pushed, n_frame + ;; Y = FramePointer + 1 + adiw Y, 1 + + ;; FP + 1 = (f7_t) arg1 + wmov r16, Y + ;; The double argument arg1 is already in R18[]. + XCALL F7_NAME (set_double_impl) + + ;; The double argument arg2 is in R10[]. Move it to R18[]. + wmov r18, r10 + wmov r20, r12 + wmov r22, r14 + ;; R16, R17 are clobbered. Fetch them from where prologue_saves put them. + ldd r24, Y + n_frame + 3 ; Saved R16 + ldd r25, Y + n_frame + 2 ; Saved R17 + ;; FP + 1 + 10 = (f7_t) arg2 + subi r16, lo8 (-F7_SIZEOF) + sbci r17, hi8 (-F7_SIZEOF) + XCALL F7_NAME (set_double_impl) + + wmov r24, Y ; &arg1 + wmov r22, r16 ; &arg2 + XCALL F7_NAME (Imul) ; arg1 *= arg2 + + ;; The 3rd double argument arg3 was passed on the stack. Move it to R18[], + ;; Don't use f7_set_pdouble() because that function is unused (for now). + .irp n, 0, 1, 2, 3, 4, 5, 6, 7 + ldd 18+\n, Y + n_frame + n_pushed + PC_SIZE + \n + .endr + XCALL F7_NAME (set_double_impl) + + wmov r24, Y ; &arg1 + wmov r22, r16 ; &arg2 + XCALL F7_NAME (Iadd) ; arg1 += arg2 + + wmov r24, Y ; &arg1 + XCALL F7_NAME (get_double) + + do_epilogue_restores n_pushed, n_frame +_ENDF __fma +#endif /* F7MOD_D_fma_ */ + + #ifdef F7MOD_D_fabs_ _DEFUN __fabs DALIAS fabs @@ -1493,7 +1639,7 @@ LABEL call_dx ; WHAT = R13 = 0 wmov r14, Z #define n_pushed 4 -#define n_frame 10 +#define n_frame F7_SIZEOF do_prologue_saves n_pushed, n_frame ;; Y = FramePointer + 1 @@ -1565,7 +1711,7 @@ LABEL call_xdd ret #define n_pushed 4 -#define n_frame 20 +#define n_frame (2 * F7_SIZEOF) call.2: do_prologue_saves n_pushed, n_frame @@ -1576,9 +1722,8 @@ call.2: ;; First double argument is already in R18[]. XCALL F7_NAME (set_double_impl) ;; FP + 11 = (f7_t) arg2 - wmov r16, Y - subi r16, lo8 (-10) - sbci r17, hi8 (-10) + subi r16, lo8 (-F7_SIZEOF) + sbci r17, hi8 (-F7_SIZEOF) ;; Move second double argument to R18[]. wmov r18, r10 wmov r20, r12 diff --git a/libgcc/config/avr/libf7/libf7-common.mk b/libgcc/config/avr/libf7/libf7-common.mk index e417715a7e52..d541b48ff3ca 100644 --- a/libgcc/config/avr/libf7/libf7-common.mk +++ b/libgcc/config/avr/libf7/libf7-common.mk @@ -22,7 +22,7 @@ F7_ASM_PARTS += addsub_mant_scaled store load F7_ASM_PARTS += to_integer to_unsigned clz normalize_with_carry normalize F7_ASM_PARTS += store_expo sqrt16 sqrt_approx div -F7_ASM_PARTS += D_class +F7_ASM_PARTS += D_class D_fma F7_ASM_PARTS += D_isnan D_isinf D_isfinite D_signbit D_copysign D_neg D_fabs F7_ASM_PARTS += call_dd call_ddd diff --git a/libgcc/config/avr/libf7/libf7.h b/libgcc/config/avr/libf7/libf7.h index 7236e611341d..d1169b18c999 100644 --- a/libgcc/config/avr/libf7/libf7.h +++ b/libgcc/config/avr/libf7/libf7.h @@ -29,6 +29,7 @@ #define F7_MANT_BYTES 7 #define F7_MANT_BITS (8 * F7_MANT_BYTES) +#define F7_SIZEOF (1 + F7_MANT_BYTES + 2) /* Using the following GCC features: -- Unnamed structs / unions (GNU-C) diff --git a/libgcc/config/avr/libf7/t-libf7 b/libgcc/config/avr/libf7/t-libf7 index 30aa280d11e3..f17e67e8523a 100644 --- a/libgcc/config/avr/libf7/t-libf7 +++ b/libgcc/config/avr/libf7/t-libf7 @@ -86,7 +86,7 @@ F7_C_FLAGS += $(F7_FLAGS) \ -fno-tree-loop-optimize \ -fno-tree-loop-im -fno-move-loop-invariants -F7_ASM_FLAGS += $(F7_FLAGS) +F7_ASM_FLAGS += $(F7_FLAGS) -g0 $(patsubst %, f7_c_%.o, $(CALL_PROLOGUES)) \ : F7_C_FLAGS += -mcall-prologues diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b9283607c0c5..400a36a04ed8 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,61 @@ +2023-10-25 Jonathan Wakely + + Backported from master: + 2023-10-25 Jonathan Wakely + + PR libstdc++/111936 + * src/libbacktrace/Makefile.am: Add -prefer-pic to libtool + compile commands. + * src/libbacktrace/Makefile.in: Regenerate. + +2023-10-25 Paul M. Bendixen + + Backported from master: + 2023-10-24 Paul M. Bendixen + + * include/Makefile.am: Move cstdarg, cstdalign and cstdbool to + freestanding. + * include/Makefile.in: Regenerate. + +2023-10-23 François Dumont + + * include/bits/hashtable_policy.h + (_Hash_code_base::_M_hash_code(const _Hash&, const _Hash_node_value<>&)): Remove. + (_Hash_code_base::_M_hash_code<_H2>(const _H2&, const _Hash_node_value<>&)): Remove. + * include/bits/hashtable.h + (_M_src_hash_code<_H2>(const _H2&, const key_type&, const __node_value_type&)): New. + (_M_merge_unique<>, _M_merge_multi<>): Use latter. + * testsuite/23_containers/unordered_map/modifiers/merge.cc + (test04, test05, test06): New test cases. + +2023-10-21 Benjamin Brock + + Backported from master: + 2023-10-21 Benjamin Brock + + * include/std/ranges (zip_view, adjacent_view): Implement + workaround for LLVM-61763. + +2023-10-21 Jonathan Wakely + + Backported from master: + 2023-10-21 Jonathan Wakely + + * include/bits/fs_dir.h (operator==(default_sentinel_t)): Fix + indentation. + +2023-10-21 Nathaniel Shead + + Backported from master: + 2023-09-29 Nathaniel Shead + + * include/bits/basic_string.h: (basic_string(basic_string&&)): + Activate _M_local_buf when needed. + (basic_string(basic_string&&, const _Alloc&)): Likewise. + * include/bits/basic_string.tcc: (basic_string::swap): Likewise. + * include/std/variant: (__detail::__variant::__construct_n): New. + (__detail::__variant::__emplace): Use __construct_n. + 2023-10-02 Tim Song Backported from master: diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index a880e8ee2275..2a42ac044367 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -849,6 +849,9 @@ c_base_builddir = . c_base_freestanding = \ ${c_base_srcdir}/cfloat \ ${c_base_srcdir}/climits \ + ${c_base_srcdir}/cstdalign \ + ${c_base_srcdir}/cstdarg \ + ${c_base_srcdir}/cstdbool \ ${c_base_srcdir}/cstddef \ ${c_base_srcdir}/cstdint \ ${c_base_srcdir}/cstdlib @@ -869,9 +872,6 @@ c_base_headers = \ ${c_base_srcdir}/cmath \ ${c_base_srcdir}/csetjmp \ ${c_base_srcdir}/csignal \ - ${c_base_srcdir}/cstdalign \ - ${c_base_srcdir}/cstdarg \ - ${c_base_srcdir}/cstdbool \ ${c_base_srcdir}/cstdio \ ${c_base_srcdir}/cstring \ ${c_base_srcdir}/ctgmath \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 0ff875b280be..bdbf015e5442 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -1194,6 +1194,9 @@ c_base_builddir = . c_base_freestanding = \ ${c_base_srcdir}/cfloat \ ${c_base_srcdir}/climits \ + ${c_base_srcdir}/cstdalign \ + ${c_base_srcdir}/cstdarg \ + ${c_base_srcdir}/cstdbool \ ${c_base_srcdir}/cstddef \ ${c_base_srcdir}/cstdint \ ${c_base_srcdir}/cstdlib @@ -1212,9 +1215,6 @@ c_base_freestanding = \ @GLIBCXX_HOSTED_TRUE@ ${c_base_srcdir}/cmath \ @GLIBCXX_HOSTED_TRUE@ ${c_base_srcdir}/csetjmp \ @GLIBCXX_HOSTED_TRUE@ ${c_base_srcdir}/csignal \ -@GLIBCXX_HOSTED_TRUE@ ${c_base_srcdir}/cstdalign \ -@GLIBCXX_HOSTED_TRUE@ ${c_base_srcdir}/cstdarg \ -@GLIBCXX_HOSTED_TRUE@ ${c_base_srcdir}/cstdbool \ @GLIBCXX_HOSTED_TRUE@ ${c_base_srcdir}/cstdio \ @GLIBCXX_HOSTED_TRUE@ ${c_base_srcdir}/cstring \ @GLIBCXX_HOSTED_TRUE@ ${c_base_srcdir}/ctgmath \ diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 870b4728928a..11b62af8fb20 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -669,6 +669,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 { if (__str._M_is_local()) { + (void)_M_use_local_data(); traits_type::copy(_M_local_buf, __str._M_local_buf, __str.length() + 1); } @@ -682,7 +683,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 // basic_stringbuf relies on writing into unallocated capacity so // we mess up the contents if we put a '\0' in the string. _M_length(__str.length()); - __str._M_data(__str._M_local_data()); + __str._M_data(__str._M_use_local_data()); __str._M_set_length(0); } @@ -708,6 +709,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 { if (__str._M_is_local()) { + (void)_M_use_local_data(); traits_type::copy(_M_local_buf, __str._M_local_buf, __str.length() + 1); _M_length(__str.length()); @@ -719,7 +721,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _M_data(__str._M_data()); _M_length(__str.length()); _M_capacity(__str._M_allocated_capacity); - __str._M_data(__str._M_local_buf); + __str._M_data(__str._M_use_local_data()); __str._M_set_length(0); } else diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index d8a279fc9edb..3495a69df6b2 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -79,6 +79,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else if (__s.length()) { + (void)_M_use_local_data(); traits_type::copy(_M_local_buf, __s._M_local_buf, __s.length() + 1); _M_length(__s.length()); @@ -87,6 +88,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else if (length()) { + (void)__s._M_use_local_data(); traits_type::copy(__s._M_local_buf, _M_local_buf, length() + 1); __s._M_length(length()); @@ -97,6 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION else { const size_type __tmp_capacity = __s._M_allocated_capacity; + (void)__s._M_use_local_data(); traits_type::copy(__s._M_local_buf, _M_local_buf, length() + 1); _M_data(__s._M_data()); @@ -108,6 +111,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const size_type __tmp_capacity = _M_allocated_capacity; if (__s._M_is_local()) { + (void)_M_use_local_data(); traits_type::copy(_M_local_buf, __s._M_local_buf, __s.length() + 1); __s._M_data(_M_data()); diff --git a/libstdc++-v3/include/bits/fs_dir.h b/libstdc++-v3/include/bits/fs_dir.h index 9dd0f896e468..3b0a493dc3fd 100644 --- a/libstdc++-v3/include/bits/fs_dir.h +++ b/libstdc++-v3/include/bits/fs_dir.h @@ -449,10 +449,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } #if __cplusplus >= 202002L - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 3719. Directory iterators should be usable with default sentinel - bool operator==(default_sentinel_t) const noexcept - { return !_M_dir; } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3719. Directory iterators should be usable with default sentinel + bool operator==(default_sentinel_t) const noexcept + { return !_M_dir; } #endif #if __cpp_impl_three_way_comparison < 201907L @@ -565,10 +565,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } #if __cplusplus >= 202002L - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 3719. Directory iterators should be usable with default sentinel - bool operator==(default_sentinel_t) const noexcept - { return !_M_dirs; } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3719. Directory iterators should be usable with default sentinel + bool operator==(default_sentinel_t) const noexcept + { return !_M_dirs; } #endif #if __cpp_impl_three_way_comparison < 201907L diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index d2ff15320fc8..dd3e655866ac 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -1066,6 +1066,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return { __n, this->_M_node_allocator() }; } + // Only use the possibly cached node's hash code if its hash function + // _H2 matches _Hash and is stateless. Otherwise recompute it using _Hash. + template + __hash_code + _M_src_hash_code(const _H2&, const key_type& __k, + const __node_value_type& __src_n) const + { + if constexpr (std::is_same_v<_H2, _Hash>) + if constexpr (std::is_empty_v<_Hash>) + return this->_M_hash_code(__src_n); + + return this->_M_hash_code(__k); + } + public: // Extract a node. node_type @@ -1103,7 +1117,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION auto __pos = __i++; const key_type& __k = _ExtractKey{}(*__pos); __hash_code __code - = this->_M_hash_code(__src.hash_function(), *__pos._M_cur); + = _M_src_hash_code(__src.hash_function(), __k, *__pos._M_cur); size_type __bkt = _M_bucket_index(__code); if (_M_find_node(__bkt, __k, __code) == nullptr) { @@ -1131,8 +1145,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION for (auto __i = __src.cbegin(), __end = __src.cend(); __i != __end;) { auto __pos = __i++; + const key_type& __k = _ExtractKey{}(*__pos); __hash_code __code - = this->_M_hash_code(__src.hash_function(), *__pos._M_cur); + = _M_src_hash_code(__src.hash_function(), __k, *__pos._M_cur); auto __nh = __src.extract(__pos); __hint = _M_insert_multi_node(__hint, __code, __nh._M_ptr)._M_cur; __nh._M_ptr = nullptr; diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index 2f79394d89ec..2528dbe21091 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -1319,19 +1319,6 @@ namespace __detail return _M_hash()(__k); } - __hash_code - _M_hash_code(const _Hash&, - const _Hash_node_value<_Value, true>& __n) const - { return __n._M_hash_code; } - - // Compute hash code using _Hash as __n _M_hash_code, if present, was - // computed using _H2. - template - __hash_code - _M_hash_code(const _H2&, - const _Hash_node_value<_Value, __cache_hash_code>& __n) const - { return _M_hash_code(_ExtractKey{}(__n._M_v())); } - __hash_code _M_hash_code(const _Hash_node_value<_Value, false>& __n) const { return _M_hash_code(_ExtractKey{}(__n._M_v())); } diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index c4d4d85bf909..421197584873 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -4535,6 +4535,9 @@ namespace views::__adaptor class zip_view<_Vs...>::_Iterator : public __detail::__zip_view_iter_cat<_Const, _Vs...> { +#ifdef __clang__ // LLVM-61763 workaround + public: +#endif __detail::__tuple_or_pair_t>...> _M_current; constexpr explicit @@ -4555,11 +4558,13 @@ namespace views::__adaptor return input_iterator_tag{}; } +#ifndef __clang__ // LLVM-61763 workaround template requires (view<_Ws> && ...) && (sizeof...(_Ws) > 0) && is_object_v<_Fp> && regular_invocable<_Fp&, range_reference_t<_Ws>...> && std::__detail::__can_reference...>> friend class zip_transform_view; +#endif public: // iterator_category defined in __zip_view_iter_cat @@ -5230,6 +5235,9 @@ namespace views::__adaptor template class adjacent_view<_Vp, _Nm>::_Iterator { +#ifdef __clang__ // LLVM-61763 workaround + public: +#endif using _Base = __detail::__maybe_const_t<_Const, _Vp>; array, _Nm> _M_current = array, _Nm>(); @@ -5270,12 +5278,14 @@ namespace views::__adaptor friend class adjacent_view; +#ifndef __clang__ // LLVM-61763 workaround template requires view<_Wp> && (_Mm > 0) && is_object_v<_Fp> && regular_invocable<__detail::__unarize<_Fp&, _Mm>, range_reference_t<_Wp>> && std::__detail::__can_reference, range_reference_t<_Wp>>> friend class adjacent_transform_view; +#endif public: using iterator_category = input_iterator_tag; diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index 5155124522f2..90e86b7c61bf 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -320,6 +320,33 @@ namespace __variant __get(_Variant&& __v) noexcept { return __variant::__get_n<_Np>(std::forward<_Variant>(__v)._M_u); } + // Gets the _Uninitialized to construct into for __u. + template + constexpr decltype(auto) + __construct_n(_Union& __u) noexcept + { + if constexpr (_Np == 0) + return &__u._M_first; + else if constexpr (_Np == 1) + { + std::_Construct(&__u._M_rest); + return &__u._M_rest._M_first; + } + else if constexpr (_Np == 2) + { + std::_Construct(&__u._M_rest); + std::_Construct(&__u._M_rest._M_rest); + return &__u._M_rest._M_rest._M_first; + } + else + { + std::_Construct(&__u._M_rest); + std::_Construct(&__u._M_rest._M_rest); + std::_Construct(&__u._M_rest._M_rest._M_rest); + return __variant::__construct_n<_Np - 3>(__u._M_rest._M_rest._M_rest); + } + } + template struct _Traits { @@ -536,8 +563,9 @@ namespace __variant __emplace(_Variant_storage<_Triv, _Types...>& __v, _Args&&... __args) { __v._M_reset(); - auto* __addr = std::__addressof(__variant::__get_n<_Np>(__v._M_u)); - std::_Construct(__addr, std::forward<_Args>(__args)...); + auto* __addr = __variant::__construct_n<_Np>(__v._M_u); + std::_Construct(__addr, in_place_index<0>, + std::forward<_Args>(__args)...); // Construction didn't throw, so can set the new index now: __v._M_index = _Np; } diff --git a/libstdc++-v3/src/libbacktrace/Makefile.am b/libstdc++-v3/src/libbacktrace/Makefile.am index 9abf9dd64a1a..998c059418eb 100644 --- a/libstdc++-v3/src/libbacktrace/Makefile.am +++ b/libstdc++-v3/src/libbacktrace/Makefile.am @@ -48,9 +48,13 @@ WARN_FLAGS = -W -Wall -Wwrite-strings -Wmissing-format-attribute \ -Wcast-qual -Werror C_WARN_FLAGS = $(WARN_FLAGS) -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wno-unused-but-set-variable CXX_WARN_FLAGS = $(WARN_FLAGS) -Wno-unused-parameter -AM_CFLAGS = $(C_WARN_FLAGS) +AM_CFLAGS = \ + $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \ + $(C_WARN_FLAGS) AM_CFLAGS += $(EXTRA_CFLAGS) -AM_CXXFLAGS = $(CXX_WARN_FLAGS) -fno-rtti -fno-exceptions +AM_CXXFLAGS = \ + $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \ + $(CXX_WARN_FLAGS) -fno-rtti -fno-exceptions AM_CXXFLAGS += $(EXTRA_CXXFLAGS) obj_prefix = std_stacktrace diff --git a/libstdc++-v3/src/libbacktrace/Makefile.in b/libstdc++-v3/src/libbacktrace/Makefile.in index 1c1242d88278..b5cce3741df3 100644 --- a/libstdc++-v3/src/libbacktrace/Makefile.in +++ b/libstdc++-v3/src/libbacktrace/Makefile.in @@ -498,9 +498,10 @@ libstdc___libbacktrace_la_CPPFLAGS = \ C_WARN_FLAGS = $(WARN_FLAGS) -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wno-unused-but-set-variable CXX_WARN_FLAGS = $(WARN_FLAGS) -Wno-unused-parameter -AM_CFLAGS = $(C_WARN_FLAGS) $(EXTRA_CFLAGS) -AM_CXXFLAGS = $(CXX_WARN_FLAGS) -fno-rtti -fno-exceptions \ - $(EXTRA_CXXFLAGS) +AM_CFLAGS = $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \ + $(C_WARN_FLAGS) $(EXTRA_CFLAGS) +AM_CXXFLAGS = $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \ + $(CXX_WARN_FLAGS) -fno-rtti -fno-exceptions $(EXTRA_CXXFLAGS) obj_prefix = std_stacktrace # Each FILE.c in SOURCES will be compiled to SHORTNAME-FILE.o diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/merge.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/merge.cc index b140ce452aab..c051b58137a4 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/merge.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/merge.cc @@ -17,15 +17,29 @@ // { dg-do run { target c++17 } } +#include +#include #include #include #include using test_type = std::unordered_map; -struct hash { - auto operator()(int i) const noexcept { return ~std::hash()(i); } -}; +template + struct xhash + { + auto operator()(const T& i) const noexcept + { return ~std::hash()(i); } + }; + + +namespace std +{ + template + struct __is_fast_hash> : __is_fast_hash> + { }; +} + struct equal : std::equal_to<> { }; template @@ -64,7 +78,7 @@ test02() { const test_type c0{ {1, 10}, {2, 20}, {3, 30} }; test_type c1 = c0; - std::unordered_map c2( c0.begin(), c0.end() ); + std::unordered_map, equal> c2( c0.begin(), c0.end() ); c1.merge(c2); VERIFY( c1 == c0 ); @@ -89,7 +103,7 @@ test03() { const test_type c0{ {1, 10}, {2, 20}, {3, 30} }; test_type c1 = c0; - std::unordered_multimap c2( c0.begin(), c0.end() ); + std::unordered_multimap, equal> c2( c0.begin(), c0.end() ); c1.merge(c2); VERIFY( c1 == c0 ); VERIFY( equal_elements(c2, c0) ); @@ -125,10 +139,164 @@ test03() VERIFY( c2.empty() ); } +void +test04() +{ + const std::unordered_map c0 + { {"one", 10}, {"two", 20}, {"three", 30} }; + + std::unordered_map c1 = c0; + std::unordered_multimap c2( c0.begin(), c0.end() ); + c1.merge(c2); + VERIFY( c1 == c0 ); + VERIFY( equal_elements(c2, c0) ); + + c1.clear(); + c1.merge(c2); + VERIFY( c1 == c0 ); + VERIFY( c2.empty() ); + + c2.merge(c1); + VERIFY( c1.empty() ); + VERIFY( equal_elements(c2, c0) ); + + c1 = c0; + c2.merge(c1); + VERIFY( c1.empty() ); + VERIFY( c2.size() == (2 * c0.size()) ); + VERIFY( c2.count("one") == 2 ); + VERIFY( c2.count("two") == 2 ); + VERIFY( c2.count("three") == 2 ); + + c1.merge(c2); + VERIFY( c1 == c0 ); + VERIFY( equal_elements(c2, c0) ); + + c1.merge(std::move(c2)); + VERIFY( c1 == c0 ); + VERIFY( equal_elements(c2, c0) ); + + c1.clear(); + c1.merge(std::move(c2)); + VERIFY( c1 == c0 ); + VERIFY( c2.empty() ); +} + +void +test05() +{ + const std::unordered_map c0 + { {"one", 10}, {"two", 20}, {"three", 30} }; + + std::unordered_map c1 = c0; + std::unordered_multimap, equal> c2( c0.begin(), c0.end() ); + c1.merge(c2); + VERIFY( c1 == c0 ); + VERIFY( equal_elements(c2, c0) ); + + c1.clear(); + c1.merge(c2); + VERIFY( c1 == c0 ); + VERIFY( c2.empty() ); + + c2.merge(c1); + VERIFY( c1.empty() ); + VERIFY( equal_elements(c2, c0) ); + + c1 = c0; + c2.merge(c1); + VERIFY( c1.empty() ); + VERIFY( c2.size() == (2 * c0.size()) ); + VERIFY( c2.count("one") == 2 ); + VERIFY( c2.count("two") == 2 ); + VERIFY( c2.count("three") == 2 ); + + c1.merge(c2); + VERIFY( c1 == c0 ); + VERIFY( equal_elements(c2, c0) ); + + c1.merge(std::move(c2)); + VERIFY( c1 == c0 ); + VERIFY( equal_elements(c2, c0) ); + + c1.clear(); + c1.merge(std::move(c2)); + VERIFY( c1 == c0 ); + VERIFY( c2.empty() ); +} + +template + using hash_f = + std::function; + +std::size_t +hash_func(const std::string& str) +{ return std::hash{}(str); } + +std::size_t +xhash_func(const std::string& str) +{ return xhash{}(str); } + +namespace std +{ + template + struct __is_fast_hash> : __is_fast_hash> + { }; +} + +void +test06() +{ + const std::unordered_map, equal> + c0({ {"one", 10}, {"two", 20}, {"three", 30} }, 3, &hash_func); + + std::unordered_map, equal> + c1(3, &hash_func); + c1 = c0; + std::unordered_multimap, equal> + c2(c0.begin(), c0.end(), 3, &xhash_func); + c1.merge(c2); + VERIFY( c1 == c0 ); + VERIFY( equal_elements(c2, c0) ); + + c1.clear(); + c1.merge(c2); + VERIFY( c1 == c0 ); + VERIFY( c2.empty() ); + + c2.merge(c1); + VERIFY( c1.empty() ); + VERIFY( equal_elements(c2, c0) ); + + c1 = c0; + c2.merge(c1); + VERIFY( c1.empty() ); + VERIFY( c2.size() == (2 * c0.size()) ); + VERIFY( c2.count("one") == 2 ); + VERIFY( c2.count("two") == 2 ); + VERIFY( c2.count("three") == 2 ); + + c1.merge(c2); + VERIFY( c1 == c0 ); + VERIFY( equal_elements(c2, c0) ); + + c1.merge(std::move(c2)); + VERIFY( c1 == c0 ); + VERIFY( equal_elements(c2, c0) ); + + c1.clear(); + c1.merge(std::move(c2)); + VERIFY( c1 == c0 ); + VERIFY( c2.empty() ); +} + int main() { test01(); test02(); test03(); + test04(); + test05(); + test06(); }