aboutsummaryrefslogtreecommitdiff
path: root/gcc/flag-types.h
AgeCommit message (Collapse)AuthorFilesLines
2020-07-27LTO: Add -fcf-protection=checkH.J. Lu1-1/+2
Mixing -fcf-protection and -fcf-protection=none objects are allowed. Linker just merges -fcf-protection values from all input objects. Add -fcf-protection=check for the final link with LTO. An error is issued if LTO object files are compiled with different -fcf-protection values. Otherwise, -fcf-protection=check is ignored at the compile time. Without explicit -fcf-protection at link time, -fcf-protection values from LTO object files are merged at the final link. gcc/ PR bootstrap/96203 * common.opt: Add -fcf-protection=check. * flag-types.h (cf_protection_level): Add CF_CHECK. * lto-wrapper.c (merge_and_complain): Issue an error for mismatching -fcf-protection values with -fcf-protection=check. Otherwise, merge -fcf-protection values. * doc/invoke.texi: Document -fcf-protection=check. gcc/testsuite/ PR bootstrap/96203 * gcc.target/i386/pr96203-1.c: New test. * gcc.target/i386/pr96203-2.c: Likewise.
2020-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r279813
2019-11-12Include new generated gcc/params.opt file.Martin Liska1-0/+11
2019-11-12 Martin Liska <mliska@suse.cz> * Makefile.in: Include params.opt. * flag-types.h (enum parloops_schedule_type): Add parloops_schedule_type used in params.opt. * params.opt: New file. From-SVN: r278084
2019-11-06introduce -fcallgraph-info optionEric Botcazou1-0/+16
This was first submitted many years ago https://gcc.gnu.org/ml/gcc-patches/2010-10/msg02468.html The command line option -fcallgraph-info is added and makes the compiler generate another output file (xxx.ci) for each compilation unit (or LTO partitoin), which is a valid VCG file (you can launch your favorite VCG viewer on it unmodified) and contains the "final" callgraph of the unit. "final" is a bit of a misnomer as this is actually the callgraph at RTL expansion time, but since most high-level optimizations are done at the Tree level and RTL doesn't usually fiddle with calls, it's final in almost all cases. Moreover, the nodes can be decorated with additional info: -fcallgraph-info=su adds stack usage info and -fcallgraph-info=da dynamic allocation info. for gcc/ChangeLog From Eric Botcazou <ebotcazou@adacore.com>, Alexandre Oliva <oliva@adacore.com> * common.opt (-fcallgraph-info[=]): New option. * doc/invoke.texi (Developer options): Document it. * opts.c (common_handle_option): Handle it. * builtins.c (expand_builtin_alloca): Record allocation if -fcallgraph-info=da. * calls.c (expand_call): If -fcallgraph-info, record the call. (emit_library_call_value_1): Likewise. * flag-types.h (enum callgraph_info_type): New type. * explow.c: Include stringpool.h. (set_stack_check_libfunc): Set SET_SYMBOL_REF_DECL on the symbol. * function.c (allocate_stack_usage_info): New. (allocate_struct_function): Call it for -fcallgraph-info. (prepare_function_start): Call it otherwise. (record_final_call, record_dynamic_alloc): New. * function.h (struct callinfo_callee): New. (CALLEE_FROM_CGRAPH_P): New. (struct callinfo_dalloc): New. (struct stack_usage): Add callees and dallocs. (record_final_call, record_dynamic_alloc): Declare. * gimplify.c (gimplify_decl_expr): Record dynamically-allocated object if -fcallgraph-info=da. * optabs-libfuncs.c (build_libfunc_function): Keep SYMBOL_REF_DECL. * print-tree.h (print_decl_identifier): Declare. (PRINT_DECL_ORIGIN, PRINT_DECL_NAME, PRINT_DECL_UNIQUE_NAME): New. * print-tree.c: Include print-tree.h. (print_decl_identifier): New function. * toplev.c: Include print-tree.h. (callgraph_info_file): New global variable. (callgraph_info_external_printed): Likewise. (output_stack_usage): Rename to... (output_stack_usage_1): ... this. Make it static, add cf parameter. If -fcallgraph-info=su, print stack usage to cf. If -fstack-usage, use print_decl_identifier for pretty-printing. (INDIRECT_CALL_NAME): New. (dump_final_node_vcg_start): New. (dump_final_callee_vcg, dump_final_node_vcg): New. (output_stack_usage): New. (lang_dependent_init): Open and start file if -fcallgraph-info. Allocated callgraph_info_external_printed. (finalize): If callgraph_info_file is not null, finish it, close it, and release callgraph_info_external_printed. for gcc/ada/ChangeLog * gcc-interface/misc.c (callgraph_info_file): Delete. Co-Authored-By: Alexandre Oliva <oliva@adacore.com> From-SVN: r277876
2019-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r267494
2018-11-29Add a new option -flive-patching={inline-only-static|inline-clone}Qing Zhao1-0/+8
to support live patching in GCC. 2018-11-29 qing zhao <qing.zhao@oracle.com> gcc/ChangeLog: * cif-code.def (EXTERN_LIVE_ONLY_STATIC): New CIF code. * common.opt: Add -flive-patching flag. * doc/invoke.texi: Document -flive-patching. * flag-types.h (enum live_patching_level): New enum. * ipa-inline.c (can_inline_edge_p): Disable external functions from inlining when flag_live_patching is LIVE_PATCHING_INLINE_ONLY_STATIC. * opts.c (control_options_for_live_patching): New function. (finish_options): Make flag_live_patching incompatible with flag_lto. Control IPA optimizations based on different levels of flag_live_patching. gcc/testsuite/ChangeLog: * gcc.dg/live-patching-1.c: New test. * gcc.dg/live-patching-2.c: New test. * gcc.dg/live-patching-3.c: New test. * gcc.dg/tree-ssa/writeonly-3.c: New test. * gcc.target/i386/ipa-stack-alignment-2.c: New test. From-SVN: r266627
2018-05-30passes.c (ipa_write_summaries): Only modify statements if body is in memory.Jan Hubicka1-0/+10
* passes.c (ipa_write_summaries): Only modify statements if body is in memory. * cgraphunit.c (ipa_passes): Also produce intermeidate code when incrementally linking. (ipa_passes): Likewise. * lto-cgraph.c (lto_output_node): When incrementally linking do not pass down resolution info. * common.opt (flag_incremental_link): Update info. * gcc.c (plugin specs): Turn flinker-output=* to -plugin-opt=-linker-output-known * toplev.c (compile_file): Also cut compilation when doing incremental link. * flag-types. (enum lto_partition_model): Add LTO_LINKER_OUTPUT_NOLTOREL. (invoke.texi): Add -flinker-output docs. * ipa.c (symbol_table::remove_unreachable_nodes): Handle LTO incremental link same way as WPA; do not stream in dead initializers. * dwarf2out.c (dwarf2out_die_ref_for_decl, darf2out_register_external_decl): Support incremental link. * lang.opt (lto_linker_output): Add nolto-rel. * lto-lang.c (lto_post_options): Handle LTO_LINKER_OUTPUT_REL and LTO_LINKER_OUTPUT_NOLTOREL. (lto_init): Generate lto when doing incremental link. * lto.c (lto_precess_name): Add lto1-inclink. * testsuite/g++.dg/lto/20081109-1_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20081118_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20081119-1_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20081120-1_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20081120-2_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20081123_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20081204-1_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20081219_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20090302_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20090313_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20091002-2_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20091002-3_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20091026-1_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20100724-1_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20101010-4_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20101015-2_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/20110311-1_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/pr45621_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/pr48042_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/pr48354-1_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/pr54625-1_0.c: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/pr54625-2_0.c: Add -flinker-output=nolto-rel. * testsuite/g++.dg/lto/pr68811_0.C: Add -flinker-output=nolto-rel. * testsuite/g++.dg/torture/pr43760.C: New test. Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20081120-1_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20081120-2_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20081126_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20081204-1_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20081204-2_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20081212-1_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20081224_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20090116_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20090126-1_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20090126-2_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20090206-1_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20090219_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20091013-1_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20091014-1_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20091015-1_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20091016-1_0.c: Add -flinker-output=nolto-rel. * testsuite/gcc.dg/lto/20091020-1_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/20091020-2_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/20091027-1_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/20100426_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/20100430-1_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/20100603-1_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/20100603-2_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/20100603-3_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/20111213-1_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/pr45736_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/pr52634_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/pr54702_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/pr59323-2_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/pr59323_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/pr60820_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/pr81406_0.c: Add -flinker-output-nolto-rel. * testsuite/gcc.dg/lto/pr83388_0.c: Add -flinker-output-nolto-rel. * testsuite/gfortran.dg/lto/20091016-1_0.f90: Add -flinker-output-nolto-rel. * testsuite/gfortran.dg/lto/20091028-1_0.f90: Add -flinker-output-nolto-rel. * testsuite/gfortran.dg/lto/20091028-2_0.f90: Add -flinker-output-nolto-rel. * testsuite/gfortran.dg/lto/pr46911_0.f: Add -flinker-output-nolto-rel. * testsuite/gfortran.dg/lto/pr47839_0.f90: Add -flinker-output-nolto-rel. From-SVN: r260963
2018-01-03Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r256169
2017-12-05invoke.texi: Document the options.Martin Liska1-0/+2
gcc/ * doc/invoke.texi: Document the options. * flag-types.h (enum sanitize_code): Add SANITIZE_POINTER_COMPARE and SANITIZE_POINTER_SUBTRACT. * ipa-inline.c (sanitize_attrs_match_for_inline_p): Add handling of SANITIZE_POINTER_COMPARE and SANITIZE_POINTER_SUBTRACT. * opts.c: Define new sanitizer options. * sanitizer.def (BUILT_IN_ASAN_POINTER_COMPARE): Likewise. (BUILT_IN_ASAN_POINTER_SUBTRACT): Likewise. gcc/c/ * c-typeck.c (pointer_diff): Add new argument and instrument pointer subtraction. (build_binary_op): Similar for pointer comparison. gcc/cp/ * typeck.c (pointer_diff): Add new argument and instrument pointer subtraction. (cp_build_binary_op): Create compound expression if doing an instrumentation. gcc/testsuite/ * c-c++-common/asan/pointer-compare-1.c: New test. * c-c++-common/asan/pointer-compare-2.c: New test. * c-c++-common/asan/pointer-subtract-1.c: New test. * c-c++-common/asan/pointer-subtract-2.c: New test. * c-c++-common/asan/pointer-subtract-3.c: New test. * c-c++-common/asan/pointer-subtract-4.c: New test. libsanitizer/ * asan/asan_descriptions.cc: Cherry-pick upstream r319668. * asan/asan_descriptions.h: Likewise. * asan/asan_report.cc: Likewise. * asan/asan_thread.cc: Likewise. * asan/asan_thread.h: Likewise. Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r255404
2017-10-29Delete obsolete SDB debug info support.James E Wilson1-1/+0
gcc/ * Makefile.in (OBJS): Delete sdbout.o. (GTFILES): Delete $(srcdir)/sdbout.c. * debug.h: Delete sdb_debug_hooks. * final.c: Delete sdbout.h include. (final_scan_insn): Delete SDB_DEBUG check. (rest_of_clean_state): Likewise. * output.h: Delete sdb_begin_function_line. * sdbout.c: Delete. * sdbout.h: Delete. * toplev.c: Delete sdbout.h include. (process_options): Delete SDB_DEBUG check. * tree-core.h (tree_type_common): Delete pointer field of tree_type_symtab. * tree.c (copy_node): Clear TYPE_SYMTAB_DIE instead of TYPE_SYMTAB_POINTER. * tree.h (TYPE_SYMTAB_POINTER): Delete. (TYPE_SYMTAB_IS_POINTER): Delete. (TYPE_SYMTAB_IS_DIE): Renumber. * xcoffout.c: Refer to former sdbout.c file. (xcoffout_begin_prologue): Use past tense for sdbout.c reference. * doc/install.texi (--with-stabs): Delete COFF and ECOFF info. * doc/invoke.texi (SEEALSO): Delete adb and sdb references. (Debugging Options): Delete -gcoff. (-gstabs): Delete SDB reference. (-gcoff): Delete. (-gcoff@var{level}): Delete. * doc/passes.texi (Debugging information output): Delete SDB and sdbout.c references. * doc/tm.texi: Regenerate. * doc/tm.texi.in (DWARF_CIE_DATA_ALIGNMENT): Delete SDB from xref. (SDB and DWARF): Change node name to DWARF and delete SDB and COFF references. (DEBUGGER_AUTO_OFFSET): Delete COFF and SDB references. (PREFERRED_DEBUGGING_TYPE): Delete SDB_DEBUG and -gcoff references. (SDB_DEBUGGING_INFO): Delete. (PUT_SDB_@dots{}, SDB_DELIM, SDB_ALLOW_UNKNOWN_REFERENCES) SDB_ALLOW_FORWARD_REFERENCES, SDB_OUTPUT_SOURCE_LINE): Delete. * target.def (output_source_filename): Delete COFF reference. * common.opt (gcoff): Delete. (gxcoff+): Update Negative chain. * defaults.h: Delete all references to SDB_DEBUGGING_INFO and SDB_DEBUG. * dwarf2out.c (gen_array_type_die): Change SDB to debuggers. * flag-types.h (enum debug_info_type): Delete SDB_DEBUG. * function.c (number_blocks): Delete SDB_DEBUGGING_INFO, SDB_DEBUG, and SDB references. (expand_function_start): Change sdb reference to past tense. (expand_function_end): Change sdb reference to past tense. * gcc.c (cpp_unique_options): Delete gcoff3 reference. * opts.c (debug_type_names): Delete coff entry. (common_handle_option): Delete OPT_gcoff case. * system.h (SDB_DEBUG, SDB_DEBUGGING_INFO): Poison. * config/dbxcoff.h (PREFERRED_DEBUGGING_TYPE): Set to DBX_DEBUG. * config/cris/cris.h: Delete SDB reference in comment. * config/i386/cygming.h: Don't define SDB_DEBUGGING_INFO. (ASM_DECLARE_FUNCTION_NAME): Delete SDB reference from comment. * config/i386/gas.h: Don't define SDB_DEBUGGING_INFO. * config/i386/i386.c (svr4_dbx_register_map): Change SDB references to past tense. (ix86_expand_prologue): Likewise. * config/i386/winnt.c (i386_pe_start_function): Don't check SDB_DEBUG. * config/ia64/ia64.h: Likewise. * config/m68k/m68kelf.h (DBX_REGISTER_NUMBER): Delete SDB reference. * config/mips/mips.h (SUBTARGET_ASM_DEBUGGING_SPEC): Delete gcoff* support. * config/mmix/mmix.h: Likewise. * config/nds32/nds32.c: Likewise. * config/stormy/storym16.h: Likewise. * config/visium/visium.h: Likewise. * config/vx-common.h (SDB_DEBUGGING_INFO): Delete undef. gcc/fortran/ * invoke.texi: Delete adb and sdb references. gccc/testsuite/ * lib/gcc-dg.exp (gcc-dg-debug-runtest): Delete -gcoff. * lib/gfortran-dg.exp (gfortran-dg-debug-runtest): Delete -gcoff. From-SVN: r254206
2017-10-20Add generic part for Intel CET enabling. The spec is available atIgor Tsimbalist1-0/+9
https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf A proposal is to introduce a target independent flag -fcf-protection=[none|branch|return|full] with a semantic to instrument a code to control validness or integrity of control-flow transfers using jump and call instructions. The main goal is to detect and block a possible malware execution through transfer the execution to unknown target address. Implementation could be either software or target based. Any target platforms can provide their implementation for instrumentation under this option. The compiler should instrument any control-flow transfer points in a program (ex. call/jmp/ret) as well as any landing pads, which are targets of control-flow transfers. A new 'nocf_check' attribute is introduced to provide hand tuning support. The attribute directs the compiler to skip a call to a function and a function's landing pad from instrumentation. The attribute can be used for function and pointer to function types, otherwise it will be ignored. Currently all platforms except i386 will report the error and do no instrumentation. i386 will provide the implementation based on a specification published by Intel for a new technology called Control-flow Enforcement Technology (CET). gcc/c-family/ * c-attribs.c (handle_nocf_check_attribute): New function. (c_common_attribute_table): Add 'nocf_check' handling. gcc/c/ * gimple-parser.c: Add second argument NULL to gimple_build_call_from_tree. gcc/ * attrib.c (comp_type_attributes): Check nocf_check attribute. * cfgexpand.c (expand_call_stmt): Set REG_CALL_NOCF_CHECK for call insn. * combine.c (distribute_notes): Add REG_CALL_NOCF_CHECK handling. * common.opt: Add fcf-protection flag. * emit-rtl.c (try_split): Add REG_CALL_NOCF_CHECK handling. * flag-types.h: Add enum cf_protection_level. * gimple.c (gimple_build_call_from_tree): Add second parameter. Add 'nocf_check' attribute propagation to gimple call. * gimple.h (gf_mask): Add GF_CALL_NOCF_CHECK. (gimple_build_call_from_tree): Update prototype. (gimple_call_nocf_check_p): New function. (gimple_call_set_nocf_check): Likewise. * gimplify.c: Add second argument to gimple_build_call_from_tree. * ipa-icf.c: Add nocf_check attribute in statement hash. * recog.c (peep2_attempt): Add REG_CALL_NOCF_CHECK handling. * reg-notes.def: Add REG_NOTE (CALL_NOCF_CHECK). * toplev.c (process_options): Add flag_cf_protection handling. From-SVN: r253936
2017-10-19flag-types.h (enum sanitize_code): Add SANITIZE_BUILTIN.Jakub Jelinek1-1/+2
* flag-types.h (enum sanitize_code): Add SANITIZE_BUILTIN. Or SANITIZE_BUILTIN into SANITIZE_UNDEFINED. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_INVALID_BUILTIN, BUILT_IN_UBSAN_HANDLE_INVALID_BUILTIN_ABORT): New builtins. * opts.c (sanitizer_opts): Add builtin. * ubsan.c (instrument_builtin): New function. (pass_ubsan::execute): Call it. (pass_ubsan::gate): Enable even for SANITIZE_BUILTIN. * doc/invoke.texi: Document -fsanitize=builtin. * c-c++-common/ubsan/builtin-1.c: New test. From-SVN: r253888
2017-09-19common.opt (-fstack-clash-protection): New option.Jeff Law1-1/+8
* common.opt (-fstack-clash-protection): New option. * flag-types.h (enum stack_check_type): Note difference between -fstack-check= and -fstack-clash-protection. * params.def (PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE): New PARAM. (PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL): Likewise. * toplev.c (process_options): Issue warnings/errors for cases not handled with -fstack-clash-protection. * doc/invoke.texi (-fstack-clash-protection): Document new option. (-fstack-check): Note additional problem with -fstack-check=generic. Note that -fstack-check is primarily for Ada and refer users to -fstack-clash-protection for stack-clash-protection. Document new params for stack clash protection. * gcc.dg/stack-check-2.c: New test. * lib/target-supports.exp (check_effective_target_supports_stack_clash_protection): New function. (check_effective_target_frame_pointer_for_non_leaf): Likewise. (check_effective_target_caller_implicit_probes): Likewise. From-SVN: r252994
2017-09-06asan.c (initialize_sanitizer_builtins): Add BT_FN_VOID_UINT8_UINT8...Wish Wu1-0/+8
* asan.c (initialize_sanitizer_builtins): Add BT_FN_VOID_UINT8_UINT8, BT_FN_VOID_UINT16_UINT16, BT_FN_VOID_UINT32_UINT32, BT_FN_VOID_UINT64_UINT64, BT_FN_VOID_FLOAT_FLOAT, BT_FN_VOID_DOUBLE_DOUBLE and BT_FN_VOID_UINT64_PTR variables. * builtin-types.def (BT_FN_VOID_UINT8_UINT8): New fn type. (BT_FN_VOID_UINT16_UINT16): Likewise. (BT_FN_VOID_UINT32_UINT32): Likewise. (BT_FN_VOID_FLOAT_FLOAT): Likewise. (BT_FN_VOID_DOUBLE_DOUBLE): Likewise. (BT_FN_VOID_UINT64_PTR): Likewise. * common.opt (flag_sanitize_coverage): New variable. (fsanitize-coverage=trace-pc): Remove. (fsanitize-coverage=): Add. * flag-types.h (enum sanitize_coverage_code): New enum. * fold-const.c (fold_range_test): Disable non-short-circuit optimization if flag_sanitize_coverage. (fold_truth_andor): Likewise. * tree-ssa-ifcombine.c (ifcombine_ifandif): Likewise. * opts.c (COVERAGE_SANITIZER_OPT): Define. (coverage_sanitizer_opts): New array. (get_closest_sanitizer_option): Add OPTS argument, handle also OPT_fsanitize_coverage_. (parse_sanitizer_options): Adjusted to also handle OPT_fsanitize_coverage_. (common_handle_option): Add OPT_fsanitize_coverage_. * sancov.c (instrument_comparison, instrument_switch): New function. (sancov_pass): Add trace-cmp support. * sanitizer.def (BUILT_IN_SANITIZER_COV_TRACE_CMP1, BUILT_IN_SANITIZER_COV_TRACE_CMP2, BUILT_IN_SANITIZER_COV_TRACE_CMP4, BUILT_IN_SANITIZER_COV_TRACE_CMP8, BUILT_IN_SANITIZER_COV_TRACE_CONST_CMP1, BUILT_IN_SANITIZER_COV_TRACE_CONST_CMP2, BUILT_IN_SANITIZER_COV_TRACE_CONST_CMP4, BUILT_IN_SANITIZER_COV_TRACE_CONST_CMP8, BUILT_IN_SANITIZER_COV_TRACE_CMPF, BUILT_IN_SANITIZER_COV_TRACE_CMPD, BUILT_IN_SANITIZER_COV_TRACE_SWITCH): New builtins. * doc/invoke.texi: Document -fsanitize-coverage=trace-cmp. * gcc.dg/sancov/cmp0.c: New test. Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r251801
2017-07-28re PR sanitizer/80998 (Implement -fsanitize=pointer-overflow)Jakub Jelinek1-1/+3
PR sanitizer/80998 * sanopt.c (pass_sanopt::execute): Handle IFN_UBSAN_PTR. * tree-ssa-alias.c (call_may_clobber_ref_p_1): Likewise. * flag-types.h (enum sanitize_code): Add SANITIZER_POINTER_OVERFLOW. Or it into SANITIZER_UNDEFINED. * ubsan.c: Include gimple-fold.h and varasm.h. (ubsan_expand_ptr_ifn): New function. (instrument_pointer_overflow): New function. (maybe_instrument_pointer_overflow): New function. (instrument_object_size): Formatting fix. (pass_ubsan::execute): Call instrument_pointer_overflow and maybe_instrument_pointer_overflow. * internal-fn.c (expand_UBSAN_PTR): New function. * ubsan.h (ubsan_expand_ptr_ifn): Declare. * sanitizer.def (__ubsan_handle_pointer_overflow, __ubsan_handle_pointer_overflow_abort): New builtins. * tree-ssa-tail-merge.c (merge_stmts_p): Handle IFN_UBSAN_PTR. * internal-fn.def (UBSAN_PTR): New internal function. * opts.c (sanitizer_opts): Add pointer-overflow. * lto-streamer-in.c (input_function): Handle IFN_UBSAN_PTR. * fold-const.c (build_range_check): Compute pointer range check in integral type if pointer arithmetics would be needed. Formatting fixes. gcc/testsuite/ * c-c++-common/ubsan/ptr-overflow-1.c: New test. * c-c++-common/ubsan/ptr-overflow-2.c: New test. libsanitizer/ * ubsan/ubsan_handlers.cc: Cherry-pick upstream r304461. * ubsan/ubsan_checks.inc: Likewise. * ubsan/ubsan_handlers.h: Likewise. From-SVN: r250656
2017-06-13Implement no_sanitize function attributeMartin Liska1-2/+2
2017-06-13 Martin Liska <mliska@suse.cz> PR sanitize/78204 * c-c++-common/ubsan/attrib-2.c (float_cast2): Enhance the test by adding no_sanitize attribute. * gcc.dg/asan/use-after-scope-4.c: Likewise. 2017-06-13 Martin Liska <mliska@suse.cz> PR sanitize/78204 * c-attribs.c (add_no_sanitize_value): New function. (handle_no_sanitize_attribute): Likewise. (handle_no_sanitize_address_attribute): Use the function. (handle_no_sanitize_thread_attribute): New function. (handle_no_address_safety_analysis_attribute): Use add_no_sanitize_value. (handle_no_sanitize_undefined_attribute): Likewise. * c-common.h: Declare new functions. * c-ubsan.c (ubsan_instrument_division): Use sanitize_flags_p. (ubsan_instrument_shift): Likewise. (ubsan_instrument_bounds): Likewise. (ubsan_maybe_instrument_array_ref): Likewise. (ubsan_maybe_instrument_reference_or_call): Likewise. 2017-06-13 Martin Liska <mliska@suse.cz> PR sanitize/78204 * asan.c (asan_sanitize_stack_p): Use sanitize_flags_p. (gate_asan): Likewise. * asan.h (asan_no_sanitize_address_p): Remove the function. (sanitize_flags_p): New function. * builtins.def: Fix coding style. * common.opt: Use renamed enum value. * convert.c (convert_to_integer_1): Use sanitize_flags_p. * doc/extend.texi: Document no_sanitize attribute. * flag-types.h (enum sanitize_code): Rename SANITIZE_NONDEFAULT to SANITIZE_UNDEFINED_NONDEFAULT. * gcc.c (sanitize_spec_function): Use the renamed enum value. * gimple-fold.c (optimize_atomic_compare_exchange_p): Use sanitize_flags_p. * gimplify.c (gimplify_function_tree): Likewise. * ipa-inline.c (sanitize_attrs_match_for_inline_p): Likewise. * opts.c (parse_no_sanitize_attribute): New function. (common_handle_option): Use renamed enum value. * opts.h (parse_no_sanitize_attribute): Declare. * tree.c (sanitize_flags_p): New function. * tree.h: Declared here. * tsan.c: Use sanitize_flags_p. * ubsan.c (ubsan_expand_null_ifn): Likewise. (instrument_mem_ref): Likewise. (instrument_bool_enum_load): Likewise. (do_ubsan_in_current_function): Remove the function. (pass_ubsan::execute): Use sanitize_flags_p. * ubsan.h: Remove do_ubsan_in_current_function * tree-cfg.c (print_no_sanitize_attr_value): New function. (dump_function_to_file): Use it here. 2017-06-13 Martin Liska <mliska@suse.cz> PR sanitize/78204 * class.c (build_base_path): Use sanitize_flags_p. * cp-gimplify.c (cp_genericize_r): Likewise. (cp_genericize_tree): Likewise. (cp_genericize): Likewise. * cp-ubsan.c (cp_ubsan_instrument_vptr_p): Likewise. * decl.c (compute_array_index_type): Likewise. (start_preparsed_function): Likewise. * decl2.c (one_static_initialization_or_destruction): Likewise. * init.c (finish_length_check): Likewise. * lambda.c (maybe_add_lambda_conv_op): Likewise. * typeck.c (cp_build_binary_op): Likewise. (build_static_cast_1): Likewise. 2017-06-13 Martin Liska <mliska@suse.cz> PR sanitize/78204 * c-convert.c (convert): Use sanitize_flags_p. * c-decl.c (grokdeclarator): Likewise. * c-typeck.c (convert_for_assignment): Likewise. (c_finish_return): Likewise. (build_binary_op): Likewise. From-SVN: r249158
2017-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r243994
2016-11-23[Patch 5/17] Add -fpermitted-flt-eval-methods=[c11|ts-18661-3]James Greenhalgh1-0/+8
gcc/c-family/ * c-opts.c (c_common_post_options): Add logic to handle the default case for -fpermitted-flt-eval-methods. gcc/ * common.opt (fpermitted-flt-eval-methods): New. * doc/invoke.texi (-fpermitted-flt-eval-methods): Document it. * flag_types.h (permitted_flt_eval_methods): New. gcc/testsuite/ * gcc.dg/fpermitted-flt-eval-methods_1.c: New. * gcc.dg/fpermitted-flt-eval-methods_2.c: New. From-SVN: r242775
2016-11-09flag-types.h (enum sanitize_code): Add SANITIZE_SHIFT_BASE and ↵Jakub Jelinek1-18/+20
SANITIZE_SHIFT_EXPONENT... * flag-types.h (enum sanitize_code): Add SANITIZE_SHIFT_BASE and SANITIZE_SHIFT_EXPONENT, change SANITIZE_SHIFT to bitwise or of them, renumber other enumerators. * opts.c (sanitizer_opts): Add shift-base and shift-exponent. * doc/invoke.texi: Document -fsanitize=shift-base and -fsanitize-shift-exponent, document -fsanitize=shift as having those 2 suboptions. c-family/ * c-ubsan.c (ubsan_instrument_shift): Handle split -fsanitize=shift-base and -fsanitize=shift-exponent. testsuite/ * gcc.dg/ubsan/c99-shift-3.c: New test. * gcc.dg/ubsan/c99-shift-4.c: New test. * gcc.dg/ubsan/c99-shift-5.c: New test. * gcc.dg/ubsan/c99-shift-6.c: New test. From-SVN: r242005
2016-09-26Fix handling of -fsanitize-recover* options.Martin Liska1-16/+16
* common.opt: Exclude SANITIZE_UNREACHABLE and SANITIZE_RETURN from default sanitize recover values. * doc/invoke.texi: Fix documentation related to -fsanitize=leak, -fsanitize=address, -fsanitize=thread and -fsanitize-recover. * flag-types.h: Replace couple of 1 << x to 1UL << x, make it consistent. * opts.c (finish_options): Do a generic loop over options that can be recovered. (parse_sanitizer_options): Exclude SANITIZE_UNREACHABLE and SANITIZE_RETURN. (common_handle_option): Likewise. * opts.h: Declare can_recover to sanitizer_opts_s. * c-c++-common/ubsan/sanitize-recover-1.c: New test. * c-c++-common/ubsan/sanitize-recover-2.c: New test. * c-c++-common/ubsan/sanitize-recover-3.c: New test. * c-c++-common/ubsan/sanitize-recover-4.c: New test. * c-c++-common/ubsan/sanitize-recover-5.c: New test. * c-c++-common/ubsan/sanitize-recover-6.c: New test. * c-c++-common/ubsan/sanitize-recover-7.c: New test. * c-c++-common/ubsan/sanitize-recover-8.c: New test. * c-c++-common/ubsan/sanitize-recover-9.c: New test. From-SVN: r240491
2016-05-02Move "X +- C1 CMP C2 to X CMP C2 -+ C1" to match.pdMarc Glisse1-24/+0
2016-05-02 Marc Glisse <marc.glisse@inria.fr> gcc/ * flag-types.h (enum warn_strict_overflow_code): Move ... * coretypes.h: ... here. * fold-const.h (fold_overflow_warning): Declare. * fold-const.c (fold_overflow_warning): Make non-static. (fold_comparison): Move the transformation of X +- C1 CMP C2 into X CMP C2 -+ C1 ... * match.pd: ... here. * gimple-fold.c (fold_stmt_1): Protect with fold_defer_overflow_warnings. gcc/testsuite/ * gcc.dg/tree-ssa/20040305-1.c: Adjust. From-SVN: r235760
2016-01-04Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r232055
2015-12-17Add a flag to control the balance between GNAT encodings and std. DWARFPierre-Marie de Rodat1-0/+15
In order to accomodate the debugger's support evolution for "new" DWARF constructs, we need to have an flag that controls the amount of GNAT encodings/standard DWARF information that is emitted in the debug info. Propagate this new parameter into the Ada front-end. gcc/ChangeLog: * common.opt (gnat_encodings): New variable (dwarf_gnat_encodings): New enum type. (fgnat_encodings): New option. * flag-types.h (enum dwarf_gnat_encodings): New. gcc/ada/ChangeLog: * gcc-interface/misc.c (gnat_encodings): Undefine macro and declare a global variable. (gnat_post_options): Initialize this global from options. From-SVN: r231761
2015-11-25re PR lto/67548 (LTO drops weak binding with "ld -r")Jan Hubicka1-0/+8
PR lto/67548 * lto-plugin.c (linker_output, linker_output_set): New statics. (all_symbols_read_handler): Add -flinker-output option. (onload): Record linker_output info. * ipa-visibility.c (cgraph_externally_visible_p, varpool_node::externally_visible_p): When doing incremental linking, hidden symbols may be still used later. (update_visibility_by_resolution_info): Do not drop weak during incremental link. (function_and_variable_visibility): Fix formating. * flag-types.h (lto_linker_output): Declare. * common.opt 9flag_incremental_link): New flag. * lto-lang.c (lto_post_options): Process flag_lto_linker_output. * lang.opt (lto_linker_output): New enum. (flinker_output): New flag. From-SVN: r230915
2015-11-08Merge of the scalar-storage-order branch.Eric Botcazou1-2/+7
From-SVN: r229965
2015-10-01bb-reorder: Add -freorder-blocks-algorithm= and wire it upSegher Boessenkool1-0/+7
This adds an -freorder-blocks-algorithm=[simple|stc] flag, with "simple" as default. For -O2 and up (except -Os) it is switched to "stc" instead. Targets that never want STC can override this. This changes -freorder-blocks to be on at -O1 and up (was -O2 and up). In effect, the changes are for -O1 (which now gets "simple" instead of nothing), -Os (which now gets "simple" instead of "stc", since STC results in much bigger code), and for targets that wish to never use STC (not in this patch though). 2015-09-23 Segher Boessenkool <segher@kernel.crashing.org> * bb-reorder.c (reorder_basic_blocks): Use the algorithm selected with flag_reorder_blocks_algorithm. * common.opt (freorder-blocks-algorithm=): New flag. (reorder_blocks_algorithm): New enum. * flag-types.h (reorder_blocks_algorithm): New enum. * opts.c (default_options_table): Use -freorder-blocks at -O1 and up, and -freorder-blocks-algorithm=stc at -O2 and up (not at -Os). From-SVN: r228318
2015-08-05coretypes.h (enum symbol_visibility): Relocate here.Andrew MacLeod1-13/+0
2015-08-05 Andrew MacLeod <amacleod@redhat.com> * coretypes.h (enum symbol_visibility): Relocate here. * flag-types.h (enum symbol_visibility): Remove. * tree-core.h (enum symbol_visibility): Remove. From-SVN: r226648
2015-05-07c-ubsan.c (ubsan_instrument_bounds): Don't skip instrumenting flexible ↵Marek Polacek1-0/+2
member array-like members if... * c-ubsan.c (ubsan_instrument_bounds): Don't skip instrumenting flexible member array-like members if SANITIZE_BOUNDS_STRICT. * doc/invoke.texi: Document -fsanitize=bounds-strict. * flag-types.h (enum sanitize_code): Add SANITIZE_BOUNDS_STRICT, or it into SANITIZE_NONDEFAULT. * opts.c (common_handle_option): Handle -fsanitize=bounds-strict. * c-c++-common/ubsan/bounds-10.c: New test. From-SVN: r222871
2015-01-15flag-types.h (enum sanitize_code): Add SANITIZE_VPTR, include SANITIZE_VPTR ↵Jakub Jelinek1-1/+2
in SANITIZE_UNDEFINED. * flag-types.h (enum sanitize_code): Add SANITIZE_VPTR, include SANITIZE_VPTR in SANITIZE_UNDEFINED. * opts.c (common_handle_option): Add -fsanitize=vptr. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_DYNAMIC_TYPE_CACHE_MISS, BUILT_IN_UBSAN_HANDLE_DYNAMIC_TYPE_CACHE_MISS_ABORT): New. * ubsan.h (enum ubsan_null_ckind): Add UBSAN_DOWNCAST_POINTER, UBSAN_DOWNCAST_REFERENCE, UBSAN_UPCAST and UBSAN_CAST_TO_VBASE. (ubsan_expand_vptr_ifn): New prototype. * internal-fn.c (expand_ANNOTATE, expand_GOMP_SIMD_LANE, expand_GOMP_SIMD_VF, expand_GOMP_SIMD_LAST_LANE, expand_UBSAN_NULL, expand_UBSAN_BOUNDS, expand_UBSAN_OBJECT_SIZE, expand_ASAN_CHECK, expand_LOOP_VECTORIZED): Make argument nameless, remove ATTRIBUTE_UNUSED. (expand_UBSAN_VPTR): New function. * internal-fn.def (UBSAN_NULL, ASAN_CHECK): Use R instead of W in fn spec. (UBSAN_VPTR): New internal function. * sanopt.c (tree_map_traits): Renamed to ... (sanopt_tree_map_traits): ... this. (sanopt_tree_triplet, sanopt_tree_triplet_map_traits): New classes. (sanopt_ctx): Adjust asan_check_map type for tree_map_traits to sanopt_tree_map_traits renaming. Add vptr_check_map field. (maybe_optimize_ubsan_vptr_ifn): New function. (sanopt_optimize_walker): Handle IFN_UBSAN_VPTR. (pass_sanopt::execute): Likewise. Call sanopt_optimize even for -fsanitize=vptr. * tree-ssa-alias.c (call_may_clobber_ref_p_1): Handle certain internal calls like pure functions for aliasing, even when they have other side-effects that prevent making them ECF_PURE. * ubsan.c (ubsan_vptr_type_cache_decl): New variable. (ubsan_expand_vptr_ifn): New function. cp/ * cp-gimplify.c (cp_genericize_r): Call cp_ubsan_maybe_instrument_member_call for member calls. (cp_ubsan_check_member_access_r): New function. (cp_genericize_tree): Call cp_ubsan_instrument_member_accesses. * cp-tree.h (cp_ubsan_maybe_instrument_member_call, cp_ubsan_instrument_member_accesses, cp_ubsan_maybe_instrument_downcast, cp_ubsan_maybe_instrument_cast_to_vbase): New prototypes. * cp-ubsan.c: New file. * Make-lang.in (CXX_AND_OBJCXX_OBJS): Add cp/cp-ubsan.o. * constexpr.c (cxx_eval_call_expression): Return void_node for IFN_UBSAN_VPTR. (potential_constant_expression_1): Return true for UBSAN_NULL, UBSAN_BOUNDS and UBSAN_VPTR internal calls. * typeck.c (build_class_member_access_expr): Provide locus for COMPONENT_REFs. (build_static_cast_1): Instrument downcasts. * class.c (build_base_path): For -fsanitize=vptr and !fixed_type_p add ubsan instrumentation for virtual_access. * call.c: Include internal-fn.h. (set_flags_from_callee): Handle internal calls. gcc/testsuite/ * g++.dg/ubsan/vptr-1.C: New test. * g++.dg/ubsan/vptr-2.C: New test. * g++.dg/ubsan/vptr-3.C: New test. * g++.dg/ubsan/vptr-4.C: New test. * g++.dg/ubsan/vptr-5.C: New test. * g++.dg/ubsan/vptr-6.C: New test. * g++.dg/ubsan/vptr-7.C: New test. * g++.dg/ubsan/vptr-8.C: New test. * g++.dg/ubsan/vptr-9.C: New test. From-SVN: r219695
2015-01-05Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r219188
2014-12-17re PR fortran/54687 (Use gcc option machinery for gfortran)Tobias Burnus1-0/+34
2014-12-17 Tobias Burnus <burnus@net-b.de> PR fortran/54687 gcc/ * flag-types.h (gfc_init_local_real, gfc_fcoarray, gfc_convert): New enums; moved from fortran/. gcc/fortran/ * gfortran.h (gfc_option_t): Remove flags which now have a Var(). (init_local_real, gfc_fcoarray): Moved to ../flag-types.h. * libgfortran.h (unit_convert): Add comment. * lang.opt (flag-convert, flag-init_real, flag-coarray): Add Var() and Enum(). * options.c (gfc_handle_coarray_option): Remove. (gfc_init_options, gfc_post_options, gfc_handle_option): Update for *.opt changes. * array.c: Update for flag-variable name changes. * check.c: Ditto. * match.c: Ditto. * resolve.c: Ditto. * simplify.c: Ditto. * trans-array.c: Ditto. * trans-decl.c: Ditto. * trans-expr.c: Ditto. * trans-intrinsic.c: Ditto. * trans-stmt.c: Ditto. * trans-types.c: Ditto. * trans.c: Ditto. From-SVN: r218808
2014-11-10Makefile.in: Remove the compilation of graphite-clast-to-gimple.o.Roman Gareev1-6/+0
[gcc/] * Makefile.in: Remove the compilation of graphite-clast-to-gimple.o. * common.opt: Remove using of fgraphite-code-generator flag. * flag-types.h: Likewise. * graphite.c: Remove using of CLooG. * graphite-blocking.c: Likewise. * graphite-dependences.c: Likewise. * graphite-poly.c: Likewise. * graphite-poly.h: Likewise. * graphite-scop-detection.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite-clast-to-gimple.c: Removed. * graphite-clast-to-gimple.h: Likewise. * graphite-htab.h: Likewise. [gcc/testsuite] * gcc.dg/graphite/isl-ast-gen-blocks-1.c: Remove using of fgraphite-code-generator flag. * gcc.dg/graphite/isl-ast-gen-blocks-2.c: Likewise. * gcc.dg/graphite/isl-ast-gen-blocks-3.c: Likewise. * gcc.dg/graphite/isl-ast-gen-blocks-4.c: Likewise. * gcc.dg/graphite/isl-ast-gen-user-1.c: Likewise. * gcc.dg/graphite/isl-codegen-loop-dumping.c: Likewise. * gcc.dg/graphite/pr35356-2.c: Likewise. * gcc.dg/graphite/isl-ast-gen-single-loop-1.c: Likewise. * gcc.dg/graphite/isl-ast-gen-single-loop-2.c: Likewise. * gcc.dg/graphite/isl-ast-gen-single-loop-3.c: Likewise. * gcc.dg/graphite/isl-ast-gen-if-1.c: Likewise. * gcc.dg/graphite/isl-ast-gen-if-2.c: Likewise. From-SVN: r217315
2014-10-16flag-types.h (sanitize_code): Don't assume targets have 32-bit integers.DJ Delorie1-5/+5
* flag-types.h (sanitize_code): Don't assume targets have 32-bit integers. From-SVN: r216349
2014-10-10asan.c (pass_sanopt::execute): Handle IFN_UBSAN_OBJECT_SIZE.Marek Polacek1-1/+3
* asan.c (pass_sanopt::execute): Handle IFN_UBSAN_OBJECT_SIZE. * doc/invoke.texi: Document -fsanitize=object-size. * flag-types.h (enum sanitize_code): Add SANITIZE_OBJECT_SIZE and or it into SANITIZE_UNDEFINED. * gimple-fold.c (gimple_fold_call): Optimize IFN_UBSAN_OBJECT_SIZE. * internal-fn.c (expand_UBSAN_OBJECT_SIZE): New function. * internal-fn.def (UBSAN_OBJECT_SIZE): Define. * opts.c (common_handle_option): Handle -fsanitize=object-size. * ubsan.c: Include tree-object-size.h. (ubsan_type_descriptor): Call tree_to_uhwi instead of tree_to_shwi. (ubsan_expand_bounds_ifn): Use false instead of 0. (ubsan_expand_objsize_ifn): New function. (instrument_object_size): New function. (pass_ubsan::execute): Add object size instrumentation. * ubsan.h (ubsan_expand_objsize_ifn): Declare. testsuite/ * c-c++-common/ubsan/object-size-1.c: New test. * c-c++-common/ubsan/object-size-2.c: New test. * c-c++-common/ubsan/object-size-3.c: New test. * c-c++-common/ubsan/object-size-4.c: New test. * c-c++-common/ubsan/object-size-5.c: New test. * c-c++-common/ubsan/object-size-6.c: New test. * c-c++-common/ubsan/object-size-7.c: New test. * c-c++-common/ubsan/object-size-8.c: New test. * c-c++-common/ubsan/object-size-9.c: New test. * g++.dg/ubsan/object-size-1.C: New test. * gcc.dg/ubsan/object-size-9.c: New test. From-SVN: r216099
2014-09-10flag-types.h (enum sanitize_code): Add SANITIZE_NONNULL_ATTRIBUTE and ↵Jakub Jelinek1-1/+5
SANITIZE_RETURNS_NONNULL_ATTRIBUTE... gcc/ * flag-types.h (enum sanitize_code): Add SANITIZE_NONNULL_ATTRIBUTE and SANITIZE_RETURNS_NONNULL_ATTRIBUTE, or them into SANITIZE_UNDEFINED. * opts.c (common_handle_option): Handle SANITIZE_NONNULL_ATTRIBUTE and SANITIZE_RETURNS_NONNULL_ATTRIBUTE and disable flag_delete_null_pointer_checks for them. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_NONNULL_ARG, BUILT_IN_UBSAN_HANDLE_NONNULL_ARG_ABORT, BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN, BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): New. * ubsan.c (instrument_bool_enum_load): Set *gsi back to stmt's iterator. (instrument_nonnull_arg, instrument_nonnull_return): New functions. (pass_ubsan::gate): Return true even for SANITIZE_NONNULL_ATTRIBUTE or SANITIZE_RETURNS_NONNULL_ATTRIBUTE. (pass_ubsan::execute): Call instrument_nonnull_{arg,return}. * doc/invoke.texi (-fsanitize=nonnull-attribute, -fsanitize=returns-nonnull-attribute): Document. gcc/testsuite/ * c-c++-common/ubsan/attrib-3.c: New test. * c-c++-common/ubsan/nonnull-1.c: New test. * c-c++-common/ubsan/nonnull-2.c: New test. * c-c++-common/ubsan/nonnull-3.c: New test. * c-c++-common/ubsan/nonnull-4.c: New test. * c-c++-common/ubsan/nonnull-5.c: New test. libsanitizer/ * ubsan/ubsan_handlers.cc, ubsan/ubsan_handlers.h: Cherry pick upstream r215485, r217389, r217391 and r217400. From-SVN: r215118
2014-08-01opts.c (common_handle_option): Handle -fsanitize=alignment.Jakub Jelinek1-1/+2
* opts.c (common_handle_option): Handle -fsanitize=alignment. * ubsan.h (enum ubsan_null_ckind): Add UBSAN_CTOR_CALL. (ubsan_expand_bounds_ifn, ubsan_expand_null_ifn): Change return type to bool. * stor-layout.h (min_align_of_type): New prototype. * asan.c (pass_sanopt::execute): Don't perform gsi_next if ubsan_expand* told us not to do it. Remove the extra gsi_end_p check. * ubsan.c: Include builtins.h. (ubsan_expand_bounds_ifn): Change return type to bool, always return true. (ubsan_expand_null_ifn): Change return type to bool, change argument to gimple_stmt_iterator *. Handle both null and alignment sanitization, take type from ckind argument's type rather than first argument. (instrument_member_call): Removed. (instrument_mem_ref): Remove t argument, add mem and base arguments. Handle both null and alignment sanitization, don't say whole struct access is member access. Build 3 argument IFN_UBSAN_NULL call instead of 2 argument. (instrument_null): Adjust instrument_mem_ref caller. Don't instrument calls here. (pass_ubsan::gate, pass_ubsan::execute): Handle SANITIZE_ALIGNMENT like SANITIZE_NULL. * stor-layout.c (min_align_of_type): New function. * flag-types.h (enum sanitize_code): Add SANITIZE_ALIGNMENT. Or it into SANITIZE_UNDEFINED. * doc/invoke.texi (-fsanitize=alignment): Document. cp/ * cp-gimplify.c (cp_genericize_r): For -fsanitize=null and/or -fsanitize=alignment call ubsan_maybe_instrument_reference for casts to REFERENCE_TYPE and ubsan_maybe_instrument_member_call for calls to member functions. c-family/ * c-common.h (min_align_of_type): Removed prototype. * c-common.c (min_align_of_type): Removed. * c-ubsan.h (ubsan_maybe_instrument_reference, ubsan_maybe_instrument_member_call): New prototypes. * c-ubsan.c: Include stor-layout.h and builtins.h. (ubsan_maybe_instrument_reference_or_call, ubsan_maybe_instrument_reference, ubsan_maybe_instrument_call): New functions. testsuite/ * c-c++-common/ubsan/align-1.c: New test. * c-c++-common/ubsan/align-2.c: New test. * c-c++-common/ubsan/align-3.c: New test. * c-c++-common/ubsan/align-4.c: New test. * c-c++-common/ubsan/align-5.c: New test. * c-c++-common/ubsan/attrib-4.c: New test. * g++.dg/ubsan/align-1.C: New test. * g++.dg/ubsan/align-2.C: New test. * g++.dg/ubsan/align-3.C: New test. * g++.dg/ubsan/attrib-1.C: New test. * g++.dg/ubsan/null-1.C: New test. * g++.dg/ubsan/null-2.C: New test. From-SVN: r213406
2014-07-31cpp.texi (__SANITIZE_ADDRESS__): Updated description.Yury Gribov1-14/+16
2014-07-31 Yury Gribov <y.gribov@samsung.com> * doc/cpp.texi (__SANITIZE_ADDRESS__): Updated description. * doc/invoke.texi (-fsanitize=kernel-address): Describe new option. * flag-types.h (SANITIZE_USER_ADDRESS, SANITIZE_KERNEL_ADDRESS): New enums. * gcc.c (sanitize_spec_function): Support new option. (SANITIZER_SPEC): Remove now redundant check. * opts.c (common_handle_option): Support new option. (finish_options): Check for incompatibilities. * toplev.c (process_options): Split userspace-specific checks. From-SVN: r213367
2014-06-29Makefile.in: Add the compilation of graphite-isl-ast-to-gimple.o.Roman Gareev1-0/+6
gcc/ * Makefile.in: Add the compilation of graphite-isl-ast-to-gimple.o. * common.opt: Add new switch fgraphite-code-generator=[isl|cloog]. * flag-types.h: Add new enum fgraphite_generator. * graphite-isl-ast-to-gimple.c: New. * graphite-isl-ast-to-gimple.h: New. * graphite.c (graphite_transform_loops): Add choice of Graphite code generator, which depends on flag_graphite_code_gen. gcc/testsuite/gcc.dg/graphite/isl-codegen-loop-dumping.c: New testcase that checks that the dump is generated. From-SVN: r212124
2014-06-20asan.c (pass_sanopt::execute): Handle IFN_UBSAN_BOUNDS.Marek Polacek1-1/+3
* asan.c (pass_sanopt::execute): Handle IFN_UBSAN_BOUNDS. * flag-types.h (enum sanitize_code): Add SANITIZE_BOUNDS and or it into SANITIZE_UNDEFINED. * doc/invoke.texi: Describe -fsanitize=bounds. * gimplify.c (gimplify_call_expr): Add gimplification of internal functions created in the FEs. * internal-fn.c: Move "internal-fn.h" after "tree.h". (expand_UBSAN_BOUNDS): New function. * internal-fn.def (UBSAN_BOUNDS): New internal function. * internal-fn.h: Don't define internal functions here. * opts.c (common_handle_option): Add -fsanitize=bounds. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_OUT_OF_BOUNDS, BUILT_IN_UBSAN_HANDLE_OUT_OF_BOUNDS_ABORT): Add. * tree-core.h: Define internal functions here. (struct tree_base): Add ifn field. * tree-pretty-print.c: Include "internal-fn.h". (dump_generic_node): Handle functions without CALL_EXPR_FN. * tree.c (get_callee_fndecl): Likewise. (build_call_expr_internal_loc): New function. * tree.def (CALL_EXPR): Update description. * tree.h (CALL_EXPR_IFN): Define. (build_call_expr_internal_loc): Declare. * ubsan.c (get_ubsan_type_info_for_type): Return 0 for non-arithmetic types. (ubsan_type_descriptor): Change bool parameter to enum ubsan_print_style. Adjust the code. Add handling of UBSAN_PRINT_ARRAY. (ubsan_expand_bounds_ifn): New function. (ubsan_expand_null_ifn): Adjust ubsan_type_descriptor call. (ubsan_build_overflow_builtin): Likewise. (instrument_bool_enum_load): Likewise. (ubsan_instrument_float_cast): Likewise. * ubsan.h (enum ubsan_print_style): New enum. (ubsan_expand_bounds_ifn): Declare. (ubsan_type_descriptor): Adjust declaration. Use a default parameter. c-family/ * c-gimplify.c: Include "c-ubsan.h" and "pointer-set.h". (ubsan_walk_array_refs_r): New function. (c_genericize): Instrument array bounds. * c-ubsan.c: Include "internal-fn.h". (ubsan_instrument_division): Mark instrumented arrays as having side effects. Adjust ubsan_type_descriptor call. (ubsan_instrument_shift): Likewise. (ubsan_instrument_vla): Adjust ubsan_type_descriptor call. (ubsan_instrument_bounds): New function. (ubsan_array_ref_instrumented_p): New function. (ubsan_maybe_instrument_array_ref): New function. * c-ubsan.h (ubsan_instrument_bounds): Declare. (ubsan_array_ref_instrumented_p): Declare. (ubsan_maybe_instrument_array_ref): Declare. testsuite/ * c-c++-common/ubsan/bounds-1.c: New test. * c-c++-common/ubsan/bounds-2.c: New test. * c-c++-common/ubsan/bounds-3.c: New test. * c-c++-common/ubsan/bounds-4.c: New test. * c-c++-common/ubsan/bounds-5.c: New test. * c-c++-common/ubsan/bounds-6.c: New test. From-SVN: r211859
2014-05-23builtins.def: Change SANITIZE_FLOAT_DIVIDE to SANITIZE_NONDEFAULT.Marek Polacek1-1/+3
* builtins.def: Change SANITIZE_FLOAT_DIVIDE to SANITIZE_NONDEFAULT. * gcc.c (sanitize_spec_function): Likewise. * convert.c (convert_to_integer): Include "ubsan.h". Add floating-point to integer instrumentation. * doc/invoke.texi: Document -fsanitize=float-cast-overflow. * flag-types.h (enum sanitize_code): Add SANITIZE_FLOAT_CAST and SANITIZE_NONDEFAULT. * opts.c (common_handle_option): Handle -fsanitize=float-cast-overflow. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_FLOAT_CAST_OVERFLOW, BUILT_IN_UBSAN_HANDLE_FLOAT_CAST_OVERFLOW_ABORT): Add. * ubsan.c: Include "realmpfr.h" and "dfp.h". (get_ubsan_type_info_for_type): Handle REAL_TYPEs. (ubsan_type_descriptor): Set tkind to 0xffff for types other than float/double/long double. (ubsan_instrument_float_cast): New function. * ubsan.h (ubsan_instrument_float_cast): Declare. testsuite/ * c-c++-common/ubsan/float-cast-overflow-1.c: New test. * c-c++-common/ubsan/float-cast-overflow-10.c: New test. * c-c++-common/ubsan/float-cast-overflow-2.c: New test. * c-c++-common/ubsan/float-cast-overflow-3.c: New test. * c-c++-common/ubsan/float-cast-overflow-4.c: New test. * c-c++-common/ubsan/float-cast-overflow-5.c: New test. * c-c++-common/ubsan/float-cast-overflow-6.c: New test. * c-c++-common/ubsan/float-cast-overflow-7.c: New test. * c-c++-common/ubsan/float-cast-overflow-7.h: New file. * c-c++-common/ubsan/float-cast-overflow-8.c: New test. * c-c++-common/ubsan/float-cast-overflow-9.c: New test. * c-c++-common/ubsan/float-cast.h: New file. * g++.dg/ubsan/float-cast-overflow-bf.C: New test. * gcc.dg/ubsan/float-cast-overflow-bf.c: New test. libsanitizer/ * ubsan/ubsan_value.cc (getFloatValue): Handle 96-bit floating-point types. Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r210862
2014-04-30gcc.c (sanitize_spec_function): Handle SANITIZE_FLOAT_DIVIDE.Marek Polacek1-0/+1
* gcc.c (sanitize_spec_function): Handle SANITIZE_FLOAT_DIVIDE. * builtins.def: Initialize builtins even for SANITIZE_FLOAT_DIVIDE. * flag-types.h (enum sanitize_code): Add SANITIZE_FLOAT_DIVIDE. * opts.c (common_handle_option): Add -fsanitize=float-divide-by-zero. c-family/ * c-ubsan.c (ubsan_instrument_division): Handle REAL_TYPEs. Perform INT_MIN / -1 sanitization only for integer types. c/ * c-typeck.c (build_binary_op): Call ubsan_instrument_division also when SANITIZE_FLOAT_DIVIDE is on. cp/ * typeck.c (cp_build_binary_op): Call ubsan_instrument_division even when SANITIZE_FLOAT_DIVIDE is on. Set doing_div_or_mod even for non-integer types. testsuite/ * c-c++-common/ubsan/div-by-zero-5.c: Fix formatting. * c-c++-common/ubsan/float-div-by-zero-1.c: New test. From-SVN: r209927
2014-04-24flag-types.h (enum ivar_visibility): Add.Dimitris Papavasiliou1-0/+10
2014-04-24 Dimitris Papavasiliou <dpapavas@gmail.com> * flag-types.h (enum ivar_visibility): Add. c-family: * c.opt (Wshadow-ivar, flocal-ivars, fivar-visibility): Add. objc: * objc-act.c (objc_ivar_visibility, objc_default_ivar_visibility): Add. (objc_init): Initialize objc_default_ivar_visibility. (objc_start_class_interface): Use objc_default_ivar_visibility. (objc_start_class_implementation): Likewise. (objc_lookup_ivar): Implement -fno-local-ivars. From-SVN: r209753
2014-04-15common.opt (lto_partition_model): New enum.Richard Biener1-0/+10
2014-04-15 Richard Biener <rguenther@suse.de> * common.opt (lto_partition_model): New enum. (flto-partition=): Merge separate options with a single with argument, add -flto-partition=one support. * flag-types.h (enum lto_partition_model): Declare. * opts.c (finish_options): Remove duplicate -flto-partition= option check. * lto-wrapper.c (run_gcc): Adjust. lto/ * lto.c: Include params.h. (do_whole_program_analysis): Switch on flag_lto_partition value, add support for LTO_PARTITION_ONE. * lto-partition.h (lto_balanced_map): Adjust. * lto-partition.c (lto_balanced_map): Get number of desired partitions as argument to support -flto-partition=one. From-SVN: r209416
2014-01-02Update copyright years in gcc/Richard Sandiford1-1/+1
From-SVN: r206289
2013-12-20ubsan.c: Include tree-ssanames.h, asan.h and gimplify-me.h.Jakub Jelinek1-1/+3
* ubsan.c: Include tree-ssanames.h, asan.h and gimplify-me.h. (ubsan_type_descriptor): Handle BOOLEAN_TYPE and ENUMERAL_TYPE like INTEGER_TYPE. (instrument_bool_enum_load): New function. (ubsan_pass): Call it. (gate_ubsan): Also enable for SANITIZE_BOOL or SANITIZE_ENUM. * asan.c (create_cond_insert_point): No longer static. * asan.h (create_cond_insert_point): Declare. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_LOAD_INVALID_VALUE): New built-in. * opts.c (common_handle_option): Handle -fsanitize=bool and -fsanitize=enum. * builtins.c (fold_builtin_memory_op): When sanitizing bool and enum loads, don't use enum or bool types for memcpy folding. * flag-types.h (SANITIZE_BOOL, SANITIZE_ENUM): New. (SANITIZE_UNDEFINED): Or these in. * c-c++-common/ubsan/load-bool-enum.c: New test. From-SVN: r206143
2013-12-04Implement -fsanitize=signed-integer-overflow.Marek Polacek1-0/+2
From-SVN: r205684
2013-11-22re PR sanitizer/59061 (Port leaksanitizer)Jakub Jelinek1-6/+8
PR sanitizer/59061 * common.opt (static-liblsan): Add. * config/gnu-user.h (STATIC_LIBLSAN_LIBS, STATIC_LIBUBSAN_LIBS): Define. * flag-types.h (enum sanitize_code): Add SANITIZE_LEAK. Renumber SANITIZE_SHIFT, SANITIZE_DIVIDE, SANITIZE_UNREACHABLE, SANITIZE_VLA, SANITIZE_RETURN. * opts.c (common_handle_option): Handle -fsanitize=leak. * gcc.c (ADD_STATIC_LIBLSAN_LIBS, LIBLSAN_SPEC): Define. (LIBUBSAN_SPEC): Don't test LIBUBSAN_EARLY_SPEC. (LIBUBSAN_EARLY_SPEC): Remove. (SANITIZER_EARLY_SPEC): Don't do anything for libubsan. (SANITIZER_SPEC): Add -fsanitize=leak handling. (sanitize_spec_function): Handle %sanitize(leak). * doc/invoke.texi (-static-liblsan, -fsanitize=leak): Document. * c-c++-common/asan/no-redundant-instrumentation-7.c: Fix cleanup-tree-dump directive. * configure.tgt: Set LSAN_SUPPORTED=yes for x86_64-linux. * configure.ac (LSAN_SUPPORTED): New AM_CONDITIONAL. * configure: Regenerated. * lsan/Makefile.am (toolexeclib_LTLIBRARIES, lsan_files, liblsan_la_SOURCES, liblsan_la_LIBADD, liblsan_la_LDFLAGS): Add. * lsan/Makefile.in: Regenerated. From-SVN: r205290
2013-11-22ubsan.c (ubsan_source_location): Don't crash on unknown locations.Jakub Jelinek1-1/+2
* ubsan.c (ubsan_source_location): Don't crash on unknown locations. (ubsan_pass): Ignore clobber stmts. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_MISSING_RETURN): New built-in. * opts.c (common_handle_option): Add -fsanitize=return. * flag-types.h (enum sanitize_code): Add SANITIZE_RETURN and or it into SANITIZE_UNDEFINED. c-family/ * c-ubsan.h (ubsan_instrument_return): New prototype. * c-ubsan.c (ubsan_instrument_return): New function. cp/ * cp-gimplify.c: Include target.h and c-family/c-ubsan.h. (cp_ubsan_maybe_instrument_return): New function. (cp_genericize): Call it if -fsanitize=return. testsuite/ * g++.dg/ubsan/return-1.C: New test. * g++.dg/ubsan/return-2.C: New test. From-SVN: r205283
2013-11-19bootstrap-ubsan.mk (POSTSTAGE1_LDFLAGS): Add -ldl.Marek Polacek1-1/+2
config/ * bootstrap-ubsan.mk (POSTSTAGE1_LDFLAGS): Add -ldl. gcc/c-family/ * c-ubsan.c (ubsan_instrument_division): Adjust ubsan_create_data call. (ubsan_instrument_shift): Likewise. (ubsan_instrument_vla): Likewise. gcc/ * opts.c (common_handle_option): Add -fsanitize=null option. Turn off -fdelete-null-pointer-checks option when doing the NULL pointer checking. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH): Add. * tree-pass.h (make_pass_ubsan): Declare. (make_pass_sanopt): Declare. * timevar.def (TV_TREE_UBSAN): New timevar. * passes.def: Add pass_sanopt and pass_ubsan. * ubsan.h (ubsan_null_ckind): New enum. (ubsan_mismatch_data): New struct. (ubsan_expand_null_ifn): Declare. (ubsan_create_data): Adjust declaration. (ubsan_type_descriptor): Likewise. * asan.c: Include "ubsan.h". (pass_data_sanopt): New pass. (execute_sanopt): New function. (gate_sanopt): Likewise. (make_pass_sanopt): Likewise. (class pass_sanopt): New class. * ubsan.c: Include tree-pass.h, gimple-ssa.h, gimple-walk.h, gimple-iterator.h and cfgloop.h. (PROB_VERY_UNLIKELY): Define. (tree_type_map_hash): New function. (ubsan_type_descriptor): Add new parameter. Improve type name generation. (ubsan_create_data): Add new parameter. Add pointer data into ubsan structure. (ubsan_expand_null_ifn): New function. (instrument_member_call): Likewise. (instrument_mem_ref): Likewise. (instrument_null): Likewise. (ubsan_pass): Likewise. (gate_ubsan): Likewise. (make_pass_ubsan): Likewise. (ubsan_instrument_unreachable): Adjust ubsan_create_data call. (class pass_ubsan): New class. (pass_data_ubsan): New pass. * flag-types.h (enum sanitize_code): Add SANITIZE_NULL. * internal-fn.c (expand_UBSAN_NULL): New function. * cgraphunit.c (varpool_finalize_decl): Call varpool_assemble_decl even when !flag_toplevel_reorder. * internal-fn.def (UBSAN_NULL): New. gcc/testsuite/ * c-c++-common/ubsan/null-1.c: New test. * c-c++-common/ubsan/null-2.c: New test. * c-c++-common/ubsan/null-3.c: New test. * c-c++-common/ubsan/null-4.c: New test. * c-c++-common/ubsan/null-5.c: New test. * c-c++-common/ubsan/null-6.c: New test. * c-c++-common/ubsan/null-7.c: New test. * c-c++-common/ubsan/null-8.c: New test. * c-c++-common/ubsan/null-9.c: New test. * c-c++-common/ubsan/null-10.c: New test. * c-c++-common/ubsan/null-11.c: New test. * gcc.dg/ubsan/c99-shift-2.c: Adjust dg-output. * c-c++-common/ubsan/shift-1.c: Likewise. * c-c++-common/ubsan/div-by-zero-3.c: Likewise. From-SVN: r205021
2013-11-03Implement -fsanitize=vla-bound.Marek Polacek1-0/+2
* opts.c (common_handle_option): Handle vla-bound. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_VLA_BOUND_NOT_POSITIVE): Define. * flag-types.h (enum sanitize_code): Add SANITIZE_VLA. * asan.c (initialize_sanitizer_builtins): Build BT_FN_VOID_PTR_PTR. c-family/ * c-ubsan.c: Don't include hash-table.h. (ubsan_instrument_vla): New function. * c-ubsan.h: Declare it. cp/ * decl.c (cp_finish_decl): Move C++1y bounds checking... (compute_array_index_type): ...here. Add VLA instrumentation. Call stabilize_vla_size. (grokdeclarator): Don't call stabilize_vla_size here. c/ * c-decl.c (grokdeclarator): Add VLA instrumentation. testsuite/ * g++.dg/ubsan/cxx1y-vla.C: New test. * c-c++-common/ubsan/vla-3.c: New test. * c-c++-common/ubsan/vla-2.c: New test. * c-c++-common/ubsan/vla-4.c: New test. * c-c++-common/ubsan/vla-1.c: New test. From-SVN: r204334