aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-09-03Daily bump.GCC Administrator1-1/+1
2023-09-02Daily bump.GCC Administrator2-1/+11
2023-09-01LoongArch: Fix bug in loongarch_emit_stack_tie [PR110484].Lulu Cheng1-1/+3
Which may result in implicit references to $fp when frame_pointer_needed is false, causing regs_ever_live[$fp] to be true when $fp is not explicitly used, resulting in $fp being used as the target replacement register in the rnreg pass. The bug originates from SPEC2017 541.leela_r(-flto). gcc/ChangeLog: PR target/110484 * config/loongarch/loongarch.cc (loongarch_emit_stack_tie): Use the frame_pointer_needed to determine whether to use the $fp register. Co-authored-by: Guo Jie <guojie@loongson.cn> (cherry picked from commit 1967f21d000e09d3d3190317af7923b578ce02b1)
2023-09-01Daily bump.GCC Administrator3-1/+24
2023-08-31Revert "c++: only declare satisfied friends" [PR109751]Jason Merrill3-4/+24
The earlier patch was only an incremental step toward making this sort of code work, and broke code that had been working. So let's revert it. This reverts commit r13-4035-gc41bbfcaf9d6ef. PR c++/109751 gcc/cp/ChangeLog: * pt.cc (tsubst_friend_function): Don't check constraints. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-friend11.C: Xfail. * g++.dg/cpp2a/concepts-friend15.C: New test.
2023-08-31c++: NRV and goto [PR92407]Jason Merrill4-0/+36
Here our named return value optimization was breaking the required destructor when the goto takes 'a' out of scope. A simple fix for the release branches is to disable the optimization in the presence of backward goto. We could do better by disabling the optimization only if there is a backward goto across the variable declaration, but we don't track that, and in GCC 14 we instead make the goto work with NRV. PR c++/92407 gcc/cp/ChangeLog: * cp-tree.h (struct language_function): Add backward_goto. * decl.cc (check_goto): Set it. * typeck.cc (check_return_expr): Prevent NRV if set. gcc/testsuite/ChangeLog: * g++.dg/opt/nrv22.C: New test.
2023-08-31Daily bump.GCC Administrator3-1/+43
2023-08-30tree-ssa-strlen: Fix up handling of conditionally zero memcpy [PR110914]Jakub Jelinek2-1/+24
The following testcase is miscompiled since r279392 aka r10-5451-gef29b12cfbb4979 The strlen pass has adjust_last_stmt function, which performs mainly strcat or strcat-like optimizations (say strcpy (x, "abcd"); strcat (x, p); or equivalent memcpy (x, "abcd", strlen ("abcd") + 1); char *q = strchr (x, 0); memcpy (x, p, strlen (p)); etc. where the first stmt stores '\0' character at the end but next immediately overwrites it and so the first memcpy can be adjusted to store 1 fewer bytes. handle_builtin_memcpy called this function in two spots, the first one guarded like: if (olddsi != NULL && tree_fits_uhwi_p (len) && !integer_zerop (len)) adjust_last_stmt (olddsi, stmt, false); i.e. only for constant non-zero length. The other spot can call it even for non-constant length but in that case we punt before that if that length isn't length of some string + 1, so again non-zero. The r279392 change I assume wanted to add some warning stuff and changed it like if (olddsi != NULL - && tree_fits_uhwi_p (len) && !integer_zerop (len)) - adjust_last_stmt (olddsi, stmt, false); + { + maybe_warn_overflow (stmt, len, rvals, olddsi, false, true); + adjust_last_stmt (olddsi, stmt, false); + } While maybe_warn_overflow possibly handles non-constant length fine, adjust_last_stmt really relies on length to be non-zero, which !integer_zerop (len) alone doesn't guarantee. While we could for len being SSA_NAME ask the ranger or tree_expr_nonzero_p, I think adjust_last_stmt will not benefit from it much, so the following patch just restores the above condition/previous behavior for the adjust_last_stmt call only. 2023-08-30 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/110914 * tree-ssa-strlen.cc (strlen_pass::handle_builtin_memcpy): Don't call adjust_last_stmt unless len is known constant. * gcc.c-torture/execute/pr110914.c: New test. (cherry picked from commit 398842e7038ea0f34054f0f694014d0ecd656846)
2023-08-30store-merging: Fix up >= 64 bit insertion [PR111015]Jakub Jelinek2-4/+33
The following testcase shows that we mishandle bit insertion for info->bitsize >= 64. The problem is in using unsigned HOST_WIDE_INT shift + subtraction + build_int_cst to compute mask, the shift invokes UB at compile time for info->bitsize 64 and larger and e.g. on the testcase with info->bitsize happens to compute mask of 0x3f rather than 0x3f'ffffffff'ffffffff. The patch fixes that by using wide_int wi::mask + wide_int_to_tree, so it handles masks in any precision (up to WIDE_INT_MAX_PRECISION ;) ). 2023-08-30 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/111015 * gimple-ssa-store-merging.cc (imm_store_chain_info::output_merged_store): Use wi::mask and wide_int_to_tree instead of unsigned HOST_WIDE_INT shift and build_int_cst to build BIT_AND_EXPR mask. * gcc.dg/pr111015.c: New test. (cherry picked from commit 49a3b35c4068091900b657cd36e5cffd41ef0c47)
2023-08-30riscv: Fix scope for memory model calculationDimitar Dimitrov1-4/+9
During libgcc configure stage for riscv32-none-elf, when "--enable-checking=yes,rtl" has been activated, the following error is observed: during RTL pass: final conftest.c: In function 'main': conftest.c:16:1: internal compiler error: RTL check: expected code 'const_int', have 'reg' in riscv_print_operand, at config/riscv/riscv.cc:4462 16 | } | ^ 0x843c4d rtl_check_failed_code1(rtx_def const*, rtx_code, char const*, int, char const*) /mnt/nvme/dinux/local-workspace/gcc/gcc/rtl.cc:916 0x8ea823 riscv_print_operand /mnt/nvme/dinux/local-workspace/gcc/gcc/config/riscv/riscv.cc:4462 0xde84b5 output_operand(rtx_def*, int) /mnt/nvme/dinux/local-workspace/gcc/gcc/final.cc:3632 0xde8ef8 output_asm_insn(char const*, rtx_def**) /mnt/nvme/dinux/local-workspace/gcc/gcc/final.cc:3544 0xded33b output_asm_insn(char const*, rtx_def**) /mnt/nvme/dinux/local-workspace/gcc/gcc/final.cc:3421 0xded33b final_scan_insn_1 /mnt/nvme/dinux/local-workspace/gcc/gcc/final.cc:2841 0xded6cb final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*) /mnt/nvme/dinux/local-workspace/gcc/gcc/final.cc:2887 0xded8b7 final_1 /mnt/nvme/dinux/local-workspace/gcc/gcc/final.cc:1979 0xdee518 rest_of_handle_final /mnt/nvme/dinux/local-workspace/gcc/gcc/final.cc:4240 0xdee518 execute /mnt/nvme/dinux/local-workspace/gcc/gcc/final.cc:4318 Fix by moving the calculation of memmodel to the cases where it is used. Regression tested for riscv32-none-elf. No changes in gcc.sum and g++.sum. PR target/109725 gcc/ChangeLog: * config/riscv/riscv.cc (riscv_print_operand): Calculate memmodel only when it is valid. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2023-08-30Daily bump.GCC Administrator1-1/+1
2023-08-29Daily bump.GCC Administrator3-1/+11
2023-08-28RISC-V: Insert vsetivli zero, 0 for vmv.x.s/vfmv.f.s instructions satisfying ↵Li Xu3-0/+56
REG_P(operand[1]) in -O0. This issue happens is because the operand1 of scalar move can be REG_P (operand[1]) in the O0 case, which causes the VSETVL PASS to not insert the vsetvl instruction correctly, and the compiler crashes. Consider this following case: int16_t foo1 (void *base, size_t vl) { int16_t maxVal = __riscv_vmv_x_s_i16m1_i16 (__riscv_vle16_v_i16m1 (base, vl)); return maxVal; } Before this patch: bug.c:15:1: internal compiler error: Segmentation fault 15 | } | ^ 0x145d723 crash_signal ../.././riscv-gcc/gcc/toplev.cc:314 0x22929dd const_csr_operand(rtx_def*, machine_mode) ../.././riscv-gcc/gcc/config/riscv/predicates.md:44 0x2292a21 csr_operand(rtx_def*, machine_mode) ../.././riscv-gcc/gcc/config/riscv/predicates.md:46 0x23dfbb0 recog_356 ../.././riscv-gcc/gcc/config/riscv/iterators.md:72 0x23efecd recog(rtx_def*, rtx_insn*, int*) ../.././riscv-gcc/gcc/config/riscv/iterators.md:89 0xdddc15 recog_memoized(rtx_insn*) ../.././riscv-gcc/gcc/recog.h:273 After this patch: vsetivli zero,0,e16,m1,ta,ma vmv.x.s a5,v1 gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (gen_vsetvl_pat): For vfmv.f.s/vmv.x.s intruction replace null avl with (const_int 0). gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/scalar_move-10.c: New test. * gcc.target/riscv/rvv/base/scalar_move-11.c: New test.
2023-08-28Daily bump.GCC Administrator3-1/+29
2023-08-27Fortran: Fix some problems blocking associate meta-bug [PR87477]Paul Thomas9-30/+311
2023-08-27 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/87477 * parse.cc (parse_associate): Replace the existing evaluation of the target rank with calls to gfc_resolve_ref and gfc_expression_rank. Identify untyped target function results with structure constructors by finding the appropriate derived type. * resolve.cc (resolve_symbol): Allow associate variables to be assumed shape. gcc/testsuite/ PR fortran/87477 * gfortran.dg/associate_54.f90 : Cope with extra error. PR fortran/102109 * gfortran.dg/pr102109.f90 : New test. PR fortran/102112 * gfortran.dg/pr102112.f90 : New test. PR fortran/102190 * gfortran.dg/pr102190.f90 : New test. PR fortran/102532 * gfortran.dg/pr102532.f90 : New test. PR fortran/109948 * gfortran.dg/pr109948.f90 : New test. PR fortran/99326 * gfortran.dg/pr99326.f90 : New test.
2023-08-27Daily bump.GCC Administrator1-1/+1
2023-08-26Daily bump.GCC Administrator3-1/+18
2023-08-25Merge branch 'releases/gcc-13' into devel/omp/gcc-13Tobias Burnus37-25/+678
Merge up to r13-7758-gbb791011b39813bc7b6fdd0d9831247ace199615 (25th Aug 2023)
2023-08-25Fix avx512ne2ps2bf16 wrong code [PR 111127]Hongyu Wang2-2/+26
Correct the parameter order for avx512ne2ps2bf16_maskz expander gcc/ChangeLog: PR target/111127 * config/i386/sse.md (avx512f_cvtne2ps2bf16_<mode>_maskz): Adjust paramter order. gcc/testsuite/ChangeLog: PR target/111127 * gcc.target/i386/pr111127.c: New test. (cherry picked from commit e62fe74e5af913079ba296c74759cd74c0759e8e)
2023-08-25Daily bump.GCC Administrator4-1/+150
2023-08-24omp-expand.cc: Fix wrong code with non-rectangular loop nest [PR111017]Tobias Burnus2-1/+74
Before commit r12-5295-g47de0b56ee455e, all gimple_build_cond in expand_omp_for_* were inserted with gsi_insert_before (gsi_p, cond_stmt, GSI_SAME_STMT); except the one dealing with the multiplicative factor that was gsi_insert_after (gsi, cond_stmt, GSI_CONTINUE_LINKING); That commit for PR103208 fixed the issue of some missing regimplify of operands of GIMPLE_CONDs by moving the condition handling to the new function expand_omp_build_cond. While that function has an 'bool after = false' argument to switch between the two variants. However, all callers ommited this argument. This commit reinstates the prior behavior by passing 'true' for the factor != 0 condition, fixing the included testcase. PR middle-end/111017 gcc/ * omp-expand.cc (expand_omp_for_init_vars): Pass after=true to expand_omp_build_cond for 'factor != 0' condition, resulting in pre-r12-5295-g47de0b56ee455e code for the gimple insert. libgomp/ * testsuite/libgomp.c-c++-common/non-rect-loop-1.c: New test. (cherry picked from commit 1dc65003b66e5a97200f454eeddcccfce34416b3)
2023-08-24tree-optimization/111070 - fix ICE with recent ifcombine fixRichard Biener2-3/+26
We now got test coverage for non-SSA name bits so the following amends the SSA_NAME_OCCURS_IN_ABNORMAL_PHI checks. PR tree-optimization/111070 * tree-ssa-ifcombine.cc (ifcombine_ifandif): Check we have an SSA name before checking SSA_NAME_OCCURS_IN_ABNORMAL_PHI. * gcc.dg/pr111070.c: New testcase. (cherry picked from commit 966b0a96523fb7adbf498ac71df5e033c70dc546)
2023-08-24tree-optimization/111039 - abnormals and bit test mergingRichard Biener2-0/+22
The following guards the bit test merging code in if-combine against the appearance of SSA names used in abnormal PHIs. PR tree-optimization/111039 * tree-ssa-ifcombine.cc (ifcombine_ifandif): Check for SSA_NAME_OCCURS_IN_ABNORMAL_PHI. * gcc.dg/pr111039.c: New testcase. (cherry picked from commit 482551a79a3d3f107f6239679ee74655cfe8707e)
2023-08-24tree-optimization/111019 - invariant motion and aliasingRichard Biener2-2/+77
The following fixes a bad choice in representing things to the alias oracle by LIM which while correct in pieces is inconsistent with itself. When canonicalizing a ref to a bare deref instead of leaving the base object and the extracted offset the same and just substituting an alternate ref the following replaces the base and the offset as well, avoiding the confusion that otherwise will arise in aliasing_matching_component_refs_p. PR tree-optimization/111019 * tree-ssa-loop-im.cc (gather_mem_refs_stmt): When canonicalizing also scrap base and offset in case the ref is indirect. * g++.dg/torture/pr111019.C: New testcase. (cherry picked from commit 745ec2135aabfbe2c0fb7780309837d17e8986d4)
2023-08-24tree-optimization/110702 - avoid zero-based memory references in IVOPTsRichard Biener2-1/+47
Sometimes IVOPTs chooses a weird induction variable which downstream leads to issues. Most of the times we can fend those off during costing by rejecting the candidate but it looks like the address description costing synthesizes is different from what we end up generating so the following fixes things up at code generation time. Specifically we avoid the create_mem_ref_raw fallback which uses a literal zero address base with the actual base in index2. For the case in question we have the address type = unsigned long offset = 0 elements = { [0] = &e * -3, [1] = (sizetype) a.9_30 * 232, [2] = ivtmp.28_44 * 4 } from which we code generate the problematical _3 = MEM[(long int *)0B + ivtmp.36_9 + ivtmp.28_44 * 4]; which references the object at address zero. The patch below recognizes the fallback after the fact and transforms the TARGET_MEM_REF memory reference into a LEA for which this form isn't problematic: _24 = &MEM[(long int *)0B + ivtmp.36_34 + ivtmp.28_44 * 4]; _3 = *_24; hereby avoiding the correctness issue. We'd later conclude the program terminates at the null pointer dereference and make the function pure, miscompling the main function of the testcase. PR tree-optimization/110702 * tree-ssa-loop-ivopts.cc (rewrite_use_address): When we created a NULL pointer based access rewrite that to a LEA. * gcc.dg/torture/pr110702.c: New testcase. (cherry picked from commit 13dfb01e5c30c3bd09333ac79d6ff96a617fea67)
2023-08-24MATCH: [PR111109] Fix bit_ior(cond,cond) when comparisons are fpAndrew Pinski2-3/+86
The patterns that were added in r13-4620-g4d9db4bdd458, missed that (a > b) and (a <= b) are not inverse of each other for floating point comparisons (if NaNs are supported). Even though there was a check for intergal types, it was only for the result of the cond rather for the type of what is being compared. The fix is to check to see if cmp and icmp are inverse of each other by using the invert_tree_comparison function. OK for trunk and GCC 13 branch? Bootstrapped and tested on x86_64-linux-gnu with no regressions. I added the testcase to execute/ieee as it requires support for NAN. PR tree-optimization/111109 gcc/ChangeLog: * match.pd (ior(cond,cond), ior(vec_cond,vec_cond)): Add check to make sure cmp and icmp are inverse. gcc/testsuite/ChangeLog: * gcc.c-torture/execute/ieee/fp-cmp-cond-1.c: New test. (cherry picked from commit 4aa14ec7d5b25722e4d02c29c8c1e22dcc5a4915)
2023-08-24debug/111080 - avoid outputting debug info for unused restrict qualified typeRichard Biener2-0/+25
The following applies some maintainance with respect to type qualifiers and kinds added by later DWARF standards to prune_unused_types_walk. The particular case in the bug is not handling (thus marking required) all restrict qualified type DIEs. I've found more DW_TAG_*_type that are unhandled, looked up the DWARF docs and added them as well based on common sense. PR debug/111080 * dwarf2out.cc (prune_unused_types_walk): Handle DW_TAG_restrict_type, DW_TAG_shared_type, DW_TAG_atomic_type, DW_TAG_immutable_type, DW_TAG_coarray_type, DW_TAG_unspecified_type and DW_TAG_dynamic_type as to only output them when referenced. * gcc.dg/debug/dwarf2/pr111080.c: New testcase. (cherry picked from commit bd2c4d6d8fffd5a6dae5217d6076cc4190bab13d)
2023-08-24Fix target_clone ("arch=graniterapids-d")liuhongt4-4/+16
Both "graniterapid-d" and "graniterapids" are attached with PROCESSOR_GRANITERAPID in processor_alias_table but mapped to different __cpu_subtype in get_intel_cpu. And get_builtin_code_for_version will try to match the first PROCESSOR_GRANITERAPIDS in processor_alias_table which maps to "granitepraids" here. 861 else if (new_target->arch_specified && new_target->arch > 0) 1862 for (i = 0; i < pta_size; i++) 1863 if (processor_alias_table[i].processor == new_target->arch) 1864 { 1865 const pta *arch_info = &processor_alias_table[i]; 1866 switch (arch_info->priority) 1867 { 1868 default: 1869 arg_str = arch_info->name; This mismatch makes dispatch_function_versions check the preidcate of__builtin_cpu_is ("graniterapids") for "graniterapids-d" and causes the issue. The patch explicitly PROCESSOR_GRANITERAPIDS_D to make a distinction. For "alderlake","raptorlake", "meteorlake" they share same isa, cost, tuning, and mapped to the same __cpu_type/__cpu_subtype in get_intel_cpu, so no need to add PROCESSOR_RAPTORLAKE and others. gcc/ChangeLog: * common/config/i386/i386-common.cc (processor_names): Add new member graniterapids-s. * config/i386/i386-options.cc (processor_alias_table): Update PROCESSOR_GRANITERAPIDS_D. (m_GRANITERAPID_D): New macro. (m_CORE_AVX512): Add m_GRANITERAPIDS_D. (processor_cost_table): Add icelake_cost for PROCESSOR_GRANITERAPIDS_D. * config/i386/i386.h (enum processor_type): Add new member PROCESSOR_GRANITERAPIDS_D. * config/i386/i386-c.cc (ix86_target_macros_internal): Handle PROCESSOR_GRANITERAPIDS_D. (cherry picked from commit afe15e9742d9fefb3f4a9b1662cb3f977e3645fd)
2023-08-24Adjust GCC V13 to GCC 13.1 in diagnotic.liuhongt1-1/+1
gcc/ChangeLog: * config/i386/i386.cc (ix86_invalid_conversion): Adjust GCC V13 to GCC 13.1. (cherry picked from commit 0a888650303750fd72878fc083dfb30b62e30809)
2023-08-24Daily bump.GCC Administrator2-1/+8
2023-08-23i386: Fix register spill failure with concat RTX [PR111010]Uros Bizjak1-2/+4
Disable (=&r,m,m) alternative for 32-bit targets. The combination of two memory operands (possibly with complex addressing mode), early clobbered output, frame pointer and PIC registers uses too much registers on a register constrained 32-bit target. PR target/111010 gcc/ChangeLog: * config/i386/i386.md (*concat<any_or_plus:mode><dwi>3_3): Disable (=&r,m,m) alternative for 32-bit targets. (*concat<any_or_plus:mode><dwi>3_4): Ditto.
2023-08-23Daily bump.GCC Administrator3-1/+54
2023-08-23RISC-V: Add riscv-vsetvl.def to t-riscvJuzhe-Zhong1-1/+2
This patch will be backport to GCC 13 and commit to trunk. gcc/ChangeLog: * config/riscv/t-riscv: Add riscv-vsetvl.def
2023-08-22doc: Remove obsolete sentence about _Float* not being supported in C++ ↵Jakub Jelinek1-1/+1
[PR106652] As mentioned in the PR, these types are supported in C++ since GCC 13, so we shouldn't confuse users. 2023-08-22 Jakub Jelinek <jakub@redhat.com> PR c++/106652 * doc/extend.texi (_Float<n>): Drop obsolete sentence that the types aren't supported in C++. (cherry picked from commit 145da6a8e1ad60f048069012d81e37f84e1585fd)
2023-08-22libstdc++: Fix std::format("{:F}", inf) to use uppercaseJonathan Wakely2-2/+20
std::format was treating {:f} and {:F} identically on the basis that for the fixed 1.234567 format there are no alphabetical characters that need to be in uppercase. But that's wrong for infinities and NaNs, which should be formatted as "INF" and "NAN" for {:F}. libstdc++-v3/ChangeLog: * include/std/format (__format::_Pres_type): Add _Pres_F. (__formatter_fp::parse): Use _Pres_F for 'F'. (__formatter_fp::format): Set __upper for _Pres_F. * testsuite/std/format/functions/format.cc: Check formatting of infinity and NaN for each presentation type. (cherry picked from commit d07bce478f9d770de5acb0480a3f0cec2f8b72d8)
2023-08-22libstdc++: Replace global std::string objects in tzdb.ccJonathan Wakely1-2/+2
When the library is built with --disable-libstdcxx-dual-abi the only type of std::string supported is the COW string, and the two global std::string objects in tzdb.cc have to allocate memory. I added them thinking they would fit in the SSO string buffer, but that's not the case when the library only uses COW strings. Replace them with string_view objects to avoid any allocations. libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (tzdata_file, leaps_file): Change type to std::string_view. (cherry picked from commit d82a85b6161cbeebfe3de5d3d4cdd355e4617e69)
2023-08-22libstdc++: Fix -Wunused-parameter in <experimental/internet>Jonathan Wakely1-1/+1
libstdc++-v3/ChangeLog: * include/experimental/internet (address_v4::to_string): Remove unused parameter name. (cherry picked from commit 8ee74c5a38fa8b83705139e6b6fa4c0b445c7c5f)
2023-08-22libstdc++: Make __cmp_cat::__unseq constructor constevalJonathan Wakely2-1/+9
This constructor should only ever be used with a literal 0 as the argument, so we can make it consteval. This has the nice advantage that it is expanded immediately in the front end, and so GDB will never step into the __cmp_cat::__unseq::__unseq(__unseq*) constructor that is uninteresting and probably confusing to users. libstdc++-v3/ChangeLog: * libsupc++/compare (__cmp_cat::__unseq): Make ctor consteval. * testsuite/18_support/comparisons/categories/zero_neg.cc: Prune excess errors caused by invalid consteval calls. (cherry picked from commit 84cff28fd282c74399e6ad80df77025a5008e851)
2023-08-22RISCV: Fix PR111074 [GCC13 BUG]xuli1-0/+3
his patch fixes this issue happens on GCC-13. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111074 This patch should be backported to GCC-13. GCC-14 has rewritten propagate_avl function, so there is no issue. PR target/111074 gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (extract_single_source): Fix bug.
2023-08-22Daily bump.GCC Administrator2-1/+11
2023-08-21OpenMP: requires unified_shared_memory patch, insert USM allocators into ↵Chung-Lin Tang9-9/+195
libgfortran (This is a backport of https://gcc.gnu.org/pipermail/gcc-patches/2022-September/601059.html) After the prior libgfortran memory allocator preparation patch, this is the actual patch that organizes unified_shared_memory allocation into libgfortran. In the current OpenMP requires implementation, the requires_mask is collected through offload LTO processing, and presented to libgomp when registering offload images through GOMP_offload_register_ver() (called by the mkoffload generated constructor linked into the program binary) This means that the only reliable place to access omp_requires_mask is in GOMP_offload_register_ver, however since it is called through an ELF constructor in the *main program*, this runs later than libgfortran/runtime/main.c:init() constructor, and because some libgfortran init actions there start allocating memory, this can cause more deallocation errors later. Another issue is that CUDA appears to be registering some cleanup actions using atexit(), which forces libgomp to register gomp_target_fini() using atexit as well (to properly run before the underlying CUDA stuff disappears). This happens to us here as well. In summary we need to: (1) order libgfortran init actions after omp_requires_mask processing is done, and (2) order libgfortran cleanup actions before gomp_target_fini, to properly deallocate stuff without crashing. We implement this by creating callback registering functions exported from libgomp to libgfortran, basically to register libgfortran init/fini actions into libgomp to run. Inside GOMP_offload_register_ver, after omp_requires_mask processing is done, we call into libgfortran through a new _gfortran_mem_allocators_init function to insert the omp_free/alloc/etc. based allocators into the Fortran runtime, when GOMP_REQUIRES_UNIFIED_SHARED_MEMORY is set. All symbol references between libgfortran/libgomp are defined with weak symbols. Test of the weak symbols are also used to determine if the other library exists in this program. For the final case where we have an OpenMP program that does NOT have offloading, we cannot passively determine in libgomp/libgfortran whether offloading exists or not, only the main program itself can, by seeing if the hidden __OFFLOAD_TABLE__ exists. But those with no offloading will not have those callback properly run (because of no offload image loading) Therefore the solution here is a constructor added into the crtoffloadend.o fragment that does a "null" call of GOMP_offload_register_ver, solely for triggering the post-offload_register callbacks when __OFFLOAD_TABLE__ is NULL. (crtoffloadend.o Makefile rule is adjusted to compile with PIC due to this) libgcc/ChangeLog: * Makefile.in (crtoffloadend$(objext)): Add $(PICFLAG) to compile rule. * offloadstuff.c (GOMP_offload_register_ver): Add declaration of weak symbol. (__OFFLOAD_TABLE__): Likewise. (init_non_offload): New function. libgfortran/ChangeLog: * gfortran.map (GFORTRAN_13): New namespace. (_gfortran_mem_allocators_init): New name inside GFORTRAN_14. * libgfortran.h (mem_allocators_init): New exported declaration. * runtime/main.c (do_init): Rename from init, add run-once guard code. (cleanup): Add run-once guard code. (GOMP_post_offload_register_callback): Declare weak symbol. (GOMP_pre_gomp_target_fini_callback): Likewise. (init): New constructor to register offload callbacks, or call do_init when not OpenMP. * runtime/memory.c (gfortran_malloc): New pointer variable. (gfortran_calloc): Likewise. (gfortran_realloc): Likewise. (gfortran_free): Likewise. (mem_allocators_init): New function. (xmalloc): Use gfortran_malloc. (xmallocarray): Use gfortran_malloc. (xcalloc): Use gfortran_calloc. (xrealloc): Use gfortran_realloc. (xfree): Use gfortran_free. libgomp/ChangeLog: * libgomp.map (GOMP_5.1.2): New version namespace. (GOMP_post_offload_register_callback): New name inside GOMP_5.1.2. (GOMP_pre_gomp_target_fini_callback): Likewise. (GOMP_DEFINE_CALLBACK_SET): Macro to define callback set. (post_offload_register): Define callback set for after offload image register. (pre_gomp_target_fini): Define callback set for before gomp_target_fini is called. (libgfortran_malloc_usm): New function. (libgfortran_calloc_usm): Likewise (libgfortran_realloc_usm): Likewise (libgfortran_free_usm): Likewise. (_gfortran_mem_allocators_init): Declare weak symbol. (gomp_libgfortran_omp_allocators_init): New function. (GOMP_offload_register_ver): Add handling of host_table == NULL, calling into libgfortran to set unified_shared_memory allocators, and execution of post_offload_register callbacks. (gomp_target_init): Register all pre_gomp_target_fini callbacks to run at end of main using atexit(). * testsuite/libgomp.fortran/target-unified_shared_memory-1.f90: New test.
2023-08-21Support -march=gracemontliuhongt2-0/+5
Alderlake-N is E-core only, add it as an alias of Alderlake. gcc/ChangeLog: * common/config/i386/cpuinfo.h (get_intel_cpu): Detect Alderlake-N. * common/config/i386/i386-common.cc (alias_table): Support -march=gracemont as an alias of -march=alderlake. (cherry picked from commit f847e0195ddab27d3d55b348c1ab6857c2a00d9d)
2023-08-21Daily bump.GCC Administrator1-1/+1
2023-08-20Daily bump.GCC Administrator2-1/+11
2023-08-19Loongarch: Fix plugin header missing install.Guo Jie1-0/+4
gcc/ChangeLog: * config/loongarch/t-loongarch: Add loongarch-driver.h into TM_H. Add loongarch-def.h and loongarch-tune.h into OPTIONS_H_EXTRA. Co-authored-by: Lulu Cheng <chenglulu@loongson.cn> (cherry picked from commit 3e3157363863ed599c367645af4f94ae32a5bdc2)
2023-08-19Daily bump.GCC Administrator1-1/+1
2023-08-18OpenMP: C++ attribute syntax fixes/testcases for loop transformationsSandra Loosemore12-24/+872
gcc/cp/ChangeLog * parser.cc (cp_parser_omp_all_clauses): Allow comma before first clause. (cp_parser_see_omp_loop_nest): Accept C++ standard attributes before RID_FOR. (cp_parser_omp_loop_nest): Process C++ standard attributes like pragmas. Improve error handling for bad pragmas/attributes. Use cp_parser_see_omp_loop_nest instead of duplicating what it does. (cp_parser_omp_tile_sizes): Permit comma before the clause. (cp_parser_omp_tile): Assert that this isn't called for inner directive. (cp_parser_omp_unroll): Likewise. gcc/testsuite/ChangeLog * g++.dg/gomp/loop-transforms/attrs-tile-1.C: New file. * g++.dg/gomp/loop-transforms/attrs-tile-2.C: New file. * g++.dg/gomp/loop-transforms/attrs-tile-3.C: New file. * g++.dg/gomp/loop-transforms/attrs-unroll-1.C: New file. * g++.dg/gomp/loop-transforms/attrs-unroll-2.C: New file. * g++.dg/gomp/loop-transforms/attrs-unroll-3.C: New file. * g++.dg/gomp/loop-transforms/attrs-unroll-inner-1.C: New file. * g++.dg/gomp/loop-transforms/attrs-unroll-inner-2.C: New file. * g++.dg/gomp/loop-transforms/attrs-unroll-inner-3.C: New file.
2023-08-18OpenMP: C++ attribute syntax fixes/testcases for "declare mapper"Sandra Loosemore9-2/+173
gcc/c-family/ChangeLog * c-omp.cc (c_omp_directives): Uncomment "declare mapper" entry. gcc/cp/ChangeLog * parser.cc (cp_parser_omp_declare_mapper): Allow commas between clauses. gcc/testsuite/ChangeLog * g++.dg/gomp/attrs-declare-mapper-3.C: New file. * g++.dg/gomp/attrs-declare-mapper-4.C: New file. * g++.dg/gomp/attrs-declare-mapper-5.C: New file. * g++.dg/gomp/attrs-declare-mapper-6.C: New file.
2023-08-18OpenMP: C++ attribute syntax fixes/testcases for "metadirective"Sandra Loosemore11-0/+321
gcc/cp/ChangeLog: * parser.cc (analyze_metadirective_body): Handle CPP_PRAGMA and CPP_PRAGMA_EOL. (cp_parser_omp_metadirective): Allow comma between clauses. gcc/testsuite/ChangeLog: * g++.dg/gomp/attrs-metadirective-1.C: New file. * g++.dg/gomp/attrs-metadirective-2.C: New file. * g++.dg/gomp/attrs-metadirective-3.C: New file. * g++.dg/gomp/attrs-metadirective-4.C: New file. * g++.dg/gomp/attrs-metadirective-5.C: New file. * g++.dg/gomp/attrs-metadirective-6.C: New file. * g++.dg/gomp/attrs-metadirective-7.C: New file. * g++.dg/gomp/attrs-metadirective-8.C: New file.
2023-08-18Merge branch 'releases/gcc-13' into devel/omp/gcc-13Tobias Burnus26-62/+267
Merge up to r13-7731-g91a5bdf2941a67590211c907181e9e0036288593 (18th Aug 2023)