mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
50332a4fdd
I've tried to build stage3 with -Wleading-whitespace=blanks -Wtrailing-whitespace=blank -Wno-error=leading-whitespace=blanks -Wno-error=trailing-whitespace=blank added to STRICT_WARN and that expectably resulted in about 2744 unique trailing whitespace warnings and 124837 leading whitespace warnings when excluding *.md files (which obviously is in big part a generator issue). Others from that are generator related, I think those need to be solved later. The following patch just fixes up the easy case (trailing whitespace), which could be easily automated: for i in `find . -name \*.h -o -name \*.cc -o -name \*.c | xargs grep -l '[ ]$' | grep -v testsuite/`; do sed -i -e 's/[ ]*$//' $i; done I've excluded files which I knew are obviously generated or go FE. Is there anything else we'd want to avoid the changes? Due to patch size, I've split it between gcc/ part (this patch) and rest (include/, libiberty/, libgcc/, libcpp/, libstdc++-v3/). 2024-10-24 Jakub Jelinek <jakub@redhat.com> gcc/ * lra-assigns.cc: Remove trailing whitespace. * symtab.cc: Likewise. * stmt.cc: Likewise. * cgraphbuild.cc: Likewise. * cfgcleanup.cc: Likewise. * loop-init.cc: Likewise. * df-problems.cc: Likewise. * diagnostic-macro-unwinding.cc: Likewise. * langhooks.h: Likewise. * except.cc: Likewise. * tree-vect-loop.cc: Likewise. * coverage.cc: Likewise. * hash-table.cc: Likewise. * ggc-page.cc: Likewise. * gimple-ssa-strength-reduction.cc: Likewise. * tree-parloops.cc: Likewise. * internal-fn.cc: Likewise. * ipa-split.cc: Likewise. * calls.cc: Likewise. * reorg.cc: Likewise. * sbitmap.h: Likewise. * omp-offload.cc: Likewise. * cfgrtl.cc: Likewise. * reginfo.cc: Likewise. * gengtype.h: Likewise. * omp-general.h: Likewise. * ipa-comdats.cc: Likewise. * gimple-range-edge.h: Likewise. * tree-ssa-structalias.cc: Likewise. * target.def: Likewise. * basic-block.h: Likewise. * graphite-isl-ast-to-gimple.cc: Likewise. * auto-profile.cc: Likewise. * optabs.cc: Likewise. * gengtype-lex.l: Likewise. * optabs.def: Likewise. * ira-build.cc: Likewise. * ira.cc: Likewise. * function.h: Likewise. * tree-ssa-propagate.cc: Likewise. * gcov-io.cc: Likewise. * builtin-types.def: Likewise. * ddg.cc: Likewise. * lra-spills.cc: Likewise. * cfg.cc: Likewise. * bitmap.cc: Likewise. * gimple-range-gori.h: Likewise. * tree-ssa-loop-im.cc: Likewise. * cfghooks.h: Likewise. * genmatch.cc: Likewise. * explow.cc: Likewise. * lto-streamer-in.cc: Likewise. * graphite-scop-detection.cc: Likewise. * ipa-prop.cc: Likewise. * gcc.cc: Likewise. * vec.h: Likewise. * cfgexpand.cc: Likewise. * config/alpha/vms.h: Likewise. * config/alpha/alpha.cc: Likewise. * config/alpha/driver-alpha.cc: Likewise. * config/alpha/elf.h: Likewise. * config/iq2000/iq2000.h: Likewise. * config/iq2000/iq2000.cc: Likewise. * config/pa/pa-64.h: Likewise. * config/pa/som.h: Likewise. * config/pa/pa.cc: Likewise. * config/pa/pa.h: Likewise. * config/pa/pa32-regs.h: Likewise. * config/c6x/c6x.cc: Likewise. * config/openbsd-stdint.h: Likewise. * config/elfos.h: Likewise. * config/lm32/lm32.cc: Likewise. * config/lm32/lm32.h: Likewise. * config/lm32/lm32-protos.h: Likewise. * config/darwin-c.cc: Likewise. * config/rx/rx.cc: Likewise. * config/host-darwin.h: Likewise. * config/netbsd.h: Likewise. * config/ia64/ia64.cc: Likewise. * config/ia64/freebsd.h: Likewise. * config/avr/avr-c.cc: Likewise. * config/avr/avr.cc: Likewise. * config/avr/avr-arch.h: Likewise. * config/avr/avr.h: Likewise. * config/avr/stdfix.h: Likewise. * config/avr/gen-avr-mmcu-specs.cc: Likewise. * config/avr/avr-log.cc: Likewise. * config/avr/elf.h: Likewise. * config/avr/gen-avr-mmcu-texi.cc: Likewise. * config/avr/avr-devices.cc: Likewise. * config/nvptx/nvptx.cc: Likewise. * config/vx-common.h: Likewise. * config/sol2.cc: Likewise. * config/rl78/rl78.cc: Likewise. * config/cris/cris.cc: Likewise. * config/arm/symbian.h: Likewise. * config/arm/unknown-elf.h: Likewise. * config/arm/linux-eabi.h: Likewise. * config/arm/arm.cc: Likewise. * config/arm/arm-mve-builtins.h: Likewise. * config/arm/bpabi.h: Likewise. * config/arm/vxworks.h: Likewise. * config/arm/arm.h: Likewise. * config/arm/aout.h: Likewise. * config/arm/elf.h: Likewise. * config/host-linux.cc: Likewise. * config/sh/sh_treg_combine.cc: Likewise. * config/sh/vxworks.h: Likewise. * config/sh/elf.h: Likewise. * config/sh/netbsd-elf.h: Likewise. * config/sh/sh.cc: Likewise. * config/sh/embed-elf.h: Likewise. * config/sh/sh.h: Likewise. * config/darwin-driver.cc: Likewise. * config/m32c/m32c.cc: Likewise. * config/frv/frv.cc: Likewise. * config/openbsd.h: Likewise. * config/aarch64/aarch64-protos.h: Likewise. * config/aarch64/aarch64-builtins.cc: Likewise. * config/aarch64/aarch64-cost-tables.h: Likewise. * config/aarch64/aarch64.cc: Likewise. * config/bfin/bfin.cc: Likewise. * config/bfin/bfin.h: Likewise. * config/bfin/bfin-protos.h: Likewise. * config/i386/gmm_malloc.h: Likewise. * config/i386/djgpp.h: Likewise. * config/i386/sol2.h: Likewise. * config/i386/stringop.def: Likewise. * config/i386/i386-features.cc: Likewise. * config/i386/openbsdelf.h: Likewise. * config/i386/cpuid.h: Likewise. * config/i386/i386.h: Likewise. * config/i386/smmintrin.h: Likewise. * config/i386/avx10_2-512convertintrin.h: Likewise. * config/i386/i386-options.cc: Likewise. * config/i386/i386-opts.h: Likewise. * config/i386/i386-expand.cc: Likewise. * config/i386/avx512dqintrin.h: Likewise. * config/i386/wmmintrin.h: Likewise. * config/i386/gnu-user.h: Likewise. * config/i386/host-mingw32.cc: Likewise. * config/i386/avx10_2bf16intrin.h: Likewise. * config/i386/cygwin.h: Likewise. * config/i386/driver-i386.cc: Likewise. * config/i386/biarch64.h: Likewise. * config/i386/host-cygwin.cc: Likewise. * config/i386/cygming.h: Likewise. * config/i386/i386-builtins.cc: Likewise. * config/i386/avx10_2convertintrin.h: Likewise. * config/i386/i386.cc: Likewise. * config/i386/gas.h: Likewise. * config/i386/freebsd.h: Likewise. * config/mingw/winnt-cxx.cc: Likewise. * config/mingw/winnt.cc: Likewise. * config/h8300/h8300.cc: Likewise. * config/host-solaris.cc: Likewise. * config/m32r/m32r.h: Likewise. * config/m32r/m32r.cc: Likewise. * config/darwin.h: Likewise. * config/sparc/linux64.h: Likewise. * config/sparc/sparc-protos.h: Likewise. * config/sparc/sysv4.h: Likewise. * config/sparc/sparc.h: Likewise. * config/sparc/linux.h: Likewise. * config/sparc/freebsd.h: Likewise. * config/sparc/sparc.cc: Likewise. * config/gcn/gcn-run.cc: Likewise. * config/gcn/gcn.cc: Likewise. * config/gcn/gcn-tree.cc: Likewise. * config/kopensolaris-gnu.h: Likewise. * config/nios2/nios2.h: Likewise. * config/nios2/elf.h: Likewise. * config/nios2/nios2.cc: Likewise. * config/host-netbsd.cc: Likewise. * config/rtems.h: Likewise. * config/pdp11/pdp11.cc: Likewise. * config/pdp11/pdp11.h: Likewise. * config/mn10300/mn10300.cc: Likewise. * config/mn10300/linux.h: Likewise. * config/moxie/moxie.h: Likewise. * config/moxie/moxie.cc: Likewise. * config/rs6000/aix71.h: Likewise. * config/rs6000/vec_types.h: Likewise. * config/rs6000/xcoff.h: Likewise. * config/rs6000/rs6000.cc: Likewise. * config/rs6000/rs6000-internal.h: Likewise. * config/rs6000/rs6000-p8swap.cc: Likewise. * config/rs6000/rs6000-c.cc: Likewise. * config/rs6000/aix.h: Likewise. * config/rs6000/rs6000-logue.cc: Likewise. * config/rs6000/rs6000-string.cc: Likewise. * config/rs6000/rs6000-call.cc: Likewise. * config/rs6000/ppu_intrinsics.h: Likewise. * config/rs6000/altivec.h: Likewise. * config/rs6000/darwin.h: Likewise. * config/rs6000/host-darwin.cc: Likewise. * config/rs6000/freebsd64.h: Likewise. * config/rs6000/spu2vmx.h: Likewise. * config/rs6000/linux.h: Likewise. * config/rs6000/si2vmx.h: Likewise. * config/rs6000/driver-rs6000.cc: Likewise. * config/rs6000/freebsd.h: Likewise. * config/vxworksae.h: Likewise. * config/mips/frame-header-opt.cc: Likewise. * config/mips/mips.h: Likewise. * config/mips/mips.cc: Likewise. * config/mips/sde.h: Likewise. * config/darwin-protos.h: Likewise. * config/mcore/mcore-elf.h: Likewise. * config/mcore/mcore.h: Likewise. * config/mcore/mcore.cc: Likewise. * config/epiphany/epiphany.cc: Likewise. * config/fr30/fr30.h: Likewise. * config/fr30/fr30.cc: Likewise. * config/riscv/riscv-vector-builtins-shapes.cc: Likewise. * config/riscv/riscv-vector-builtins-bases.cc: Likewise. * config/visium/visium.h: Likewise. * config/mmix/mmix.cc: Likewise. * config/v850/v850.cc: Likewise. * config/v850/v850-c.cc: Likewise. * config/v850/v850.h: Likewise. * config/stormy16/stormy16.cc: Likewise. * config/stormy16/stormy16-protos.h: Likewise. * config/stormy16/stormy16.h: Likewise. * config/arc/arc.cc: Likewise. * config/vxworks.cc: Likewise. * config/microblaze/microblaze-c.cc: Likewise. * config/microblaze/microblaze-protos.h: Likewise. * config/microblaze/microblaze.h: Likewise. * config/microblaze/microblaze.cc: Likewise. * config/freebsd-spec.h: Likewise. * config/m68k/m68kelf.h: Likewise. * config/m68k/m68k.cc: Likewise. * config/m68k/netbsd-elf.h: Likewise. * config/m68k/linux.h: Likewise. * config/freebsd.h: Likewise. * config/host-openbsd.cc: Likewise. * regcprop.cc: Likewise. * dumpfile.cc: Likewise. * combine.cc: Likewise. * tree-ssa-forwprop.cc: Likewise. * ipa-profile.cc: Likewise. * hw-doloop.cc: Likewise. * opts.cc: Likewise. * gcc-ar.cc: Likewise. * tree-cfg.cc: Likewise. * incpath.cc: Likewise. * tree-ssa-sccvn.cc: Likewise. * function.cc: Likewise. * genattrtab.cc: Likewise. * rtl.def: Likewise. * genchecksum.cc: Likewise. * profile.cc: Likewise. * df-core.cc: Likewise. * tree-pretty-print.cc: Likewise. * tree.h: Likewise. * plugin.cc: Likewise. * tree-ssa-loop-ch.cc: Likewise. * emit-rtl.cc: Likewise. * haifa-sched.cc: Likewise. * gimple-range-edge.cc: Likewise. * range-op.cc: Likewise. * tree-ssa-ccp.cc: Likewise. * dwarf2cfi.cc: Likewise. * recog.cc: Likewise. * vtable-verify.cc: Likewise. * system.h: Likewise. * regrename.cc: Likewise. * tree-ssa-dom.cc: Likewise. * loop-unroll.cc: Likewise. * lra-constraints.cc: Likewise. * pretty-print.cc: Likewise. * ifcvt.cc: Likewise. * ipa.cc: Likewise. * alloc-pool.h: Likewise. * collect2.cc: Likewise. * pointer-query.cc: Likewise. * cfgloop.cc: Likewise. * toplev.cc: Likewise. * sese.cc: Likewise. * gengtype.cc: Likewise. * gimplify-me.cc: Likewise. * double-int.cc: Likewise. * bb-reorder.cc: Likewise. * dwarf2out.cc: Likewise. * tree-ssa-loop-ivcanon.cc: Likewise. * tree-ssa-reassoc.cc: Likewise. * cgraph.cc: Likewise. * sel-sched.cc: Likewise. * attribs.cc: Likewise. * expr.cc: Likewise. * tree-ssa-scopedtables.h: Likewise. * gimple-range-cache.cc: Likewise. * ipa-pure-const.cc: Likewise. * tree-inline.cc: Likewise. * genhooks.cc: Likewise. * gimple-range-phi.h: Likewise. * shrink-wrap.cc: Likewise. * tree.cc: Likewise. * gimple.cc: Likewise. * backend.h: Likewise. * opts-common.cc: Likewise. * cfg-flags.def: Likewise. * gcse-common.cc: Likewise. * tree-ssa-scopedtables.cc: Likewise. * ccmp.cc: Likewise. * builtins.def: Likewise. * builtin-attrs.def: Likewise. * postreload.cc: Likewise. * sched-deps.cc: Likewise. * ipa-inline-transform.cc: Likewise. * tree-vect-generic.cc: Likewise. * ipa-polymorphic-call.cc: Likewise. * builtins.cc: Likewise. * sel-sched-ir.cc: Likewise. * trans-mem.cc: Likewise. * ipa-visibility.cc: Likewise. * cgraph.h: Likewise. * tree-ssa-phiopt.cc: Likewise. * genopinit.cc: Likewise. * ipa-inline.cc: Likewise. * omp-low.cc: Likewise. * ipa-utils.cc: Likewise. * tree-ssa-math-opts.cc: Likewise. * tree-ssa-ifcombine.cc: Likewise. * gimple-range.cc: Likewise. * ipa-fnsummary.cc: Likewise. * ira-color.cc: Likewise. * value-prof.cc: Likewise. * varasm.cc: Likewise. * ipa-icf.cc: Likewise. * ira-emit.cc: Likewise. * lto-streamer.h: Likewise. * lto-wrapper.cc: Likewise. * regs.h: Likewise. * gengtype-parse.cc: Likewise. * alias.cc: Likewise. * lto-streamer.cc: Likewise. * real.h: Likewise. * wide-int.h: Likewise. * targhooks.cc: Likewise. * gimple-ssa-warn-access.cc: Likewise. * real.cc: Likewise. * ipa-reference.cc: Likewise. * bitmap.h: Likewise. * ginclude/float.h: Likewise. * ginclude/stddef.h: Likewise. * ginclude/stdarg.h: Likewise. * ginclude/stdatomic.h: Likewise. * optabs.h: Likewise. * sel-sched-ir.h: Likewise. * convert.cc: Likewise. * cgraphunit.cc: Likewise. * lra-remat.cc: Likewise. * tree-if-conv.cc: Likewise. * gcov-dump.cc: Likewise. * tree-predcom.cc: Likewise. * dominance.cc: Likewise. * gimple-range-cache.h: Likewise. * ipa-devirt.cc: Likewise. * rtl.h: Likewise. * ubsan.cc: Likewise. * tree-ssa.cc: Likewise. * ssa.h: Likewise. * cse.cc: Likewise. * jump.cc: Likewise. * hwint.h: Likewise. * caller-save.cc: Likewise. * coretypes.h: Likewise. * ipa-fnsummary.h: Likewise. * tree-ssa-strlen.cc: Likewise. * modulo-sched.cc: Likewise. * cgraphclones.cc: Likewise. * lto-cgraph.cc: Likewise. * hw-doloop.h: Likewise. * data-streamer.h: Likewise. * compare-elim.cc: Likewise. * profile-count.h: Likewise. * tree-vect-loop-manip.cc: Likewise. * ree.cc: Likewise. * reload.cc: Likewise. * tree-ssa-loop-split.cc: Likewise. * tree-into-ssa.cc: Likewise. * gcse.cc: Likewise. * cfgloopmanip.cc: Likewise. * df.h: Likewise. * fold-const.cc: Likewise. * wide-int.cc: Likewise. * gengtype-state.cc: Likewise. * sanitizer.def: Likewise. * tree-ssa-sink.cc: Likewise. * target-hooks-macros.h: Likewise. * tree-ssa-pre.cc: Likewise. * gimple-pretty-print.cc: Likewise. * ipa-utils.h: Likewise. * tree-outof-ssa.cc: Likewise. * tree-ssa-coalesce.cc: Likewise. * gimple-match.h: Likewise. * tree-ssa-loop-niter.cc: Likewise. * tree-loop-distribution.cc: Likewise. * tree-emutls.cc: Likewise. * tree-eh.cc: Likewise. * varpool.cc: Likewise. * ssa-iterators.h: Likewise. * asan.cc: Likewise. * reload1.cc: Likewise. * cfgloopanal.cc: Likewise. * tree-vectorizer.cc: Likewise. * simplify-rtx.cc: Likewise. * opts-global.cc: Likewise. * gimple-ssa-store-merging.cc: Likewise. * expmed.cc: Likewise. * tree-ssa-loop-prefetch.cc: Likewise. * tree-ssa-dse.h: Likewise. * tree-vect-stmts.cc: Likewise. * gimple-fold.cc: Likewise. * lra-coalesce.cc: Likewise. * data-streamer-out.cc: Likewise. * diagnostic.cc: Likewise. * tree-ssa-alias.cc: Likewise. * tree-vect-patterns.cc: Likewise. * common/common-target.def: Likewise. * common/config/rx/rx-common.cc: Likewise. * common/config/msp430/msp430-common.cc: Likewise. * common/config/avr/avr-common.cc: Likewise. * common/config/i386/i386-common.cc: Likewise. * common/config/pdp11/pdp11-common.cc: Likewise. * common/config/rs6000/rs6000-common.cc: Likewise. * common/config/mcore/mcore-common.cc: Likewise. * graphite.cc: Likewise. * gimple-low.cc: Likewise. * genmodes.cc: Likewise. * gimple-loop-jam.cc: Likewise. * lto-streamer-out.cc: Likewise. * predict.cc: Likewise. * omp-expand.cc: Likewise. * gimple-array-bounds.cc: Likewise. * predict.def: Likewise. * opts.h: Likewise. * tree-stdarg.cc: Likewise. * gimplify.cc: Likewise. * ira-lives.cc: Likewise. * loop-doloop.cc: Likewise. * lra.cc: Likewise. * gimple-iterator.h: Likewise. * tree-sra.cc: Likewise. gcc/fortran/ * trans-openmp.cc: Remove trailing whitespace. * trans-common.cc: Likewise. * match.h: Likewise. * scanner.cc: Likewise. * gfortranspec.cc: Likewise. * io.cc: Likewise. * iso-c-binding.def: Likewise. * iso-fortran-env.def: Likewise. * types.def: Likewise. * openmp.cc: Likewise. * f95-lang.cc: Likewise. gcc/analyzer/ * state-purge.cc: Remove trailing whitespace. * region-model.h: Likewise. * region-model.cc: Likewise. * program-point.cc: Likewise. * exploded-graph.h: Likewise. * program-state.cc: Likewise. * supergraph.cc: Likewise. gcc/c-family/ * c-ubsan.cc: Remove trailing whitespace. * stub-objc.cc: Likewise. * c-pragma.cc: Likewise. * c-ppoutput.cc: Likewise. * c-indentation.cc: Likewise. * c-ada-spec.cc: Likewise. * c-opts.cc: Likewise. * c-common.cc: Likewise. * c-format.cc: Likewise. * c-omp.cc: Likewise. * c-objc.h: Likewise. * c-cppbuiltin.cc: Likewise. * c-attribs.cc: Likewise. * c-target.def: Likewise. * c-common.h: Likewise. gcc/c/ * c-typeck.cc: Remove trailing whitespace. * gimple-parser.cc: Likewise. * c-parser.cc: Likewise. * c-decl.cc: Likewise. gcc/cp/ * vtable-class-hierarchy.cc: Remove trailing whitespace. * typeck2.cc: Likewise. * decl.cc: Likewise. * init.cc: Likewise. * semantics.cc: Likewise. * module.cc: Likewise. * rtti.cc: Likewise. * cxx-pretty-print.cc: Likewise. * cvt.cc: Likewise. * mangle.cc: Likewise. * name-lookup.h: Likewise. * coroutines.cc: Likewise. * error.cc: Likewise. * lambda.cc: Likewise. * tree.cc: Likewise. * g++spec.cc: Likewise. * decl2.cc: Likewise. * cp-tree.h: Likewise. * parser.cc: Likewise. * pt.cc: Likewise. * call.cc: Likewise. * lex.cc: Likewise. * cp-lang.cc: Likewise. * cp-tree.def: Likewise. * constexpr.cc: Likewise. * typeck.cc: Likewise. * name-lookup.cc: Likewise. * optimize.cc: Likewise. * search.cc: Likewise. * mapper-client.cc: Likewise. * ptree.cc: Likewise. * class.cc: Likewise. gcc/jit/ * docs/examples/tut04-toyvm/toyvm.cc: Remove trailing whitespace. gcc/lto/ * lto-object.cc: Remove trailing whitespace. * lto-symtab.cc: Likewise. * lto-partition.cc: Likewise. * lang-specs.h: Likewise. * lto-lang.cc: Likewise. gcc/objc/ * objc-encoding.cc: Remove trailing whitespace. * objc-map.h: Likewise. * objc-next-runtime-abi-01.cc: Likewise. * objc-act.cc: Likewise. * objc-map.cc: Likewise. gcc/objcp/ * objcp-decl.cc: Remove trailing whitespace. * objcp-lang.cc: Likewise. * objcp-decl.h: Likewise. gcc/rust/ * util/optional.h: Remove trailing whitespace. * util/expected.h: Likewise. * util/rust-unicode-data.h: Likewise. gcc/m2/ * mc-boot/GFpuIO.cc: Remove trailing whitespace. * mc-boot/GFIO.cc: Likewise. * mc-boot/GFormatStrings.cc: Likewise. * mc-boot/GCmdArgs.cc: Likewise. * mc-boot/GDebug.h: Likewise. * mc-boot/GM2Dependent.cc: Likewise. * mc-boot/GRTint.cc: Likewise. * mc-boot/GDebug.cc: Likewise. * mc-boot/GmcError.cc: Likewise. * mc-boot/Gmcp4.cc: Likewise. * mc-boot/GM2RTS.cc: Likewise. * mc-boot/GIO.cc: Likewise. * mc-boot/Gmcp5.cc: Likewise. * mc-boot/GDynamicStrings.cc: Likewise. * mc-boot/Gmcp1.cc: Likewise. * mc-boot/GFormatStrings.h: Likewise. * mc-boot/Gmcp2.cc: Likewise. * mc-boot/Gmcp3.cc: Likewise. * pge-boot/GFIO.cc: Likewise. * pge-boot/GDebug.h: Likewise. * pge-boot/GM2Dependent.cc: Likewise. * pge-boot/GDebug.cc: Likewise. * pge-boot/GM2RTS.cc: Likewise. * pge-boot/GSymbolKey.cc: Likewise. * pge-boot/GIO.cc: Likewise. * pge-boot/GIndexing.cc: Likewise. * pge-boot/GDynamicStrings.cc: Likewise. * pge-boot/GFormatStrings.h: Likewise. gcc/go/ * go-gcc.cc: Remove trailing whitespace. * gospec.cc: Likewise.
635 lines
16 KiB
C++
635 lines
16 KiB
C++
/* Gimple Represented as Polyhedra.
|
|
Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
|
Contributed by Sebastian Pop <sebastian.pop@inria.fr>.
|
|
|
|
This file is part of GCC.
|
|
|
|
GCC is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3, or (at your option)
|
|
any later version.
|
|
|
|
GCC is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GCC; see the file COPYING3. If not see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
/* This pass converts GIMPLE to GRAPHITE, performs some loop
|
|
transformations and then converts the resulting representation back
|
|
to GIMPLE.
|
|
|
|
An early description of this pass can be found in the GCC Summit'06
|
|
paper "GRAPHITE: Polyhedral Analyses and Optimizations for GCC".
|
|
The wiki page http://gcc.gnu.org/wiki/Graphite contains pointers to
|
|
the related work. */
|
|
|
|
#define INCLUDE_ISL
|
|
#define INCLUDE_MEMORY
|
|
|
|
#include "config.h"
|
|
#include "system.h"
|
|
#include "coretypes.h"
|
|
#include "backend.h"
|
|
#include "diagnostic-core.h"
|
|
#include "cfgloop.h"
|
|
#include "tree-pass.h"
|
|
#include "pretty-print.h"
|
|
#include "cfganal.h"
|
|
|
|
#ifdef HAVE_isl
|
|
#include "cfghooks.h"
|
|
#include "tree.h"
|
|
#include "gimple.h"
|
|
#include "ssa.h"
|
|
#include "fold-const.h"
|
|
#include "gimple-iterator.h"
|
|
#include "tree-cfg.h"
|
|
#include "tree-ssa-loop.h"
|
|
#include "tree-data-ref.h"
|
|
#include "tree-scalar-evolution.h"
|
|
#include "dbgcnt.h"
|
|
#include "tree-parloops.h"
|
|
#include "tree-cfgcleanup.h"
|
|
#include "tree-vectorizer.h"
|
|
#include "tree-ssa-loop-manip.h"
|
|
#include "tree-ssa.h"
|
|
#include "tree-into-ssa.h"
|
|
#include "tree-ssa-propagate.h"
|
|
#include "graphite.h"
|
|
|
|
/* Print global statistics to FILE. */
|
|
|
|
static void
|
|
print_global_statistics (FILE* file)
|
|
{
|
|
long n_bbs = 0;
|
|
long n_loops = 0;
|
|
long n_stmts = 0;
|
|
long n_conditions = 0;
|
|
profile_count n_p_bbs = profile_count::zero ();
|
|
profile_count n_p_loops = profile_count::zero ();
|
|
profile_count n_p_stmts = profile_count::zero ();
|
|
profile_count n_p_conditions = profile_count::zero ();
|
|
|
|
basic_block bb;
|
|
|
|
FOR_ALL_BB_FN (bb, cfun)
|
|
{
|
|
gimple_stmt_iterator psi;
|
|
|
|
n_bbs++;
|
|
if (bb->count.initialized_p ())
|
|
n_p_bbs += bb->count;
|
|
|
|
/* Ignore artificial surrounding loop. */
|
|
if (bb == bb->loop_father->header
|
|
&& bb->index != 0)
|
|
{
|
|
n_loops++;
|
|
n_p_loops += bb->count;
|
|
}
|
|
|
|
if (EDGE_COUNT (bb->succs) > 1)
|
|
{
|
|
n_conditions++;
|
|
if (bb->count.initialized_p ())
|
|
n_p_conditions += bb->count;
|
|
}
|
|
|
|
for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi))
|
|
{
|
|
n_stmts++;
|
|
if (bb->count.initialized_p ())
|
|
n_p_stmts += bb->count;
|
|
}
|
|
}
|
|
|
|
fprintf (file, "\nGlobal statistics (");
|
|
fprintf (file, "BBS:%ld, ", n_bbs);
|
|
fprintf (file, "LOOPS:%ld, ", n_loops);
|
|
fprintf (file, "CONDITIONS:%ld, ", n_conditions);
|
|
fprintf (file, "STMTS:%ld)\n", n_stmts);
|
|
fprintf (file, "Global profiling statistics (");
|
|
fprintf (file, "BBS:");
|
|
n_p_bbs.dump (file);
|
|
fprintf (file, ", LOOPS:");
|
|
n_p_loops.dump (file);
|
|
fprintf (file, ", CONDITIONS:");
|
|
n_p_conditions.dump (file);
|
|
fprintf (file, ", STMTS:");
|
|
n_p_stmts.dump (file);
|
|
fprintf (file, ")\n\n");
|
|
}
|
|
|
|
/* Print statistics for SCOP to FILE. */
|
|
|
|
static void
|
|
print_graphite_scop_statistics (FILE* file, scop_p scop)
|
|
{
|
|
long n_bbs = 0;
|
|
long n_loops = 0;
|
|
long n_stmts = 0;
|
|
long n_conditions = 0;
|
|
profile_count n_p_bbs = profile_count::zero ();
|
|
profile_count n_p_loops = profile_count::zero ();
|
|
profile_count n_p_stmts = profile_count::zero ();
|
|
profile_count n_p_conditions = profile_count::zero ();
|
|
|
|
basic_block bb;
|
|
|
|
FOR_ALL_BB_FN (bb, cfun)
|
|
{
|
|
gimple_stmt_iterator psi;
|
|
loop_p loop = bb->loop_father;
|
|
|
|
if (!bb_in_sese_p (bb, scop->scop_info->region))
|
|
continue;
|
|
|
|
n_bbs++;
|
|
if (bb->count.initialized_p ())
|
|
n_p_bbs += bb->count;
|
|
|
|
if (EDGE_COUNT (bb->succs) > 1)
|
|
{
|
|
n_conditions++;
|
|
n_p_conditions += bb->count;
|
|
}
|
|
|
|
for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi))
|
|
{
|
|
n_stmts++;
|
|
n_p_stmts += bb->count;
|
|
}
|
|
|
|
if (loop->header == bb && loop_in_sese_p (loop, scop->scop_info->region))
|
|
{
|
|
n_loops++;
|
|
n_p_loops += bb->count;
|
|
}
|
|
}
|
|
|
|
fprintf (file, "\nFunction Name: %s\n", current_function_name ());
|
|
|
|
edge scop_begin = scop->scop_info->region.entry;
|
|
edge scop_end = scop->scop_info->region.exit;
|
|
|
|
fprintf (file, "\nSCoP (entry_edge (bb_%d, bb_%d), ",
|
|
scop_begin->src->index, scop_begin->dest->index);
|
|
fprintf (file, "exit_edge (bb_%d, bb_%d))",
|
|
scop_end->src->index, scop_end->dest->index);
|
|
|
|
fprintf (file, "\nSCoP statistics (");
|
|
fprintf (file, "BBS:%ld, ", n_bbs);
|
|
fprintf (file, "LOOPS:%ld, ", n_loops);
|
|
fprintf (file, "CONDITIONS:%ld, ", n_conditions);
|
|
fprintf (file, "STMTS:%ld)\n", n_stmts);
|
|
fprintf (file, "SCoP profiling statistics (");
|
|
fprintf (file, "BBS:");
|
|
n_p_bbs.dump (file);
|
|
fprintf (file, ", LOOPS:");
|
|
n_p_loops.dump (file);
|
|
fprintf (file, ", CONDITIONS:");
|
|
n_p_conditions.dump (file);
|
|
fprintf (file, ", STMTS:");
|
|
n_p_stmts.dump (file);
|
|
fprintf (file, ")\n\n");
|
|
}
|
|
|
|
/* Print statistics for SCOPS to FILE. */
|
|
|
|
static void
|
|
print_graphite_statistics (FILE* file, vec<scop_p> scops)
|
|
{
|
|
int i;
|
|
scop_p scop;
|
|
|
|
FOR_EACH_VEC_ELT (scops, i, scop)
|
|
print_graphite_scop_statistics (file, scop);
|
|
}
|
|
|
|
struct seir_cache_key
|
|
{
|
|
hashval_t hash;
|
|
int entry_dest;
|
|
int exit_src;
|
|
int loop_num;
|
|
tree expr;
|
|
};
|
|
|
|
struct sese_scev_hash : typed_noop_remove <seir_cache_key>
|
|
{
|
|
typedef seir_cache_key value_type;
|
|
typedef seir_cache_key compare_type;
|
|
static hashval_t hash (const seir_cache_key &key) { return key.hash; }
|
|
static bool
|
|
equal (const seir_cache_key &key1, const seir_cache_key &key2)
|
|
{
|
|
return (key1.hash == key2.hash
|
|
&& key1.entry_dest == key2.entry_dest
|
|
&& key1.exit_src == key2.exit_src
|
|
&& key1.loop_num == key2.loop_num
|
|
&& operand_equal_p (key1.expr, key2.expr, 0));
|
|
}
|
|
static void mark_deleted (seir_cache_key &key) { key.expr = NULL_TREE; }
|
|
static const bool empty_zero_p = false;
|
|
static void mark_empty (seir_cache_key &key) { key.entry_dest = 0; }
|
|
static bool is_deleted (const seir_cache_key &key) { return !key.expr; }
|
|
static bool is_empty (const seir_cache_key &key) { return key.entry_dest == 0; }
|
|
};
|
|
|
|
static hash_map<sese_scev_hash, tree> *seir_cache;
|
|
|
|
/* Same as scalar_evolution_in_region but caches results so we avoid
|
|
re-computing evolutions during transform phase. */
|
|
|
|
tree
|
|
cached_scalar_evolution_in_region (const sese_l ®ion, loop_p loop,
|
|
tree expr)
|
|
{
|
|
seir_cache_key key;
|
|
key.entry_dest = region.entry->dest->index;
|
|
key.exit_src = region.exit->src->index;
|
|
key.loop_num = loop->num;
|
|
key.expr = expr;
|
|
inchash::hash hstate (0);
|
|
hstate.add_int (key.entry_dest);
|
|
hstate.add_int (key.exit_src);
|
|
hstate.add_int (key.loop_num);
|
|
inchash::add_expr (key.expr, hstate);
|
|
key.hash = hstate.end ();
|
|
|
|
bool existed;
|
|
tree &chrec = seir_cache->get_or_insert (key, &existed);
|
|
if (!existed)
|
|
chrec = scalar_evolution_in_region (region, loop, expr);
|
|
return chrec;
|
|
}
|
|
|
|
/* Deletes all scops in SCOPS. */
|
|
|
|
static void
|
|
free_scops (vec<scop_p> scops)
|
|
{
|
|
int i;
|
|
scop_p scop;
|
|
|
|
FOR_EACH_VEC_ELT (scops, i, scop)
|
|
free_scop (scop);
|
|
|
|
scops.release ();
|
|
}
|
|
|
|
/* Transforms LOOP to the canonical loop closed SSA form. */
|
|
|
|
static void
|
|
canonicalize_loop_closed_ssa (loop_p loop, edge e)
|
|
{
|
|
basic_block bb;
|
|
gphi_iterator psi;
|
|
|
|
bb = e->dest;
|
|
|
|
/* Make the loop-close PHI node BB contain only PHIs and have a
|
|
single predecessor. */
|
|
if (single_pred_p (bb))
|
|
{
|
|
e = split_block_after_labels (bb);
|
|
bb = e->src;
|
|
}
|
|
else
|
|
{
|
|
basic_block close = split_edge (e);
|
|
e = single_succ_edge (close);
|
|
for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
|
|
{
|
|
gphi *phi = psi.phi ();
|
|
use_operand_p use_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, e);
|
|
tree arg = USE_FROM_PTR (use_p);
|
|
|
|
/* Only add close phi nodes for SSA_NAMEs defined in LOOP. */
|
|
if (TREE_CODE (arg) != SSA_NAME
|
|
|| SSA_NAME_IS_DEFAULT_DEF (arg)
|
|
|| ! flow_bb_inside_loop_p (loop,
|
|
gimple_bb (SSA_NAME_DEF_STMT (arg))))
|
|
continue;
|
|
|
|
tree res = copy_ssa_name (arg);
|
|
gphi *close_phi = create_phi_node (res, close);
|
|
add_phi_arg (close_phi, arg, gimple_phi_arg_edge (close_phi, 0),
|
|
UNKNOWN_LOCATION);
|
|
SET_USE (use_p, res);
|
|
}
|
|
bb = close;
|
|
}
|
|
|
|
/* Eliminate duplicates. This relies on processing loops from
|
|
innermost to outer. */
|
|
for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
|
|
{
|
|
gphi_iterator gsi = psi;
|
|
gphi *phi = psi.phi ();
|
|
|
|
/* At this point, PHI should be a close phi in normal form. */
|
|
gcc_assert (gimple_phi_num_args (phi) == 1);
|
|
|
|
/* Iterate over the next phis and remove duplicates. */
|
|
gsi_next (&gsi);
|
|
while (!gsi_end_p (gsi))
|
|
if (gimple_phi_arg_def (phi, 0) == gimple_phi_arg_def (gsi.phi (), 0)
|
|
&& may_propagate_copy (gimple_phi_result (gsi.phi ()),
|
|
gimple_phi_result (phi)))
|
|
{
|
|
replace_uses_by (gimple_phi_result (gsi.phi ()),
|
|
gimple_phi_result (phi));
|
|
remove_phi_node (&gsi, true);
|
|
}
|
|
else
|
|
gsi_next (&gsi);
|
|
}
|
|
}
|
|
|
|
/* Converts the current loop closed SSA form to a canonical form
|
|
expected by the Graphite code generation.
|
|
|
|
The loop closed SSA form has the following invariant: a variable
|
|
defined in a loop that is used outside the loop appears only in the
|
|
phi nodes in the destination of the loop exit. These phi nodes are
|
|
called close phi nodes.
|
|
|
|
The canonical loop closed SSA form contains the extra invariants:
|
|
|
|
- when the loop contains only one exit, the close phi nodes contain
|
|
only one argument. That implies that the basic block that contains
|
|
the close phi nodes has only one predecessor, that is a basic block
|
|
in the loop.
|
|
|
|
- the basic block containing the close phi nodes does not contain
|
|
other statements.
|
|
|
|
- there exist only one phi node per definition in the loop.
|
|
|
|
In addition to that we also make sure that loop exit edges are
|
|
first in the successor edge vector. This is to make RPO order
|
|
as computed by pre_and_rev_post_order_compute be consistent with
|
|
what initial schedule generation expects.
|
|
*/
|
|
|
|
static void
|
|
canonicalize_loop_form (void)
|
|
{
|
|
for (auto loop : loops_list (cfun, LI_FROM_INNERMOST))
|
|
{
|
|
edge e = single_exit (loop);
|
|
if (!e || (e->flags & (EDGE_COMPLEX|EDGE_FAKE)))
|
|
continue;
|
|
|
|
canonicalize_loop_closed_ssa (loop, e);
|
|
|
|
/* If the exit is not first in the edge vector make it so. */
|
|
if (e != EDGE_SUCC (e->src, 0))
|
|
{
|
|
unsigned ei;
|
|
for (ei = 0; EDGE_SUCC (e->src, ei) != e; ++ei)
|
|
;
|
|
std::swap (EDGE_SUCC (e->src, ei), EDGE_SUCC (e->src, 0));
|
|
}
|
|
}
|
|
|
|
/* We can end up releasing duplicate exit PHIs and also introduce
|
|
additional copies so the cached information isn't correct anymore. */
|
|
scev_reset ();
|
|
|
|
checking_verify_loop_closed_ssa (true);
|
|
}
|
|
|
|
isl_ctx *the_isl_ctx;
|
|
|
|
/* Perform a set of linear transforms on the loops of the current
|
|
function. */
|
|
|
|
void
|
|
graphite_transform_loops (void)
|
|
{
|
|
int i;
|
|
scop_p scop;
|
|
bool changed = false;
|
|
vec<scop_p> scops = vNULL;
|
|
isl_ctx *ctx;
|
|
|
|
/* If a function is parallel it was most probably already run through graphite
|
|
once. No need to run again. */
|
|
if (parallelized_function_p (cfun->decl))
|
|
return;
|
|
|
|
calculate_dominance_info (CDI_DOMINATORS);
|
|
|
|
/* We rely on post-dominators during merging of SESE regions so those
|
|
have to be meaningful. */
|
|
connect_infinite_loops_to_exit ();
|
|
|
|
ctx = isl_ctx_alloc ();
|
|
isl_options_set_on_error (ctx, ISL_ON_ERROR_ABORT);
|
|
the_isl_ctx = ctx;
|
|
|
|
sort_sibling_loops (cfun);
|
|
canonicalize_loop_form ();
|
|
|
|
/* Print the loop structure. */
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
{
|
|
print_loops (dump_file, 2);
|
|
print_loops (dump_file, 3);
|
|
}
|
|
|
|
seir_cache = new hash_map<sese_scev_hash, tree>;
|
|
|
|
calculate_dominance_info (CDI_POST_DOMINATORS);
|
|
build_scops (&scops);
|
|
free_dominance_info (CDI_POST_DOMINATORS);
|
|
|
|
/* Remove the fake exits before transform given they are not reflected
|
|
in loop structures we end up verifying. */
|
|
remove_fake_exit_edges ();
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
{
|
|
print_graphite_statistics (dump_file, scops);
|
|
print_global_statistics (dump_file);
|
|
}
|
|
|
|
FOR_EACH_VEC_ELT (scops, i, scop)
|
|
if (dbg_cnt (graphite_scop))
|
|
{
|
|
scop->isl_context = ctx;
|
|
if (!build_poly_scop (scop))
|
|
continue;
|
|
|
|
if (!apply_poly_transforms (scop))
|
|
continue;
|
|
|
|
changed = true;
|
|
if (graphite_regenerate_ast_isl (scop)
|
|
&& dump_enabled_p ())
|
|
{
|
|
dump_user_location_t loc = find_loop_location
|
|
(scops[i]->scop_info->region.entry->dest->loop_father);
|
|
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
|
|
"loop nest optimized\n");
|
|
}
|
|
}
|
|
|
|
delete seir_cache;
|
|
seir_cache = NULL;
|
|
|
|
if (changed)
|
|
{
|
|
mark_virtual_operands_for_renaming (cfun);
|
|
update_ssa (TODO_update_ssa);
|
|
checking_verify_ssa (true, true);
|
|
rewrite_into_loop_closed_ssa (NULL, 0);
|
|
scev_reset ();
|
|
checking_verify_loop_structure ();
|
|
}
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
{
|
|
int num_no_dependency = 0;
|
|
|
|
for (auto loop : loops_list (cfun, 0))
|
|
if (loop->can_be_parallel)
|
|
num_no_dependency++;
|
|
|
|
fprintf (dump_file, "%d loops carried no dependency.\n",
|
|
num_no_dependency);
|
|
}
|
|
|
|
free_scops (scops);
|
|
the_isl_ctx = NULL;
|
|
isl_ctx_free (ctx);
|
|
|
|
if (changed)
|
|
{
|
|
/* FIXME: Graphite does not update profile meaningfully currently. */
|
|
cfun->cfg->full_profile = false;
|
|
cleanup_tree_cfg ();
|
|
profile_status_for_fn (cfun) = PROFILE_ABSENT;
|
|
release_recorded_exits (cfun);
|
|
tree_estimate_probability (false);
|
|
}
|
|
}
|
|
|
|
#else /* If isl is not available: #ifndef HAVE_isl. */
|
|
|
|
static void
|
|
graphite_transform_loops (void)
|
|
{
|
|
sorry ("Graphite loop optimizations cannot be used (isl is not available).");
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
static unsigned int
|
|
graphite_transforms (struct function *fun)
|
|
{
|
|
if (number_of_loops (fun) <= 1)
|
|
return 0;
|
|
|
|
graphite_transform_loops ();
|
|
|
|
return 0;
|
|
}
|
|
|
|
static bool
|
|
gate_graphite_transforms (void)
|
|
{
|
|
/* Enable -fgraphite pass if any one of the graphite optimization flags
|
|
is turned on. */
|
|
if (flag_graphite_identity
|
|
|| flag_loop_parallelize_all
|
|
|| flag_loop_nest_optimize)
|
|
flag_graphite = 1;
|
|
|
|
return flag_graphite != 0;
|
|
}
|
|
|
|
namespace {
|
|
|
|
const pass_data pass_data_graphite =
|
|
{
|
|
GIMPLE_PASS, /* type */
|
|
"graphite0", /* name */
|
|
OPTGROUP_LOOP, /* optinfo_flags */
|
|
TV_GRAPHITE, /* tv_id */
|
|
( PROP_cfg | PROP_ssa ), /* properties_required */
|
|
0, /* properties_provided */
|
|
0, /* properties_destroyed */
|
|
0, /* todo_flags_start */
|
|
0, /* todo_flags_finish */
|
|
};
|
|
|
|
class pass_graphite : public gimple_opt_pass
|
|
{
|
|
public:
|
|
pass_graphite (gcc::context *ctxt)
|
|
: gimple_opt_pass (pass_data_graphite, ctxt)
|
|
{}
|
|
|
|
/* opt_pass methods: */
|
|
bool gate (function *) final override { return gate_graphite_transforms (); }
|
|
|
|
}; // class pass_graphite
|
|
|
|
} // anon namespace
|
|
|
|
gimple_opt_pass *
|
|
make_pass_graphite (gcc::context *ctxt)
|
|
{
|
|
return new pass_graphite (ctxt);
|
|
}
|
|
|
|
namespace {
|
|
|
|
const pass_data pass_data_graphite_transforms =
|
|
{
|
|
GIMPLE_PASS, /* type */
|
|
"graphite", /* name */
|
|
OPTGROUP_LOOP, /* optinfo_flags */
|
|
TV_GRAPHITE_TRANSFORMS, /* tv_id */
|
|
( PROP_cfg | PROP_ssa ), /* properties_required */
|
|
0, /* properties_provided */
|
|
0, /* properties_destroyed */
|
|
0, /* todo_flags_start */
|
|
0, /* todo_flags_finish */
|
|
};
|
|
|
|
class pass_graphite_transforms : public gimple_opt_pass
|
|
{
|
|
public:
|
|
pass_graphite_transforms (gcc::context *ctxt)
|
|
: gimple_opt_pass (pass_data_graphite_transforms, ctxt)
|
|
{}
|
|
|
|
/* opt_pass methods: */
|
|
bool gate (function *) final override { return gate_graphite_transforms (); }
|
|
unsigned int execute (function *fun) final override
|
|
{
|
|
return graphite_transforms (fun);
|
|
}
|
|
|
|
}; // class pass_graphite_transforms
|
|
|
|
} // anon namespace
|
|
|
|
gimple_opt_pass *
|
|
make_pass_graphite_transforms (gcc::context *ctxt)
|
|
{
|
|
return new pass_graphite_transforms (ctxt);
|
|
}
|
|
|
|
|