mirror of git://gcc.gnu.org/git/gcc.git
![]() * coretypes.h (gimple_seq, const_gimple_seq): Typedef as gimple. * gimple.h (struct gimple_seq_node_d, struct gimple_seq_d): Remove. (const_gimple_seq_node): Remove. (gimple_seq_node): Typedef as gimple. (struct gimple_statement_base): Add next and prev members, adjust all WORD markers in using structs. (union gimple_statement_d): Link via gsbase.next field for GC and PCH. (gimple_seq_first, gimple_seq_first_stmt, gimple_seq_last, gimple_seq_last_stmt): Adjust as gimple_seq, gimple_seq_node and gimple are the same. (gimple_seq_set_last, gimple_seq_set_first): Don't allocate gimple_seq, adjust. (gimple_init_singleton): New function. (gsi_start_1, gsi_last_1, gsi_end_p, gsi_one_before_end_p): Adjust. (gsi_next, gsi_prev): Adjust, handle prev cyclic list correctly. (gsi_stmt): Adjust. (gsi_stmt_ptr): Remove. (enum gimple_alloc_kind): Remove gimple_alloc_kind_seq member. * gimple-iterator.c (update_bb_for_stmts): Take last parameter again, adjust for above changes. (update_call_edge_frequencies): Adjust for above changes. (gsi_insert_seq_nodes_before): Rewrite for new data structure. (gsi_insert_seq_nodes_after): Ditto. (gsi_split_seq_after): Ditto. (gsi_set_stmt): Ditto. (gsi_split_seq_before): Ditto. (gsi_remove): Ditto. (gsi_insert_seq_before_without_update): Don't free sequence. (gsi_insert_seq_after_without_update): Ditto. (gsi_replace): Assert some more invariants. (gsi_insert_before_without_update, gsi_insert_after_without_update): Tidy. (gsi_for_stmt): Don't search for stmt. (gsi_insert_on_edge_immediate): Tidy. * gimple.c (gimple_alloc_k): Remove "sequences". (gimple_seq_cache): Remove. (gimple_alloc_stat): Make stmt a singleton sequence. (gimple_seq_alloc, gimple_seq_free): Remove. (gimple_assign_set_rhs_with_ops_1): Ensure new stmt is a singleton. (gimple_copy): Ditto. * gimplify.c (gimplify_cleanup_point_expr): Use gsi_set_stmt, create iterator from correct sequence. * tree-phinodes.c (make_phi_node): Make stmt a singleton. * gimple.h (gimple_stmt_iterator <seq>): Make it be pointer to gimple_seq. (gimple_seq_set_last, gimple_seq_set_first): Take pointer to sequence, lazily allocate it. (bb_seq_addr): New function. (gsi_start_1): Rename from gsi_start, but take pointer to sequence. (gsi_start): Macro to wrap gsi_start_1 taking pointer of argument. (gsi_none): New function. (gsi_start_bb): Adjust. (gsi_last_1): Rename from gsi_last, but take pointer to sequence. (gsi_last): Macro to wrap gsi_last_1 taking pointer of argument. (gsi_last_bb): Adjust. (gsi_seq): Adjust. * tree-flow-inline.h (phi_nodes_ptr): New function. * gimple-iterator.c (gsi_insert_seq_nodes_before): Adjust to datastructure and interface change. (gsi_insert_seq_before_without_update): Ditto. (gsi_insert_seq_nodes_after): Ditto. (gsi_insert_seq_after_without_update): Ditto. (gsi_split_seq_after): Ditto, don't use gimple_seq_alloc. (gsi_split_seq_before): Ditto. (gsi_start_phis): Adjust. * tree-vect-loop.c (vect_determine_vectorization_factor): Use gsi_none. (vect_transform_loop): Ditto. * gimple.c (gimple_seq_add_stmt, gimple_seq_add_seq, gimple_seq_copy): Don't use gimple_seq_alloc. * gimplify.c (gimple_seq_add_stmt_without_update): Ditto. (gimplify_seq_add_seq): Ditto. * lto-streamer-in.c (make_new_block): Ditto. * tree-cfg.c (create_bb): Ditto. * tree-sra.c (initialize_parameter_reductions): Ditto. * gimple.h (gimple_seq_first, gimple_seq_first_stmt, gimple_seq_last, gimple_seq_last_stmt, gimple_seq_set_last, gimple_seq_set_first, gimple_seq_empty_p, gimple_seq_alloc_with_stmt, bb_seq, set_bb_seq): Move down to after gimple_statement_d definition. * gimple-fold.c (gimplify_and_update_call_from_tree): Use gsi_replace_with_seq, instead of inserting itself. * gimple-iterator.c (gsi_replace_with_seq): New function. * tree-ssa-forwprop.c (forward_propagate_comparison): Take iterator instead of statement, advance it. (ssa_forward_propagate_and_combine): Adjust call to above. * tree-phinodes.c (add_phi_node_to_bb): Tidy, don't use gimple_seq_alloc. * omp-low.c (finalize_task_copyfn): Don't use gimple_seq_alloc. * tree-nested.c (walk_gimple_omp_for): Ditto. * trans-mem.c (lower_transaction): Ditto. * tree-eh.c (do_return_redirection): Ditto. (do_goto_redirection): Ditto. (lower_try_finally_switch): Ditto. * gimplify.c (gimplify_stmt): Ditto. (gimplify_scan_omp_clauses): Ditto. (gimplify_omp_for): Ditto. (gimplify_function_tree): Ditto. * gimple-fold.c (gimplify_and_update_call_from_tree): Ditto. * tree-mudflap.c (mf_decl_cache_locals): Ditto. (mf_build_check_statement_for): Ditto. (mx_register_decls): Ditto. * graphite-sese-to-poly.c (remove_invariant_phi): Ditto, and don't use itertors to append. (insert_stmts): Ditto. (insert_out_of_ssa_copy): Ditto. (insert_out_of_ssa_copy_on_edge): Ditto. * gimple.h (gimple_bind_body_ptr): New function. (gimple_bind_body): Use it. (gimple_catch_handler): Use gimple_catch_handler_ptr. (gimple_eh_filter_failure_ptr): New function. (gimple_eh_filter_failure): Use it. (gimple_eh_else_n_body_ptr): New function. (gimple_eh_else_n_body): Use it. (gimple_eh_else_e_body_ptr): New function. (gimple_eh_else_e_body): Use it. (gimple_try_eval_ptr): New function. (gimple_try_eval): Use it. (gimple_try_cleanup_ptr): New function. (gimple_try_cleanup): Use it. (gimple_wce_cleanup_ptr): New function. (gimple_wce_cleanup): Use it. (gimple_omp_body_ptr): New function. (gimple_omp_body): Use it. (gimple_omp_for_pre_body_ptr): New function. (gimple_omp_for_pre_body): Use it. (gimple_transaction_body_ptr): New function. (gimple_transaction_body): Use it. (gsi_split_seq_before): Adjust to return nothing and take pointer to sequence. (gsi_set_stmt): Declare. (gsi_replace_with_seq): Declare. (walk_gimple_seq_mod): Declare. * function.h (struct function <gimple_body>): Use typedef gimple_seq. * gimple-iterator.c (gsi_set_stmt): New function. (gsi_split_seq_before): Return new sequence via pointer argument. (gsi_replace): Use gsi_set_stmt. * tree-ssa-loop-im.c (move_computations_stmt): First remove then insert stmt. * tree-complex.c (update_complex_components_on_edge): Don't copy gsi. * tree-phinodes.c (resize_phi_node): Don't resize stmt in-place, return new stmt. (reserve_phi_args_for_new_edge): Change call to above, use gsi_set_stmt. * omp-low.c (lower_omp): Change prototype to take pointer to sequence. (lower_rec_input_clauses): Use gimple_seq_add_seq instead of iterators. Adjust call to lower_omp. (lower_lastprivate_clauses): Adjust call to lower_omp. (lower_reduction_clauses): Ditto. (expand_omp_taskreg): Nullify non-cfg body of child_fn. (lower_omp_sections): Don't explicitely count sequence length, nullify lowered bodies earlier, ensure stmts are part of only one sequence, adjust call to lower_omp. (lower_omp_single): Ensure stmts are part of only one sequence, adjust call to lower_omp. (lower_omp_master): Ditto. (lower_omp_ordered): Ditto. (lower_omp_critical): Ditto. (lower_omp_for): Ditto. (lower_omp_taskreg): Ditto, tidy. (lower_omp_1): Adjust calls to lower_omp. (execute_lower_omp): Ditto. (lower_omp): Adjust to take pointer to sequence. (diagnose_sb_2): Use walk_gimple_seq_mod. (diagnose_omp_structured_block_errors): Ditto and set possibly changed function body. * gimple-low.c (lower_function_body): Set function body after it stabilizes. (lower_sequence): Adjust to take pointer to sequence. (lower_omp_directive): Ensure stmt isn't put twice into the sequence, adjust call to lower_sequence. (lower_stmt): Adjust calls to lower_sequence. (lower_gimple_bind): Ditto. (gimple_try_catch_may_fallthru): Call gsi_start with lvalue. * tree-nested.c (walk_body): Take pointer to sequence, use walk_gimple_seq_mod. (walk_function): Adjust call to walk_body, set possibly changed body. (walk_gimple_omp_for): Adjust calls to walk_body. (convert_nonlocal_omp_clauses): Ditto. (convert_nonlocal_reference_stmt): Ditto. (convert_local_omp_clauses): Ditto. (convert_local_reference_stmt): Ditto. (convert_tramp_reference_stmt): Ditto. (convert_gimple_call): Ditto. (convert_nl_goto_reference): Use local iterator copy. * gimple.c (walk_gimple_seq_mod): Renamed from walk_gimple_seq, but taking pointer to sequence, ensure gsi_start is called with callers lvalue. (walk_gimple_seq): New wrapper around walk_gimple_seq_mod, asserting that the sequence head didn't change. (walk_gimple_stmt): Replace all calls to walk_gimple_seq with walk_gimple_seq_mod. * trans-mem.c (lower_transaction): Use walk_gimple_seq_mod. (execute_lower_tm): Ditto, and set possibly changed body. * tree-eh.c (lower_eh_constructs_1): Take pointer to sequence, call gsi_start with that lvalue. (replace_goto_queue_stmt_list): Ditto. (replace_goto_queue_1): Adjust calls to replace_goto_queue_stmt_list. (replace_goto_queue): Ditto. (lower_try_finally_nofallthru): Adjust calls to lower_eh_constructs_1. (lower_try_finally_onedest): Ditto. (lower_try_finally_copy): Ditto. (lower_try_finally_switch): Ditto. (lower_try_finally): Ditto. (lower_eh_filter): Ditto. (lower_eh_must_not_throw): Ditto. (lower_cleanup): Ditto. (lower_eh_constructs_2): Ditto. (lower_catch): Ditto, and ensure gsi_start is called with lvalue. (lower_eh_constructs): Adjust calls to lower_eh_constructs_1, and set possibly changed body. (optimize_double_finally): Call gsi_start with lvalue. * tree-cfg.c (make_blocks): Adjust call to gsi_split_seq_before. (gimple_split_block): Ditto. (gimple_merge_blocks): Use gsi_start_phis. (move_stmt_r): Use walk_gimple_seq_mod. * tree-ssa-dse.c (dse_enter_block): Use gsi_last_bb. * cgraphbuild.c (build_cgraph_edges): Use gsi_start_phis. (rebuild_cgraph_edges): Ditto. (cgraph_rebuild_references): Ditto. * ipa-prop.c (ipa_analyze_params_uses): Ditto. * tree-inline.c (copy_phis_for_bb): Ditto. * tree-ssa-dce.c: Ditto. * cgraphunit.c (cgraph_analyze_function): Use gimple_has_body_p. From-SVN: r187053 |
||
---|---|---|
.. | ||
ada | ||
c-family | ||
common | ||
config | ||
cp | ||
doc | ||
fortran | ||
ginclude | ||
go | ||
java | ||
lto | ||
objc | ||
objcp | ||
po | ||
testsuite | ||
ABOUT-GCC-NLS | ||
BASE-VER | ||
COPYING | ||
COPYING.LIB | ||
COPYING3 | ||
COPYING3.LIB | ||
ChangeLog | ||
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.dataflow | ||
ChangeLog.graphite | ||
ChangeLog.lib | ||
ChangeLog.ptr | ||
ChangeLog.tree-ssa | ||
ChangeLog.tuples | ||
DATESTAMP | ||
DEV-PHASE | ||
FSFChangeLog | ||
FSFChangeLog.10 | ||
FSFChangeLog.11 | ||
LANGUAGES | ||
Makefile.in | ||
ONEWS | ||
README.Portability | ||
acinclude.m4 | ||
aclocal.m4 | ||
addresses.h | ||
alias.c | ||
alias.h | ||
alloc-pool.c | ||
alloc-pool.h | ||
attribs.c | ||
auto-inc-dec.c | ||
basic-block.h | ||
bb-reorder.c | ||
bb-reorder.h | ||
bitmap.c | ||
bitmap.h | ||
bt-load.c | ||
builtin-attrs.def | ||
builtin-types.def | ||
builtins.c | ||
builtins.def | ||
builtins.h | ||
c-aux-info.c | ||
c-config-lang.in | ||
c-convert.c | ||
c-decl.c | ||
c-errors.c | ||
c-lang.c | ||
c-lang.h | ||
c-objc-common.c | ||
c-objc-common.h | ||
c-parser.c | ||
c-tree.h | ||
c-typeck.c | ||
caller-save.c | ||
calls.c | ||
cfg.c | ||
cfganal.c | ||
cfgbuild.c | ||
cfgcleanup.c | ||
cfgexpand.c | ||
cfghooks.c | ||
cfghooks.h | ||
cfglayout.c | ||
cfglayout.h | ||
cfgloop.c | ||
cfgloop.h | ||
cfgloopanal.c | ||
cfgloopmanip.c | ||
cfgrtl.c | ||
cgraph.c | ||
cgraph.h | ||
cgraphbuild.c | ||
cgraphunit.c | ||
cif-code.def | ||
collect2-aix.c | ||
collect2-aix.h | ||
collect2.c | ||
collect2.h | ||
combine-stack-adj.c | ||
combine.c | ||
common.opt | ||
compare-elim.c | ||
conditions.h | ||
config.build | ||
config.gcc | ||
config.host | ||
config.in | ||
configure | ||
configure.ac | ||
convert.c | ||
convert.h | ||
coretypes.h | ||
coverage.c | ||
coverage.h | ||
cppbuiltin.c | ||
cppbuiltin.h | ||
cppdefault.c | ||
cppdefault.h | ||
cppspec.c | ||
cprop.c | ||
cse.c | ||
cselib.c | ||
cselib.h | ||
cstamp-h.in | ||
data-streamer-in.c | ||
data-streamer-out.c | ||
data-streamer.c | ||
data-streamer.h | ||
dbgcnt.c | ||
dbgcnt.def | ||
dbgcnt.h | ||
dbxout.c | ||
dbxout.h | ||
dce.c | ||
dce.h | ||
ddg.c | ||
ddg.h | ||
debug.c | ||
debug.h | ||
defaults.h | ||
df-core.c | ||
df-problems.c | ||
df-scan.c | ||
df.h | ||
dfp.c | ||
dfp.h | ||
diagnostic-core.h | ||
diagnostic.c | ||
diagnostic.def | ||
diagnostic.h | ||
dojump.c | ||
dominance.c | ||
domwalk.c | ||
domwalk.h | ||
double-int.c | ||
double-int.h | ||
dse.c | ||
dwarf2asm.c | ||
dwarf2asm.h | ||
dwarf2cfi.c | ||
dwarf2out.c | ||
dwarf2out.h | ||
ebitmap.c | ||
ebitmap.h | ||
emit-rtl.c | ||
emit-rtl.h | ||
errors.c | ||
errors.h | ||
et-forest.c | ||
et-forest.h | ||
except.c | ||
except.h | ||
exec-tool.in | ||
explow.c | ||
expmed.c | ||
expmed.h | ||
expr.c | ||
expr.h | ||
final.c | ||
fixed-value.c | ||
fixed-value.h | ||
flag-types.h | ||
flags.h | ||
fold-const.c | ||
fp-test.c | ||
function.c | ||
function.h | ||
fwprop.c | ||
gcc-ar.c | ||
gcc-plugin.h | ||
gcc.c | ||
gcc.h | ||
gccspec.c | ||
gcov-dump.c | ||
gcov-io.c | ||
gcov-io.h | ||
gcov-iov.c | ||
gcov.c | ||
gcse.c | ||
gcse.h | ||
gdbinit.in | ||
genattr-common.c | ||
genattr.c | ||
genattrtab.c | ||
genautomata.c | ||
gencheck.c | ||
genchecksum.c | ||
gencodes.c | ||
genconditions.c | ||
genconfig.c | ||
genconstants.c | ||
genemit.c | ||
genenums.c | ||
genextract.c | ||
genflags.c | ||
gengenrtl.c | ||
gengtype-lex.l | ||
gengtype-parse.c | ||
gengtype-state.c | ||
gengtype.c | ||
gengtype.h | ||
genhooks.c | ||
genmddeps.c | ||
genmodes.c | ||
genmultilib | ||
genopinit.c | ||
genoutput.c | ||
genpeep.c | ||
genpreds.c | ||
genrecog.c | ||
gensupport.c | ||
gensupport.h | ||
ggc-common.c | ||
ggc-internal.h | ||
ggc-none.c | ||
ggc-page.c | ||
ggc-zone.c | ||
ggc.h | ||
gimple-fold.c | ||
gimple-fold.h | ||
gimple-iterator.c | ||
gimple-low.c | ||
gimple-pretty-print.c | ||
gimple-pretty-print.h | ||
gimple-streamer-in.c | ||
gimple-streamer-out.c | ||
gimple-streamer.h | ||
gimple.c | ||
gimple.def | ||
gimple.h | ||
gimplify.c | ||
glimits.h | ||
godump.c | ||
graph.c | ||
graph.h | ||
graphds.c | ||
graphds.h | ||
graphite-blocking.c | ||
graphite-clast-to-gimple.c | ||
graphite-clast-to-gimple.h | ||
graphite-cloog-compat.h | ||
graphite-cloog-util.c | ||
graphite-cloog-util.h | ||
graphite-dependences.c | ||
graphite-dependences.h | ||
graphite-interchange.c | ||
graphite-poly.c | ||
graphite-poly.h | ||
graphite-ppl.c | ||
graphite-ppl.h | ||
graphite-scop-detection.c | ||
graphite-scop-detection.h | ||
graphite-sese-to-poly.c | ||
graphite-sese-to-poly.h | ||
graphite.c | ||
gsstruct.def | ||
gstab.h | ||
gsyms.h | ||
gsyslimits.h | ||
gtm-builtins.def | ||
haifa-sched.c | ||
hard-reg-set.h | ||
highlev-plugin-common.h | ||
hooks.c | ||
hooks.h | ||
host-default.c | ||
hosthooks-def.h | ||
hosthooks.h | ||
hw-doloop.c | ||
hw-doloop.h | ||
hwint.c | ||
hwint.h | ||
ifcvt.c | ||
incpath.c | ||
incpath.h | ||
init-regs.c | ||
input.c | ||
input.h | ||
insn-addr.h | ||
insn-notes.def | ||
integrate.c | ||
integrate.h | ||
internal-fn.c | ||
internal-fn.def | ||
internal-fn.h | ||
intl.c | ||
intl.h | ||
ipa-cp.c | ||
ipa-inline-analysis.c | ||
ipa-inline-transform.c | ||
ipa-inline.c | ||
ipa-inline.h | ||
ipa-prop.c | ||
ipa-prop.h | ||
ipa-pure-const.c | ||
ipa-ref-inline.h | ||
ipa-ref.c | ||
ipa-ref.h | ||
ipa-reference.c | ||
ipa-reference.h | ||
ipa-split.c | ||
ipa-utils.c | ||
ipa-utils.h | ||
ipa.c | ||
ira-build.c | ||
ira-color.c | ||
ira-conflicts.c | ||
ira-costs.c | ||
ira-emit.c | ||
ira-int.h | ||
ira-lives.c | ||
ira.c | ||
ira.h | ||
jump.c | ||
langhooks-def.h | ||
langhooks.c | ||
langhooks.h | ||
lcm.c | ||
libfuncs.h | ||
limitx.h | ||
limity.h | ||
lists.c | ||
loop-doloop.c | ||
loop-init.c | ||
loop-invariant.c | ||
loop-iv.c | ||
loop-unroll.c | ||
loop-unswitch.c | ||
lower-subreg.c | ||
lower-subreg.h | ||
lto-cgraph.c | ||
lto-compress.c | ||
lto-compress.h | ||
lto-opts.c | ||
lto-section-in.c | ||
lto-section-out.c | ||
lto-streamer-in.c | ||
lto-streamer-out.c | ||
lto-streamer.c | ||
lto-streamer.h | ||
lto-symtab.c | ||
lto-wrapper.c | ||
machmode.def | ||
machmode.h | ||
main.c | ||
matrix-reorg.c | ||
mcf.c | ||
mkconfig.sh | ||
mode-classes.def | ||
mode-switching.c | ||
modulo-sched.c | ||
omega.c | ||
omega.h | ||
omp-builtins.def | ||
omp-low.c | ||
opt-functions.awk | ||
opt-gather.awk | ||
opt-include.awk | ||
opt-read.awk | ||
optabs.c | ||
optabs.h | ||
optc-gen.awk | ||
optc-save-gen.awk | ||
opth-gen.awk | ||
opts-common.c | ||
opts-diagnostic.h | ||
opts-global.c | ||
opts.c | ||
opts.h | ||
output.h | ||
params.c | ||
params.def | ||
params.h | ||
passes.c | ||
plugin.c | ||
plugin.def | ||
plugin.h | ||
pointer-set.c | ||
pointer-set.h | ||
postreload-gcse.c | ||
postreload.c | ||
predict.c | ||
predict.def | ||
predict.h | ||
prefix.c | ||
prefix.h | ||
pretty-print.c | ||
pretty-print.h | ||
print-rtl.c | ||
print-tree.c | ||
profile.c | ||
profile.h | ||
read-md.c | ||
read-md.h | ||
read-rtl.c | ||
real.c | ||
real.h | ||
realmpfr.c | ||
realmpfr.h | ||
recog.c | ||
recog.h | ||
ree.c | ||
reg-notes.def | ||
reg-stack.c | ||
regcprop.c | ||
reginfo.c | ||
regmove.c | ||
regrename.c | ||
regrename.h | ||
regs.h | ||
regset.h | ||
regstat.c | ||
reload.c | ||
reload.h | ||
reload1.c | ||
reorg.c | ||
resource.c | ||
resource.h | ||
rtl-error.c | ||
rtl-error.h | ||
rtl.c | ||
rtl.def | ||
rtl.h | ||
rtlanal.c | ||
rtlhooks-def.h | ||
rtlhooks.c | ||
sbitmap.c | ||
sbitmap.h | ||
sched-deps.c | ||
sched-ebb.c | ||
sched-int.h | ||
sched-rgn.c | ||
sched-vis.c | ||
sdbout.c | ||
sdbout.h | ||
sel-sched-dump.c | ||
sel-sched-dump.h | ||
sel-sched-ir.c | ||
sel-sched-ir.h | ||
sel-sched.c | ||
sel-sched.h | ||
sese.c | ||
sese.h | ||
simplify-rtx.c | ||
sparseset.c | ||
sparseset.h | ||
sreal.c | ||
sreal.h | ||
ssaexpand.h | ||
stab.def | ||
stack-ptr-mod.c | ||
statistics.c | ||
statistics.h | ||
stmt.c | ||
stor-layout.c | ||
store-motion.c | ||
streamer-hooks.c | ||
streamer-hooks.h | ||
stringpool.c | ||
symtab.c | ||
sync-builtins.def | ||
system.h | ||
target-def.h | ||
target-globals.c | ||
target-globals.h | ||
target-hooks-macros.h | ||
target.def | ||
target.h | ||
targhooks.c | ||
targhooks.h | ||
timevar.c | ||
timevar.def | ||
timevar.h | ||
tlink.c | ||
toplev.c | ||
toplev.h | ||
tracer.c | ||
trans-mem.c | ||
trans-mem.h | ||
tree-affine.c | ||
tree-affine.h | ||
tree-browser.c | ||
tree-browser.def | ||
tree-call-cdce.c | ||
tree-cfg.c | ||
tree-cfgcleanup.c | ||
tree-chrec.c | ||
tree-chrec.h | ||
tree-complex.c | ||
tree-data-ref.c | ||
tree-data-ref.h | ||
tree-dfa.c | ||
tree-diagnostic.c | ||
tree-diagnostic.h | ||
tree-dump.c | ||
tree-dump.h | ||
tree-eh.c | ||
tree-emutls.c | ||
tree-flow-inline.h | ||
tree-flow.h | ||
tree-if-conv.c | ||
tree-inline.c | ||
tree-inline.h | ||
tree-into-ssa.c | ||
tree-iterator.c | ||
tree-iterator.h | ||
tree-loop-distribution.c | ||
tree-mudflap.c | ||
tree-mudflap.h | ||
tree-nested.c | ||
tree-nomudflap.c | ||
tree-nrv.c | ||
tree-object-size.c | ||
tree-optimize.c | ||
tree-outof-ssa.c | ||
tree-parloops.c | ||
tree-pass.h | ||
tree-phinodes.c | ||
tree-predcom.c | ||
tree-pretty-print.c | ||
tree-pretty-print.h | ||
tree-profile.c | ||
tree-scalar-evolution.c | ||
tree-scalar-evolution.h | ||
tree-sra.c | ||
tree-ssa-address.c | ||
tree-ssa-alias.c | ||
tree-ssa-alias.h | ||
tree-ssa-ccp.c | ||
tree-ssa-coalesce.c | ||
tree-ssa-copy.c | ||
tree-ssa-copyrename.c | ||
tree-ssa-dce.c | ||
tree-ssa-dom.c | ||
tree-ssa-dse.c | ||
tree-ssa-forwprop.c | ||
tree-ssa-ifcombine.c | ||
tree-ssa-live.c | ||
tree-ssa-live.h | ||
tree-ssa-loop-ch.c | ||
tree-ssa-loop-im.c | ||
tree-ssa-loop-ivcanon.c | ||
tree-ssa-loop-ivopts.c | ||
tree-ssa-loop-manip.c | ||
tree-ssa-loop-niter.c | ||
tree-ssa-loop-prefetch.c | ||
tree-ssa-loop-unswitch.c | ||
tree-ssa-loop.c | ||
tree-ssa-math-opts.c | ||
tree-ssa-operands.c | ||
tree-ssa-operands.h | ||
tree-ssa-phiopt.c | ||
tree-ssa-phiprop.c | ||
tree-ssa-pre.c | ||
tree-ssa-propagate.c | ||
tree-ssa-propagate.h | ||
tree-ssa-reassoc.c | ||
tree-ssa-sccvn.c | ||
tree-ssa-sccvn.h | ||
tree-ssa-sink.c | ||
tree-ssa-strlen.c | ||
tree-ssa-structalias.c | ||
tree-ssa-tail-merge.c | ||
tree-ssa-ter.c | ||
tree-ssa-threadedge.c | ||
tree-ssa-threadupdate.c | ||
tree-ssa-uncprop.c | ||
tree-ssa-uninit.c | ||
tree-ssa.c | ||
tree-ssanames.c | ||
tree-stdarg.c | ||
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 | ||
tree-vect-generic.c | ||
tree-vect-loop-manip.c | ||
tree-vect-loop.c | ||
tree-vect-patterns.c | ||
tree-vect-slp.c | ||
tree-vect-stmts.c | ||
tree-vectorizer.c | ||
tree-vectorizer.h | ||
tree-vrp.c | ||
tree.c | ||
tree.def | ||
tree.h | ||
treestruct.def | ||
tsystem.h | ||
typeclass.h | ||
value-prof.c | ||
value-prof.h | ||
var-tracking.c | ||
varasm.c | ||
varpool.c | ||
vec.c | ||
vec.h | ||
vecir.h | ||
vecprim.h | ||
version.c | ||
version.h | ||
vmsdbg.h | ||
vmsdbgout.c | ||
web.c | ||
xcoff.h | ||
xcoffout.c | ||
xcoffout.h |
README.Portability
Copyright (C) 2000, 2003 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 know 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.