gcc/gcc
Dominik Vogt 1135a1330c Drop excess size used for run time allocated stack variables.
* get_dynamic_stack_size is passed a SIZE of a data block (which is
  allocated elsewhere), the SIZE_ALIGN of the SIZE (i.e. the alignment
  of the underlying memory units (e.g. 32 bytes split into 4 times 8
  bytes = 64 bit alignment) and the REQUIRED_ALIGN of the data portion
  of the allocated memory.

* Assuming the function is called with SIZE = 2, SIZE_ALIGN = 8 and
  REQUIRED_ALIGN = 64 it first adds 7 bytes to SIZE -> 9.  This is
  what is needed to have two bytes 8-byte-aligned at some memory
  location without any known alignment.

* Finally round_push is called to round up SIZE to a multiple of the
  stack slot size.

The key to understanding this is that the function assumes that
STACK_DYNMAIC_OFFSET is completely unknown at the time its called
and therefore it does not make assumptions about the alignment of
STACKPOINTER + STACK_DYNMAIC_OFFSET.  The latest patch simply
hard-codes that SP + SDO is supposed to be aligned to at least
stack slot size (and does that in a very complicated way).  Since
there is no guarantee that this is the case on all targets, the
patch is broken.  It may miscalculate a SIZE that is too small in
some cases.

However, on many targets there is some guarantee about the
alignment of SP + SDO even if the actual value of SDO is unknown.
On s390x it's always 8-byte-aligned (stack slot size).  So the
right fix should be to add knowledge about the target's guaranteed
alignment of SP + SDO to the function.  I'm right now testing a
much simpler patch that uses
REGNO_POINTER_ALIGN(VIRTUAL_STACK_DYNAMIC_REGNUM) as the
alignment.


gcc/ChangeLog:

2016-08-23  Dominik Vogt  <vogt@linux.vnet.ibm.com>

	* explow.c (get_dynamic_stack_size): Take known alignment of stack
	pointer + STACK_DYNAMIC_OFFSET into account when calculating the
	size needed.  Correct a typo in a comment.

From-SVN: r239688
2016-08-23 09:20:15 +00:00
..
ada
c Implement C _FloatN, _FloatNx types. 2016-08-19 18:43:26 +01:00
c-family re PR c++/77321 (crash in warn_for_memset) 2016-08-22 21:53:59 +00:00
common re PR target/70677 (Suboptimal cond on AVR: unneeded stack frame) 2016-08-04 07:52:38 +00:00
config S/390: Add splitter for "and" with complement. 2016-08-23 09:01:42 +00:00
cp re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-18 10:28:03 +00:00
doc Add minimal _FloatN, _FloatNx built-in functions. 2016-08-22 12:57:39 +01:00
fortran re PR fortran/60774 (f951: internal compiler error: Segmentation fault: 11) 2016-08-22 18:23:43 +00:00
ginclude Implement C _FloatN, _FloatNx types. 2016-08-19 18:43:26 +01:00
go compiler: don't permit P.M if P is a pointer type 2016-08-22 21:30:49 +00:00
java re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
jit
lto
objc re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
objcp
po Regenerate .pot files. 2016-08-19 22:06:53 +01:00
testsuite S/390: Fix insv-1.c test with -m31. 2016-08-23 09:13:31 +00:00
ABOUT-GCC-NLS
acinclude.m4
aclocal.m4
addresses.h
alias.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
alias.h
alloc-pool.c
alloc-pool.h
asan.c Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
asan.h
attribs.c
attribs.h
auto-inc-dec.c
auto-profile.c
auto-profile.h
backend.h
BASE-VER
basic-block.h
bb-reorder.c
bb-reorder.h
bitmap.c
bitmap.h
bt-load.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
builtin-attrs.def
builtin-types.def Add minimal _FloatN, _FloatNx built-in functions. 2016-08-22 12:57:39 +01:00
builtins.c Support __builtin_isinf_sign for new floating-point types (PR middle-end/77269). 2016-08-22 19:03:59 +01:00
builtins.def Add minimal _FloatN, _FloatNx built-in functions. 2016-08-22 12:57:39 +01:00
builtins.h
caller-save.c
calls.c [PATCH][PR64971]Convert function pointer to Pmode when emit call. 2016-08-09 17:20:14 +00:00
calls.h
ccmp.c
ccmp.h
cfg-flags.def
cfg.c
cfg.h
cfganal.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
cfganal.h
cfgbuild.c
cfgbuild.h
cfgcleanup.c
cfgcleanup.h
cfgexpand.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
cfgexpand.h
cfghooks.c tree-cfgcleanup.c (tree_forwarder_block_p): Use bb_loop_header_p. 2016-08-05 07:41:45 +00:00
cfghooks.h
cfgloop.c cfgloop.h (struct loop): New field constraints. 2016-07-29 15:44:00 +00:00
cfgloop.h cfgloop.h (struct loop): New field constraints. 2016-07-29 15:44:00 +00:00
cfgloopanal.c
cfgloopmanip.c re PR tree-optimization/72772 (Missed SCEV after pass reordering@236440) 2016-08-11 09:02:04 +00:00
cfgloopmanip.h
cfgrtl.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
cfgrtl.h
cgraph.c
cgraph.h
cgraphbuild.c
cgraphclones.c
cgraphunit.c tree-pass.h (make_pass_materialize_all_clones): Declare. 2016-08-18 10:41:53 +00:00
ChangeLog Drop excess size used for run time allocated stack variables. 2016-08-23 09:20:15 +00:00
ChangeLog-1997
ChangeLog-1998
ChangeLog-1999
ChangeLog-2000
ChangeLog-2001
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog.dataflow
ChangeLog.gimple-classes
ChangeLog.graphite
ChangeLog.jit
ChangeLog.lib
ChangeLog.ptr
ChangeLog.tree-ssa
ChangeLog.tuples
chkp-builtins.def
cif-code.def
cilk-builtins.def
cilk-common.c
cilk.h
cilkplus.def
collect2-aix.c
collect2-aix.h
collect2.c
collect2.h
collect-utils.c
collect-utils.h
combine-stack-adj.c
combine.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
common.md
common.opt passes.c (execute_todo): Do not push/pop TV_TODO. 2016-08-12 07:38:24 +00:00
compare-elim.c
conditions.h
config.build
config.gcc
config.host
config.in
configure
configure.ac
context.c
context.h
convert.c
convert.h
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
coretypes.h Cherry-pick fprofile-generate-atomic from google/gcc-4_9 2016-08-10 13:11:42 +00:00
coverage.c Do not use LONG_LONG_TYPE_SIZE in #if macro condition 2016-08-17 06:55:35 +00:00
coverage.h
cppbuiltin.c
cppbuiltin.h
cppdefault.c
cppdefault.h
cprop.c
cse.c re PR target/70903 (wrong code with bfi @ aarch64 with -Os) 2016-08-04 13:20:57 +00:00
cselib.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-09 16:39:28 +00:00
cselib.h
cstamp-h.in
data-streamer-in.c data-streamer-in.c (streamer_read_wide_int): New. 2016-08-06 21:11:26 +00:00
data-streamer-out.c data-streamer-in.c (streamer_read_wide_int): New. 2016-08-06 21:11:26 +00:00
data-streamer.c
data-streamer.h data-streamer-in.c (streamer_read_wide_int): New. 2016-08-06 21:11:26 +00:00
DATESTAMP Daily bump. 2016-08-23 00:16:16 +00:00
dbgcnt.c
dbgcnt.def
dbgcnt.h
dbxout.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
dbxout.h
dce.c
dce.h
ddg.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
ddg.h
debug.c
debug.h
defaults.h defaults.h (LOG2_BITS_PER_UNIT): Move from here... 2016-07-27 20:35:35 +00:00
DEV-PHASE
df-core.c re PR rtl-optimization/72855 (Long compile time due to integrity checking during dataflow analysis per loop) 2016-08-11 22:20:41 +00:00
df-problems.c
df-scan.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
df.h
dfp.c
dfp.h
diagnostic-color.c
diagnostic-color.h
diagnostic-core.h
diagnostic-show-locus.c Reimplement removal fix-it hints in terms of replace 2016-08-19 21:18:05 +00:00
diagnostic.c Reimplement removal fix-it hints in terms of replace 2016-08-19 21:18:05 +00:00
diagnostic.def
diagnostic.h Allow calling diagnostic_show_locus without a diagnostic_info 2016-08-18 19:12:54 +00:00
dojump.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
dojump.h
dominance.c
dominance.h
domwalk.c
domwalk.h
double-int.c
double-int.h
dse.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
dumpfile.c
dumpfile.h
dwarf2asm.c
dwarf2asm.h
dwarf2cfi.c
dwarf2out.c DWARF: do not emit DW_TAG_variable to materialize DWARF procedures 2016-08-18 14:39:22 +00:00
dwarf2out.h
emit-rtl.c 016-08-04 Bernd Edlinger <bernd.edlinger@hotmail.de> 2016-08-04 13:23:36 +00:00
emit-rtl.h
errors.c
errors.h
et-forest.c
et-forest.h
except.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
except.h
exec-tool.in
explow.c Drop excess size used for run time allocated stack variables. 2016-08-23 09:20:15 +00:00
explow.h
expmed.c re PR middle-end/67485 (expmed.c sanitizer detects overflow) 2016-08-16 18:48:16 +02:00
expmed.h
expr.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
expr.h
fibonacci_heap.c
fibonacci_heap.h
file-find.c
file-find.h
final.c Add source information to -fverbose-asm 2016-08-19 00:18:18 +00:00
fixed-value.c
fixed-value.h
flag-types.h
flags.h
fold-const-call.c Add minimal _FloatN, _FloatNx built-in functions. 2016-08-22 12:57:39 +01:00
fold-const-call.h
fold-const.c Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
fold-const.h
fp-test.c
FSFChangeLog
FSFChangeLog.10
FSFChangeLog.11
function-tests.c
function.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
function.h
fwprop.c
gcc-ar.c
gcc-main.c
gcc-plugin.h
gcc-rich-location.c
gcc-rich-location.h
gcc-symtab.h
gcc.c Fix invalid memory access in gcc.c (driver/72765) 2016-08-15 11:16:50 +00:00
gcc.h
gcov-counter.def
gcov-dump.c
gcov-io.c
gcov-io.h Do not use LONG_LONG_TYPE_SIZE in #if macro condition 2016-08-17 06:55:35 +00:00
gcov-iov.c
gcov-tool.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
gcov.c gcov: add new option (--hash-filenames) (PR 2016-08-16 14:14:18 +00:00
gcse-common.c
gcse-common.h
gcse.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
gcse.h
gdbasan.in
gdbhooks.py
gdbinit.in
gen-pass-instances.awk
genattr-common.c
genattr.c
genattrtab.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
genautomata.c
gencfn-macros.c
gencheck.c
genchecksum.c
gencodes.c
genconditions.c
genconfig.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
genconstants.c
genemit.c
genenums.c
generic-match-head.c
generic-match.h
genextract.c
genflags.c
gengenrtl.c
gengtype-lex.l
gengtype-parse.c
gengtype-state.c
gengtype.c Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
gengtype.h
genhooks.c
genmatch.c
genmddeps.c
genmddump.c
genmodes.c Teach VRP to register assertions along default switch labels (PR18046) 2016-07-26 15:19:58 +00:00
genmultilib
genopinit.c
genoutput.c
genpeep.c
genpreds.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
genrecog.c
gensupport.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
gensupport.h
gentarget-def.c
ggc-common.c
ggc-internal.h
ggc-none.c
ggc-page.c
ggc-tests.c
ggc.h
gimple-builder.c Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
gimple-builder.h
gimple-expr.c
gimple-expr.h
gimple-fold.c gimple-fold.c (gimple_fold_call): Use gimple_call_noreturn_p instead of testing ECF_NORETURN bit in gimple_call_flags. 2016-08-17 16:24:53 +02:00
gimple-fold.h
gimple-iterator.c
gimple-iterator.h
gimple-laddress.c Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
gimple-low.c gimple-fold.c (gimple_fold_call): Use gimple_call_noreturn_p instead of testing ECF_NORETURN bit in gimple_call_flags. 2016-08-17 16:24:53 +02:00
gimple-low.h
gimple-match-head.c
gimple-match.h
gimple-predict.h
gimple-pretty-print.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
gimple-pretty-print.h
gimple-ssa-backprop.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
gimple-ssa-isolate-paths.c
gimple-ssa-nonnull-compare.c
gimple-ssa-split-paths.c
gimple-ssa-strength-reduction.c gimple-ssa-strength-reduction.c (slsr_process_phi): Remove dead and unnecessary call to gimple_bb. 2016-07-26 14:13:52 +00:00
gimple-ssa.h
gimple-streamer-in.c
gimple-streamer-out.c
gimple-streamer.h
gimple-walk.c
gimple-walk.h
gimple.c Designate the widest case label to be the default label 2016-08-04 18:11:08 +00:00
gimple.def
gimple.h
gimplify-me.c
gimplify-me.h
gimplify.c re PR middle-end/70895 (OpenACC: loop reduction does not work. Output is zero.) 2016-08-18 14:46:19 +00:00
gimplify.h
glimits.h
godump.c
graph.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
graph.h
graphds.c
graphds.h
graphite-dependences.c
graphite-isl-ast-to-gimple.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
graphite-optimize-isl.c
graphite-poly.c
graphite-scop-detection.c
graphite-sese-to-poly.c
graphite.c
graphite.h
gsstruct.def
gstab.h
gsyms.h
gsyslimits.h
gtm-builtins.def
haifa-sched.c merge adjust_cost and adjust_cost_2 target hooks 2016-07-28 11:01:49 +00:00
hard-reg-set.h
hash-map-tests.c
hash-map-traits.h
hash-map.h
hash-set-tests.c
hash-set.h
hash-table.c
hash-table.h
hash-traits.h
highlev-plugin-common.h
hooks.c
hooks.h
host-default.c
hosthooks-def.h
hosthooks.h
hsa-brig-format.h
hsa-brig.c
hsa-dump.c
hsa-gen.c Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
hsa-regalloc.c
hsa.c
hsa.h
hw-doloop.c
hw-doloop.h
hwint.c
hwint.h
ifcvt.c
ifcvt.h
inchash.c
inchash.h
incpath.c
incpath.h
init-regs.c
input.c selftest.h: add class line_table_test 2016-08-18 16:22:10 +00:00
input.h selftest.h: add class line_table_test 2016-08-18 16:22:10 +00:00
insn-addr.h
insn-notes.def
internal-fn.c Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
internal-fn.def
internal-fn.h
intl.c
intl.h
ipa-chkp.c
ipa-chkp.h
ipa-comdats.c
ipa-cp.c
ipa-devirt.c
ipa-hsa.c
ipa-icf-gimple.c
ipa-icf-gimple.h
ipa-icf.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
ipa-icf.h
ipa-inline-analysis.c
ipa-inline-transform.c
ipa-inline.c
ipa-inline.h
ipa-polymorphic-call.c [PR ipa/71981] Make get_dynamic_type grok MEM_REF 2016-08-09 18:05:30 +02:00
ipa-profile.c
ipa-prop.c re PR target/68273 (Wrong code on mips/mipsel due to (invalid?) peeking at alignments in function_arg.) 2016-08-09 07:38:13 +00:00
ipa-prop.h
ipa-pure-const.c
ipa-ref.c
ipa-ref.h
ipa-reference.c
ipa-reference.h
ipa-split.c
ipa-utils.c
ipa-utils.h
ipa-visibility.c
ipa.c tree-pass.h (make_pass_materialize_all_clones): Declare. 2016-08-18 10:41:53 +00:00
ira-build.c
ira-color.c
ira-conflicts.c
ira-costs.c
ira-emit.c
ira-int.h
ira-lives.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
ira.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
ira.h
is-a.h
jump.c
langhooks-def.h [PR63240] generate debug info for defaulted member functions 2016-08-12 07:11:50 +00:00
langhooks.c
langhooks.h [PR63240] generate debug info for defaulted member functions 2016-08-12 07:11:50 +00:00
LANGUAGES
lcm.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
lcm.h
libfuncs.h
limitx.h
limity.h
lists.c
lock-and-run.sh
loop-doloop.c
loop-init.c
loop-invariant.c
loop-iv.c
loop-unroll.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
loop-unroll.h
lower-subreg.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
lower-subreg.h
lra-assigns.c re PR rtl-optimization/69847 (Spec 2006 403.gcc slows down with -mlra vs. reload on PowerPC) 2016-08-02 16:07:36 +00:00
lra-coalesce.c
lra-constraints.c lra: A multiple_sets is not a simple_move_p (PR73650) 2016-08-15 18:17:21 +02:00
lra-eliminations.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
lra-int.h re PR rtl-optimization/69847 (Spec 2006 403.gcc slows down with -mlra vs. reload on PowerPC) 2016-08-02 16:07:36 +00:00
lra-lives.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
lra-remat.c re PR rtl-optimization/69847 (Spec 2006 403.gcc slows down with -mlra vs. reload on PowerPC) 2016-08-02 16:07:36 +00:00
lra-spills.c re PR rtl-optimization/72821 (RTL check: expected elt 2 type 'B', have '0' (rtx barrier) in BLOCK_FOR_INSN, at rtl.h:1424) 2016-08-08 15:58:46 +02:00
lra.c re PR rtl-optimization/69847 (Spec 2006 403.gcc slows down with -mlra vs. reload on PowerPC) 2016-08-02 16:07:36 +00:00
lra.h
lto-cgraph.c
lto-compress.c
lto-compress.h
lto-opts.c
lto-section-in.c
lto-section-names.h
lto-section-out.c
lto-streamer-in.c data-streamer-in.c (streamer_read_wide_int): New. 2016-08-06 21:11:26 +00:00
lto-streamer-out.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
lto-streamer.c
lto-streamer.h
lto-wrapper.c
machmode.def
machmode.h
main.c
Makefile.in Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
match.pd match.pd (x | 0 -> x): Add. 2016-08-19 07:03:48 +00:00
mcf.c
mem-stats-traits.h
mem-stats.h
memory-block.cc
memory-block.h
mkconfig.sh
mode-classes.def
mode-switching.c
modulo-sched.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
multiple_target.c
omp-builtins.def
omp-low.c omp-low.c (lower_oacc_reductions): Adjust variable lookup to use maybe_lookup_decl... 2016-08-17 12:08:30 +00:00
omp-low.h
omp-simd-clone.c re PR middle-end/68762 (link error for inline function decorated with OpenMP declare simd) 2016-08-08 21:45:53 +02:00
ONEWS
opt-functions.awk
opt-gather.awk
opt-include.awk
opt-read.awk
optabs-libfuncs.c
optabs-libfuncs.h
optabs-query.c
optabs-query.h
optabs-tree.c
optabs-tree.h
optabs.c
optabs.def
optabs.h
optc-gen.awk
optc-save-gen.awk
opth-gen.awk
opts-common.c
opts-diagnostic.h
opts-global.c
opts.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
opts.h
output.h
params-enum.h
params-list.h
params-options.h
params.c
params.def Teach VRP to register assertions along default switch labels (PR18046) 2016-07-26 15:19:58 +00:00
params.h
pass_manager.h
passes.c passes.c (execute_todo): Do not push/pop TV_TODO. 2016-08-12 07:38:24 +00:00
passes.def tree-pass.h (make_pass_materialize_all_clones): Declare. 2016-08-18 10:41:53 +00:00
plugin.c
plugin.def
plugin.h
postreload-gcse.c
postreload.c
predict.c gimple-fold.c (gimple_fold_call): Use gimple_call_noreturn_p instead of testing ECF_NORETURN bit in gimple_call_flags. 2016-08-17 16:24:53 +02:00
predict.def
predict.h
prefix.c
prefix.h
pretty-print.c
pretty-print.h
print-rtl.c
print-rtl.h
print-tree.c Improve readability of debug_tree() dumps for SSA_NAME and VECTOR_CST 2016-08-22 15:13:16 +00:00
print-tree.h
profile.c
profile.h
read-md.c
read-md.h
read-rtl.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
README.Portability
real.c Implement C _FloatN, _FloatNx types. 2016-08-19 18:43:26 +01:00
real.h Implement C _FloatN, _FloatNx types. 2016-08-19 18:43:26 +01:00
realmpfr.c
realmpfr.h
recog.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
recog.h
ree.c ree.c (rest_of_handle_ree): Remove redundant timevar push/pop. 2016-08-15 11:07:52 +00:00
reg-notes.def
reg-stack.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-09 16:39:28 +00:00
regcprop.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
regcprop.h
reginfo.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
regrename.c
regrename.h
regs.h
regset.h
regstat.c
reload1.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
reload.c [RELOAD] Don't assume subreg mem address is ok 2016-08-18 08:11:22 +09:30
reload.h
reorg.c
resource.c
resource.h
rtl-chkp.c
rtl-chkp.h
rtl-error.c
rtl-error.h
rtl-iter.h
rtl-tests.c
rtl.c
rtl.def
rtl.h
rtlanal.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
rtlhash.c
rtlhash.h
rtlhooks-def.h
rtlhooks.c
sancov.c
sanitizer.def
sanopt.c
sbitmap.c
sbitmap.h add auto_sbitmap class 2016-07-26 10:43:58 +00:00
sched-deps.c
sched-ebb.c
sched-int.h
sched-rgn.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
sdbout.c
sdbout.h
sel-sched-dump.c
sel-sched-dump.h
sel-sched-ir.c
sel-sched-ir.h
sel-sched.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
sel-sched.h
selftest-run-tests.c Add selftests to selftest.c 2016-08-11 23:36:46 +00:00
selftest.c Evict selftest tempfiles from the diagnostics file cache 2016-08-18 13:07:53 +00:00
selftest.h selftest.h: add class line_table_test 2016-08-18 16:22:10 +00:00
sese.c
sese.h
shrink-wrap.c
shrink-wrap.h
signop.h
simplify-rtx.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
sparseset.c
sparseset.h
spellcheck-tree.c
spellcheck-tree.h
spellcheck.c
spellcheck.h
sreal.c
sreal.h
ssa-iterators.h ssa-iterators.h (ssa_vuse_operand): New inline. 2016-08-18 07:21:11 +00:00
ssa.h Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
stab.def
stack-ptr-mod.c
statistics.c re PR lto/77305 (-fdump-tree-all and -flto causes ICE) 2016-08-23 07:21:36 +00:00
statistics.h
stmt.c
stmt.h
stor-layout.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
stor-layout.h
store-motion.c make pattern_regs a vec 2016-07-28 11:01:34 +00:00
streamer-hooks.c
streamer-hooks.h
stringpool.c
stringpool.h
substring-locations.h Fix caret locations in format_type_warning (PR c/72857) 2016-08-16 18:19:34 +00:00
symbol-summary.h
symtab.c
sync-builtins.def
system.h Use static_assert for STATIC_ASSERT for C++11 onwards 2016-07-27 14:49:06 +00:00
target-def.h
target-globals.c
target-globals.h
target-hooks-macros.h
target-insns.def
target.def Implement C _FloatN, _FloatNx types. 2016-08-19 18:43:26 +01:00
target.h
targhooks.c Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
targhooks.h Implement C _FloatN, _FloatNx types. 2016-08-19 18:43:26 +01:00
timevar.c passes.c (execute_todo): Do not push/pop TV_TODO. 2016-08-12 07:38:24 +00:00
timevar.def
timevar.h passes.c (execute_todo): Do not push/pop TV_TODO. 2016-08-12 07:38:24 +00:00
tlink.c
toplev.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
toplev.h
tracer.c
tracer.h
trans-mem.c
trans-mem.h
tree-affine.c
tree-affine.h
tree-call-cdce.c
tree-cfg.c gimple-fold.c (gimple_fold_call): Use gimple_call_noreturn_p instead of testing ECF_NORETURN bit in gimple_call_flags. 2016-08-17 16:24:53 +02:00
tree-cfg.h
tree-cfgcleanup.c re PR middle-end/77259 (ICE in emit_move_insn since r232167) 2016-08-17 15:56:30 +02:00
tree-cfgcleanup.h
tree-chkp-opt.c tree-ssa.c: Include tree-cfg.h and tree-dfa.h. 2016-08-17 08:18:47 +00:00
tree-chkp.c re PR middle-end/72657 ([CHKP] internal compiler error: in ix86_expand_builtin) 2016-07-28 12:58:37 +00:00
tree-chkp.h
tree-chrec.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
tree-chrec.h
tree-complex.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:15:57 +00:00
tree-core.h Implement C _FloatN, _FloatNx types. 2016-08-19 18:43:26 +01:00
tree-data-ref.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
tree-data-ref.h
tree-dfa.c
tree-dfa.h
tree-diagnostic.c
tree-diagnostic.h
tree-dump.c
tree-dump.h
tree-eh.c
tree-eh.h
tree-emutls.c
tree-hash-traits.h
tree-hasher.h
tree-if-conv.c ssa-iterators.h (ssa_vuse_operand): New inline. 2016-08-18 07:21:11 +00:00
tree-inline.c tree-inline.c (remap_ssa_name): Check for POINTER_TYPE_P before accessing SSA_NAME_PTR_INFO. 2016-08-04 09:15:03 +00:00
tree-inline.h
tree-into-ssa.c tree-pass.h (make_pass_materialize_all_clones): Declare. 2016-08-18 10:41:53 +00:00
tree-into-ssa.h
tree-iterator.c
tree-iterator.h
tree-loop-distribution.c re PR tree-optimization/72824 (Signed floating point zero semantics broken at optimization level -O3 (tree-loop-distribute-patterns)) 2016-08-15 10:31:05 +02:00
tree-nested.c
tree-nested.h
tree-nrv.c
tree-object-size.c
tree-object-size.h
tree-outof-ssa.c add a constructor to elim_graph 2016-07-26 10:44:25 +00:00
tree-outof-ssa.h
tree-parloops.c
tree-parloops.h
tree-pass.h tree-pass.h (make_pass_materialize_all_clones): Declare. 2016-08-18 10:41:53 +00:00
tree-phinodes.c ssa-iterators.h (ssa_vuse_operand): New inline. 2016-08-18 07:21:11 +00:00
tree-phinodes.h ssa-iterators.h (ssa_vuse_operand): New inline. 2016-08-18 07:21:11 +00:00
tree-predcom.c re PR tree-optimization/71083 (Unaligned bit-field address when predictive commoning) 2016-08-12 19:30:39 +00:00
tree-pretty-print.c
tree-pretty-print.h
tree-profile.c Do not use LONG_LONG_TYPE_SIZE in #if macro condition 2016-08-17 06:55:35 +00:00
tree-scalar-evolution.c re PR tree-optimization/72772 (Missed SCEV after pass reordering@236440) 2016-08-09 15:01:49 +00:00
tree-scalar-evolution.h
tree-sra.c
tree-ssa-address.c Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
tree-ssa-address.h
tree-ssa-alias.c
tree-ssa-alias.h
tree-ssa-ccp.c tree-ssa-ccp.c (extend_mask): New param sgn. 2016-08-06 18:11:24 +00:00
tree-ssa-coalesce.c
tree-ssa-coalesce.h
tree-ssa-copy.c
tree-ssa-dce.c
tree-ssa-dom.c
tree-ssa-dom.h
tree-ssa-dse.c
tree-ssa-forwprop.c tree-ssa-forwprop.c (pass_forwprop::execute): Use RPO order. 2016-08-22 08:25:30 +00:00
tree-ssa-ifcombine.c
tree-ssa-live.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
tree-ssa-live.h
tree-ssa-loop-ch.c
tree-ssa-loop-im.c re PR middle-end/71734 (FAIL: libgomp.fortran/simd4.f90 -O3 -g execution test) 2016-08-10 08:03:02 -07:00
tree-ssa-loop-ivcanon.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
tree-ssa-loop-ivopts.c
tree-ssa-loop-ivopts.h
tree-ssa-loop-manip.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
tree-ssa-loop-manip.h
tree-ssa-loop-niter.c re PR tree-optimization/72817 (wrong code at -O3 on x86_64-linux-gnu (in both 32-bit and 64-bit modes)) 2016-08-16 09:13:50 +00:00
tree-ssa-loop-niter.h re PR tree-optimization/72772 (Missed SCEV after pass reordering@236440) 2016-08-09 15:01:49 +00:00
tree-ssa-loop-prefetch.c
tree-ssa-loop-unswitch.c re PR tree-optimization/23855 (loop header should also be pulled out of the inner loop too) 2016-08-17 08:11:32 +00:00
tree-ssa-loop.c
tree-ssa-loop.h
tree-ssa-math-opts.c
tree-ssa-operands.c
tree-ssa-operands.h
tree-ssa-phionlycprop.c
tree-ssa-phiopt.c
tree-ssa-phiprop.c
tree-ssa-pre.c re PR tree-optimization/77290 (test case gcc.dg/tree-ssa/pr71347.c fails starting with r239565) 2016-08-19 07:43:11 +00:00
tree-ssa-propagate.c re PR tree-optimization/76783 (wrong code with conditional vector assignment @ -Og) 2016-08-16 11:22:47 +00:00
tree-ssa-propagate.h
tree-ssa-reassoc.c re PR tree-optimization/71994 (ICE: verify_gimple failed) 2016-07-27 22:45:46 +00:00
tree-ssa-sccvn.c re PR tree-optimization/73434 (Wrong code with casting, branches and aliasing) 2016-08-15 09:56:00 +00:00
tree-ssa-sccvn.h
tree-ssa-scopedtables.c
tree-ssa-scopedtables.h
tree-ssa-sink.c
tree-ssa-strlen.c
tree-ssa-structalias.c add [cd]tors to scc_info 2016-07-26 10:44:31 +00:00
tree-ssa-tail-merge.c
tree-ssa-ter.c
tree-ssa-ter.h
tree-ssa-threadbackward.c tree-ssa-threadbackward.c (pass_data_thread_jumps): Remove unconditional TODO_cleanup_cfg. 2016-08-11 08:49:56 +00:00
tree-ssa-threadbackward.h
tree-ssa-threadedge.c Improve forward jump threading of switch statements (PR18046) 2016-08-05 23:29:53 +00:00
tree-ssa-threadedge.h
tree-ssa-threadupdate.c tree-ssa-threadupdate.c (thread_block_1): Remove unnecessary restriction on threading to a loop header. 2016-08-05 08:00:00 +00:00
tree-ssa-threadupdate.h
tree-ssa-uncprop.c
tree-ssa-uninit.c
tree-ssa.c tree-ssa.c: Include tree-cfg.h and tree-dfa.h. 2016-08-17 08:18:47 +00:00
tree-ssa.h
tree-ssanames.c
tree-ssanames.h Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
tree-stdarg.c use auto_sbitmap in various places 2016-07-26 10:44:08 +00:00
tree-stdarg.h
tree-streamer-in.c
tree-streamer-out.c
tree-streamer.c
tree-streamer.h
tree-switch-conversion.c
tree-tailcall.c
tree-vect-data-refs.c re PR tree-optimization/72517 (436.cactusADM: More than 40% regression in O3 and Ofast on AMD bdver4 m/c.) 2016-07-27 11:10:25 +00:00
tree-vect-generic.c
tree-vect-loop-manip.c re PR tree-optimization/77286 (ICE in fold_convert_loc, at fold-const.c:2248 building 435.gromacs) 2016-08-19 07:02:05 +00:00
tree-vect-loop.c re PR tree-optimization/71752 (ICE in compute_live_loop_exits, at tree-ssa-loop-manip.c:229 w/ -O1 -ftree-vectorize) 2016-08-17 15:31:44 +00:00
tree-vect-patterns.c
tree-vect-slp.c re PR tree-optimization/71752 (ICE in compute_live_loop_exits, at tree-ssa-loop-manip.c:229 w/ -O1 -ftree-vectorize) 2016-08-17 15:31:44 +00:00
tree-vect-stmts.c
tree-vectorizer.c re PR tree-optimization/57558 (Loop not vectorized if iteration count could be infinite) 2016-07-29 15:48:25 +00:00
tree-vectorizer.h re PR tree-optimization/69848 (poor vectorization of a loop from SPEC2006 464.h264ref) 2016-08-12 14:58:20 +00:00
tree-vrp.c re PR middle-end/27336 (delete null checks in callers to nonnull functions) 2016-08-23 07:23:19 +00:00
tree-vrp.h Makefile.in: Add tree-vrp.h to GTFILES. 2016-08-20 05:43:01 +00:00
tree.c Implement C _FloatN, _FloatNx types. 2016-08-19 18:43:26 +01:00
tree.def
tree.h Add minimal _FloatN, _FloatNx built-in functions. 2016-08-22 12:57:39 +01:00
treestruct.def
tsan.c
tsan.h
tsystem.h
typeclass.h
typed-splay-tree.h
ubsan.c re PR c/71512 (ICE: verify_gimple failed with UBSAN) 2016-08-12 21:56:26 +02:00
ubsan.h
valtrack.c
valtrack.h
value-prof.c Fix usage of POW2 histogram 2016-08-09 20:57:39 +00:00
value-prof.h
var-tracking.c re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
varasm.c [PATCH] [GCC] Don't use section anchors for declarations that don't fit in a single anchor range 2016-08-18 08:45:53 +00:00
varasm.h
varpool.c
vec.c
vec.h
version.c
version.h
vmsdbg.h
vmsdbgout.c
vtable-verify.c
vtable-verify.h
web.c
wide-int-print.cc
wide-int-print.h
wide-int.cc
wide-int.h
xcoff.h
xcoffout.c
xcoffout.h

Copyright (C) 2000-2016 Free Software Foundation, Inc.

This file is intended to contain a few notes about writing C code
within GCC so that it compiles without error on the full range of
compilers GCC needs to be able to compile on.

The problem is that many ISO-standard constructs are not accepted by
either old or buggy compilers, and we keep getting bitten by them.
This knowledge until now has been sparsely spread around, so I
thought I'd collect it in one useful place.  Please add and correct
any problems as you come across them.

I'm going to start from a base of the ISO C90 standard, since that is
probably what most people code to naturally.  Obviously using
constructs introduced after that is not a good idea.

For the complete coding style conventions used in GCC, please read
http://gcc.gnu.org/codingconventions.html


String literals
---------------

Irix6 "cc -n32" and OSF4 "cc" have problems with constant string
initializers with parens around it, e.g.

const char string[] = ("A string");

This is unfortunate since this is what the GNU gettext macro N_
produces.  You need to find a different way to code it.

Some compilers like MSVC++ have fairly low limits on the maximum
length of a string literal; 509 is the lowest we've come across.  You
may need to break up a long printf statement into many smaller ones.


Empty macro arguments
---------------------

ISO C (6.8.3 in the 1990 standard) specifies the following:

If (before argument substitution) any argument consists of no
preprocessing tokens, the behavior is undefined.

This was relaxed by ISO C99, but some older compilers emit an error,
so code like

#define foo(x, y) x y
foo (bar, )

needs to be coded in some other way.


Avoid unnecessary test before free
----------------------------------

Since SunOS 4 stopped being a reasonable portability target,
(which happened around 2007) there has been no need to guard
against "free (NULL)".  Thus, any guard like the following
constitutes a redundant test:

  if (P)
    free (P);

It is better to avoid the test.[*]
Instead, simply free P, regardless of whether it is NULL.

[*] However, if your profiling exposes a test like this in a
performance-critical loop, say where P is nearly always NULL, and
the cost of calling free on a NULL pointer would be prohibitively
high, consider using __builtin_expect, e.g., like this:

  if (__builtin_expect (ptr != NULL, 0))
    free (ptr);



Trigraphs
---------

You weren't going to use them anyway, but some otherwise ISO C
compliant compilers do not accept trigraphs.


Suffixes on Integer Constants
-----------------------------

You should never use a 'l' suffix on integer constants ('L' is fine),
since it can easily be confused with the number '1'.


			Common Coding Pitfalls
			======================

errno
-----

errno might be declared as a macro.


Implicit int
------------

In C, the 'int' keyword can often be omitted from type declarations.
For instance, you can write

  unsigned variable;

as shorthand for

  unsigned int variable;

There are several places where this can cause trouble.  First, suppose
'variable' is a long; then you might think

  (unsigned) variable

would convert it to unsigned long.  It does not.  It converts to
unsigned int.  This mostly causes problems on 64-bit platforms, where
long and int are not the same size.

Second, if you write a function definition with no return type at
all:

  operate (int a, int b)
  {
    ...
  }

that function is expected to return int, *not* void.  GCC will warn
about this.

Implicit function declarations always have return type int.  So if you
correct the above definition to

  void
  operate (int a, int b)
  ...

but operate() is called above its definition, you will get an error
about a "type mismatch with previous implicit declaration".  The cure
is to prototype all functions at the top of the file, or in an
appropriate header.

Char vs unsigned char vs int
----------------------------

In C, unqualified 'char' may be either signed or unsigned; it is the
implementation's choice.  When you are processing 7-bit ASCII, it does
not matter.  But when your program must handle arbitrary binary data,
or fully 8-bit character sets, you have a problem.  The most obvious
issue is if you have a look-up table indexed by characters.

For instance, the character '\341' in ISO Latin 1 is SMALL LETTER A
WITH ACUTE ACCENT.  In the proper locale, isalpha('\341') will be
true.  But if you read '\341' from a file and store it in a plain
char, isalpha(c) may look up character 225, or it may look up
character -31.  And the ctype table has no entry at offset -31, so
your program will crash.  (If you're lucky.)

It is wise to use unsigned char everywhere you possibly can.  This
avoids all these problems.  Unfortunately, the routines in <string.h>
take plain char arguments, so you have to remember to cast them back
and forth - or avoid the use of strxxx() functions, which is probably
a good idea anyway.

Another common mistake is to use either char or unsigned char to
receive the result of getc() or related stdio functions.  They may
return EOF, which is outside the range of values representable by
char.  If you use char, some legal character value may be confused
with EOF, such as '\377' (SMALL LETTER Y WITH UMLAUT, in Latin-1).
The correct choice is int.

A more subtle version of the same mistake might look like this:

  unsigned char pushback[NPUSHBACK];
  int pbidx;
  #define unget(c) (assert(pbidx < NPUSHBACK), pushback[pbidx++] = (c))
  #define get(c) (pbidx ? pushback[--pbidx] : getchar())
  ...
  unget(EOF);

which will mysteriously turn a pushed-back EOF into a SMALL LETTER Y
WITH UMLAUT.


Other common pitfalls
---------------------

o Expecting 'plain' char to be either sign or unsigned extending.

o Shifting an item by a negative amount or by greater than or equal to
  the number of bits in a type (expecting shifts by 32 to be sensible
  has caused quite a number of bugs at least in the early days).

o Expecting ints shifted right to be sign extended.

o Modifying the same value twice within one sequence point.

o Host vs. target floating point representation, including emitting NaNs
  and Infinities in a form that the assembler handles.

o qsort being an unstable sort function (unstable in the sense that
  multiple items that sort the same may be sorted in different orders
  by different qsort functions).

o Passing incorrect types to fprintf and friends.

o Adding a function declaration for a module declared in another file to
  a .c file instead of to a .h file.