Skip to content
Snippets Groups Projects
  1. Oct 24, 2024
    • David Malcolm's avatar
      Use unique_ptr in more places in pretty_printer/diagnostics [PR116613] · bf43fe6a
      David Malcolm authored
      
      My forthcoming patches for PR other/116613 make much more use of
      cloning of pretty_printers than before, so it makes sense as a
      preliminary patch for the result of pretty_printer::clone to be a
      std::unique_ptr, rather than add more manual uses of "delete".
      
      On doing so, I noticed various other places where naked new/delete is
      used for run-time configuration of diagnostics:
      * the output format (text vs SARIF)
      * client data hooks
      * the option manager
      * the URLifier
      
      Hence this patch also makes use of std::unique_ptr and ::make_unique for
      managing such client policy classes, and also for diagnostic_buffer's
      per-format implementations.
      
      Unfortunately we can't directly include <memory> in our internal headers
      but instead any of our TUs that make use of std::unique_ptr must #define
      INCLUDE_MEMORY before including system.h.
      
      Hence the bulk of this patch is taken up with adding a define of
      INCLUDE_MEMORY to hundreds of source files: everything that includes
      diagnostic.h or pretty-print.h (and thus anything transitively such as
      includers of lto-wrapper.h, c-tree.h, cp-tree.h and rtl-ssa.h).
      
      Thanks to Gaius Mulley for the parts of the patch that regenerated the
      m2 files.
      
      gcc/ada/ChangeLog:
      	PR other/116613
      	* gcc-interface/misc.cc: Add #define INCLUDE_MEMORY
      	* gcc-interface/trans.cc: Likewise.
      	* gcc-interface/utils.cc: Likewise.
      
      gcc/analyzer/ChangeLog:
      	PR other/116613
      	* analyzer-logging.cc: Add #define INCLUDE_MEMORY
      	(logger::logger): Update for m_pp becoming a unique_ptr.
      	(logger::~logger): Likewise.
      	(logger::log_va_partial): Likewise.
      	(logger::end_log_line): Likewise.
      	* analyzer-logging.h (logger::get_printer): Likewise.
      	(logger::m_pp): Convert to a unique_ptr.
      	* analyzer.cc (make_label_text): Use
      	diagnostic_context::clone_printer and use unique_ptr.
      	(make_label_text_n): Likewise.
      	* bar-chart.cc: Add #define INCLUDE_MEMORY
      	* pending-diagnostic.cc (evdesc::event_desc::formatted_print):
      	Use diagnostic_context::clone_printer and use unique_ptr.
      	* sm-malloc.cc (sufficiently_similar_p): Likewise.
      	* supergraph.cc (supergraph::dump_dot_to_file): Likewise.
      
      gcc/c-family/ChangeLog:
      	PR other/116613
      	* c-ada-spec.cc: Add #define INCLUDE_MEMORY.
      	* c-attribs.cc: Likewise.
      	* c-common.cc: Likewise.
      	* c-format.cc: Likewise.
      	* c-gimplify.cc: Likewise.
      	* c-indentation.cc: Likewise.
      	* c-opts.cc: Likewise.
      	* c-pch.cc: Likewise.
      	* c-pragma.cc: Likewise.
      	* c-pretty-print.cc: Likewise.  Add #include "make-unique.h".
      	(c_pretty_printer::clone): Use std::unique_ptr and ::make_unique.
      	* c-pretty-print.h (c_pretty_printer::clone): Use std::unique_ptr.
      	* c-type-mismatch.cc: Add #define INCLUDE_MEMORY.
      	* c-warn.cc: Likewise.
      
      gcc/c/ChangeLog:
      	PR other/116613
      	* c-aux-info.cc: Add #define INCLUDE_MEMORY.
      	* c-convert.cc: Likewise.
      	* c-errors.cc: Likewise.
      	* c-fold.cc: Likewise.
      	* c-lang.cc: Likewise.
      	* c-objc-common.cc: Likewise.
      	(pp_markup::element_quoted_type::print_type): Use unique_ptr.
      	* c-typeck.cc: Add #define INCLUDE_MEMORY.
      	* gimple-parser.cc: Likewise.
      
      gcc/cp/ChangeLog:
      	PR other/116613
      	* call.cc: Add #define INCLUDE_MEMORY.
      	* class.cc: Likewise.
      	* constexpr.cc: Likewise.
      	* constraint.cc: Likewise.
      	* contracts.cc: Likewise.
      	* coroutines.cc: Likewise.
      	* cp-gimplify.cc: Likewise.
      	* cp-lang.cc: Likewise.
      	* cp-objcp-common.cc: Likewise.
      	* cp-ubsan.cc: Likewise.
      	* cvt.cc: Likewise.
      	* cxx-pretty-print.cc: Likewise.  Add #include "cp-tree.h".
      	(cxx_pretty_printer::clone): Use std::unique_ptr and
      	::make_unique.
      	* cxx-pretty-print.h (cxx_pretty_printer::clone): Use
      	std::unique_ptr.
      	* decl2.cc: Add #define INCLUDE_MEMORY.
      	* dump.cc: Likewise.
      	* except.cc: Likewise.
      	* expr.cc: Likewise.
      	* friend.cc: Likewise.
      	* init.cc: Likewise.
      	* lambda.cc: Likewise.
      	* logic.cc: Likewise.
      	* mangle.cc: Likewise.
      	* method.cc: Likewise.
      	* optimize.cc: Likewise.
      	* pt.cc: Likewise.
      	* ptree.cc: Likewise.
      	* rtti.cc: Likewise.
      	* search.cc: Likewise.
      	* semantics.cc: Likewise.
      	* tree.cc: Likewise.
      	* typeck.cc: Likewise.
      	* typeck2.cc: Likewise.
      	* vtable-class-hierarchy.cc: Likewise.
      
      gcc/d/ChangeLog:
      	PR other/116613
      	* d-attribs.cc: Add #define INCLUDE_MEMORY.
      	* d-builtins.cc: Likewise.
      	* d-codegen.cc: Likewise.
      	* d-convert.cc: Likewise.
      	* d-diagnostic.cc: Likewise.
      	* d-frontend.cc: Likewise.
      	* d-lang.cc: Likewise.
      	* d-longdouble.cc: Likewise.
      	* d-target.cc: Likewise.
      	* decl.cc: Likewise.
      	* expr.cc: Likewise.
      	* intrinsics.cc: Likewise.
      	* modules.cc: Likewise.
      	* toir.cc: Likewise.
      	* typeinfo.cc: Likewise.
      	* types.cc: Likewise.
      
      gcc/fortran/ChangeLog:
      	PR other/116613
      	* arith.cc: Add #define INCLUDE_MEMORY.
      	* array.cc: Likewise.
      	* bbt.cc: Likewise.
      	* check.cc: Likewise.
      	* class.cc: Likewise.
      	* constructor.cc: Likewise.
      	* convert.cc: Likewise.
      	* cpp.cc: Likewise.
      	* data.cc: Likewise.
      	* decl.cc: Likewise.
      	* dependency.cc: Likewise.
      	* dump-parse-tree.cc: Likewise.
      	* error.cc: Likewise.
      	* expr.cc: Likewise.
      	* f95-lang.cc: Likewise.
      	* frontend-passes.cc: Likewise.
      	* interface.cc: Likewise.
      	* intrinsic.cc: Likewise.
      	* io.cc: Likewise.
      	* iresolve.cc: Likewise.
      	* match.cc: Likewise.
      	* matchexp.cc: Likewise.
      	* misc.cc: Likewise.
      	* module.cc: Likewise.
      	* openmp.cc: Likewise.
      	* options.cc: Likewise.
      	* parse.cc: Likewise.
      	* primary.cc: Likewise.
      	* resolve.cc: Likewise.
      	* scanner.cc: Likewise.
      	* simplify.cc: Likewise.
      	* st.cc: Likewise.
      	* symbol.cc: Likewise.
      	* target-memory.cc: Likewise.
      	* trans-array.cc: Likewise.
      	* trans-common.cc: Likewise.
      	* trans-const.cc: Likewise.
      	* trans-decl.cc: Likewise.
      	* trans-expr.cc: Likewise.
      	* trans-intrinsic.cc: Likewise.
      	* trans-io.cc: Likewise.
      	* trans-openmp.cc: Likewise.
      	* trans-stmt.cc: Likewise.
      	* trans-types.cc: Likewise.
      	* trans.cc: Likewise.
      
      gcc/go/ChangeLog:
      	PR other/116613
      	* go-backend.cc: Add #define INCLUDE_MEMORY.
      	* go-lang.cc: Likewise.
      
      gcc/jit/ChangeLog:
      	PR other/116613
      	* dummy-frontend.cc: Add #define INCLUDE_MEMORY.
      	* jit-playback.cc: Likewise.
      	* jit-recording.cc: Likewise.
      
      gcc/lto/ChangeLog:
      	PR other/116613
      	* lto-common.cc: Add #define INCLUDE_MEMORY.
      	* lto-dump.cc: Likewise.
      	* lto-partition.cc: Likewise.
      	* lto-symtab.cc: Likewise.
      	* lto.cc: Likewise.
      
      gcc/m2/ChangeLog:
      	PR other/116613
      	* gm2-gcc/gcc-consolidation.h: Add #define INCLUDE_MEMORY.
      	* gm2-gcc/m2configure.cc: Likewise.
      	* mc-boot/GASCII.cc: Regenerate.
      	* mc-boot/GASCII.h: Ditto.
      	* mc-boot/GArgs.cc: Ditto.
      	* mc-boot/GArgs.h: Ditto.
      	* mc-boot/GAssertion.cc: Ditto.
      	* mc-boot/GAssertion.h: Ditto.
      	* mc-boot/GBreak.cc: Ditto.
      	* mc-boot/GBreak.h: Ditto.
      	* mc-boot/GCOROUTINES.h: Ditto.
      	* mc-boot/GCmdArgs.cc: Ditto.
      	* mc-boot/GCmdArgs.h: Ditto.
      	* mc-boot/GDebug.cc: Ditto.
      	* mc-boot/GDebug.h: Ditto.
      	* mc-boot/GDynamicStrings.cc: Ditto.
      	* mc-boot/GDynamicStrings.h: Ditto.
      	* mc-boot/GEnvironment.cc: Ditto.
      	* mc-boot/GEnvironment.h: Ditto.
      	* mc-boot/GFIO.cc: Ditto.
      	* mc-boot/GFIO.h: Ditto.
      	* mc-boot/GFormatStrings.cc: Ditto.
      	* mc-boot/GFormatStrings.h: Ditto.
      	* mc-boot/GFpuIO.cc: Ditto.
      	* mc-boot/GFpuIO.h: Ditto.
      	* mc-boot/GIO.cc: Ditto.
      	* mc-boot/GIO.h: Ditto.
      	* mc-boot/GIndexing.cc: Ditto.
      	* mc-boot/GIndexing.h: Ditto.
      	* mc-boot/GM2Dependent.cc: Ditto.
      	* mc-boot/GM2Dependent.h: Ditto.
      	* mc-boot/GM2EXCEPTION.cc: Ditto.
      	* mc-boot/GM2EXCEPTION.h: Ditto.
      	* mc-boot/GM2RTS.cc: Ditto.
      	* mc-boot/GM2RTS.h: Ditto.
      	* mc-boot/GMemUtils.cc: Ditto.
      	* mc-boot/GMemUtils.h: Ditto.
      	* mc-boot/GNumberIO.cc: Ditto.
      	* mc-boot/GNumberIO.h: Ditto.
      	* mc-boot/GPushBackInput.cc: Ditto.
      	* mc-boot/GPushBackInput.h: Ditto.
      	* mc-boot/GRTExceptions.cc: Ditto.
      	* mc-boot/GRTExceptions.h: Ditto.
      	* mc-boot/GRTco.h: Ditto.
      	* mc-boot/GRTentity.h: Ditto.
      	* mc-boot/GRTint.cc: Ditto.
      	* mc-boot/GRTint.h: Ditto.
      	* mc-boot/GSArgs.cc: Ditto.
      	* mc-boot/GSArgs.h: Ditto.
      	* mc-boot/GSFIO.cc: Ditto.
      	* mc-boot/GSFIO.h: Ditto.
      	* mc-boot/GSYSTEM.h: Ditto.
      	* mc-boot/GSelective.h: Ditto.
      	* mc-boot/GStdIO.cc: Ditto.
      	* mc-boot/GStdIO.h: Ditto.
      	* mc-boot/GStorage.cc: Ditto.
      	* mc-boot/GStorage.h: Ditto.
      	* mc-boot/GStrCase.cc: Ditto.
      	* mc-boot/GStrCase.h: Ditto.
      	* mc-boot/GStrIO.cc: Ditto.
      	* mc-boot/GStrIO.h: Ditto.
      	* mc-boot/GStrLib.cc: Ditto.
      	* mc-boot/GStrLib.h: Ditto.
      	* mc-boot/GStringConvert.cc: Ditto.
      	* mc-boot/GStringConvert.h: Ditto.
      	* mc-boot/GSysExceptions.h: Ditto.
      	* mc-boot/GSysStorage.cc: Ditto.
      	* mc-boot/GSysStorage.h: Ditto.
      	* mc-boot/GTimeString.cc: Ditto.
      	* mc-boot/GTimeString.h: Ditto.
      	* mc-boot/GUnixArgs.h: Ditto.
      	* mc-boot/Galists.cc: Ditto.
      	* mc-boot/Galists.h: Ditto.
      	* mc-boot/Gdecl.cc: Ditto.
      	* mc-boot/Gdecl.h: Ditto.
      	* mc-boot/Gdtoa.h: Ditto.
      	* mc-boot/Gerrno.h: Ditto.
      	* mc-boot/Gkeyc.cc: Ditto.
      	* mc-boot/Gkeyc.h: Ditto.
      	* mc-boot/Gldtoa.h: Ditto.
      	* mc-boot/Glibc.h: Ditto.
      	* mc-boot/Glibm.h: Ditto.
      	* mc-boot/Glists.cc: Ditto.
      	* mc-boot/Glists.h: Ditto.
      	* mc-boot/GmcComment.cc: Ditto.
      	* mc-boot/GmcComment.h: Ditto.
      	* mc-boot/GmcComp.cc: Ditto.
      	* mc-boot/GmcComp.h: Ditto.
      	* mc-boot/GmcDebug.cc: Ditto.
      	* mc-boot/GmcDebug.h: Ditto.
      	* mc-boot/GmcError.cc: Ditto.
      	* mc-boot/GmcError.h: Ditto.
      	* mc-boot/GmcFileName.cc: Ditto.
      	* mc-boot/GmcFileName.h: Ditto.
      	* mc-boot/GmcLexBuf.cc: Ditto.
      	* mc-boot/GmcLexBuf.h: Ditto.
      	* mc-boot/GmcMetaError.cc: Ditto.
      	* mc-boot/GmcMetaError.h: Ditto.
      	* mc-boot/GmcOptions.cc: Ditto.
      	* mc-boot/GmcOptions.h: Ditto.
      	* mc-boot/GmcPreprocess.cc: Ditto.
      	* mc-boot/GmcPreprocess.h: Ditto.
      	* mc-boot/GmcPretty.cc: Ditto.
      	* mc-boot/GmcPretty.h: Ditto.
      	* mc-boot/GmcPrintf.cc: Ditto.
      	* mc-boot/GmcPrintf.h: Ditto.
      	* mc-boot/GmcQuiet.cc: Ditto.
      	* mc-boot/GmcQuiet.h: Ditto.
      	* mc-boot/GmcReserved.cc: Ditto.
      	* mc-boot/GmcReserved.h: Ditto.
      	* mc-boot/GmcSearch.cc: Ditto.
      	* mc-boot/GmcSearch.h: Ditto.
      	* mc-boot/GmcStack.cc: Ditto.
      	* mc-boot/GmcStack.h: Ditto.
      	* mc-boot/GmcStream.cc: Ditto.
      	* mc-boot/GmcStream.h: Ditto.
      	* mc-boot/Gmcflex.h: Ditto.
      	* mc-boot/Gmcp1.cc: Ditto.
      	* mc-boot/Gmcp1.h: Ditto.
      	* mc-boot/Gmcp2.cc: Ditto.
      	* mc-boot/Gmcp2.h: Ditto.
      	* mc-boot/Gmcp3.cc: Ditto.
      	* mc-boot/Gmcp3.h: Ditto.
      	* mc-boot/Gmcp4.cc: Ditto.
      	* mc-boot/Gmcp4.h: Ditto.
      	* mc-boot/Gmcp5.cc: Ditto.
      	* mc-boot/Gmcp5.h: Ditto.
      	* mc-boot/GnameKey.cc: Ditto.
      	* mc-boot/GnameKey.h: Ditto.
      	* mc-boot/GsymbolKey.cc: Ditto.
      	* mc-boot/GsymbolKey.h: Ditto.
      	* mc-boot/Gtermios.h: Ditto.
      	* mc-boot/Gtop.cc: Ditto.
      	* mc-boot/Gvarargs.cc: Ditto.
      	* mc-boot/Gvarargs.h: Ditto.
      	* mc-boot/Gwlists.cc: Ditto.
      	* mc-boot/Gwlists.h: Ditto.
      	* mc-boot/Gwrapc.h: Ditto.
      	* mc/keyc.mod (checkGccConfigSystem): Add
      	#define INCLUDE_MEMORY.
      	* pge-boot/GASCII.cc: Regenerate.
      	* pge-boot/GASCII.h: Ditto.
      	* pge-boot/GArgs.cc: Ditto.
      	* pge-boot/GArgs.h: Ditto.
      	* pge-boot/GAssertion.cc: Ditto.
      	* pge-boot/GAssertion.h: Ditto.
      	* pge-boot/GBreak.h: Ditto.
      	* pge-boot/GCmdArgs.h: Ditto.
      	* pge-boot/GDebug.cc: Ditto.
      	* pge-boot/GDebug.h: Ditto.
      	* pge-boot/GDynamicStrings.cc: Ditto.
      	* pge-boot/GDynamicStrings.h: Ditto.
      	* pge-boot/GEnvironment.h: Ditto.
      	* pge-boot/GFIO.cc: Ditto.
      	* pge-boot/GFIO.h: Ditto.
      	* pge-boot/GFormatStrings.h: Ditto.
      	* pge-boot/GFpuIO.h: Ditto.
      	* pge-boot/GIO.cc: Ditto.
      	* pge-boot/GIO.h: Ditto.
      	* pge-boot/GIndexing.cc: Ditto.
      	* pge-boot/GIndexing.h: Ditto.
      	* pge-boot/GLists.cc: Ditto.
      	* pge-boot/GLists.h: Ditto.
      	* pge-boot/GM2Dependent.cc: Ditto.
      	* pge-boot/GM2Dependent.h: Ditto.
      	* pge-boot/GM2EXCEPTION.cc: Ditto.
      	* pge-boot/GM2EXCEPTION.h: Ditto.
      	* pge-boot/GM2RTS.cc: Ditto.
      	* pge-boot/GM2RTS.h: Ditto.
      	* pge-boot/GNameKey.cc: Ditto.
      	* pge-boot/GNameKey.h: Ditto.
      	* pge-boot/GNumberIO.cc: Ditto.
      	* pge-boot/GNumberIO.h: Ditto.
      	* pge-boot/GOutput.cc: Ditto.
      	* pge-boot/GOutput.h: Ditto.
      	* pge-boot/GPushBackInput.cc: Ditto.
      	* pge-boot/GPushBackInput.h: Ditto.
      	* pge-boot/GRTExceptions.cc: Ditto.
      	* pge-boot/GRTExceptions.h: Ditto.
      	* pge-boot/GSArgs.h: Ditto.
      	* pge-boot/GSEnvironment.h: Ditto.
      	* pge-boot/GSFIO.cc: Ditto.
      	* pge-boot/GSFIO.h: Ditto.
      	* pge-boot/GSYSTEM.h: Ditto.
      	* pge-boot/GScan.h: Ditto.
      	* pge-boot/GStdIO.cc: Ditto.
      	* pge-boot/GStdIO.h: Ditto.
      	* pge-boot/GStorage.cc: Ditto.
      	* pge-boot/GStorage.h: Ditto.
      	* pge-boot/GStrCase.cc: Ditto.
      	* pge-boot/GStrCase.h: Ditto.
      	* pge-boot/GStrIO.cc: Ditto.
      	* pge-boot/GStrIO.h: Ditto.
      	* pge-boot/GStrLib.cc: Ditto.
      	* pge-boot/GStrLib.h: Ditto.
      	* pge-boot/GStringConvert.h: Ditto.
      	* pge-boot/GSymbolKey.cc: Ditto.
      	* pge-boot/GSymbolKey.h: Ditto.
      	* pge-boot/GSysExceptions.h: Ditto.
      	* pge-boot/GSysStorage.cc: Ditto.
      	* pge-boot/GSysStorage.h: Ditto.
      	* pge-boot/GTimeString.h: Ditto.
      	* pge-boot/GUnixArgs.h: Ditto.
      	* pge-boot/Gbnflex.cc: Ditto.
      	* pge-boot/Gbnflex.h: Ditto.
      	* pge-boot/Gdtoa.h: Ditto.
      	* pge-boot/Gerrno.h: Ditto.
      	* pge-boot/Gldtoa.h: Ditto.
      	* pge-boot/Glibc.h: Ditto.
      	* pge-boot/Glibm.h: Ditto.
      	* pge-boot/Gpge.cc: Ditto.
      	* pge-boot/Gtermios.h: Ditto.
      	* pge-boot/Gwrapc.h: Ditto.
      
      gcc/objc/ChangeLog:
      	PR other/116613
      	* objc-act.cc: Add #define INCLUDE_MEMORY.
      	* objc-encoding.cc: Likewise.
      	* objc-gnu-runtime-abi-01.cc: Likewise.
      	* objc-lang.cc: Likewise.
      	* objc-next-runtime-abi-01.cc: Likewise.
      	* objc-next-runtime-abi-02.cc: Likewise.
      	* objc-runtime-shared-support.cc: Likewise.
      
      gcc/objcp/ChangeLog:: Add #define INCLUDE_MEMORY.
      	PR other/116613
      	* objcp-decl.cc
      	* objcp-lang.cc: Likewise.
      
      gcc/rust/ChangeLog:
      	PR other/116613
      	* resolve/rust-ast-resolve-expr.cc: Add #define INCLUDE_MEMORY.
      	* rust-attribs.cc: Likewise.
      	* rust-system.h: Likewise.
      
      gcc/ChangeLog:
      	PR other/116613
      	* asan.cc: Add #define INCLUDE_MEMORY.
      	* attribs.cc: Likewise.
      	(attr_access::array_as_string): Use
      	diagnostic_context::clone_printer and use unique_ptr.
      	* auto-profile.cc: Add #define INCLUDE_MEMORY.
      	* calls.cc: Likewise.
      	* cfganal.cc: Likewise.
      	* cfgexpand.cc: Likewise.
      	* cfghooks.cc: Likewise.
      	* cfgloop.cc: Likewise.
      	* cgraph.cc: Likewise.
      	* cgraphclones.cc: Likewise.
      	* cgraphunit.cc: Likewise.
      	* collect-utils.cc: Likewise.
      	* collect2.cc: Likewise.
      	* common/config/aarch64/aarch64-common.cc: Likewise.
      	* common/config/arm/arm-common.cc: Likewise.
      	* common/config/avr/avr-common.cc: Likewise.
      	* config/aarch64/aarch64-cc-fusion.cc: Likewise.
      	* config/aarch64/aarch64-early-ra.cc: Likewise.
      	* config/aarch64/aarch64-sve-builtins.cc: Likewise.
      	* config/arc/arc.cc: Likewise.
      	* config/arm/aarch-common.cc: Likewise.
      	* config/arm/arm-mve-builtins.cc: Likewise.
      	* config/avr/avr-devices.cc: Likewise.
      	* config/avr/driver-avr.cc: Likewise.
      	* config/bpf/bpf.cc: Likewise.
      	* config/bpf/btfext-out.cc: Likewise.
      	* config/bpf/core-builtins.cc: Likewise.
      	* config/darwin.cc: Likewise.
      	* config/i386/driver-i386.cc: Likewise.
      	* config/i386/i386-builtins.cc: Likewise.
      	* config/i386/i386-expand.cc: Likewise.
      	* config/i386/i386-features.cc: Likewise.
      	* config/i386/i386-options.cc: Likewise.
      	* config/loongarch/loongarch-builtins.cc: Likewise.
      	* config/mingw/winnt-cxx.cc: Likewise.
      	* config/mingw/winnt.cc: Likewise.
      	* config/mips/mips.cc: Likewise.
      	* config/msp430/driver-msp430.cc: Likewise.
      	* config/nvptx/mkoffload.cc: Likewise.
      	* config/nvptx/nvptx.cc: Likewise.
      	* config/riscv/riscv-avlprop.cc: Likewise.
      	* config/riscv/riscv-vector-builtins.cc: Likewise.
      	* config/riscv/riscv-vsetvl.cc: Likewise.
      	* config/rs6000/driver-rs6000.cc: Likewise.
      	* config/rs6000/host-darwin.cc: Likewise.
      	* config/rs6000/rs6000-c.cc: Likewise.
      	* config/s390/s390-c.cc: Likewise.
      	* config/s390/s390.cc: Likewise.
      	* config/sol2-cxx.cc: Likewise.
      	* config/vms/vms-c.cc: Likewise.
      	* config/xtensa/xtensa-dynconfig.cc: Likewise.
      	* coroutine-passes.cc: Likewise.
      	* coverage.cc: Likewise.
      	* data-streamer-in.cc: Likewise.
      	* data-streamer-out.cc: Likewise.
      	* data-streamer.cc: Likewise.
      	* diagnostic-buffer.h (diagnostic_buffer::~diagnostic_buffer):
      	Delete.
      	(diagnostic_buffer::m_per_format_buffer): Use std::unique_ptr.
      	* diagnostic-client-data-hooks.h (make_compiler_data_hooks): Use
      	std::unique_ptr for return type.
      	* diagnostic-format-json.cc
      	(json_output_format::make_per_format_buffer): Likewise.
      	(diagnostic_output_format_init_json): Update for usage of
      	std::unique_ptr in set_output_format.
      	* diagnostic-format-sarif.cc
      	(sarif_output_format::make_per_format_buffer): Use std::unique_ptr
      	for return type.
      	(diagnostic_output_format_init_sarif): Update for usage of
      	std::unique_ptr.
      	(test_message_with_embedded_link): Likewise for set_urlifier.
      	* diagnostic-format-text.cc: Add #define INCLUDE_MEMORY.  Include
      	"make-unique.h".
      	(diagnostic_text_output_format::set_buffer): Use std::unique_ptr.
      	* diagnostic-format-text.h
      	(diagnostic_text_output_format::set_buffer): Likewise.
      	* diagnostic-format.h
      	(diagnostic_output_format::make_per_format_buffer): Likewise.
      	* diagnostic-global-context.cc:
      	* diagnostic-macro-unwinding.cc: Likewise.
      	* diagnostic-show-locus.cc: Likewise.
      	* diagnostic-spec.cc: Likewise.
      	* diagnostic.cc (diagnostic_context::set_output_format): Use
      	std::unique_ptr for input.
      	(diagnostic_context::set_client_data_hooks): Likewise.
      	(diagnostic_context::set_option_manager): Likewise.
      	(diagnostic_context::set_urlifier): Likewise.
      	(diagnostic_context::set_diagnostic_buffer): Update for use of
      	std::unique_ptr.
      	(diagnostic_buffer::diagnostic_buffer): Likewise.
      	(diagnostic_buffer::~diagnostic_buffer): Delete.
      	* diagnostic.h: Complain if INCLUDE_MEMORY was not defined.
      	(diagnostic_context::set_output_format): Use std::unique_ptr for
      	input.
      	(diagnostic_context::set_client_data_hooks): Likewise.
      	(diagnostic_context::set_option_manager): Likewise.
      	(diagnostic_context::set_urlifier): Likewise.
      	(diagnostic_context::clone_printer): New.
      	(diagnostic_context::m_printer): Update comment.
      	(diagnostic_context::m_option_mgr): Likewise.
      	(diagnostic_context::m_urlifier): Likewise.
      	(diagnostic_context::m_edit_context_ptr): Likewise.
      	(diagnostic_context::m_output_format): Likewise.
      	(diagnostic_context::m_client_data_hooks): Likewise.
      	(diagnostic_context::m_theme): Likewise.
      	* digraph.cc: Add #define INCLUDE_MEMORY.
      	* dwarf2out.cc: Likewise.
      	* edit-context.cc: Likewise.
      	* except.cc: Likewise.
      	* expr.cc: Likewise.
      	* file-prefix-map.cc: Likewise.
      	* final.cc: Likewise.
      	* fwprop.cc: Likewise.
      	* gcc-plugin.h: Likewise.
      	* gcc-rich-location.cc: Likewise.
      	* gcc-urlifier.cc: Likewise.  Add #include "make-unique.h".
      	(make_gcc_urlifier): Use std::unique_ptr and ::make_unique.
      	* gcc-urlifier.h (make_gcc_urlifier): Use std::unique_ptr.
      	* gcc.cc: Add #define INCLUDE_MEMORY.  Include
      	"pretty-print-urlifier.h".
      	* gcov-dump.cc: Add #define INCLUDE_MEMORY.
      	* gcov-tool.cc: Likewise.
      	* gengtype.cc (open_base_files): Likewise to output.
      	* genmatch.cc: Likewise.
      	* gimple-fold.cc: Likewise.
      	* gimple-harden-conditionals.cc: Likewise.
      	* gimple-harden-control-flow.cc: Likewise.
      	* gimple-if-to-switch.cc: Likewise.
      	* gimple-lower-bitint.cc: Likewise.
      	* gimple-predicate-analysis.cc: Likewise.
      	* gimple-pretty-print.cc: Likewise.
      	* gimple-range-cache.cc: Likewise.
      	* gimple-range-edge.cc: Likewise.
      	* gimple-range-fold.cc: Likewise.
      	* gimple-range-gori.cc: Likewise.
      	* gimple-range-infer.cc: Likewise.
      	* gimple-range-op.cc: Likewise.
      	* gimple-range-path.cc: Likewise.
      	* gimple-range-phi.cc: Likewise.
      	* gimple-range-trace.cc: Likewise.
      	* gimple-range.cc: Likewise.
      	* gimple-ssa-backprop.cc: Likewise.
      	* gimple-ssa-sprintf.cc: Likewise.
      	* gimple-ssa-store-merging.cc: Likewise.
      	* gimple-ssa-strength-reduction.cc: Likewise.
      	* gimple-ssa-warn-access.cc: Likewise.
      	* gimple-ssa-warn-alloca.cc: Likewise.
      	* gimple-ssa-warn-restrict.cc: Likewise.
      	* gimple-streamer-in.cc: Likewise.
      	* gimple-streamer-out.cc: Likewise.
      	* gimple.cc: Likewise.
      	* gimplify.cc: Likewise.
      	* graph.cc: Likewise.
      	* graphviz.cc: Likewise.
      	* input.cc: Likewise.
      	* ipa-cp.cc: Likewise.
      	* ipa-devirt.cc: Likewise.
      	* ipa-fnsummary.cc: Likewise.
      	* ipa-free-lang-data.cc: Likewise.
      	* ipa-icf-gimple.cc: Likewise.
      	* ipa-icf.cc: Likewise.
      	* ipa-inline-analysis.cc: Likewise.
      	* ipa-inline.cc: Likewise.
      	* ipa-modref-tree.cc: Likewise.
      	* ipa-modref.cc: Likewise.
      	* ipa-param-manipulation.cc: Likewise.
      	* ipa-polymorphic-call.cc: Likewise.
      	* ipa-predicate.cc: Likewise.
      	* ipa-profile.cc: Likewise.
      	* ipa-prop.cc: Likewise.
      	* ipa-pure-const.cc: Likewise.
      	* ipa-reference.cc: Likewise.
      	* ipa-split.cc: Likewise.
      	* ipa-sra.cc: Likewise.
      	* ipa-strub.cc: Likewise.
      	* ipa-utils.cc: Likewise.
      	* langhooks.cc: Likewise.
      	* late-combine.cc: Likewise.
      	* lto-cgraph.cc: Likewise.
      	* lto-compress.cc: Likewise.
      	* lto-opts.cc: Likewise.
      	* lto-section-in.cc: Likewise.
      	* lto-section-out.cc: Likewise.
      	* lto-streamer-in.cc: Likewise.
      	* lto-streamer-out.cc: Likewise.
      	* lto-streamer.cc: Likewise.
      	* lto-wrapper.cc: Likewise.  Include "make-unique.h".
      	(main): Use ::make_unique when creating option manager.
      	* multiple_target.cc: Likewise.
      	* omp-expand.cc: Likewise.
      	* omp-general.cc: Likewise.
      	* omp-low.cc: Likewise.
      	* omp-oacc-neuter-broadcast.cc: Likewise.
      	* omp-offload.cc: Likewise.
      	* omp-simd-clone.cc: Likewise.
      	* optc-gen.awk: Likewise in output.
      	* optc-save-gen.awk: Likewise in output.
      	* options-urls-cc-gen.awk: Likewise in output.
      	* opts-common.cc: Likewise.
      	* opts-global.cc: Likewise.
      	* opts.cc: Likewise.
      	* pair-fusion.cc: Likewise.
      	* passes.cc: Likewise.
      	* pointer-query.cc: Likewise.
      	* predict.cc: Likewise.
      	* pretty-print.cc (pretty_printer::clone): Use std::unique_ptr and
      	::make_unique.
      	* pretty-print.h: Complain if INCLUDE_MEMORY is not defined.
      	(pretty_printer::clone): Use std::unique_ptr.
      	* print-rtl.cc: Add #define INCLUDE_MEMORY.
      	* print-tree.cc: Likewise.
      	* profile-count.cc: Likewise.
      	* range-op-float.cc: Likewise.
      	* range-op-ptr.cc: Likewise.
      	* range-op.cc: Likewise.
      	* range.cc: Likewise.
      	* read-rtl-function.cc: Likewise.
      	* rtl-error.cc: Likewise.
      	* rtl-ssa/accesses.cc: Likewise.
      	* rtl-ssa/blocks.cc: Likewise.
      	* rtl-ssa/changes.cc: Likewise.
      	* rtl-ssa/functions.cc: Likewise.
      	* rtl-ssa/insns.cc: Likewise.
      	* rtl-ssa/movement.cc: Likewise.
      	* rtl-tests.cc: Likewise.
      	* sanopt.cc: Likewise.
      	* sched-rgn.cc: Likewise.
      	* selftest-diagnostic-path.cc: Likewise.
      	* selftest-diagnostic.cc: Likewise.
      	* splay-tree-utils.cc: Likewise.
      	* sreal.cc: Likewise.
      	* stmt.cc: Likewise.
      	* substring-locations.cc: Likewise.
      	* symtab-clones.cc: Likewise.
      	* symtab-thunks.cc: Likewise.
      	* symtab.cc: Likewise.
      	* text-art/box-drawing.cc: Likewise.
      	* text-art/canvas.cc: Likewise.
      	* text-art/ruler.cc: Likewise.
      	* text-art/selftests.cc: Likewise.
      	* text-art/theme.cc: Likewise.
      	* toplev.cc: Likewise.  Include "make-unique.h".
      	(general_init): Use ::make_unique when setting option_manager.
      	* trans-mem.cc: Add #define INCLUDE_MEMORY.
      	* tree-affine.cc: Likewise.
      	* tree-call-cdce.cc: Likewise.
      	* tree-cfg.cc: Likewise.
      	* tree-chrec.cc: Likewise.
      	* tree-dfa.cc: Likewise.
      	* tree-diagnostic-client-data-hooks.cc: Include "make-unique.h".
      	(make_compiler_data_hooks): Use std::unique_ptr and ::make_unique.
      	* tree-diagnostic.cc: Add #define INCLUDE_MEMORY.
      	* tree-dump.cc: Likewise.
      	* tree-inline.cc: Likewise.
      	* tree-into-ssa.cc: Likewise.
      	* tree-logical-location.cc: Likewise.
      	* tree-nested.cc: Likewise.
      	* tree-nrv.cc: Likewise.
      	* tree-object-size.cc: Likewise.
      	* tree-outof-ssa.cc: Likewise.
      	* tree-pretty-print.cc: Likewise.
      	* tree-profile.cc: Likewise.
      	* tree-scalar-evolution.cc: Likewise.
      	* tree-sra.cc: Likewise.
      	* tree-ssa-address.cc: Likewise.
      	* tree-ssa-alias.cc: Likewise.
      	* tree-ssa-ccp.cc: Likewise.
      	* tree-ssa-coalesce.cc: Likewise.
      	* tree-ssa-copy.cc: Likewise.
      	* tree-ssa-dce.cc: Likewise.
      	* tree-ssa-dom.cc: Likewise.
      	* tree-ssa-forwprop.cc: Likewise.
      	* tree-ssa-ifcombine.cc: Likewise.
      	* tree-ssa-loop-ch.cc: Likewise.
      	* tree-ssa-loop-im.cc: Likewise.
      	* tree-ssa-loop-manip.cc: Likewise.
      	* tree-ssa-loop-niter.cc: Likewise.
      	* tree-ssa-loop-split.cc: Likewise.
      	* tree-ssa-math-opts.cc: Likewise.
      	* tree-ssa-operands.cc: Likewise.
      	* tree-ssa-phiprop.cc: Likewise.
      	* tree-ssa-pre.cc: Likewise.
      	* tree-ssa-propagate.cc: Likewise.
      	* tree-ssa-reassoc.cc: Likewise.
      	* tree-ssa-sccvn.cc: Likewise.
      	* tree-ssa-scopedtables.cc: Likewise.
      	* tree-ssa-sink.cc: Likewise.
      	* tree-ssa-strlen.cc: Likewise.
      	* tree-ssa-structalias.cc: Likewise.
      	* tree-ssa-ter.cc: Likewise.
      	* tree-ssa-uninit.cc: Likewise.
      	* tree-ssa.cc: Likewise.
      	* tree-ssanames.cc: Likewise.
      	* tree-stdarg.cc: Likewise.
      	* tree-streamer-in.cc: Likewise.
      	* tree-streamer-out.cc: Likewise.
      	* tree-streamer.cc: Likewise.
      	* tree-switch-conversion.cc: Likewise.
      	* tree-tailcall.cc: Likewise.
      	* tree-vrp.cc: Likewise.
      	* tree.cc: Likewise.
      	* ubsan.cc: Likewise.
      	* value-pointer-equiv.cc: Likewise.
      	* value-prof.cc: Likewise.
      	* value-query.cc: Likewise.
      	* value-range-pretty-print.cc: Likewise.
      	* value-range-storage.cc: Likewise.
      	* value-range.cc: Likewise.
      	* value-relation.cc: Likewise.
      	* var-tracking.cc: Likewise.
      	* varpool.cc: Likewise.
      	* vr-values.cc: Likewise.
      	* wide-int-print.cc: Likewise.
      
      gcc/testsuite/ChangeLog:
      	PR other/116613
      	* gcc.dg/plugin/diagnostic_group_plugin.c: Update for use of
      	std::unique_ptr.
      	* gcc.dg/plugin/diagnostic_plugin_xhtml_format.c: Likewise.
      	* gcc.dg/plugin/ggcplug.c: Likewise.
      
      libgcc/ChangeLog:
      	PR other/116613
      	* libgcov-util.c: Add #define INCLUDE_MEMORY.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      Co-authored-by: default avatarGaius Mulley <gaiusmod2@gmail.com>
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      bf43fe6a
    • David Malcolm's avatar
      Add comment about pp_format to diagnostic_context::report_diagnostic · fc1a0019
      David Malcolm authored
      
      No functional change intended.
      
      gcc/ChangeLog:
      	* diagnostic.cc (diagnostic_context::report_diagnostic): Add
      	comment about interaction of this code with pretty-print
      	formatting phaes.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      fc1a0019
    • Ricardo Jesus's avatar
      aarch64: libstdc++: Use shufflevector instead of shuffle in opt_random.h · cc33531d
      Ricardo Jesus authored
      
      This patch modifies the implementation of the vectorized mersenne
      twister random number generator to use __builtin_shufflevector instead
      of __builtin_shuffle. This makes it (almost) compatible with Clang.
      
      To make the implementation fully compatible with Clang, Clang will need
      to support internal Neon types like __Uint8x16_t and __Uint32x4_t, which
      currently it does not. This looks like an oversight in Clang and so will
      be addressed separately.
      
      I see no codegen change with this patch.
      
      Bootstrapped and tested on aarch64-none-linux-gnu.
      
      libstdc++-v3/ChangeLog:
      
      	* config/cpu/aarch64/opt/ext/opt_random.h (__VEXT): Replace uses
      	of __builtin_shuffle with __builtin_shufflevector.
      	(__aarch64_lsl_128): Move shift amount to a template parameter.
      	(__aarch64_lsr_128): Move shift amount to a template parameter.
      	(__aarch64_recursion): Update call sites of __aarch64_lsl_128
      	and __aarch64_lsr_128.
      
      Signed-off-by: default avatarRicardo Jesus <rjj@nvidia.com>
      Unverified
      cc33531d
    • Richard Sandiford's avatar
      Record nonzero bits in the irange_bitmask of POLY_INT_CSTs · b02503d3
      Richard Sandiford authored
      At the moment, ranger punts entirely on POLY_INT_CSTs.  Numerical
      ranges are a bit difficult, unless we do start modelling bounds on
      the indeterminates.  But we can at least track the nonzero bits.
      
      gcc/
      	* value-query.cc (range_query::get_tree_range): Use get_nonzero_bits
      	to populate the irange_bitmask of a POLY_INT_CST.
      
      gcc/testsuite/
      	* gcc.target/aarch64/sve/cnt_fold_6.c: New test.
      b02503d3
    • Richard Sandiford's avatar
      Try to simplify (X >> C1) * (C2 << C1) -> X * C2 · af19e46c
      Richard Sandiford authored
      This patch adds a rule to simplify (X >> C1) * (C2 << C1) -> X * C2
      when the low C1 bits of X are known to be zero.  As with the earlier
      X >> C1 << (C2 + C1) patch, any single conversion is allowed between
      the shift and the multiplication.
      
      gcc/
      	* match.pd: Simplify (X >> C1) * (C2 << C1) -> X * C2 if the
      	low C1 bits of X are zero.
      
      gcc/testsuite/
      	* gcc.dg/tree-ssa/shifts-3.c: New test.
      	* gcc.dg/tree-ssa/shifts-4.c: Likewise.
      	* gcc.target/aarch64/sve/cnt_fold_5.c: Likewise.
      af19e46c
    • Richard Sandiford's avatar
      Handle POLY_INT_CSTs in get_nonzero_bits · d6c4badf
      Richard Sandiford authored
      This patch extends get_nonzero_bits to handle POLY_INT_CSTs,
      The easiest (but also most useful) case is that the number
      of trailing zeros in the runtime value is at least the number
      of trailing zeros in each individual component.
      
      In principle, we could do this for coeffs 1 and above only,
      and then OR in ceoff 0.  This would give ~0x11 for [14, 32], say.
      But that's future work.
      
      gcc/
      	* tree-ssanames.cc (get_nonzero_bits): Handle POLY_INT_CSTs.
      	* match.pd (with_possible_nonzero_bits): Likewise.
      
      gcc/testsuite/
      	* gcc.target/aarch64/sve/cnt_fold_4.c: New test.
      d6c4badf
    • Richard Sandiford's avatar
      Try to simplify (X >> C1) << (C1 + C2) -> X << C2 · ec8e8d35
      Richard Sandiford authored
      This patch adds a rule to simplify (X >> C1) << (C1 + C2) -> X << C2
      when the low C1 bits of X are known to be zero.
      
      Any single conversion can take place between the shifts.  E.g. for
      a truncating conversion, any extra bits of X that are preserved by
      truncating after the shift are immediately lost by the shift left.
      And the sign bits used for an extending conversion are the same as
      the sign bits used for the rshift.  (A double conversion of say
      int->unsigned->uint64_t would be wrong though.)
      
      gcc/
      	* match.pd: Simplify (X >> C1) << (C1 + C2) -> X << C2 if the
      	low C1 bits of X are zero.
      
      gcc/testsuite/
      	* gcc.dg/tree-ssa/shifts-1.c: New test.
      	* gcc.dg/tree-ssa/shifts-2.c: Likewise.
      ec8e8d35
    • Richard Sandiford's avatar
      Generalise ((X /[ex] A) +- B) * A -> X +- A * B rule · 8d01bc7d
      Richard Sandiford authored
      match.pd had a rule to simplify ((X /[ex] A) +- B) * A -> X +- A * B
      when A and B are INTEGER_CSTs.  This patch extends it to handle the
      case where the outer multiplication is by a factor of A, not just
      A itself.  It also handles addition and multiplication of poly_ints.
      (Exact division by a poly_int seems unlikely.)
      
      gcc/
      	* match.pd: Generalise ((X /[ex] A) +- B) * A -> X +- A * B rule
      	to ((X /[ex] C1) +- C2) * (C1 * C3) -> (X * C3) +- (C1 * C2 * C3).
      
      gcc/testsuite/
      	* gcc.dg/tree-ssa/mulexactdiv-5.c: New test.
      	* gcc.dg/tree-ssa/mulexactdiv-6.c: Likewise.
      	* gcc.dg/tree-ssa/mulexactdiv-7.c: Likewise.
      	* gcc.dg/tree-ssa/mulexactdiv-8.c: Likewise.
      	* gcc.target/aarch64/sve/cnt_fold_3.c: Likewise.
      8d01bc7d
    • Richard Sandiford's avatar
      Simplify (X /[ex] C1) * (C1 * C2) -> X * C2 · b381e84c
      Richard Sandiford authored
      gcc/
      	* match.pd: Simplify (X /[ex] C1) * (C1 * C2) -> X * C2.
      
      gcc/testsuite/
      	* gcc.dg/tree-ssa/mulexactdiv-1.c: New test.
      	* gcc.dg/tree-ssa/mulexactdiv-2.c: Likewise.
      	* gcc.dg/tree-ssa/mulexactdiv-3.c: Likewise.
      	* gcc.dg/tree-ssa/mulexactdiv-4.c: Likewise.
      	* gcc.target/aarch64/sve/cnt_fold_1.c: Likewise.
      	* gcc.target/aarch64/sve/cnt_fold_2.c: Likewise.
      b381e84c
    • Richard Sandiford's avatar
      Use get_nonzero_bits to simplify trunc_div to exact_div · e2e798b8
      Richard Sandiford authored
      There are a limited number of existing rules that benefit from
      knowing that a division is exact.  Later patches will add more.
      
      gcc/
      	* match.pd: Simplify X / (1 << C) to X /[ex] (1 << C) if the
      	low C bits of X are clear
      
      gcc/testsuite/
      	* gcc.dg/tree-ssa/cmpexactdiv-6.c: New test.
      e2e798b8
    • Richard Sandiford's avatar
      Make more places handle exact_div like trunc_div · 3e93828e
      Richard Sandiford authored
      I tried to look for places where we were handling TRUNC_DIV_EXPR
      more favourably than EXACT_DIV_EXPR.
      
      Most of the places that I looked at but didn't change were handling
      div/mod pairs.  But there's bound to be others I missed...
      
      gcc/
      	* match.pd: Extend some rules to handle exact_div like trunc_div.
      	* tree.h (trunc_or_exact_div_p): New function.
      	* tree-ssa-loop-niter.cc (is_rshift_by_1): Use it.
      	* tree-ssa-loop-ivopts.cc (force_expr_to_var_cost): Handle
      	EXACT_DIV_EXPR.
      3e93828e
    • Andrew MacLeod's avatar
      Implement pointer_or_operator. · f24e1087
      Andrew MacLeod authored
      The class pointer_or is no longer used, and can be removed.  Its
      functionality was never moved to the new dispatch system.
      This implements operator_bitwise_or::fold_range() for prange operands.
      
      	* range-op-mixed.h (operator_bitwise_or::fold_range): Add prange
      	variant.
      	* range-op-ptr.cc (class pointer_or_operator): Remove.
      	(pointer_or_operator::op1_range): Remove.
      	(pointer_or_operator::op2_range): Remove.
      	(pointer_or_operator::wi_fold): Remove.
      	(operator_bitwise_or::fold_range): New prange variant.
      f24e1087
    • Andrew MacLeod's avatar
      Remove pointer_and_operator. · f9d94c1d
      Andrew MacLeod authored
      This operator class predates the dispatch system, and is no longer used.
      The functionality of wi_fold has been replaced by
      operator_bitwise_and::fold_range with prange operaands.
      
      	* range-op-ptr.cc (class pointer_and_operator): Remove.
      	(pointer_and_operator::wi_fold): Remove.
      f9d94c1d
    • Andrew MacLeod's avatar
      Remove pointer_min_max_operator. · 7173e2ff
      Andrew MacLeod authored
      The pointer_min_max_operator class was used before the current dispatch
      system was created.  These operations have been transferred to
      operator_min::fold_range () and operator_max::fold_range () with prange
      operands.
      
      This class is no longer used for anything, delete it.
      
      	* range-op-ptr.cc (class pointer_min_max_operator): Remove.
      	(pointer_min_max_operator::wi_fold): Remove.
      7173e2ff
    • Andrew MacLeod's avatar
      Cleanup pointer_plus_operator. · 20d80c84
      Andrew MacLeod authored
      The POINTER_PLUS operator still carries some remnamts of the old
      irange interface, which is now dead code with prange.
      
      	* range-op-ptr.cc (pointer_plus_operator::wi_fold): Remove.
      	(pointer_plus_operator::op2_range): Remove irange variant.
      	(pointer_plus_operator::update_bitmask): Likewise.
      20d80c84
    • Jakub Jelinek's avatar
      c++: Further fix for get_member_function_from_ptrfunc [PR117259] · b25d3201
      Jakub Jelinek authored
      The following testcase shows that the previous get_member_function_from_ptrfunc
      changes weren't sufficient and we still have cases where
      -fsanitize=undefined with pointers to member functions can cause wrong code
      being generated and related false positive warnings.
      
      The problem is that save_expr doesn't always create SAVE_EXPR, it can skip
      some invariant arithmetics and in the end it could be really large
      expressions which would be evaluated several times (and what is worse, with
      -fsanitize=undefined those expressions then can have SAVE_EXPRs added to
      their subparts for -fsanitize=bounds or -fsanitize=null or
      -fsanitize=alignment instrumentation).  Tried to just build1 a SAVE_EXPR
      + add TREE_SIDE_EFFECTS instead of save_expr, but that doesn't work either,
      because cp_fold happily optimizes those SAVE_EXPRs away when it sees
      SAVE_EXPR operand is tree_invariant_p.
      
      So, the following patch instead of using save_expr or building SAVE_EXPR
      manually builds a TARGET_EXPR.  Both types are pointers, so it doesn't need
      to be destroyed in any way, but TARGET_EXPR is what doesn't get optimized
      away immediately.
      
      2024-10-24  Jakub Jelinek  <jakub@redhat.com>
      
      	PR c++/117259
      	* typeck.cc (get_member_function_from_ptrfunc): Use force_target_expr
      	rather than save_expr for instance_ptr and function.  Don't call it
      	for TREE_CONSTANT.
      
      	* g++.dg/ubsan/pr117259.C: New test.
      b25d3201
    • Jakub Jelinek's avatar
      asan: Fix up build_check_stmt gsi handling [PR117209] · 885143fa
      Jakub Jelinek authored
      gsi_safe_insert_before properly updates gsi_bb in gimple_stmt_iterator
      in case it splits objects, but unfortunately build_check_stmt was in
      some places (but not others) using a copy of the iterator rather than
      the iterator passed from callers and so didn't propagate that to callers.
      I guess it didn't matter much before when it was just using
      gsi_insert_before as that really didn't change the iterator.
      The !before_p case is apparently dead code, nothing is calling it with
      before_p=false since around 4.9.
      
      2024-10-24  Jakub Jelinek  <jakub@redhat.com>
      
      	PR sanitizer/117209
      	* asan.cc (maybe_cast_to_ptrmode): Formatting fix.
      	(build_check_stmt): Don't copy *iter into gsi, perform all
      	the updates on iter directly.
      
      	* gcc.dg/asan/pr117209.c: New test.
      885143fa
    • Jennifer Schmitz's avatar
      SVE intrinsics: Fold svsra with op1 all zeros to svlsr/svasr. · f6fbc0d2
      Jennifer Schmitz authored
      
      A common idiom in intrinsics loops is to have accumulator intrinsics
      in an unrolled loop with an accumulator initialized to zero at the beginning.
      Propagating the initial zero accumulator into the first iteration
      of the loop and simplifying the first accumulate instruction is a
      desirable transformation that we should teach GCC.
      Therefore, this patch folds svsra to svlsr/svasr if op1 is all zeros,
      producing the lower latency instructions LSR/ASR instead of USRA/SSRA.
      We implemented this optimization in svsra_impl::fold.
      
      Tests were added to check the produced assembly for use of LSR/ASR.
      
      The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
      OK for mainline?
      
      Signed-off-by: default avatarJennifer Schmitz <jschmitz@nvidia.com>
      
      gcc/
      	* config/aarch64/aarch64-sve-builtins-sve2.cc
      	(svsra_impl::fold): Fold svsra to svlsr/svasr if op1 is all zeros.
      
      gcc/testsuite/
      	* gcc.target/aarch64/sve2/acle/asm/sra_s32.c: New test.
      	* gcc.target/aarch64/sve2/acle/asm/sra_s64.c: Likewise.
      	* gcc.target/aarch64/sve2/acle/asm/sra_u32.c: Likewise.
      	* gcc.target/aarch64/sve2/acle/asm/sra_u64.c: Likewise.
      f6fbc0d2
    • Soumya AR's avatar
      SVE intrinsics: Fold constant operands for svlsl. · 3e7549ec
      Soumya AR authored
      
      This patch implements constant folding for svlsl. Test cases have been added to
      check for the following cases:
      
      Zero, merge, and don't care predication.
      Shift by 0.
      Shift by register width.
      Overflow shift on signed and unsigned integers.
      Shift on a negative integer.
      Maximum possible shift, eg. shift by 7 on an 8-bit integer.
      
      The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
      OK for mainline?
      
      Signed-off-by: default avatarSoumya AR <soumyaa@nvidia.com>
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64-sve-builtins-base.cc (svlsl_impl::fold):
      	Try constant folding.
      	* config/aarch64/aarch64-sve-builtins.cc (aarch64_const_binop):
      	Return 0 if shift is out of range.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/aarch64/sve/const_fold_lsl_1.c: New test.
      Unverified
      3e7549ec
    • Jennifer Schmitz's avatar
      SVE intrinsics: Fold division and multiplication by -1 to neg · fc40202c
      Jennifer Schmitz authored
      
      Because a neg instruction has lower latency and higher throughput than
      sdiv and mul, svdiv and svmul by -1 can be folded to svneg. For svdiv,
      this is already implemented on the RTL level; for svmul, the
      optimization was still missing.
      This patch implements folding to svneg for both operations using the
      gimple_folder. For svdiv, the transform is applied if the divisor is -1.
      Svmul is folded if either of the operands is -1. A case distinction of
      the predication is made to account for the fact that svneg_m has 3 arguments
      (argument 0 holds the values for the inactive lanes), while svneg_x and
      svneg_z have only 2 arguments.
      Tests were added or adjusted to check the produced assembly and runtime
      tests were added to check correctness.
      
      The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
      OK for mainline?
      
      Signed-off-by: default avatarJennifer Schmitz <jschmitz@nvidia.com>
      
      gcc/
      	* config/aarch64/aarch64-sve-builtins-base.cc (svdiv_impl::fold):
      	Fold division by -1 to svneg.
      	(svmul_impl::fold): Fold multiplication by -1 to svneg.
      
      gcc/testsuite/
      	* gcc.target/aarch64/sve/acle/asm/div_s32.c: New test.
      	* gcc.target/aarch64/sve/acle/asm/mul_s16.c: Adjust expected outcome.
      	* gcc.target/aarch64/sve/acle/asm/mul_s32.c: New test.
      	* gcc.target/aarch64/sve/acle/asm/mul_s64.c: Adjust expected outcome.
      	* gcc.target/aarch64/sve/acle/asm/mul_s8.c: Likewise.
      	* gcc.target/aarch64/sve/div_const_run.c: New test.
      	* gcc.target/aarch64/sve/mul_const_run.c: Likewise.
      fc40202c
    • Jennifer Schmitz's avatar
      SVE intrinsics: Add constant folding for svindex. · 90e38c4f
      Jennifer Schmitz authored
      
      This patch folds svindex with constant arguments into a vector series.
      We implemented this in svindex_impl::fold using the function build_vec_series.
      For example,
      svuint64_t f1 ()
      {
        return svindex_u642 (10, 3);
      }
      compiled with -O2 -march=armv8.2-a+sve, is folded to {10, 13, 16, ...}
      in the gimple pass lower.
      This optimization benefits cases where svindex is used in combination with
      other gimple-level optimizations.
      For example,
      svuint64_t f2 ()
      {
          return svmul_x (svptrue_b64 (), svindex_u64 (10, 3), 5);
      }
      has previously been compiled to
      f2:
              index   z0.d, #10, #3
              mul     z0.d, z0.d, #5
              ret
      Now, it is compiled to
      f2:
              mov     x0, 50
              index   z0.d, x0, #15
              ret
      
      We added test cases checking
      - the application of the transform during gimple for constant arguments,
      - the interaction with another gimple-level optimization.
      
      The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
      OK for mainline?
      
      Signed-off-by: default avatarJennifer Schmitz <jschmitz@nvidia.com>
      
      gcc/
      	* config/aarch64/aarch64-sve-builtins-base.cc
      	(svindex_impl::fold): Add constant folding.
      
      gcc/testsuite/
      	* gcc.target/aarch64/sve/index_const_fold.c: New test.
      90e38c4f
    • Wang Pengcheng's avatar
      [PATCH] RISC-V: override alignment of function/jump/loop · 078f7c4f
      Wang Pengcheng authored
      
      Just like what AArch64 has done.
      
      Signed-off-by: default avatarWang Pengcheng <wangpengcheng.pp@bytedance.com>
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv.cc (struct riscv_tune_param): Add new
      	tune options.
      	(riscv_override_options_internal): Override the default alignment
      	when not optimizing for size.
      078f7c4f
    • Yang Yujie's avatar
      libffi: LoongArch: Fix soft-float builds of libffi · a616b7e1
      Yang Yujie authored
      This patch correspond to the upstream PR:
      https://github.com/libffi/libffi/pull/817
      And has been merged.
      
      libffi/ChangeLog:
      
      	* src/loongarch64/ffi.c: Avoid defining floats
      	in struct call_context if the ABI is soft-float.
      a616b7e1
    • Jakub Jelinek's avatar
      testsuite: Fix up pr116488.c and pr117226.c tests [PR116488] · 8df549fc
      Jakub Jelinek authored
      Hi!
      
      On Mon, Oct 21, 2024 at 01:39:52PM -0600, Jeff Law wrote:
      > 	* gcc.dg/torture/pr116488.c: New test.
      > 	* gcc.dg/torture/pr117226.c: New test.
      
      These two tests FAIL on powerpc64le-linux (and I assume on all other
      -funsigned-char defaulting targets).
      
      The following patch fixes that, tested on powerpc64le-linux and
      x86_64-linux (-m32/-m64); on x86_64 also tested before/after with
      -funsigned-char.
      
      Ok for trunk?
      
      2024-10-22  Jakub Jelinek  <jakub@redhat.com>
      
      	PR rtl-optimization/116488
      	PR rtl-optimization/117226
      	* gcc.dg/torture/pr116488.c (c, e): Change type from char to
      	signed char.
      	* gcc.dg/torture/pr117226.c (main): Change f type from char to
      	signed char.
      8df549fc
    • Pan Li's avatar
      RISC-V: Add testcases for form 4 of signed vector SAT_ADD · 03b469ee
      Pan Li authored
      
      Form 4:
        #define DEF_VEC_SAT_S_ADD_FMT_4(T, UT, MIN, MAX)                     \
        void __attribute__((noinline))                                       \
        vec_sat_s_add_##T##_fmt_4 (T *out, T *op_1, T *op_2, unsigned limit) \
        {                                                                    \
          unsigned i;                                                        \
          for (i = 0; i < limit; i++)                                        \
            {                                                                \
              T x = op_1[i];                                                 \
              T y = op_2[i];                                                 \
              T sum;                                                         \
              bool overflow = __builtin_add_overflow (x, y, &sum);           \
              out[i] = !overflow ? sum : x < 0 ? MIN : MAX;                  \
            }                                                                \
        }
      
      DEF_VEC_SAT_S_ADD_FMT_4 (int8_t, uint8_t, INT8_MIN, INT8_MAX)
      
      The below test are passed for this patch.
      * The rv64gcv fully regression test.
      
      It is test only patch and obvious up to a point, will commit it
      directly if no comments in next 48H.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/vec_sat_arith.h: Add test helper macros.
      	* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-13.c: New test.
      	* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-14.c: New test.
      	* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-15.c: New test.
      	* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-16.c: New test.
      	* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-13.c: New test.
      	* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-14.c: New test.
      	* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-15.c: New test.
      	* gcc.target/riscv/rvv/autovec/binop/vec_sat_s_add-run-16.c: New test.
      
      Signed-off-by: default avatarPan Li <pan2.li@intel.com>
      Signed-off-by: default avatarPan Li <pan2.li@intel.com>
      03b469ee
    • GCC Administrator's avatar
      Daily bump. · fa546b66
      GCC Administrator authored
      fa546b66
  2. Oct 23, 2024
    • Andrew Pinski's avatar
      aarch64: Fix warning in aarch64_ptrue_reg · 820464ef
      Andrew Pinski authored
      
      After r15-4579-g9ffcf1f193b477, we get the following warning/error while bootstrapping on aarch64:
      ```
      ../../gcc/gcc/config/aarch64/aarch64.cc: In function ‘rtx_def* aarch64_ptrue_reg(machine_mode, unsigned int)’:
      ../../gcc/gcc/config/aarch64/aarch64.cc:3643:21: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
       3643 |   for (int i = 0; i < vl; i++)
            |                   ~~^~~~
      ```
      
      This changes the type of i to unsigned to match the type of vl.
      
      Pushed as obvious after a bootstrap/test on aarch64-linux-gnu.
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64.cc (aarch64_ptrue_reg): Fix type
      	of induction variable i.
      
      Signed-off-by: default avatarAndrew Pinski <quic_apinski@quicinc.com>
      820464ef
    • Andrew Pinski's avatar
      match: Reject non-const internal functions [PR117260] · 36e3e682
      Andrew Pinski authored
      
      When internal functions support was added to match (r6-4979-gc9e926ce2bdc8b),
      the check for ECF_CONST was the builtin function side. Though before r15-4503-g8d6d6d537fdc,
      there was no use of maybe_push_res_to_seq with non-const internal functions so the check
      would not make a difference.
      
      This adds the check for internal functions just as there is a check for builtins.
      
      Note I didn't add a testcase because there was no non-const internal function
      which could be used on x86_64 in a decent manor.
      
      Bootstrapped and tested on x86_64-linux-gnu.
      
      gcc/ChangeLog:
      
      	PR tree-optimization/117260
      	* gimple-match-exports.cc (maybe_push_res_to_seq): Reject non-const
      	internal functions.
      
      Signed-off-by: default avatarAndrew Pinski <quic_apinski@quicinc.com>
      36e3e682
    • Jonathan Wakely's avatar
      ginclude: stdalign.h should define __xxx_is_defined macros for C++ · 5467f5b5
      Jonathan Wakely authored
      The __alignas_is_defined macro has been required by C++ since C++11, and
      C++ Library DR 4036 clarified that __alignof_is_defined should be
      defined too. The whole <stdalign.h> header was deprecated for C++23 (see
      LWG 3827) and is likely to be removed for C++26 (see P3348), but we can
      deal with that later.
      
      The macros alignas and alignof should not be defined, as they're
      keywords in C++.
      
      gcc/ChangeLog:
      
      	* ginclude/stdalign.h (__alignas_is_defined): Define for C++.
      	(__alignof_is_defined): Likewise.
      
      libstdc++-v3/ChangeLog:
      
      	* testsuite/18_support/headers/cstdalign/macros.cc: New test.
      Unverified
      5467f5b5
    • Jonathan Wakely's avatar
      top-level: Add pull request template for Forgejo · f342d66d
      Jonathan Wakely authored
      ChangeLog:
      
      	* .forgejo/PULL_REQUEST_TEMPLATE.md: New file.
      Unverified
      f342d66d
    • David Malcolm's avatar
      jit: reset state in varasm.cc [PR117275] · 779c0390
      David Malcolm authored
      
      PR jit/117275 reports various jit test failures seen on
      powerpc64le-unknown-linux-gnu due to hitting this assertion
      in varasm.cc on the 2nd compilation in a process:
      
      #2  0x00007ffff63e67d0 in assemble_external_libcall (fun=0x7ffff2a4b1d8)
          at ../../src/gcc/varasm.cc:2650
      2650          gcc_assert (!pending_assemble_externals_processed);
      (gdb) p pending_assemble_externals_processed
      $1 = true
      
      We're not properly resetting state in varasm.cc after a compile
      for libgccjit.
      
      Fixed thusly.
      
      gcc/ChangeLog:
      	PR jit/117275
      	* toplev.cc (toplev::finalize): Call varasm_cc_finalize.
      	* varasm.cc (varasm_cc_finalize): New.
      	* varasm.h (varasm_cc_finalize): New decl.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      779c0390
    • Pengxuan Zheng's avatar
      aarch64: Improve scalar mode popcount expansion by using SVE [PR113860] · 9ffcf1f1
      Pengxuan Zheng authored
      
      This is similar to the recent improvements to the Advanced SIMD popcount
      expansion by using SVE. We can utilize SVE to generate more efficient code for
      scalar mode popcount too.
      
      Changes since v1:
      * v2: Add a new VNx1BI mode and a new test case for V1DI.
      * v3: Abandon VNx1BI changes and add a new variant of aarch64_ptrue_reg.
      
      	PR target/113860
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64-protos.h (aarch64_ptrue_reg): New function.
      	* config/aarch64/aarch64-simd.md (popcount<mode>2): Update pattern to
      	also support V1DI mode.
      	* config/aarch64/aarch64.cc (aarch64_ptrue_reg): New function.
      	* config/aarch64/aarch64.md (popcount<mode>2): Add TARGET_SVE support.
      	* config/aarch64/iterators.md (VDQHSD_V1DI): New mode iterator.
      	(SVE_VDQ_I): Add V1DI.
      	(bitsize): Likewise.
      	(VPRED): Likewise.
      	(VEC_POP_MODE): New mode attribute.
      	(vec_pop_mode): Likewise.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/aarch64/popcnt-sve.c: Update test.
      	* gcc.target/aarch64/popcnt11.c: New test.
      	* gcc.target/aarch64/popcnt12.c: New test.
      
      Signed-off-by: default avatarPengxuan Zheng <quic_pzheng@quicinc.com>
      9ffcf1f1
    • Andrew MacLeod's avatar
      Implement operator_pointer_diff::fold_range · 774ad67f
      Andrew MacLeod authored
      prange has no default fold_range processing like irange does, so each
      pointer specific operator needs to implement its own fold routine.
      
      	PR tree-optimization/117222
      	gcc/
      	* range-op-ptr.cc (operator_pointer_diff::fold_range): New.
      	(operator_pointer_diff::op1_op2_relation_effect): Remove irange
      	variant.
      	(operator_pointer_diff::update_bitmask): Likewise.
      
      	gcc/testsuite
      	* g++.dg/pr117222.C: New.
      774ad67f
    • Jonathan Wakely's avatar
      libstdc++: Add -D_GLIBCXX_ASSERTIONS default for -O0 to API history · 4b0f2388
      Jonathan Wakely authored
      libstdc++-v3/ChangeLog:
      
      	* doc/xml/manual/evolution.xml: Document that assertions are
      	enabled for unoptimized builds.
      	* doc/html/*: Regenerate.
      Unverified
      4b0f2388
    • Jonathan Wakely's avatar
      libstdc++: Add GLIBCXX_TESTSUITE_STDS example to docs · 5a661ecd
      Jonathan Wakely authored
      libstdc++-v3/ChangeLog:
      
      	* doc/xml/manual/test.xml: Add GLIBCXX_TESTSUITE_STDS example.
      	* doc/html/manual/test.html: Regenerate.
      Unverified
      5a661ecd
    • David Malcolm's avatar
      diagnostics: implement buffering for non-textual formats [PR105916] · f565063a
      David Malcolm authored
      
      PR fortran/105916 reports stray diagnostics appearing in JSON and SARIF
      output from gfortran.
      
      In order to handle various awkard parsing issues, the Fortran frontend
      implements buffering of diagnostics, so that diagnostics reported to
      global_dc can be either:
      (a) immediately issued, or
      (b) speculatively reported to global_dc, and stored in a buffer, to
      either be issued later or discarded.
      
      This buffering code in gcc/fortran/error.cc directly manipulates
      implementation details of the diagnostic_context such as the
      pretty_printer's buffer, and the counts of how many diagnostics have
      been issued.  The issue is that this manipulation of pretty_printer's
      buffer doesn't work for formats such as JSON and SARIF where diagnostics
      are handled in a different way (such as by accumulating json::object
      instances in an array).
      
      This patch moves responsibility for such buffering of diagnostics from
      fortran's error.cc to the diagnostic subsystem.  It introduces a new
      class diagnostic_buffer representing a particular buffer of diagnostics
      that have been reported but not yet issued.  Each diagnostic output
      format implements buffering in a different way, and so there is a
      new class hierarchy, diagnostic_per_format_buffer, representing the
      various format-specific ways that buffering is to be implemented.  This
      is hidden as an implementation detail of diagnostic_buffer.
      
      The patch also updates how diagnostics of each kind (e.g. warnings vs
      errors) are counted, so that if buffering is enabled, the count is
      incremented within the buffer, and the counts in the diagnostic_context
      are only updated if and when the buffer is flushed; checking for
      max_errors is similarly updated to support both buffered and unbuffered
      cases.
      
      For ease of debugging, the patch extends the "dump" functions within the
      diagnostics subsystem, so that e.g. global_dc->dump () now prints the
      buffering status, e.g.:
      
      (gdb) call global_dc->dump()
      diagnostic_context:
        counts:
          (none)
        output format:
          sarif_output_format
        printer:
          m_show_color: false
          m_url_format: bel
          m_buffer:
            m_formatted_obstack current object: length 0:
            m_chunk_obstack current object: length 0:
        diagnostic buffer:
          m_per_format_buffer:
            counts:
              error: 1
            diagnostic_sarif_format_buffer:
              result[0]:
      {"ruleId": "error",
       "level": "error",
       "message": {"text": "Function ‘program’ requires an argument list at (1)"},
       "locations": [{"physicalLocation": {"artifactLocation": {"uri": "../../src/gcc/testsuite/gfortran.dg/pr105954.f90",
                                                                "uriBaseId": "PWD"},
                                           "region": {"startLine": 6,
                                                      "startColumn": 8,
                                                      "endColumn": 9},
                                           "contextRegion": {"startLine": 6,
              "snippet": {"text": "program p\n"}}}}]}
      
      which shows that no diagnostics have been issued yet, but the active
      diagnostic_buffer has a single error buffered within it, in SARIF form.
      
      Similarly, it's possible to use "dump" on a diagnostic_buffer to directly
      query its contents; here's the same example, this time with the text
      output format:
      
      (gdb) call error_buffer.buffer.dump()
      m_per_format_buffer:
        counts:
          error: 1
        diagnostic_text_format_buffer:
          m_formatted_obstack current object: length 232:
            00000000: 1b 5b 30 31 6d 1b 5b 4b 2e 2e 2f 2e 2e 2f 73 72 | .[01m.[K../../sr
            00000010: 63 2f 67 63 63 2f 74 65 73 74 73 75 69 74 65 2f | c/gcc/testsuite/
            00000020: 67 66 6f 72 74 72 61 6e 2e 64 67 2f 70 72 31 30 | gfortran.dg/pr10
            00000030: 35 39 35 34 2e 66 39 30 3a 36 3a 38 3a 1b 5b 6d | 5954.f90:6:8:.[m
            00000040: 1b 5b 4b 0a 0a 20 20 20 20 36 20 7c 20 70 72 6f | .[K..    6 | pro
            00000050: 67 72 61 6d 20 70 0a 20 20 20 20 20 20 7c 20 20 | gram p.      |
            00000060: 20 20 20 20 20 20 1b 5b 30 31 3b 33 31 6d 1b 5b |       .[01;31m.[
            00000070: 4b 31 1b 5b 6d 1b 5b 4b 0a 1b 5b 30 31 3b 33 31 | K1.[m.[K..[01;31
            00000080: 6d 1b 5b 4b 45 72 72 6f 72 3a 1b 5b 6d 1b 5b 4b | m.[KError:.[m.[K
            00000090: 20 46 75 6e 63 74 69 6f 6e 20 e2 80 98 1b 5b 30 |  Function ....[0
            000000a0: 31 6d 1b 5b 4b 70 72 6f 67 72 61 6d 1b 5b 6d 1b | 1m.[Kprogram.[m.
            000000b0: 5b 4b e2 80 99 20 72 65 71 75 69 72 65 73 20 61 | [K... requires a
            000000c0: 6e 20 61 72 67 75 6d 65 6e 74 20 6c 69 73 74 20 | n argument list
            000000d0: 61 74 20 1b 5b 30 31 3b 33 31 6d 1b 5b 4b 28 31 | at .[01;31m.[K(1
            000000e0: 29 1b 5b 6d 1b 5b 4b 0a                         | ).[m.[K.
          m_chunk_obstack current object: length 0:
      
      showing that we have an error in error_buffer, with colorized text.
      
      gcc/ChangeLog:
      	PR fortran/105916
      	* diagnostic-buffer.h: New file.
      	* diagnostic-format-json.cc: Define INCLUDE_VECTOR.  Include
      	"diagnostic-buffer.h".
      	(class diagnostic_json_format_buffer): New subclass.
      	(class json_output_format): Add friend class
      	diagnostic_json_format_buffer.
      	(json_output_format::make_per_format_buffer): New vfunc
      	implementation.
      	(json_output_format::set_buffer): New vfunc implementation.
      	(json_output_format::json_output_format): Initialize m_buffer.
      	(json_output_format::m_buffer): New field.
      	(diagnostic_json_format_buffer::dump): New.
      	(diagnostic_json_format_buffer::empty_p): New.
      	(diagnostic_json_format_buffer::move_to): New.
      	(diagnostic_json_format_buffer::clear): New.
      	(diagnostic_json_format_buffer::flush): New.
      	(json_output_format::on_report_diagnostic): Implement optional
      	buffering.
      	* diagnostic-format-sarif.cc: Include "diagnostic-buffer.h".
      	(class diagnostic_sarif_format_buffer): New subclass.
      	(class sarif_builder): Add friend
      	class diagnostic_sarif_format_buffer.
      	(sarif_builder::num_results): New accessor.
      	(sarif_builder::get_result): New accessor.
      	(sarif_builder::on_report_diagnostic): Add param "buffer"; use it
      	to implement optional buffering.
      	(diagnostic_sarif_format_buffer::dump): New.
      	(diagnostic_sarif_format_buffer::empty_p): New.
      	(diagnostic_sarif_format_buffer::move_to): New.
      	(diagnostic_sarif_format_buffer::clear): New.
      	(diagnostic_sarif_format_buffer::flush): New.
      	(sarif_output_format::make_per_format_buffer): New vfunc
      	implementation.
      	(sarif_output_format::set_buffer): New vfunc implementation.
      	(sarif_output_format::on_report_diagnostic): Pass m_buffer to
      	sarif_builder::on_report_diagnostic.
      	(sarif_output_format::num_results): New accessor.
      	(sarif_output_format::get_result): New accessor.
      	(diagnostic_output_format::diagnostic_output_format): Initialize
      	m_buffer.
      	(diagnostic_output_format::m_buffer): New field.
      	(diagnostic_output_format::num_results): Get accessor.
      	(diagnostic_output_format::get_result): Get accessor.
      	(selftest::get_message_from_result): New.
      	(selftest::test_buffering): New.
      	(selftest::diagnostic_format_sarif_cc_tests): Call it.
      	* diagnostic-format-text.cc: Include
      	"diagnostic-client-data-hooks.h".
      	(class diagnostic_text_format_buffer): New subclass.
      	(diagnostic_text_format_buffer::diagnostic_text_format_buffer):
      	New.
      	(diagnostic_text_format_buffer::dump): New.
      	(diagnostic_text_format_buffer::empty_p): New.
      	(diagnostic_text_format_buffer::move_to): New.
      	(diagnostic_text_format_buffer::clear): New.
      	(diagnostic_text_format_buffer::flush): New.
      	(diagnostic_text_output_format::dump): Dump m_saved_output_buffer.
      	(diagnostic_text_output_format::set_buffer): New.
      	(diagnostic_text_output_format::make_per_format_buffer): New.
      	* diagnostic-format-text.h
      	(diagnostic_text_output_format::diagnostic_text_output_format):
      	Initialize m_saved_output_buffer.
      	(diagnostic_text_output_format::set_buffer): New decl.
      	(diagnostic_text_output_format::make_per_format_buffer): New decl.
      	(diagnostic_text_output_format::m_saved_output_buffer): New field.
      	* diagnostic-format.h (class diagnostic_per_format_buffer): New
      	forward decl.
      	(diagnostic_output_format::make_per_format_buffer): New vfunc.
      	(diagnostic_output_format::set_buffer): New vfunc.
      	* diagnostic.cc: Include "diagnostic-buffer.h".
      	(diagnostic_context::initialize): Replace memset with call to
      	"clear" on m_diagnostic_counters.  Initializer
      	m_diagnostic_buffer.
      	(diagnostic_context::finish): Call set_diagnostic_buffer with
      	nullptr.
      	(diagnostic_context::dump): Update for encapsulation of counts
      	into m_diagnostic_counters.  Dump m_diagnostic_buffer.
      	(diagnostic_context::execution_failed_p): Update for encapsulation of
      	counts into m_diagnostic_counters.
      	(diagnostic_context::check_max_errors): Likewise.
      	(diagnostic_context::report_diagnostic): Likewise.  Eliminate
      	diagnostic_check_max_errors in favor of check_max_errors.
      	Update increment of counter to support buffering.  Eliminate
      	diagnostic_action_after_output in favor of action_after_output.
      	Only add fixits to m_edit_context_ptr if buffering is disabled.
      	Only call diagnostic_output_format::after_diagnostic if buffering
      	is disabled.
      	(diagnostic_context::error_recursion):  Eliminate
      	diagnostic_action_after_output in favor of action_after_output.
      	(diagnostic_context::set_diagnostic_buffer): New.
      	(diagnostic_context::clear_diagnostic_buffer): New.
      	(diagnostic_context::flush_diagnostic_buffer): New.
      	(diagnostic_counters::diagnostic_counters): New.
      	(diagnostic_counters::dump): New.
      	(diagnostic_counters::move_to): New.
      	(diagnostic_counters::clear): New.
      	(diagnostic_buffer::diagnostic_buffer): New.
      	(diagnostic_buffer::~diagnostic_buffer): New.
      	(diagnostic_buffer::dump): New.
      	(diagnostic_buffer::empty_p): New.
      	(diagnostic_buffer::move_to): New.
      	(diagnostic_buffer::ensure_per_format_buffer): New.
      	(c_diagnostic_cc_tests): Remove stray newline.
      	* diagnostic.h (class diagnostic_buffer): New forward decl.
      	(struct diagnostic_counters): New.
      	(diagnostic_context::check_max_errors): Make private.
      	(diagnostic_context::action_after_output): Make private.
      	(diagnostic_context::get_output_format): Make non-const.
      	(diagnostic_context::diagnostic_count): Update for change
      	to m_diagnostic_counters.
      	(diagnostic_context::set_diagnostic_buffer): New decl.
      	(diagnostic_context::get_diagnostic_buffer): New decl.
      	(diagnostic_context::clear_diagnostic_buffer): New decl.
      	(diagnostic_context::flush_diagnostic_buffer): New decl.
      	(diagnostic_context::m_diagnostic_count): Replace array with...
      	(diagnostic_context::m_diagnostic_counters): ...this.
      	(diagnostic_context::m_diagnostic_buffer): New field.
      	(diagnostic_action_after_output): Delete.
      	(diagnostic_check_max_errors): Delete.
      
      gcc/fortran/ChangeLog:
      	PR fortran/105916
      	* error.cc (pp_error_buffer, pp_warning_buffer): Convert from
      	output_buffer * to diagnostic_buffer *.
      	(warningcount_buffered, werrorcount_buffered): Eliminate.
      	(gfc_error_buffer::gfc_error_buffer): Move constructor definition
      	here, and initialize "buffer" using *global_dc.
      	(gfc_output_buffer_empty_p): Delete in favor of
      	diagnostic_buffer::empty_p.
      	(gfc_clear_pp_buffer): Replace with...
      	(gfc_clear_diagnostic_buffer): ...this, moving implementation
      	details to diagnostic_context::clear_diagnostic_buffer.
      	(gfc_warning): Replace buffering implementation with calls
      	to global_dc->get_diagnostic_buffer and
      	global_dc->set_diagnostic_buffer.
      	(gfc_clear_warning): Update for renaming of gfc_clear_pp_buffer
      	and elimination of warningcount_buffered and werrorcount_buffered.
      	(gfc_warning_check): Replace buffering implementation with calls
      	to pp_warning_buffer->empty_p and
      	global_dc->flush_diagnostic_buffer.
      	(gfc_error_opt): Replace buffering implementation with calls to
      	global_dc->get_diagnostic_buffer and set_diagnostic_buffer.
      	(gfc_clear_error): Update for renaming of gfc_clear_pp_buffer.
      	(gfc_error_flag_test): Replace call to gfc_output_buffer_empty_p
      	with call to diagnostic_buffer::empty_p.
      	(gfc_error_check): Replace buffering implementation with calls
      	to pp_error_buffer->empty_p and global_dc->flush_diagnostic_buffer.
      	(gfc_move_error_buffer_from_to): Replace buffering implementation
      	with usage of diagnostic_buffer.
      	(gfc_free_error): Update for renaming of gfc_clear_pp_buffer.
      	(gfc_diagnostics_init): Use "new" directly when creating
      	pp_warning_buffer.  Remove setting of m_flush_p on the two
      	buffers, as this is handled by diagnostic_buffer and by
      	diagnostic_text_format_buffer's constructor.
      	* gfortran.h: Replace #include "pretty-print.h" for output_buffer
      	with #include "diagnostic-buffer.h" for diagnostic_buffer.
      	(struct gfc_error_buffer): Change type of field "buffer" from
      	output_buffer to diagnostic_buffer.  Move definition of constructor
      	into error.cc so that it can use global_dc.
      
      gcc/testsuite/ChangeLog:
      	PR fortran/105916
      	* gcc.dg/plugin/diagnostic_plugin_xhtml_format.c: Include
      	"diagnostic-buffer.h".
      	(class diagnostic_xhtml_format_buffer): New subclass.
      	(class xhtml_builder): Add friend
      	class diagnostic_xhtml_format_buffer.
      	(diagnostic_xhtml_format_buffer::dump): New.
      	(diagnostic_xhtml_format_buffer::empty_p): New.
      	(diagnostic_xhtml_format_buffer::move_to): New.
      	(diagnostic_xhtml_format_buffer::clear): New.
      	(diagnostic_xhtml_format_buffer::flush): New.
      	(xhtml_builder::on_report_diagnostic): Add "buffer" param, and use
      	it.
      	(xhtml_output_format::dump): Fix typo.
      	(xhtml_output_format::make_per_format_buffer): New.
      	(xhtml_output_format::set_buffer): New.
      	(xhtml_output_format::on_report_diagnostic): Fix whitespace.  Pass
      	m_buffer to xhtml_builder::on_report_diagnostic.
      	(xhtml_output_format::xhtml_output_format): Initialize m_buffer.
      	(xhtml_output_format::m_buffer): New field.
      	* gfortran.dg/diagnostic-format-json-pr105916.F90: New test.
      	* gfortran.dg/diagnostic-format-sarif-1.F90: New test.
      	* gfortran.dg/diagnostic-format-sarif-1.py: New support script.
      	* gfortran.dg/diagnostic-format-sarif-pr105916.f90: New test.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      f565063a
    • Jonathan Wakely's avatar
      libstdc++: Replace std::__to_address in C++20 branch in <string> · de2dc623
      Jonathan Wakely authored
      
      As noted by Patrick, r15-4546-g85e5b80ee2de80 should have changed the
      usage of std::__to_address to std::to_address in the C++20-specific
      branch that works on types satisfying std::contiguous_iterator.
      
      libstdc++-v3/ChangeLog:
      
      	* include/bits/basic_string.h (assign(Iter, Iter)): Call
      	std::to_address instead of __to_address.
      
      Reviewed-by: default avatarPatrick Palka <ppalka@redhat.com>
      Unverified
      de2dc623
    • Paul Thomas's avatar
      Fortran: Generic processing of assumed rank objects (f202y) [PR116733] · c5fa2108
      Paul Thomas authored
      2024-10-23  Paul Thomas  <pault@gcc.gnu.org>
      
      gcc/fortran
      	PR fortran/116733
      	* array.cc : White space corrections.
      	* expr.cc (gfc_check_pointer_assign): Permit assumed rank
      	target with -std=f202y. Add constraints that the data pointer
      	object must have rank remapping specified and the that the data
      	target be contiguous.
      	* gfortran.h : Add a gfc_array_ref field 'ar' to the structure
      	'gfc_association_list'.
      	* interface.cc (gfc_compare_actual_formal): If -Wsurprising
      	is set, emit a warning if an assumed size array is passed to an
      	assumed rank dummy.
      	* intrinsic.cc (do_ts29113_check): Permit an assumed rank arg.
      	for reshape if -std=f202y and the argument is contiguous.
      	* invoke.texi : Introduce -std=f202y. Whitespace errors.
      	* lang.opt : Accept -std=f202y.
      	* libgfortran.h : Define GFC_STD_F202Y.
      	* match.cc (gfc_match_associate): If -std=f202y an assumed rank
      	selector is allowed if it is contiguous and the associate name
      	has rank remapping specified.
      	* options.cc (gfc_init_options): -std=f202y is equivalent to
      	-std=f2023 with experimental f202y features. White space issues
      	* parse.cc (parse_associate): If the selector is assumed rank,
      	use the 'ar' field of the association list to build an array
      	specification.
      	* primary.cc (gfc_match_varspec): Do not resolve the assumed
      	rank selector of a class associate name at this stage to avoid
      	the rank change.
      	* resolve.cc (find_array_spec): If an array_ref dimension is -1
      	reset it with the rank in the object's array_spec.
      	(gfc_expression_rank): Do not check dimen types for an assumed
      	rank variable expression.
      	(resolve_variable): Do not emit the assumed rank context error
      	if the context is pointer assignment and the variable is a
      	target.
      	(resolve_assoc_var): Resolve the bounds and check for missing
      	bounds in the rank remap of an associate name with an assumed
      	rank selector. Do not correct the rank of an associate name
      	with an assumed rank selector.
      	(resolve_symbol): Allow the reference to an assumed rank object
      	if -std-f202y is enabled and the current operation is
      	EXEC_BLOCK.
      	* st.cc (gfc_free_association_list): Free bounds expressions
      	of the 'ar' field, if present.
      	* trans-array.cc (gfc_conv_ss_startstride): If -std=f202y and
      	bounds checking activated, do not apply the assertion.
      	* trans-expr.cc (gfc_trans_pointer_assignment): An assumed rank
      	target has its offset set to zero.
      	* trans-stmt.cc (trans_associate_var): If the selector is
      	assumed rank, call gfc_trans_pointer_assignment using the 'ar'
      	field in the association list as the array reference for expr1.
      	The data target, expr2, is a copy of the selector expression.
      
      gcc/testsuite/
      	PR fortran/116733
      	* gfortran.dg/associate_3.f03: Change error message.
      	* gfortran.dg/f202y/f202y.exp: Enable tests of f202y features.
      	* gfortran.dg/f202y/generic_assumed_rank_1.f90: New test.
      	* gfortran.dg/f202y/generic_assumed_rank_2.f90: New test.
      	* gfortran.dg/f202y/generic_assumed_rank_3.f90: New test.
      c5fa2108
    • Wilco Dijkstra's avatar
      AArch64: Remove redundant check in aarch64_simd_mov · 2ac01a4e
      Wilco Dijkstra authored
      The split condition in aarch64_simd_mov uses aarch64_simd_special_constant_p.
      While doing the split, it checks the mode before calling
      aarch64_maybe_generate_simd_constant.  This risky since it may result in
      unexpectedly calling aarch64_split_simd_move instead of
      aarch64_maybe_generate_simd_constant.  Since the mode is already checked,
      remove the spurious explicit mode check.
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64-simd.md (aarch64_simd_mov<VQMOV:mode>):
      	Remove redundant mode check.
      2ac01a4e
    • Wilco Dijkstra's avatar
      AArch64: Fix copysign patterns · 7c7c895c
      Wilco Dijkstra authored
      The current copysign pattern has a mismatch in the predicates and constraints -
      operand[2] is a register_operand but also has an alternative X which allows any
      operand.  Since it is a floating point operation, having an integer alternative
      makes no sense.  Change the expander to always use vector immediates which
      results in better code and sharing of immediates between copysign and xorsign.
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64.md (copysign<GPF:mode>3): Widen immediate to
      	vector.
      	(copysign<GPF:mode>3_insn): Use VQ_INT_EQUIV in operand 3.
      	* config/aarch64/iterators.md (VQ_INT_EQUIV): New iterator.
      	(vq_int_equiv): Likewise.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/aarch64/copysign_3.c: New test.
      	* gcc.target/aarch64/copysign_4.c: New test.
      	* gcc.target/aarch64/fneg-abs_2.c: Fixup test.
      	* gcc.target/aarch64/sve/fneg-abs_2.c: Likewise.
      7c7c895c
Loading