Skip to content
Snippets Groups Projects
  1. Oct 22, 2023
    • Iain Sandoe's avatar
      Config,Darwin: Allow for configuring Darwin to use embedded runpath. · 6a6d3817
      Iain Sandoe authored
      Recent Darwin versions place contraints on the use of run paths
      specified in environment variables.  This breaks some assumptions
      in the GCC build.
      
      This change allows the user to configure a Darwin build to use
      '@rpath/libraryname.dylib' in library names and then to add an
      embedded runpath to executables (and libraries with dependents).
      
      The embedded runpath is added by default unless the user adds
      '-nodefaultrpaths' to the link line.
      
      For an installed compiler, it means that any executable built with
      that compiler will reference the runtimes installed with the
      compiler (equivalent to hard-coding the library path into the name
      of the library).
      
      During build-time configurations  any "-B" entries will be added to
      the runpath thus the newly-built libraries will be found by exes.
      
      Since the install name is set in libtool, that decision needs to be
      available here (but might also cause dependent ones in Makefiles,
      so we need to export a conditional).
      
      This facility is not available for Darwin 8 or earlier, however the
      existing environment variable runpath does work there.
      
      We default this on for systems where the external DYLD_LIBRARY_PATH
      does not work and off for Darwin 8 or earlier.  For systems that can
      use either method, if the value is unset, we use the default (which
      is currently DYLD_LIBRARY_PATH).
      
      ChangeLog:
      
      	* configure: Regenerate.
      	* configure.ac: Do not add default runpaths to GCC exes
      	when we are building -static-libstdc++/-static-libgcc (the
      	default).
      	* libtool.m4: Add 'enable-darwin-at-runpath'.  Act  on the
      	enable flag to alter Darwin libraries to use @rpath names.
      
      gcc/ChangeLog:
      
      	* aclocal.m4: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      	* config/darwin.h: Handle Darwin rpaths.
      	* config/darwin.opt: Handle Darwin rpaths.
      	* Makefile.in:  Handle Darwin rpaths.
      
      gcc/ada/ChangeLog:
      
      	* gcc-interface/Makefile.in: Handle Darwin rpaths.
      
      gcc/jit/ChangeLog:
      	* Make-lang.in: Handle Darwin rpaths.
      
      libatomic/ChangeLog:
      
      	* Makefile.am: Handle Darwin rpaths.
      	* Makefile.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      
      libbacktrace/ChangeLog:
      
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      
      libcc1/ChangeLog:
      
      	* configure: Regenerate.
      
      libffi/ChangeLog:
      
      	* Makefile.am: Handle Darwin rpaths.
      	* Makefile.in: Regenerate.
      	* configure: Regenerate.
      
      libgcc/ChangeLog:
      
      	* config/t-slibgcc-darwin: Generate libgcc_s
      	with an @rpath name.
      	* config.host: Handle Darwin rpaths.
      
      libgfortran/ChangeLog:
      
      	* Makefile.am: Handle Darwin rpaths.
      	* Makefile.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths
      
      libgm2/ChangeLog:
      
      	* Makefile.am: Handle Darwin rpaths.
      	* Makefile.in: Regenerate.
      	* aclocal.m4: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      	* libm2cor/Makefile.am: Handle Darwin rpaths.
      	* libm2cor/Makefile.in: Regenerate.
      	* libm2iso/Makefile.am: Handle Darwin rpaths.
      	* libm2iso/Makefile.in: Regenerate.
      	* libm2log/Makefile.am: Handle Darwin rpaths.
      	* libm2log/Makefile.in: Regenerate.
      	* libm2min/Makefile.am: Handle Darwin rpaths.
      	* libm2min/Makefile.in: Regenerate.
      	* libm2pim/Makefile.am: Handle Darwin rpaths.
      	* libm2pim/Makefile.in: Regenerate.
      
      libgomp/ChangeLog:
      
      	* Makefile.am: Handle Darwin rpaths.
      	* Makefile.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths
      
      libitm/ChangeLog:
      
      	* Makefile.am: Handle Darwin rpaths.
      	* Makefile.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      
      libobjc/ChangeLog:
      
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      
      libphobos/ChangeLog:
      
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      	* libdruntime/Makefile.am: Handle Darwin rpaths.
      	* libdruntime/Makefile.in: Regenerate.
      	* src/Makefile.am: Handle Darwin rpaths.
      	* src/Makefile.in: Regenerate.
      
      libquadmath/ChangeLog:
      
      	* Makefile.am: Handle Darwin rpaths.
      	* Makefile.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      
      libsanitizer/ChangeLog:
      
      	* asan/Makefile.am: Handle Darwin rpaths.
      	* asan/Makefile.in: Regenerate.
      	* configure: Regenerate.
      	* hwasan/Makefile.am: Handle Darwin rpaths.
      	* hwasan/Makefile.in: Regenerate.
      	* lsan/Makefile.am: Handle Darwin rpaths.
      	* lsan/Makefile.in: Regenerate.
      	* tsan/Makefile.am: Handle Darwin rpaths.
      	* tsan/Makefile.in: Regenerate.
      	* ubsan/Makefile.am: Handle Darwin rpaths.
      	* ubsan/Makefile.in: Regenerate.
      
      libssp/ChangeLog:
      
      	* Makefile.am: Handle Darwin rpaths.
      	* Makefile.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      
      libstdc++-v3/ChangeLog:
      
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      	* src/Makefile.am: Handle Darwin rpaths.
      	* src/Makefile.in: Regenerate.
      
      libvtv/ChangeLog:
      
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      
      lto-plugin/ChangeLog:
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      
      zlib/ChangeLog:
      	* configure: Regenerate.
      	* configure.ac: Handle Darwin rpaths.
      6a6d3817
    • Iain Sandoe's avatar
      Driver: Provide a spec to insert rpaths for compiler lib dirs. · 829b0c4c
      Iain Sandoe authored
      This provides a spec to insert "-rpath DDD" for each DDD corresponding
      to a compiler startfile directory.  This allows a target to use @rpath
      as the install path for libraries, and have the compiler provide the
      necessary rpath to handle this.
      
      Embed real paths, not relative ones.
      
      We embed a runpath for every path in which libraries might be found.  This
      change ensures that we embed the actual real path and not a relative one from
      the compiler's version-specific directory.
      
      e.g.
      /opt/distro/gcc-11-3Dr0/lib
      
      instead of:
      /opt/distro/gcc-11-3Dr0/lib/gcc/x86_64-apple-darwin19/11.3.0/../../..
      
      This ensures that if we install, for example, 11.4.0 (and delete the 11.3.0
      installation) exes built by 11.3 would continue to function (providing, of course
      that 11.4 does not bump any SO names).
      
      gcc/ChangeLog:
      	* gcc.cc (RUNPATH_OPTION): New.
      	(do_spec_1): Provide '%P' as a spec to insert rpaths for
      	each compiler startfile path.
      829b0c4c
    • Andrew Burgess's avatar
      libgcc: support heap-based trampolines · 8abddb18
      Andrew Burgess authored
      
      Add support for heap-based trampolines on x86_64-linux, aarch64-linux,
      and x86_64-darwin. Implement the __builtin_nested_func_ptr_created and
      __builtin_nested_func_ptr_deleted functions for these targets.
      
      Co-Authored-By: default avatarMaxim Blinov <maxim.blinov@embecosm.com>
      Co-Authored-By: default avatarIain Sandoe <iain@sandoe.co.uk>
      Co-Authored-By: default avatarFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>
      
      libgcc/ChangeLog:
      
      	* libgcc2.h (__builtin_nested_func_ptr_created): Declare.
      	(__builtin_nested_func_ptr_deleted): Declare.
      	* libgcc-std.ver.in: Add the new symbols.
      	* config/aarch64/heap-trampoline.c: Implement heap-based
      	trampolines for aarch64.
      	* config/aarch64/t-heap-trampoline: Add rule to build
      	config/aarch64/heap-trampoline.c
      	* config/i386/heap-trampoline.c: Implement heap-based
      	trampolines for x86_64.
      	* config/i386/t-heap-trampoline: Add rule to build
      	config/i386/heap-trampoline.cc
      	* config.host: Handle --enable-heap-trampolines on
      	x86_64-*-linux*, aarch64-*-linux*, x86_64-*-darwin*.
      8abddb18
    • Andrew Burgess's avatar
      target: Support heap-based trampolines · cbf6da16
      Andrew Burgess authored
      
      Enable -ftrampoline-impl=heap by default if we are on macOS 11
      or later.
      
      Co-Authored-By: default avatarMaxim Blinov <maxim.blinov@embecosm.com>
      Co-Authored-By: default avatarFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>
      Co-Authored-By: default avatarIain Sandoe <iain@sandoe.co.uk>
      
      gcc/ChangeLog:
      
      	* config.gcc: Default to heap trampolines on macOS 11 and above.
      	* config/i386/darwin.h: Define X86_CUSTOM_FUNCTION_TEST.
      	* config/i386/i386.h: Define X86_CUSTOM_FUNCTION_TEST.
      	* config/i386/i386.cc: Use X86_CUSTOM_FUNCTION_TEST.
      cbf6da16
    • Andrew Burgess's avatar
      core: Support heap-based trampolines · 28d8c680
      Andrew Burgess authored
      
      Generate heap-based nested function trampolines
      
      Add support for allocating nested function trampolines on an
      executable heap rather than on the stack. This is motivated by targets
      such as AArch64 Darwin, which globally prohibit executing code on the
      stack.
      
      The target-specific routines for allocating and writing trampolines are
      to be provided in libgcc.
      
      The gcc flag -ftrampoline-impl controls whether to generate code
      that instantiates trampolines on the stack, or to emit calls to
      __builtin_nested_func_ptr_created and
      __builtin_nested_func_ptr_deleted. Note that this flag is completely
      independent of libgcc: If libgcc is for any reason missing those
      symbols, you will get a link failure.
      
      This implementation imposes some implicit restrictions as compared to
      stack trampolines. longjmp'ing back to a state before a trampoline was
      created will cause us to skip over the corresponding
      __builtin_nested_func_ptr_deleted, which will leak trampolines
      starting from the beginning of the linked list of allocated
      trampolines. There may be scope for instrumenting longjmp/setjmp to
      trigger cleanups of trampolines.
      
      Co-Authored-By: default avatarMaxim Blinov <maxim.blinov@embecosm.com>
      Co-Authored-By: default avatarIain Sandoe <iain@sandoe.co.uk>
      Co-Authored-By: default avatarFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>
      
      gcc/ChangeLog:
      
      	* builtins.def (BUILT_IN_NESTED_PTR_CREATED): Define.
      	(BUILT_IN_NESTED_PTR_DELETED): Ditto.
      	* common.opt (ftrampoline-impl): Add option to control
      	generation of trampoline instantiation (heap or stack).
      	* coretypes.h: Define enum trampoline_impl.
      	* tree-nested.cc (convert_tramp_reference_op): Don't bother calling
      	__builtin_adjust_trampoline for heap trampolines.
      	(finalize_nesting_tree_1): Emit calls to
      	__builtin_nested_...{created,deleted} if we're generating with
      	-ftrampoline-impl=heap.
      	* tree.cc (build_common_builtin_nodes): Build
      	__builtin_nested_...{created,deleted}.
      	* doc/invoke.texi (-ftrampoline-impl): Document.
      28d8c680
    • Tsukasa OI's avatar
      RISC-V: Prohibit combination of 'E' and 'H' · 11f50716
      Tsukasa OI authored
      According to the ratified privileged specification (version 20211203),
      it says:
      
      > The hypervisor extension depends on an "I" base integer ISA with 32 x
      > registers (RV32I or RV64I), not RV32E, which has only 16 x registers.
      
      Also in the latest draft, it also prohibits RV64E with the 'H' extension.
      This commit prohibits the combination of 'E' and 'H' extensions.
      
      gcc/ChangeLog:
      
      	* common/config/riscv/riscv-common.cc (riscv_subset_list::parse):
      	Prohibit 'E' and 'H' combinations.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/arch-26.c: New test.
      11f50716
    • Tsukasa OI's avatar
      RISC-V: 'Zfa' extension is now ratified · f232391a
      Tsukasa OI authored
      Since this extension is ratified, it now has the version number 1.0.
      
      Reference:
      <https://github.com/riscv/riscv-isa-manual/pull/1096>
      
      gcc/ChangeLog:
      
      	* common/config/riscv/riscv-common.cc (riscv_ext_version_table):
      	Change version number of the 'Zfa' extension to 1.0.
      f232391a
    • GCC Administrator's avatar
      Daily bump. · bc43a9e2
      GCC Administrator authored
      bc43a9e2
  2. Oct 21, 2023
    • Jonathan Wakely's avatar
      libstdc++: Split std::basic_string::_M_use_local_data into two functions · 405a4140
      Jonathan Wakely authored
      This splits out the activate-the-union-member-for-constexpr logic from
      _M_use_local_data, so that it can be used separately in cases that don't
      need to use std::pointer_traits<pointer>::pointer_to to obtain the
      return value.
      
      This leaves only three uses of _M_use_local_data() which are all of the
      same form:
      
        __s._M_data(_M_use_local_data());
        __s._M_set_length(0);
      
      We could remove _M_use_local_data() and change those three places to use
      a new _M_reset() function that does:
      
        _M_init_local_buf();
        _M_data(_M_local_data());
        _M_set_length(0);
      
      This is left for a future change.
      
      libstdc++-v3/ChangeLog:
      
      	* include/bits/basic_string.h (_M_init_local_buf()): New
      	function.
      	(_M_use_local_data()): Use _M_init_local_buf.
      	(basic_string(), basic_string(const Alloc&))
      	(basic_string(basic_string&&))
      	(basic_string(basic_string&&, const Alloc&)): Use
      	_M_init_local_buf instead of _M_use_local_data().
      	* include/bits/basic_string.tcc (swap(basic_string&))
      	(_M_construct(InIter, InIter, input_iterator_tag))
      	(_M_construct(InIter, InIter, forward_iterator_tag))
      	(_M_construct(size_type, CharT), reserve()): Likewise.
      405a4140
    • Benjamin Brock's avatar
      libstdc++: Workaround for LLVM-61763 in <ranges> · be34a8b5
      Benjamin Brock authored
      
      This patch adds a small workaround that avoids declaring constrained
      friends when compiling with Clang, instead making some members public.
      MSVC's standard library has implemented a similar workaround.
      
      Signed-off-by: default avatarBenjamin Brock <brock@cs.berkeley.edu>
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/ranges (zip_view, adjacent_view): Implement
      	workaround for LLVM-61763.
      be34a8b5
    • Dimitrij Mijoski's avatar
      libstdc++: testsuite: Enhance codecvt_unicode with tests for length() · 59a7d389
      Dimitrij Mijoski authored
      We can test codecvt::length() with the same data that we test
      codecvt::in(). For each call of in() we add another call to length().
      Some additional small cosmentic changes are applied.
      
      libstdc++-v3/ChangeLog:
      
      	* testsuite/22_locale/codecvt/codecvt_unicode.h: Test length()
      59a7d389
    • Jonathan Wakely's avatar
      libstdc++: Fix formatting of filesystem directory iterators · 77209d43
      Jonathan Wakely authored
      Fix indentation.
      
      libstdc++-v3/ChangeLog:
      
      	* include/bits/fs_dir.h (operator==(default_sentinel_t)): Fix
      	indentation.
      77209d43
    • Florian Weimer's avatar
      C99 testsuite readiness: Compile more tests with -std=gnu89 · 57cbb1d3
      Florian Weimer authored
      gcc/testsuite/
      
      	* gcc.c-torture/compile/20000403-1.c: Compile with -std=gnu89.
      	* gcc.c-torture/compile/20000511-1.c: Likewise.
      	* gcc.c-torture/compile/20000804-1.c: Likewise.
      	* gcc.c-torture/compile/20020418-1.c: Likewise.
      	* gcc.c-torture/compile/20020927-1.c: Likewise.
      	* gcc.c-torture/compile/20030109-1.c: Likewise.
      	* gcc.c-torture/compile/20030224-1.c: Likewise.
      	* gcc.c-torture/compile/20030415-1.c: Likewise.
      	* gcc.c-torture/compile/20030612-1.c: Likewise.
      	* gcc.c-torture/compile/20030917-1.c: Likewise.
      	* gcc.c-torture/compile/20031113-1.c: Likewise.
      	* gcc.c-torture/compile/20031220-2.c: Likewise.
      	* gcc.c-torture/compile/20040309-1.c: Likewise.
      	* gcc.c-torture/compile/20040310-1.c: Likewise.
      	* gcc.c-torture/compile/20040317-3.c: Likewise.
      	* gcc.c-torture/compile/20040817-1.c: Likewise.
      	* gcc.c-torture/compile/20091215-1.c: Likewise.
      	* gcc.c-torture/compile/86.c: Likewise.
      	* gcc.c-torture/compile/900216-1.c: Likewise.
      	* gcc.c-torture/compile/900313-1.c: Likewise.
      	* gcc.c-torture/compile/900407-1.c: Likewise.
      	* gcc.c-torture/compile/900516-1.c: Likewise.
      	* gcc.c-torture/compile/920409-2.c: Likewise.
      	* gcc.c-torture/compile/920415-1.c: Likewise.
      	* gcc.c-torture/compile/920428-1.c: Likewise.
      	* gcc.c-torture/compile/920428-5.c: Likewise.
      	* gcc.c-torture/compile/920428-7.c: Likewise.
      	* gcc.c-torture/compile/920501-1.c: Likewise.
      	* gcc.c-torture/compile/920501-13.c: Likewise.
      	* gcc.c-torture/compile/920501-15.c: Likewise.
      	* gcc.c-torture/compile/920501-16.c: Likewise.
      	* gcc.c-torture/compile/920501-18.c: Likewise.
      	* gcc.c-torture/compile/920501-20.c: Likewise.
      	* gcc.c-torture/compile/920501-6.c: Likewise.
      	* gcc.c-torture/compile/920501-7.c: Likewise.
      	* gcc.c-torture/compile/920502-1.c: Likewise.
      	* gcc.c-torture/compile/920502-2.c: Likewise.
      	* gcc.c-torture/compile/920520-1.c: Likewise.
      	* gcc.c-torture/compile/920521-1.c: Likewise.
      	* gcc.c-torture/compile/920608-1.c: Likewise.
      	* gcc.c-torture/compile/920617-1.c: Likewise.
      	* gcc.c-torture/compile/920617-2.c: Likewise.
      	* gcc.c-torture/compile/920625-1.c: Likewise.
      	* gcc.c-torture/compile/920625-2.c: Likewise.
      	* gcc.c-torture/compile/920626-1.c: Likewise.
      	* gcc.c-torture/compile/920706-1.c: Likewise.
      	* gcc.c-torture/compile/920710-2.c: Likewise.
      	* gcc.c-torture/compile/920723-1.c: Likewise.
      	* gcc.c-torture/compile/920808-1.c: Likewise.
      	* gcc.c-torture/compile/920809-1.c: Likewise.
      	* gcc.c-torture/compile/920817-1.c: Likewise.
      	* gcc.c-torture/compile/920831-1.c: Likewise.
      	* gcc.c-torture/compile/920917-1.c: Likewise.
      	* gcc.c-torture/compile/920928-2.c: Likewise.
      	* gcc.c-torture/compile/920928-5.c: Likewise.
      	* gcc.c-torture/compile/921012-1.c: Likewise.
      	* gcc.c-torture/compile/921021-1.c: Likewise.
      	* gcc.c-torture/compile/921024-1.c: Likewise.
      	* gcc.c-torture/compile/921103-1.c: Likewise.
      	* gcc.c-torture/compile/921109-1.c: Likewise.
      	* gcc.c-torture/compile/921111-1.c: Likewise.
      	* gcc.c-torture/compile/921116-2.c: Likewise.
      	* gcc.c-torture/compile/921118-1.c: Likewise.
      	* gcc.c-torture/compile/921202-1.c: Likewise.
      	* gcc.c-torture/compile/921202-2.c: Likewise.
      	* gcc.c-torture/compile/921203-1.c: Likewise.
      	* gcc.c-torture/compile/921203-2.c: Likewise.
      	* gcc.c-torture/compile/921206-1.c: Likewise.
      	* gcc.c-torture/compile/930109-1.c: Likewise.
      	* gcc.c-torture/compile/930111-1.c: Likewise.
      	* gcc.c-torture/compile/930117-1.c: Likewise.
      	* gcc.c-torture/compile/930118-1.c: Likewise.
      	* gcc.c-torture/compile/930120-1.c: Likewise.
      	* gcc.c-torture/compile/930217-1.c: Likewise.
      	* gcc.c-torture/compile/930325-1.c: Likewise.
      	* gcc.c-torture/compile/930411-1.c: Likewise.
      	* gcc.c-torture/compile/930427-2.c: Likewise.
      	* gcc.c-torture/compile/930503-2.c: Likewise.
      	* gcc.c-torture/compile/930506-2.c: Likewise.
      	* gcc.c-torture/compile/930513-2.c: Likewise.
      	* gcc.c-torture/compile/930530-1.c: Likewise.
      	* gcc.c-torture/compile/930602-1.c: Likewise.
      	* gcc.c-torture/compile/930618-1.c: Likewise.
      	* gcc.c-torture/compile/930623-1.c: Likewise.
      	* gcc.c-torture/compile/931003-1.c: Likewise.
      	* gcc.c-torture/compile/931013-1.c: Likewise.
      	* gcc.c-torture/compile/931013-2.c: Likewise.
      	* gcc.c-torture/compile/931102-2.c: Likewise.
      	* gcc.c-torture/compile/931203-1.c: Likewise.
      	* gcc.c-torture/compile/940718-1.c: Likewise.
      	* gcc.c-torture/compile/941014-1.c: Likewise.
      	* gcc.c-torture/compile/941014-2.c: Likewise.
      	* gcc.c-torture/compile/941014-3.c: Likewise.
      	* gcc.c-torture/compile/941014-4.c: Likewise.
      	* gcc.c-torture/compile/941111-1.c: Likewise.
      	* gcc.c-torture/compile/941113-1.c: Likewise.
      	* gcc.c-torture/compile/950124-1.c: Likewise.
      	* gcc.c-torture/compile/950329-1.c: Likewise.
      	* gcc.c-torture/compile/950612-1.c: Likewise.
      	* gcc.c-torture/compile/950618-1.c: Likewise.
      	* gcc.c-torture/compile/950719-1.c: Likewise.
      	* gcc.c-torture/compile/950910-1.c: Likewise.
      	* gcc.c-torture/compile/950922-1.c: Likewise.
      	* gcc.c-torture/compile/951106-1.c: Likewise.
      	* gcc.c-torture/compile/951222-1.c: Likewise.
      	* gcc.c-torture/compile/960106-1.c: Likewise.
      	* gcc.c-torture/compile/960319-1.c: Likewise.
      	* gcc.c-torture/compile/960829-1.c: Likewise.
      	* gcc.c-torture/compile/970206-1.c: Likewise.
      	* gcc.c-torture/compile/980825-1.c: Likewise.
      	* gcc.c-torture/compile/990829-1.c: Likewise.
      	* gcc.c-torture/compile/991213-2.c: Likewise.
      57cbb1d3
    • Pan Li's avatar
      RISC-V: Support partial VLS mode when preference fixed-vlmax [PR111857] · 66c26e5c
      Pan Li authored
      
      Given we have code like below:
      
      typedef char vnx16i __attribute__ ((vector_size (16)));
      
      vnx16i __attribute__ ((noinline, noclone))
      test (vnx16i x, vnx16i y)
      {
        return __builtin_shufflevector (x, y, 11, 12, 13, 14, 11, 12, 13, 14,
                                              11, 12, 13, 14, 11, 12, 13, 14);
      }
      
      It can perform the auto vectorization when
      
      -march=rv64gcv_zvl1024b --param=riscv-autovec-preference=fixed-vlmax
      
      but cannot when
      
      -march=rv64gcv_zvl2048b --param=riscv-autovec-preference=fixed-vlmax
      
      The reason comes from the miniaml machine mode of QI is RVVMF8QI, which
      is 1024 / 8 = 128 bits, aka the size of VNx16QI. When we set zvl2048b,
      the bit size of RVVMFQI is 2048 / 8 = 256, which is not matching the
      bit size of VNx16QI (128 bits).
      
      Thus, this patch would like to enable the VLS mode for such case, aka
      VNx16QI vls mode for zvl2048b.
      
      Before this patch:
      test:
        srli    a4,a1,40
        andi    a4,a4,0xff
        srli    a3,a1,32
        srli    a5,a1,48
        slli    a0,a4,8
        andi    a3,a3,0xff
        andi    a5,a5,0xff
        slli    a2,a5,16
        or      a0,a3,a0
        srli    a1,a1,56
        or      a0,a0,a2
        slli    a2,a1,24
        slli    a3,a3,32
        or      a0,a0,a2
        slli    a4,a4,40
        or      a0,a0,a3
        slli    a5,a5,48
        or      a0,a0,a4
        or      a0,a0,a5
        slli    a1,a1,56
        or      a0,a0,a1
        mv      a1,a0
        ret
      
      After this patch:
      test:
        vsetivli        zero,16,e8,mf8,ta,ma
        vle8.v  v2,0(a1)
        vsetivli        zero,4,e32,mf2,ta,ma
        vrgather.vi     v1,v2,3
        vsetivli        zero,16,e8,mf8,ta,ma
        vse8.v  v1,0(a0)
        ret
      
      	PR target/111857
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv-opts.h (TARGET_VECTOR_VLS): Remove.
      	* config/riscv/riscv-protos.h (vls_mode_valid_p): New func decl.
      	* config/riscv/riscv-v.cc (autovectorize_vector_modes): Replace
      	macro reference to func.
      	(vls_mode_valid_p): New func impl for vls mode valid or not.
      	* config/riscv/riscv-vector-switch.def (VLS_ENTRY): Replace
      	macro reference to func.
      	* config/riscv/vector-iterators.md: Ditto.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/vls-vlmax/perm-4.c: Adjust checker.
      	* gcc.target/riscv/rvv/autovec/vls/def.h: Add help define.
      	* gcc.target/riscv/rvv/autovec/vls-vlmax/pr111857-0.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls-vlmax/pr111857-1.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls-vlmax/pr111857-2.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls-vlmax/pr111857-3.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls-vlmax/pr111857-4.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls-vlmax/pr111857-5.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls-vlmax/pr111857-6.c: New test.
      
      Signed-off-by: default avatarPan Li <pan2.li@intel.com>
      66c26e5c
    • GCC Administrator's avatar
      Daily bump. · 6f684dd2
      GCC Administrator authored
      6f684dd2
  3. Oct 20, 2023
    • Roger Sayle's avatar
      PR 106245: Split (x<<31)>>31 as -(x&1) in i386.md · e2886967
      Roger Sayle authored
      This patch is the backend piece of a solution to PRs 101955 and 106245,
      that adds a define_insn_and_split to the i386 backend, to perform sign
      extension of a single (least significant) bit using and $1 then neg.
      
      Previously, (x<<31)>>31 would be generated as
      
              sall    $31, %eax	// 3 bytes
              sarl    $31, %eax	// 3 bytes
      
      with this patch the backend now generates:
      
              andl    $1, %eax	// 3 bytes
              negl    %eax		// 2 bytes
      
      Not only is this smaller in size, but microbenchmarking confirms
      that it's a performance win on both Intel and AMD; Intel sees only a
      2% improvement (perhaps just a size effect), but AMD sees a 7% win.
      
      2023-10-21  Roger Sayle  <roger@nextmovesoftware.com>
      	    Uros Bizjak  <ubizjak@gmail.com>
      
      gcc/ChangeLog
      	PR middle-end/101955
      	PR tree-optimization/106245
      	* config/i386/i386.md (*extv<mode>_1_0): New define_insn_and_split.
      
      gcc/testsuite/ChangeLog
      	PR middle-end/101955
      	PR tree-optimization/106245
      	* gcc.target/i386/pr106245-2.c: New test case.
      	* gcc.target/i386/pr106245-3.c: New 32-bit test case.
      	* gcc.target/i386/pr106245-4.c: New 64-bit test case.
      	* gcc.target/i386/pr106245-5.c: Likewise.
      e2886967
    • Jason Merrill's avatar
      c++: abstract class and overload resolution · 55731b59
      Jason Merrill authored
      In my implementation of P0929 I treated a conversion to an rvalue of
      abstract class type as a bad conversion, but that's still too soon to check
      it; we need to wait until we're done with overload resolution.
      
      gcc/cp/ChangeLog:
      
      	* call.cc (implicit_conversion_1): Rename...
      	(implicit_conversion): ...to this.  Remove the old wrapper.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/template/sfinae-dr657.C: Adjust.
      55731b59
    • Jason Merrill's avatar
      testsuite: constexpr-diag1.C and implicit constexpr · 7d4e9913
      Jason Merrill authored
      This test doesn't break as expected with implicit constexpr.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp1y/constexpr-diag1.C: Add -fno-implicit-constexpr.
      7d4e9913
    • Jason Merrill's avatar
      c++: fix tourney logic · ff04531b
      Jason Merrill authored
      In r13-3766 I changed the logic at the end of tourney to avoid redundant
      comparisons, but the change also meant skipping any less-good matches
      between the champ_compared_to_predecessor candidate and champ itself.
      
      This should not be a correctness issue, since we believe that joust is a
      partial order.  But it can lead to missed warnings, as in this testcase.
      
      gcc/cp/ChangeLog:
      
      	* call.cc (tourney): Only skip champ_compared_to_predecessor.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/warn/Wsign-promo1.C: New test.
      ff04531b
    • Nathan Sidwell's avatar
      c++: Constructor streaming [PR105322] · 084addf8
      Nathan Sidwell authored
      An expresion node's type is streamed after the expression's operands,
      because the type can come from some aspect of an operand (for instance
      decltype and noexcept). There's a comment in the code explaining that.
      
      But that doesn't work for constructors, which can directly reference
      components of their type (eg FIELD_DECLS). If this is a
      type-introducing CONSTRUCTOR, we need to ensure the type has been
      streamed first. So move CONSTRUCTOR stream to after the type streaming.
      
      The reason things like COMPONENT_REF work is that they stream their
      first operand first, and that introduces the type that their second
      operand looks up a field in.
      
      	gcc/cp/
      	PR c++/105322
      	* module.cc (trees_out::core_vals): Stream CONSTRUCTOR operands
      	after the type.
      	(trees_in::core_vals): Likewise.
      	gcc/testsuite/
      	* g++.dg/modules/decltype-1_a.C: New.
      	* g++.dg/modules/decltype-1_b.C: New.
      	* g++.dg/modules/lambda-5_a.C: New.
      	* g++.dg/modules/lambda-5_b.C: New.
      084addf8
    • Florian Weimer's avatar
      c: -Wint-conversion should cover pointer/integer mismatches in ?: · 7069ea90
      Florian Weimer authored
      gcc/c/
      
      	PR c/109827
      	PR other/44209
      	* c-typeck.cc (build_conditional_expr): Use OPT_Wint_conversion
      	for pointer/integer mismatch warnings.
      
      gcc/testsuite/
      
      	* gcc.dg/Wint-conversion-3.c: New.
      7069ea90
    • Florian Weimer's avatar
      c: -Wincompatible-pointer-types should cover mismatches in ?: · 857a6ee2
      Florian Weimer authored
      gcc/c/
      
      	PR c/109826
      	PR other/44209
      	* c-typeck.cc (build_conditional_expr): Use
      	OPT_Wincompatible_pointer_types for pointer mismatches.
      	Emit location information for the operand.
      
      gcc/testsuite/
      
      	* gcc.dg/Wincompatible-pointer-types-2.c: New.
      	* gcc.dg/Wincompatible-pointer-types-3.c: New.
      	* gcc.dg/Wincompatible-pointer-types-4.c: New.
      857a6ee2
    • David Edelsohn's avatar
      bootstrap: tm_p.h requires memmodel.h on SPARC. · 8f75e6cf
      David Edelsohn authored
      
      SPARC target header references memmodel, which requires memmodel.h.
      
      gcc/ChangeLog:
      
      	* gimple-harden-control-flow.cc: Include memmodel.h.
      
      Signed-off-by: default avatarDavid Edelsohn <dje.gcc@gmail.com>
      8f75e6cf
    • Marek Polacek's avatar
      c-family: char8_t and aliasing in C vs C++ [PR111884] · 281699fb
      Marek Polacek authored
      In the PR, Joseph says that in C char8_t is not a distinct type.  So
      we should behave as if it can alias anything, like ordinary char.
      In C, unsigned_char_type_node == char8_type_node, so with this patch
      we return 0 instead of -1.  And the following comment says:
      
        /* The C standard guarantees that any object may be accessed via an
           lvalue that has narrow character type (except char8_t).  */
        if (t == char_type_node
            || t == signed_char_type_node
            || t == unsigned_char_type_node)
          return 0;
      
      Which appears to be wrong, so I'm adjusting that as well.
      
      	PR c/111884
      
      gcc/c-family/ChangeLog:
      
      	* c-common.cc (c_common_get_alias_set): Return -1 for char8_t only
      	in C++.
      
      gcc/testsuite/ChangeLog:
      
      	* c-c++-common/alias-1.c: New test.
      281699fb
    • David Edelsohn's avatar
      bootstrap: Include tm_p.h · a663fe63
      David Edelsohn authored
      
      ASM_GENERATE_INTERNAL_LABEL may use target-specific functions, so
      tm_p.h must be included.  This fixes bootstrap breakage on AIX, at least.
      
      gcc/ChangeLog
      
      	* gimple-harden-control-flow.cc: Include tm_p.h.
      
      Signed-off-by: default avatarDavid Edelsohn <dje.gcc@gmail.com>
      a663fe63
    • Patrick Palka's avatar
      rust: build failure after NON_DEPENDENT_EXPR removal [PR111899] · 5ac53c02
      Patrick Palka authored
      This patch removes stray NON_DEPENDENT_EXPR checks following the removal
      of this tree code from the C++ FE.  (Since this restores the build I
      supppose it means the Rust FE never creates NON_DEPENDENT_EXPR trees in
      the first place, so no further analysis is needed.)
      
      	PR rust/111899
      
      gcc/rust/ChangeLog:
      
      	* backend/rust-constexpr.cc (potential_constant_expression_1):
      	Remove NON_DEPENDENT_EXPR handling.
      	* backend/rust-tree.cc (mark_exp_read): Likewise.
      	(mark_use): Likewise.
      	(lvalue_kind): Likewise.
      5ac53c02
    • Marek Polacek's avatar
      libstdc++: add casts to from_chars in <charconv> [PR111883] · 1d9263f2
      Marek Polacek authored
      This fixes
      
      .../charconv: In function 'std::from_chars_result std::from_chars(const char*, const char*, _Float16&, chars_format)':
      .../charconv:687:17: warning: converting to '_Float16' from 'float' with greater conversion rank
        687 |       __value = __val;
            |                 ^~~~~
      .../charconv: In function 'std::from_chars_result std::from_chars(const char*, const char*, __gnu_cxx::__bfloat16_t&, chars_format)':
      .../charconv:763:17: warning: converting to '__gnu_cxx::__bfloat16_t' {aka '__bf16'} from 'float' with greater conversion rank
        763 |       __value = __val;
            |                 ^~~~~
      
      which was breaking a test:
      
      FAIL: g++.dg/warn/Wstringop-overflow-6.C  -std=gnu++26 (test for excess errors)
      
      	PR testsuite/111883
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/charconv (from_chars): Add explicit casts.
      1d9263f2
    • Andre Vieira's avatar
      ifcvt: Don't lower bitfields with non-constant offsets [PR 111882] · 24cf1f60
      Andre Vieira authored
      This patch stops lowering of bitfields by ifcvt when they have non-constant
      offsets as we are not likely to be able to do anything useful with those during
      vectorization.  That also fixes the issue reported in PR 111882, which was
      being caused by an offset with a side-effect being lowered, but constants have
      no side-effects so we will no longer run into that problem.
      
      gcc/ChangeLog:
      
      	PR tree-optimization/111882
      	* tree-if-conv.cc (get_bitfield_rep): Return NULL_TREE for bitfields
      	with non-constant offsets.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/vect/pr111882.c: New test.
      24cf1f60
    • Patrick Palka's avatar
      c++: rename tsubst_copy_and_build and tsubst_expr · c29d5523
      Patrick Palka authored
      
      After the previous patch, we now only have two tsubst entry points for
      expression trees: tsubst_copy_and_build and tsubst_expr.  The former
      despite its unwieldy name is the main entry point, and the latter is
      just a superset of the former that also handles statement trees.  We
      could merge them so that we just have tsubst_expr, but it seems natural
      to distinguish statement trees from expression trees and to maintain a
      separate entry point for them.
      
      To that end, this this patch renames tsubst_copy_and_build to
      tsubst_expr, and renames the current tsubst_expr to tsubst_stmt, which
      continues to be a superset of the former (which is convenient since
      sometimes expression trees appear in statement contexts, e.g. a branch
      of an IF_STMT could be NOP_EXPR).  (Making tsubst_stmt disjoint from
      tsubst_expr is left as future work if deemed desirable.)
      
      This patch in turn renames suitable existing uses of tsubst_expr (that
      expect to take statement trees) to use tsubst_stmt.  Thus untouched
      tsubst_expr calls are implicitly strengthened to expect only expression
      trees after this patch.  For the tsubst_omp_* routines I opted to rename
      all existing uses to ensure no unintended functional change.  This patch
      also moves the handling of CO_YIELD_EXPR and CO_AWAIT_EXPR from tsubst_stmt
      to tsubst_expr since they're indeed expression trees.
      
      gcc/cp/ChangeLog:
      
      	* cp-lang.cc (objcp_tsubst_copy_and_build): Rename to ...
      	(objcp_tsubst_expr): ... this.
      	* cp-objcp-common.h (objcp_tsubst_copy_and_build): Rename to ...
      	(objcp_tsubst_expr): ... this.
      	* cp-tree.h (tsubst_copy_and_build): Remove declaration.
      	* init.cc (maybe_instantiate_nsdmi_init): Use tsubst_expr
      	instead of tsubst_copy_and_build.
      	* pt.cc (expand_integer_pack): Likewise.
      	(instantiate_non_dependent_expr_internal): Likewise.
      	(instantiate_class_template): Use tsubst_stmt instead of
      	tsubst_expr for STATIC_ASSERT.
      	(tsubst_function_decl): Adjust tsubst_copy_and_build uses.
      	(tsubst_arg_types): Likewise.
      	(tsubst_exception_specification): Likewise.
      	(tsubst_tree_list): Likewise.
      	(tsubst): Likewise.
      	(tsubst_name): Likewise.
      	(tsubst_omp_clause_decl): Use tsubst_stmt instead of tsubst_expr.
      	(tsubst_omp_clauses): Likewise.
      	(tsubst_copy_asm_operands): Adjust tsubst_copy_and_build use.
      	(tsubst_omp_for_iterator): Use tsubst_stmt instead of tsubst_expr.
      	(tsubst_expr): Rename to ...
      	(tsubst_stmt): ... this.
      	<case CO_YIELD_EXPR, CO_AWAIT_EXPR>: Move to tsubst_expr.
      	(tsubst_omp_udr): Use tsubst_stmt instead of tsubst_expr.
      	(tsubst_non_call_postfix_expression): Adjust tsubst_copy_and_build
      	use.
      	(tsubst_lambda_expr): Likewise.  Use tsubst_stmt instead of
      	tsubst_expr for the body of a lambda.
      	(tsubst_copy_and_build_call_args): Rename to ...
      	(tsubst_call_args): ... this.  Adjust tsubst_copy_and_build use.
      	(tsubst_copy_and_build): Rename to tsubst_expr.  Adjust
      	tsubst_copy_and_build and tsubst_copy_and_build_call_args use.
      	<case TRANSACTION_EXPR>: Use tsubst_stmt instead of tsubst_expr.
      	(maybe_instantiate_noexcept): Adjust tsubst_copy_and_build use.
      	(instantiate_body): Use tsubst_stmt instead of tsubst_expr for
      	substituting the function body.
      	(tsubst_initializer_list): Adjust tsubst_copy_and_build use.
      
      gcc/objcp/ChangeLog:
      
      	* objcp-lang.cc (objcp_tsubst_copy_and_build): Rename to ...
      	(objcp_tsubst_expr): ... this.  Adjust tsubst_copy_and_build
      	uses.
      
      Reviewed-by: default avatarJason Merrill <jason@redhat.com>
      c29d5523
    • Patrick Palka's avatar
      c++: merge tsubst_copy into tsubst_copy_and_build · 3e3d73ed
      Patrick Palka authored
      
      The relationship between tsubst_copy_and_build and tsubst_copy (two of
      the main template argument substitution routines for expression trees)
      is rather hazy.  The former is mostly a superset of the latter, with
      some differences.
      
      The main apparent difference is their handling of various tree codes,
      but much of the tree code handling in tsubst_copy appears to be dead
      code.  This is because tsubst_copy mostly gets (directly) called on
      id-expressions rather than on arbitrary expressions.  The interesting
      tree codes are PARM_DECL, VAR_DECL, BIT_NOT_EXPR, SCOPE_REF,
      TEMPLATE_ID_EXPR and IDENTIFIER_NODE:
      
       * for PARM_DECL and VAR_DECL, tsubst_copy_and_build calls tsubst_copy
         followed by doing some extra handling of its own
       * for BIT_NOT_EXPR tsubst_copy implicitly handles unresolved destructor
         calls (i.e. the first operand is an identifier or a type)
       * for SCOPE_REF, TEMPLATE_ID_EXPR and IDENTIFIER_NODE tsubst_copy
         refrains from doing name lookup of the terminal name
      
      Other more minor differences are that tsubst_copy exits early when
      'args' is null, and it calls maybe_dependent_member_ref, and finally
      it dispatches to tsubst for type trees.[1]
      
      Thus tsubst_copy is similar enough to tsubst_copy_and_build that it
      makes sense to merge the two functions, with the main difference we
      want to preserve is tsubst_copy's lack of name lookup for id-expressions.
      This patch achieves this via a new tsubst flag tf_no_name_lookup which
      controls name lookup and resolution of a (top-level) id-expression.
      
      [1]: Exiting early for null 'args' doesn't seem right since it means we
      return templated trees even when !processing_template_decl.  And
      dispatching to tsubst for type trees muddles the distinction between
      type and expressions which makes things less clear at the call site.
      So these properties of tsubst_copy don't seem worth preserving.
      
      N.B. the diff for this patch looks much cleaner when generated using
      the "patience diff" algorithm via Git's --patience flag.
      
      gcc/cp/ChangeLog:
      
      	* cp-tree.h (enum tsubst_flags): Add tf_no_name_lookup.
      	* pt.cc (tsubst_pack_expansion): Use tsubst for substituting
      	BASES_TYPE.
      	(tsubst_decl) <case USING_DECL>: Use tsubst_name instead of
      	tsubst_copy.
      	(tsubst) <case TEMPLATE_TYPE_PARM>: Use tsubst_copy_and_build
      	instead of tsubst_copy for substituting
      	CLASS_PLACEHOLDER_TEMPLATE.
      	<case TYPENAME_TYPE>: Use tsubst_name instead of tsubst_copy for
      	substituting TYPENAME_TYPE_FULLNAME.
      	(tsubst_name): Define.
      	(tsubst_qualified_id): Use tsubst_name instead of tsubst_copy
      	for substituting the component name of a SCOPE_REF.
      	(tsubst_copy): Remove.
      	(tsubst_copy_and_build): Clear tf_no_name_lookup at the start,
      	and remember if it was set.  Call maybe_dependent_member_ref if
      	tf_no_name_lookup was not set.
      	<case IDENTIFIER_NODE>: Don't do name lookup if tf_no_name_lookup
      	was set.
      	<case TEMPLATE_ID_EXPR>: If tf_no_name_lookup was set, use
      	tsubst_name instead of tsubst_copy_and_build to substitute the
      	template and don't finish the template-id.
      	<case BIT_NOT_EXPR>: Handle identifier and type operand (if
      	tf_no_name_lookup was set).
      	<case SCOPE_REF>: Avoid trying to resolve a SCOPE_REF if
      	tf_no_name_lookup was set by calling build_qualified_name directly
      	instead of tsubst_qualified_id.
      	<case SIZEOF_EXPR>: Handling of sizeof...  copied from tsubst_copy.
      	<case CALL_EXPR>: Use tsubst_name instead of tsubst_copy to
      	substitute a TEMPLATE_ID_EXPR callee naming an unresolved template.
      	<case COMPONENT_REF>: Likewise to substitute the member.
      	<case FUNCTION_DECL>: Copied from tsubst_copy and merged with ...
      	<case VAR_DECL, PARM_DECL>: ... these.  Initial handling copied
      	from tsubst_copy.  Optimize local variable substitution by
      	trying retrieve_local_specialization before checking
      	uses_template_parms.
      	<case CONST_DECL>: Copied from tsubst_copy.
      	<case FIELD_DECL>: Likewise.
      	<case NAMESPACE_DECL>: Likewise.
      	<case OVERLOAD>: Likewise.
      	<case TEMPLATE_DECL>: Likewise.
      	<case TEMPLATE_PARM_INDEX>: Likewise.
      	<case TYPE_DECL>: Likewise.
      	<case CLEANUP_POINT_EXPR>: Likewise.
      	<case OFFSET_REF>: Likewise.
      	<case EXPR_PACK_EXPANSION>: Likewise.
      	<case NONTYPE_ARGUMENT_PACK>: Likewise.
      	<case *_CST>: Likewise.
      	<case *_*_FOLD_EXPR>: Likewise.
      	<case DEBUG_BEGIN_STMT>: Likewise.
      	<case CO_AWAIT_EXPR>: Likewise.
      	<case TRAIT_EXPR>: Use tsubst and tsubst_copy_and_build instead
      	of tsubst_copy.
      	<default>: Copied from tsubst_copy.
      	(tsubst_initializer_list): Use tsubst and tsubst_copy_and_build
      	instead of tsubst_copy.
      
      Reviewed-by: default avatarJason Merrill <jason@redhat.com>
      3e3d73ed
    • Patrick Palka's avatar
      c++: non-static memfn call dependence cleanup [PR106086] · 909672f0
      Patrick Palka authored
      In cp_parser_postfix_expression, and in the CALL_EXPR case of
      tsubst_copy_and_build, we essentially repeat the type-dependent and
      COMPONENT_REF callee cases of finish_call_expr.  This patch deduplicates
      this logic by making both spots consistently go through finish_call_expr.
      
      This allows us to easily fix PR106086 -- which is about us neglecting to
      capture 'this' when we resolve a use of a non-static member function of
      the current instantiation only at lambda regeneration time -- by moving
      the call to maybe_generic_this_capture from the parser to finish_call_expr
      so that we consider capturing 'this' at regeneration time as well.
      
      	PR c++/106086
      
      gcc/cp/ChangeLog:
      
      	* parser.cc (cp_parser_postfix_expression): Consolidate three
      	calls to finish_call_expr, one to build_new_method_call and
      	one to build_min_nt_call_vec into one call to finish_call_expr.
      	Don't call maybe_generic_this_capture here.
      	* pt.cc (tsubst_copy_and_build) <case CALL_EXPR>: Remove
      	COMPONENT_REF callee handling.
      	(type_dependent_expression_p): Use t_d_object_e_p instead of
      	t_d_e_p for COMPONENT_REF and OFFSET_REF.
      	* semantics.cc (finish_call_expr): In the type-dependent case,
      	call maybe_generic_this_capture here instead.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/template/crash127.C: Expect additional error due to
      	being able to check the member access expression ahead of time.
      	Strengthen the test by not instantiating the class template.
      	* g++.dg/cpp1y/lambda-generic-this5.C: New test.
      909672f0
    • Patrick Palka's avatar
      c++: remove NON_DEPENDENT_EXPR, part 2 · cd0e05b7
      Patrick Palka authored
      
      This follow-up patch removes build_non_dependent_expr (and
      make_args_non_dependent) and calls thereof, no functional change.
      
      gcc/cp/ChangeLog:
      
      	* call.cc (build_new_method_call): Remove calls to
      	build_non_dependent_expr and/or make_args_non_dependent.
      	* coroutines.cc (finish_co_return_stmt): Likewise.
      	* cp-tree.h (build_non_dependent_expr): Remove.
      	(make_args_non_dependent): Remove.
      	* decl2.cc (grok_array_decl): Remove calls to
      	build_non_dependent_expr and/or make_args_non_dependent.
      	(build_offset_ref_call_from_tree): Likewise.
      	* init.cc (build_new): Likewise.
      	* pt.cc (make_args_non_dependent): Remove.
      	(test_build_non_dependent_expr): Remove.
      	(cp_pt_cc_tests): Adjust.
      	* semantics.cc (finish_expr_stmt): Remove calls to
      	build_non_dependent_expr and/or make_args_non_dependent.
      	(finish_for_expr): Likewise.
      	(finish_call_expr): Likewise.
      	(finish_omp_atomic): Likewise.
      	* typeck.cc (finish_class_member_access_expr): Likewise.
      	(build_x_indirect_ref): Likewise.
      	(build_x_binary_op): Likewise.
      	(build_x_array_ref): Likewise.
      	(build_x_vec_perm_expr): Likewise.
      	(build_x_shufflevector): Likewise.
      	(build_x_unary_op): Likewise.
      	(cp_build_addressof): Likewise.
      	(build_x_conditional_expr): Likewise.
      	(build_x_compound_expr): Likewise.
      	(build_static_cast): Likewise.
      	(build_x_modify_expr): Likewise.
      	(check_return_expr): Likewise.
      	* typeck2.cc (build_x_arrow): Likewise.
      
      Reviewed-by: default avatarJason Merrill <jason@redhat.com>
      cd0e05b7
    • Patrick Palka's avatar
      c++: remove NON_DEPENDENT_EXPR, part 1 · dad31187
      Patrick Palka authored
      This tree code dates all the way back to r69130[1] which implemented
      typing of non-dependent expressions.  Its motivation was never clear (to
      me at least) since its documentation in e.g. cp-tree.def doesn't seem
      accurate anymore.  build_non_dependent_expr has since gained a bunch of
      edge cases about whether or how to wrap certain templated trees, making
      it hard to reason about in general.
      
      So this patch removes this tree code, and temporarily turns
      build_non_dependent_expr into the identity function.  The subsequent
      patch will remove build_non_dependent_expr and adjust its callers
      appropriately.
      
      We now need to more thoroughly handle templated (sub)trees in a couple
      of places which previously didn't need to since they didn't look through
      NON_DEPENDENT_EXPR.
      
      [1]: https://gcc.gnu.org/pipermail/gcc-patches/2003-July/109355.html
      
      
      
      gcc/c-family/ChangeLog:
      
      	* c-warn.cc (check_address_or_pointer_of_packed_member): Handle
      	type-dependent callee of CALL_EXPR.
      
      gcc/cp/ChangeLog:
      
      	* class.cc (instantiate_type): Remove NON_DEPENDENT_EXPR
      	handling.
      	* constexpr.cc (cxx_eval_constant_expression): Likewise.
      	(potential_constant_expression_1): Likewise.
      	* coroutines.cc (coro_validate_builtin_call): Don't
      	expect ALIGNOF_EXPR to be wrapped in NON_DEPENDENT_EXPR.
      	* cp-objcp-common.cc (cp_common_init_ts): Remove
      	NON_DEPENDENT_EXPR handling.
      	* cp-tree.def (NON_DEPENDENT_EXPR): Remove.
      	* cp-tree.h (build_non_dependent_expr): Temporarily redefine as
      	the identity function.
      	* cvt.cc (maybe_warn_nodiscard): Handle type-dependent and
      	variable callee of CALL_EXPR.
      	* cxx-pretty-print.cc (cxx_pretty_printer::expression): Remove
      	NON_DEPENDENT_EXPR handling.
      	* error.cc (dump_decl): Likewise.
      	(dump_expr): Likewise.
      	* expr.cc (mark_use): Likewise.
      	(mark_exp_read): Likewise.
      	* pt.cc (build_non_dependent_expr): Remove.
      	* tree.cc (lvalue_kind): Remove NON_DEPENDENT_EXPR handling.
      	(cp_stabilize_reference): Likewise.
      	* typeck.cc (warn_for_null_address): Likewise.
      	(cp_build_binary_op): Handle type-dependent SIZEOF_EXPR operands.
      	(cp_build_unary_op) <case TRUTH_NOT_EXPR>: Don't fold inside a
      	template.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/concepts/var-concept3.C: Adjust expected diagnostic
      	for attempting to call a variable concept.
      
      Reviewed-by: default avatarJason Merrill <jason@redhat.com>
      dad31187
    • Tamar Christina's avatar
      middle-end: don't pass loop_vinfo to vect_set_loop_condition during prolog peeling · eb15fad3
      Tamar Christina authored
      During the refactoring I had passed loop_vinfo on to vect_set_loop_condition
      during prolog peeling.  This parameter is unused in most cases except for in
      vect_set_loop_condition_partial_vectors where it's behaviour depends on whether
      loop_vinfo is NULL or not.  Apparently this code expect it to be NULL and it
      reads the structures from a different location.
      
      This fixes the failing testcase which was not using the lens values determined
      earlier in vectorizable_store because it was looking it up in the given
      loop_vinfo instead.
      
      gcc/ChangeLog:
      
      	PR tree-optimization/111866
      	* tree-vect-loop-manip.cc (vect_do_peeling): Pass null as vinfo to
      	vect_set_loop_condition during prolog peeling.
      eb15fad3
    • Richard Biener's avatar
      tree-optimization/111383 - testcase for fixed PR · a1fc2cc0
      Richard Biener authored
      	PR tree-optimization/111383
      	PR tree-optimization/110243
      gcc/testsuite/
      	* gcc.dg/torture/pr111383.c: New testcase.
      a1fc2cc0
    • Richard Biener's avatar
      tree-optimization/111445 - simple_iv simplification fault · 9692309e
      Richard Biener authored
      The following fixes a missed check in the simple_iv attempt
      to simplify (signed T)((unsigned T) base + step) where it
      allows a truncating inner conversion leading to wrong code.
      
      	PR tree-optimization/111445
      	* tree-scalar-evolution.cc (simple_iv_with_niters):
      	Add missing check for a sign-conversion.
      
      	* gcc.dg/torture/pr111445.c: New testcase.
      9692309e
    • Richard Biener's avatar
      tree-optimization/110243 - IVOPTs introducing undefined overflow · 44e7e449
      Richard Biener authored
      The following addresses IVOPTs rewriting expressions in its
      strip_offset without caring for definedness of overflow.  Rather
      than the earlier attempt of just using the proper
      split_constant_offset from data-ref analysis the following adjusts
      IVOPTs helper trying to minimize changes from this fix, possibly
      easing backports.
      
      	PR tree-optimization/110243
      	PR tree-optimization/111336
      	* tree-ssa-loop-ivopts.cc (strip_offset_1): Rewrite
      	operations with undefined behavior on overflow to
      	unsigned arithmetic.
      
      	* gcc.dg/torture/pr110243.c: New testcase.
      	* gcc.dg/torture/pr111336.c: Likewise.
      44e7e449
    • Richard Biener's avatar
      tree-optimization/111891 - fix assert in vectorizable_simd_clone_call · d70575f5
      Richard Biener authored
      The following fixes the assert in vectorizable_simd_clone_call to
      assert we have a vector type during transform.  Whether we have
      one during analysis depends on whether another SLP user decided
      on the type of a constant/external already.  When we end up with
      a mismatch in desire the updating will fail and make vectorization
      fail.
      
      	PR tree-optimization/111891
      	* tree-vect-stmts.cc (vectorizable_simd_clone_call): Fix
      	assert.
      
      	* gfortran.dg/pr111891.f90: New testcase.
      d70575f5
    • Andrew Stubbs's avatar
      amdgcn: add -march=gfx1030 EXPERIMENTAL · c7ec7bd1
      Andrew Stubbs authored
      Accept the architecture configure option and resolve build failures.  This is
      enough to build binaries, but I've not got a device to test it on, so there
      are probably runtime issues to fix.  The cache control instructions might be
      unsafe (or too conservative), and the kernel metadata might be off.  Vector
      reductions will need to be reworked for RDNA2.  In principle, it would be
      better to use wavefrontsize32 for this architecture, but that would mean
      switching everything to allow SImode masks, so wavefrontsize64 it is.
      
      The multilib is not included in the default configuration so either configure
      --with-arch=gfx1030 or include it in --with-multilib-list=gfx1030,....
      
      The majority of this patch has no effect on other devices, but changing from
      using scalar writes for the exit value to vector writes means we don't need
      the scalar cache write-back instruction anywhere (which doesn't exist in RDNA2).
      
      gcc/ChangeLog:
      
      	* config.gcc: Allow --with-arch=gfx1030.
      	* config/gcn/gcn-hsa.h (NO_XNACK): gfx1030 does not support xnack.
      	(ASM_SPEC): gfx1030 needs -mattr=+wavefrontsize64 set.
      	* config/gcn/gcn-opts.h (enum processor_type): Add PROCESSOR_GFX1030.
      	(TARGET_GFX1030): New.
      	(TARGET_RDNA2): New.
      	* config/gcn/gcn-valu.md (@dpp_move<mode>): Disable for RDNA2.
      	(addc<mode>3<exec_vcc>): Add RDNA2 syntax variant.
      	(subc<mode>3<exec_vcc>): Likewise.
      	(<convop><mode><vndi>2_exec): Add RDNA2 alternatives.
      	(vec_cmp<mode>di): Likewise.
      	(vec_cmp<u><mode>di): Likewise.
      	(vec_cmp<mode>di_exec): Likewise.
      	(vec_cmp<u><mode>di_exec): Likewise.
      	(vec_cmp<mode>di_dup): Likewise.
      	(vec_cmp<mode>di_dup_exec): Likewise.
      	(reduc_<reduc_op>_scal_<mode>): Disable for RDNA2.
      	(*<reduc_op>_dpp_shr_<mode>): Likewise.
      	(*plus_carry_dpp_shr_<mode>): Likewise.
      	(*plus_carry_in_dpp_shr_<mode>): Likewise.
      	* config/gcn/gcn.cc (gcn_option_override): Recognise gfx1030.
      	(gcn_global_address_p): RDNA2 only allows smaller offsets.
      	(gcn_addr_space_legitimate_address_p): Likewise.
      	(gcn_omp_device_kind_arch_isa): Recognise gfx1030.
      	(gcn_expand_epilogue): Use VGPRs instead of SGPRs.
      	(output_file_start): Configure gfx1030.
      	* config/gcn/gcn.h (TARGET_CPU_CPP_BUILTINS): Add __RDNA2__;
      	(ASSEMBLER_DIALECT): New.
      	* config/gcn/gcn.md (rdna): New define_attr.
      	(enabled): Use "rdna" attribute.
      	(gcn_return): Remove s_dcache_wb.
      	(addcsi3_scalar): Add RDNA2 syntax variant.
      	(addcsi3_scalar_zero): Likewise.
      	(addptrdi3): Likewise.
      	(mulsi3): v_mul_lo_i32 should be v_mul_lo_u32 on all ISA.
      	(*memory_barrier): Add RDNA2 syntax variant.
      	(atomic_load<mode>): Add RDNA2 cache control variants, and disable
      	scalar atomics for RDNA2.
      	(atomic_store<mode>): Likewise.
      	(atomic_exchange<mode>): Likewise.
      	* config/gcn/gcn.opt (gpu_type): Add gfx1030.
      	* config/gcn/mkoffload.cc (EF_AMDGPU_MACH_AMDGCN_GFX1030): New.
      	(main): Recognise -march=gfx1030.
      	* config/gcn/t-omp-device: Add gfx1030 isa.
      
      libgcc/ChangeLog:
      
      	* config/gcn/amdgcn_veclib.h (CDNA3_PLUS): Set false for __RDNA2__.
      
      libgomp/ChangeLog:
      
      	* plugin/plugin-gcn.c (EF_AMDGPU_MACH_AMDGCN_GFX1030): New.
      	(isa_hsa_name): Recognise gfx1030.
      	(isa_code): Likewise.
      	* team.c (defined): Remove s_endpgm.
      c7ec7bd1
    • Richard Biener's avatar
      tree-optimization/111000 - restrict invariant motion of shifts · d118738e
      Richard Biener authored
      The following restricts moving variable shifts to when they are
      always executed in the loop as we currently do not have an efficient
      way to rewrite them to something that is unconditionally
      well-defined and value range analysis will otherwise compute
      invalid ranges for the shift operand.
      
      	PR tree-optimization/111000
      	* stor-layout.h (element_precision): Move ..
      	* tree.h (element_precision): .. here.
      	* tree-ssa-loop-im.cc (movement_possibility_1): Restrict
      	motion of shifts and rotates.
      
      	* gcc.dg/torture/pr111000.c: New testcase.
      d118738e
Loading