Commit Graph

63 Commits

Author SHA1 Message Date
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Jakub Jelinek 967ca9b932 re PR c++/70594 (-fcompare-debug failure)
PR c++/70594
	* ipa-utils.h (polymorphic_ctor_dtor_p): New prototype.
	* ipa-polymorphic-call.c (polymorphic_ctor_dtor_p): New function.
	(inlined_polymorphic_ctor_dtor_block_p): Use it.
	* tree-ssa-live.c (remove_unused_scope_block_p): When
	in_ctor_dtor_block, avoid discarding not just BLOCKs with
	BLOCK_ABSTRACT_ORIGIN being FUNCTION_DECL, but even when
	block_ultimate_origin is FUNCTION_DECL.
	(remove_unused_locals): If current_function_decl is
	polymorphic_ctor_dtor_p, pass initial true to
	remove_unused_scope_block_p' is_ctor_dtor_block.

From-SVN: r234987
2016-04-14 21:21:31 +02:00
Jakub Jelinek 818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Jan Hubicka a6c5361c08 ipa-devirt.c (type_with_linkage_p, [...]): Move to ...
* ipa-devirt.c (type_with_linkage_p, type_in_anonymous_namespace_p,
	odr_type_p): Move to ...
	* ipa-utils.h (type_with_linkage_p, type_in_anonymous_namespace_p,
	odr_type_p): here; miscro-optimize.

From-SVN: r231098
2015-12-01 06:36:02 +00:00
Trevor Saunders 355fe0884b switch from gimple to gimple*
This renames the gimple_statement_base struct to gimple removes the
typedef of gimple_statement_base * to gimple, and then adjusts all of
the places that use the type.

gcc/ChangeLog:

2015-09-19  Trevor Saunders  <tbsaunde@tbsaunde.org>

	* coretypes.h (gimple): Change typedef to be a forward
	declaration.
	* gimple.h (gimple_statement_base): rename to gimple.
	* (all functions and types using gimple): Adjust.
	* *.[ch]: Likewise.

gcc/cp/ChangeLog:

2015-09-19  Trevor Saunders  <tbsaunde@tbsaunde.org>

	* cp-gimplify.c (gimplify_must_not_throw_expr): Adjust.

From-SVN: r227941
2015-09-20 00:52:59 +00:00
Jan Hubicka 6542950e80 re PR lto/65378 (Tweak to wording of -Wodr message)
PR lto/65378
	* ipa-utils.h (warn_types_mismatch): Update prototype.
	* ipa-devirt.c (odr_types_equivalent_p): Add loc1/loc2
	parameters.
	(type_mismatch_p): New function.
	(warn_types_mismatch): Reorg to work better on non-C++ types.
	(odr_types_equivalent_p): Add loc1/loc2 parameters.
	(add_type_duplicate): Update.
	* lto-symtab.c (warn_type_compatibility_p): Fix call of
	odr_or_derived_type_p.
	(lto_symtab_merge_decls_2): Update call of warn_types_mismatch.

From-SVN: r224248
2015-06-08 20:37:53 +00:00
Jan Hubicka 70e7f2a2df ipa-utils.h (method_class_type): Remove.
* ipa-utils.h (method_class_type): Remove.
	* cgraphunit.c (walk_polymorphic_call_targets): Use TYPE_METHOD_BASETYPE.
	* ipa-devirt.c (type_in_anonymous_namespace_p): Check that it is called
	on main variants only.
	(method_class_type): Remove.
	(update_type_inheritance_graph): Use TYPE_METHOD_BASETYPE.
	(build_type_inheritance_graph): Likewise.
	* ipa-icf.c (sem_function::equals_wpa): Likewise.
	* pa-polymorphic-call.c (decl_maybe_in_construction_p, 
	check_stmt_for_type_change): Use TYPE_METHOD_BASETYPE.

From-SVN: r223629
2015-05-24 06:13:44 +00:00
Jan Hubicka 4d6eb35a6d ipa-devirt.c (type_in_anonymous_namespace_p): Return true or implicit declarations.
* ipa-devirt.c (type_in_anonymous_namespace_p): Return true
	or implicit declarations.
	(odr_type_p): Check that TYPE_NAME is TYPE_DECL before looking
	into it.
	(get_odr_type): Check type has linkage before adding bases.
	(register_odr_type): Check that type has linkage before adding it.
	(type_known_to_have_no_deriavations_p): Rename to ..
	(type_known_to_have_no_derivations_p): This one.
	* ipa-utils.h (type_known_to_have_no_deriavations_p): Rename to ..
	(type_known_to_have_no_derivations_p): This one.
	* ipa-polymorphic-call.c
	(ipa_polymorphic_call_context::restrict_to_inner_type): Check that
	type has linkage.

From-SVN: r223415
2015-05-19 21:02:06 +00:00
Jan Hubicka 259d29e396 ipa-utils.h (warn_types_mismatch, [...]): Declare.
* ipa-utils.h (warn_types_mismatch, odr_or_derived_type_p,
	odr_types_equivalent_p): Declare.
	(odr_type_p): Use gcc_checking_assert.
	(type_in_anonymous_namespace_p) Declare.
	(type_with_linkage_p): Declare.
	* common.opt (Wlto-type-mismatch): New warning.
	* ipa-devirt.c (compound_type_base): New function.
	(odr_or_derived_type_p): New function.
	(odr_types_equivalent_p): New function.
	(add_type_duplicate): Simplify.
	(type_with_linkage_p): Add hack to prevent false positives on C types
	(type_in_anonymous_namespace_p): Likewise.
	* tree.c (need_assembler_name_p): Use type_with_linkage.
	* tree.h (type_in_anonymous_namespace_p): Remove.
	* doc/invoke.texi (-Wlto-type-mismatch): Document

	* lto-symtab.c (warn_type_compatibility_p): Break out from ...;
	compare ODR types (if available) and function types.
	(lto_symtab_merge): ... here; output ODR violation warnings
	and call warn_types_mismatch.

	* gfortran.dg/lto/20091028-2_1.c: Fix return value.
	* gfortran.dg/lto/pr41576_1.f90: Add interface.
	* gfortran.dg/lto/pr41521_0.f90: Disable lto-type-mismatch
	* gfortran.dg/lto/pr60635_0.f90: Disable lto-type-mismatch.
	* gfortran.dg/lto/20091028-1_1.c: Fix return type.
	* gcc.dg/lto/20120723_0.c: Disbale lto-type-mismatch.

From-SVN: r223258
2015-05-16 23:18:29 +00:00
Jan Hubicka e7a677ca1a ipa-devirt.c (type_with_linkage_p): New function.
* ipa-devirt.c (type_with_linkage_p): New function.
	(type_in_anonymous_namespace_p): Move here from tree.c; assert that
	type has linkage.
	(odr_type_p): Move here from ipa-utils.h; use type_with_linkage_p.
	(can_be_name_hashed_p): Simplify.
	(hash_odr_name): Check that type has linkage before checking if it is
	anonymous.
	(types_same_for_odr): Likewise.
	(odr_name_hasher::equal): Likewise.
	(odr_subtypes_equivalent_p): Likewise.
	(warn_types_mismatch): Likewise.
	(get_odr_type): Likewise.
	(odr_types_equivalent_p): Fix checking of TYPE_MAIN_VARIANT.
	* ipa-utils.h (odr_type_p): Move offline.
	* tree.c (need_assembler_name_p): Fix handling of types
	without linkages.
	(type_in_anonymous_namespace_p): Move to ipa-devirt.c

From-SVN: r223094
2015-05-12 18:30:40 +00:00
Jakub Jelinek 00a0ea64ee re PR ipa/65610 (Compare debug failure with -g3 -fsanitize=undefined -fno-sanitize=vptr -O3)
PR ipa/65610
	* ipa-utils.h (inlined_polymorphic_ctor_dtor_block_p): Declare.
	* ipa-polymorphic-call.c (inlined_polymorphic_ctor_dtor_block_p): New
	function.
	(decl_maybe_in_construction_p, noncall_stmt_may_be_vtbl_ptr_store):
	Use it.
	* ipa-prop.c (param_type_may_change_p): Likewise.
	* tree-ssa-live.c: Include ipa-utils.h and its dependencies.
	(remove_unused_scope_block_p): Add in_ctor_dtor_block
	argument.  Before inlining, preserve
	inlined_polymorphic_ctor_dtor_block_p blocks and the outermost block
	with FUNCTION_DECL BLOCK_ABSTRACT_ORIGIN inside of them.  Adjust
	recursive calls.
	(remove_unused_locals): Adjust remove_unused_scope_block_p caller.

	* g++.dg/ubsan/pr65610.C: New test.

From-SVN: r221781
2015-03-30 23:56:02 +02:00
Jan Hubicka 609570b49e re PR lto/65316 (LTO: Uninitialized memory / ICE with -g -fno-lto-odr-type-merging: in types_same_for_odr, at ipa-devirt.c:465)
PR lto/65316
	* ipa-utils.h (types_odr_comparable): Add strict argument.
	* ipa-devirt.c: Fix whitespace;
	(odr_hasher): Remove.
	(odr_name_hasher, odr_vtable_hasher): New hashers.
	(can_be_name_hashed_p): New predicate.
	(hash_type_name): remove.
	(hash_odr_name): New.
	(odr_name_hasher::hash): new.
	(can_be_vtable_hashed_p): New.
	(hash_odr_vtable): New.
	(odr_vtable_hasher::hash): New.
	(types_same_for_odr): Add strict parameter.
	(types_odr_comparable): Likewise.
	(odr_name_hasher::equal): New.
	(odr_vtable_hasher::equal): New.
	(odr_name_hasher::remove): New.
	(odr_hash_type): Change to hash_table<odr_name_hasher>.
	(odr_vtable_hash_type): New.
	(odr_vtable_hash): New.
	(odr_subtypes_equivalent_p): Do strict comparsion.
	(add_type_duplicate): Merge type names; cleanup; avoid type
	duplicates.
	(register_odr_type): Initialize vtable hash.
	(build_type_inheritance_graph): Likewise
	(get_odr_type): Reorg to use two hashes.
	(dump_possible_polymorphic_call_targets): Move sanity check after debug
	output.
	(ipa_devirt): Dump type_inheritance_graph.
	(types_same_for_odr): Add strict mode.
	* g++.dg/lto/pr65316_0.C: New testcase.
	* g++.dg/lto/pr65316_1.C: New testcase.

From-SVN: r221275
2015-03-09 00:29:14 +00:00
Jan Hubicka b730d1c991 re PR ipa/64872 (ICE: Segmentation fault during Chromium PGO build)
PR ipa/64872
	* ipa-utils.c (ipa_merge_profiles): Add release argument.
	* ipa-icf.c (sem_function::merge): Do not release body when merging.
	* ipa-utils.h (ipa_merge_profiles): Update prototype.

From-SVN: r220329
2015-02-01 18:46:14 +00:00
Jakub Jelinek 5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00
Jan Hubicka 1be0e58d30 tree.c (free_lang_data_in_type): If BINFO has no important information in it, set it to NULL.
* tree.c (free_lang_data_in_type): If BINFO has no important
	information in it, set it to NULL.
	(get_binfo_at_offset): Do not walk fields, only bases.
	* ipa-utils.h (polymorphic_type_binfo_p): Be ready for BINFO_TYPE
	to be NULL.
	* ipa-polymorphic-call.c (record_known_type): Likewise.

From-SVN: r217824
2014-11-20 06:15:03 +00:00
Felix Yang 1c5fd343de ipa-utils.h: Fix typo in comments.
* ipa-utils.h: Fix typo in comments.
        * ipa-profile.c: Likewise.
        * tree-ssa-loop-ivcanon.c: Fix typo in comments and debugging dump.

From-SVN: r217507
2014-11-13 16:04:30 +00:00
Andrew MacLeod c582198bd9 cgraph.h: Flatten.
* cgraph.h: Flatten.  Remove all include files.
	(symbol_table::initialize): Move to cgraph.c.
	* cgraph.c: Adjust include files.
	(symbol_table::initialize): Relocate from cgraph.h.
	* gengtype.c (open_base_files): Adjust include files.
	* gccplugin.h: Add hash-map.h, is-a.h, plugin-api.h, and ipa-ref.h to
	included files.
	* ipa-inline.h: Remove all include files.
	* ipa-prop.h: Ditto.
	* ipa-reference.h: Ditto.
	* ipa-utils.h: Ditto:
	* lto-streamer.h: Remove cgraph.h from include list.
	* asan.c: Adjust include files.
	* auto-profile.c: Ditto.
	* bb-reorder.c: Ditto.
	* calls.c: Ditto.
	* cfgexpand.c: Ditto.
	* cgraphbuild.c: Ditto.
	* cgraphclones.c: Ditto.
	* cgraphunit.c: Ditto.
	* combine.c: Ditto.
	* coverage.c: Ditto.
	* data-streamer.c: Ditto.
	* data-streamer-in.c: Ditto.
	* data-streamer-out.c: Ditto.
	* dbxout.c: Ditto.
	* dwarf2out.c: Ditto.
	* except.c: Ditto.
	* expr.c: Ditto.
	* final.c: Ditto.
	* fold-const.c: Ditto.
	* ggc-page.c: Ditto.
	* gimple-fold.c: Ditto.
	* gimple-iterator.c: Ditto.
	* gimple-pretty-print.c: Ditto.
	* gimple-streamer-in.c: Ditto.
	* gimple-streamer-out.c: Ditto.
	* gimplify.c: Ditto.
	* ipa.c: Ditto.
	* ipa-comdats.c: Ditto.
	* ipa-cp.c: Ditto.
	* ipa-devirt.c: Ditto.
	* ipa-icf.c: Ditto.
	* ipa-icf-gimple.c: Ditto.
	* ipa-inline-analysis.c: Ditto.
	* ipa-inline.c: Ditto.
	* ipa-inline-transform.c: Ditto.
	* ipa-polymorphic-call.c: Ditto.
	* ipa-profile.c: Ditto.
	* ipa-prop.c: Ditto.
	* ipa-pure-const.c: Ditto.
	* ipa-ref.c: Ditto.
	* ipa-reference.c: Ditto.
	* ipa-split.c: Ditto.
	* ipa-utils.c: Ditto.
	* ipa-visibility.c: Ditto.
	* langhooks.c: Ditto.
	* lto-cgraph.c: Ditto.
	* lto-compress.c: Ditto.
	* lto-opts.c: Ditto.
	* lto-section-in.c: Ditto.
	* lto-section-out.c: Ditto.
	* lto-streamer.c: Ditto.
	* lto-streamer-in.c: Ditto.
	* lto-streamer-out.c: Ditto.
	* omp-low.c: Ditto.
	* opts-global.c: Ditto.
	* passes.c: Ditto.
	* predict.c: Ditto.
	* print-tree.c: Ditto.
	* profile.c: Ditto.
	* ree.c: Ditto.
	* stor-layout.c: Ditto.
	* symtab.c: Ditto.
	* toplev.c: Ditto.
	* trans-mem.c: Ditto.
	* tree.c: Ditto.
	* tree-cfg.c: Ditto.
	* tree-eh.c: Ditto.
	* tree-emutls.c: Ditto.
	* tree-inline.c: Ditto.
	* tree-nested.c: Ditto.
	* tree-pretty-print.c: Ditto.
	* tree-profile.c: Ditto.
	* tree-sra.c: Ditto.
	* tree-ssa-alias.c: Ditto.
	* tree-ssa-loop-ivcanon.c: Ditto.
	* tree-ssa-loop-ivopts.c: Ditto.
	* tree-ssa-pre.c: Ditto.
	* tree-ssa-structalias.c: Ditto.
	* tree-streamer.c: Ditto.
	* tree-streamer-in.c: Ditto.
	* tree-streamer-out.c: Ditto.
	* tree-switch-conversion.c: Ditto.
	* tree-tailcall.c: Ditto.
	* tree-vect-data-refs.c: Ditto.
	* tree-vectorizer.c: Ditto.
	* tree-vect-stmts.c: Ditto.
	* tsan.c: Ditto.
	* ubsan.c: Ditto.
	* value-prof.c: Ditto.
	* varasm.c: Ditto.
	* varpool.c: Ditto.
	* config/arm/arm.c: Ditto.
	* config/bfin/bfin.c: Ditto.
	* config/c6x/c6x.c: Ditto.
	* config/cris/cris.c: Ditto.
	* config/darwin.c: Ditto.
	* config/darwin-c.c: Ditto.
	* config/i386/i386.c: Ditto.
	* config/i386/winnt.c: Ditto.
	* config/microblaze/microblaze.c: Ditto.
	* config/mips/mips.c: Ditto.
	* config/rs6000/rs6000.c: Ditto.
	* config/rx/rx.c: Ditto.

	* ada/gcc-interface/trans.c: Adjust include files.
	* ada/gcc-interface/utils.c: Ditto.

	* c/c-decl.c: Adjust include files.
	* c/c-parser.c: Ditto.

	* c-family/c-common.c: Adjust include files.
	* c-family/c-gimplify.c: Ditto.
	* c-family/cilk.c: Ditto.
	* c-family/c-pragma.c: Ditto.
	* c-family/c-ubsan.c: Ditto.

	* cp/call.c: Adjust include files.
	* cp/class.c: Ditto.
	* cp/decl2.c: Ditto.
	* cp/decl.c: Ditto.
	* cp/lambda.c: Ditto.
	* cp/mangle.c: Ditto.
	* cp/method.c: Ditto.
	* cp/optimize.c: Ditto.
	* cp/parser.c: Ditto.
	* cp/semantics.c: Ditto.
	* cp/tree.c: Ditto.
	* cp/vtable-class-hierarchy.c: Ditto.

	* fortran/f95-lang.c: Adjust include files.
	* fortran/trans-decl.c: Ditto.

	* go/go-gcc.cc: Adjust include files.

	* java/class.c: Adjust include files.
	* java/decl.c: Ditto.
	* java/jcf-parse.c: Ditto.
	* java/resource.c: Ditto.

	* lto/lto.c: Adjust include files.
	* lto/lto-lang.c: Ditto.
	* lto/lto-object.c: Ditto.
	* lto/lto-partition.c: Ditto.
	* lto/lto-symtab.c: Ditto.

	* objc/objc-act.c: Adjust include files.

From-SVN: r216805
2014-10-28 16:17:19 +00:00
Jan Hubicka 5ce97055e0 ipa-prop.h (ipa_get_controlled_uses): Add hack to avoid ICE when speculation is added.
* ipa-prop.h (ipa_get_controlled_uses): Add hack to avoid ICE
	when speculation is added.
	(ipa_edge_args): Add polymorphic_call_contexts.
	(ipa_get_ith_polymorhic_call_context): New accesor.
	(ipa_make_edge_direct_to_target): Add SPECULATIVE parameter.
	* ipa-prop.c (ipa_print_node_jump_functions_for_edge): Print contexts.
	(ipa_compute_jump_functions_for_edge): Compute contexts.
	(update_jump_functions_after_inlining): Update contexts.
	(ipa_make_edge_direct_to_target): Add SPECULATIVE argument;
	update dumping; add speculative edge creation.
	(try_make_edge_direct_virtual_call): Add CTX_PTR parameter; handle
	context updating.
	(update_indirect_edges_after_inlining): Pass down context.
	(ipa_edge_duplication_hook): Duplicate contexts.
	(ipa_write_node_info): Stream out contexts.
	(ipa_read_node_info): Stream in contexts.
	* ipa-devirt.c (type_all_derivations_known_p): Avoid ICE on non-ODR
	types.
	(try_speculative_devirtualization): New function.
	* ipa-utils.h (try_speculative_devirtualization): Declare.

From-SVN: r215794
2014-10-02 07:03:15 +00:00
Martin Liska bf898b300e cgraph.c (cgraph_node::release_body): New argument keep_arguments introduced.
* cgraph.c (cgraph_node::release_body): New argument keep_arguments
	introduced.
	* cgraph.h: Likewise.
	* cgraphunit.c (cgraph_node::create_wrapper): Usage of new argument introduced.
	* ipa-utils.h (polymorphic_type_binfo_p): Safe check for binfos created by Java.
	* tree-ssa-alias.c (ao_ref_base_alias_set): Static function transformed to global.
	* tree-ssa-alias.h: Likewise.

From-SVN: r215640
2014-09-26 10:37:44 +00:00
Jan Hubicka aa803cc76e ipa-utils.h (subbinfo_with_vtable_at_offset, [...]): Declare.
* ipa-utils.h (subbinfo_with_vtable_at_offset, type_all_derivations_known_p,
	type_known_to_have_no_deriavations_p, types_must_be_same_for_odr,
	types_odr_comparable): Declare.
	(polymorphic_type_binfo_p): Move here from ipa-devirt.c
	* ipa-polymorphic-call.c: New file.
	(contains_polymorphic_type_p, possible_placement_new,
	ipa_polymorphic_call_context::restrict_to_inner_class,
	contains_type_p, decl_maybe_in_construction_p,
	ipa_polymorphic_call_context::stream_out,
	ipa_polymorphic_call_context::debug,
	ipa_polymorphic_call_context::stream_in,
	ipa_polymorphic_call_context::set_by_decl,
	ipa_polymorphic_call_context::set_by_invariant,
	walk_ssa_copies,
	ipa_polymorphic_call_context::ipa_polymorphic_call_context,
	type_change_info, noncall_stmt_may_be_vtbl_ptr_store,
	extr_type_from_vtbl_ptr_store, record_known_type
	check_stmt_for_type_change,
	ipa_polymorphic_call_context::get_dynamic_type): Move here from
	ipa-devirt.c
	* ipa-devirt.c: No longer include data-streamer.h, lto-streamer.h
	and streamer-hooks.h
	(contains_polymorphic_type_p, possible_placement_new,
	ipa_polymorphic_call_context::restrict_to_inner_class,
	contains_type_p, decl_maybe_in_construction_p,
	ipa_polymorphic_call_context::stream_out,
	ipa_polymorphic_call_context::debug,
	ipa_polymorphic_call_context::stream_in,
	ipa_polymorphic_call_context::set_by_decl,
	ipa_polymorphic_call_context::set_by_invariant,
	walk_ssa_copies,
	ipa_polymorphic_call_context::ipa_polymorphic_call_context,
	type_change_info, noncall_stmt_may_be_vtbl_ptr_store,
	extr_type_from_vtbl_ptr_store, record_known_type
	check_stmt_for_type_change,
	ipa_polymorphic_call_context::get_dynamic_type): Move to
	ipa-polymorphic-call.c
	(type_all_derivations_known_p, types_odr_comparable,
	types_must_be_same_for_odr): Export.
	(type_known_to_have_no_deriavations_p): New function.
	* Makefile.in: Add ipa-polymorphic-call.c

From-SVN: r215615
2014-09-25 19:52:20 +00:00
Jan Hubicka 2f28755fbf ipa-devirt.c (polymorphic_call_target_d): Add SPECULATIVE; reorder for better storage.
* ipa-devirt.c (polymorphic_call_target_d): Add SPECULATIVE; reorder
	for better storage.
	(polymorphic_call_target_hasher::hash): Hash SPECULATIVE.
	(possible_polymorphic_call_targets): Instead of computing both
	speculative and non-speculative answers, do just one at a time.
	Replace NONSPECULATIVE_TARGETSP parameter with SPECULATIVE flag.
	(dump_targets): Break out from ...
	(dump_possible_polymorphic_call_targets): ... here; dump both speculative
	and non-speculative lists.
	(ipa_devirt): Update for new possible_polymorphic_call_targets API.
	* ipa-utils.h (possible_polymorphic_call_targets): Update.

	* testsuite/g++.dg/ipa/devirt-34.C: Update template.

From-SVN: r215614
2014-09-25 18:57:44 +00:00
Jan Hubicka ba3923391e cgraph.h (class ipa_polymorphic_call_context): Move here from ipa-utils.h; add stream_int and stream_out methods.
* cgraph.h (class ipa_polymorphic_call_context): Move here from
	ipa-utils.h; add stream_int and stream_out methods.
	(cgraph_indirect_call_info): Remove SPECILATIVE_OFFSET,
	OUTER_TYPE, SPECULATIVE_OUTER_TYPE, MAYBE_IN_CONSTRUCTION
	MAYBE_DERIVED_TYPE and SPECULATIEVE_MAYBE_DERIVED_TYPE;
	add CONTEXT.
	(ipa_polymorphic_call_context::ipa_polymorphic_call_context,
	ipa_polymorphic_call_context::ipa_polymorphic_call_context,
	ipa_polymorphic_call_context::clear_speculation,
	ipa_polymorphic_call_context::clear_outer_type): Move here from
	ipa-utils.h
	* ipa-utils.h (class ipa_polymorphic_call_context): Move to cgraph.h
	(ipa_polymorphic_call_context::ipa_polymorphic_call_context,
	ipa_polymorphic_call_context::ipa_polymorphic_call_context,
	ipa_polymorphic_call_context::clear_speculation,
	ipa_polymorphic_call_context::clear_outer_type): Likewise.
	* ipa-devirt.c: Include data-streamer.h, lto-streamer.h and
	streamer-hooks.h
	(ipa_polymorphic_call_context::stream_out): New method.
	(ipa_polymorphic_call_context::stream_in): New method.
	(noncall_stmt_may_be_vtbl_ptr_store): Add forgotten static.
	* ipa-prop.c (ipa_analyze_indirect_call_uses): Do not care about
	OUTER_TYPE.
	(ipa_analyze_call_uses): Simplify.
	(update_indirect_edges_after_inlining): Do not care about outer_type.
	(ipa_write_indirect_edge_info): Update.
	(ipa_write_indirect_edge_info): Likewise.
	* cgraph.c (cgraph_node::create_indirect_edge): Simplify.
	(dump_edge_flags): Break out from ...
	(cgraph_node::dump): ... here; dump indirect edges.

From-SVN: r215575
2014-09-25 01:48:34 +00:00
Jan Hubicka a198145843 ipa-utils.h (polymorphic_call_context): Add metdhos dump, debug and clear_outer_type.
* ipa-utils.h (polymorphic_call_context): Add
	metdhos dump, debug and clear_outer_type.
	(ipa_polymorphic_call_context::ipa_polymorphic_call_context): Simplify.
	(ipa_polymorphic_call_context::clear_outer_type): New method.
	* ipa-prop.c (ipa_analyze_call_uses): Do not overwrite offset.
	* ipa-devirt.c (types_odr_comparable): New function.
	(types_must_be_same_for_odr): New function.
	(odr_subtypes_equivalent_p): Simplify.
	(possible_placement_new): Break out from ...
	(ipa_polymorphic_call_context::restrict_to_inner_type): ... here;
	be more cuatious about returning false in cases the context may be
	valid in derived type or via placement new.
	(contains_type_p): Clear maybe_derived_type
	(ipa_polymorphic_call_context::dump): New method.
	(ipa_polymorphic_call_context::debug): New method.
	(ipa_polymorphic_call_context::set_by_decl): Cleanup comment.
	(ipa_polymorphic_call_context::set_by_invariant): Simplify.
	(ipa_polymorphic_call_context::ipa_polymorphic_call_context): Simplify.
	(possible_polymorphic_call_targets): Trust context.restrict_to_inner_class
	to suceed on all valid cases; remove confused sanity check.
	(dump_possible_polymorphic_call_targets): Simplify.

From-SVN: r215569
2014-09-24 20:30:21 +00:00
Jan Hubicka 6f8091fc3e ipa-utils.h (ipa_polymorphic_call_context): Turn into class; add ctors.
* ipa-utils.h (ipa_polymorphic_call_context): Turn into class; add ctors.
	(possible_polymorphic_call_targets, dump_possible_polymorphic_call_targets,
	possible_polymorphic_call_target_p, possible_polymorphic_call_target_p): Simplify.
	(get_dynamic_type): Remove.
	* ipa-devirt.c (ipa_dummy_polymorphic_call_context): Remove.
	(clear_speculation): Bring to ipa-deivrt.h
	(get_class_context): Rename to ...
	(ipa_polymorphic_call_context::restrict_to_inner_class): ... this one.
	(contains_type_p): Update.
	(get_dynamic_type): Rename to ...
	ipa_polymorphic_call_context::get_dynamic_type(): ... this one.
	(possible_polymorphic_call_targets): UPdate.
	* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Update.
	* ipa-prop.c (ipa_analyze_call_uses): Update.

From-SVN: r215418
2014-09-20 06:22:58 +00:00
Jan Hubicka 1ee85ee19b common.opt (flto-odr-type-merging): New flag.
* common.opt (flto-odr-type-merging): New flag.
	* ipa-deivrt.c (hash_type_name): Use ODR names for hasing if availale.
	(types_same_for_odr): Likewise.
	(odr_subtypes_equivalent_p): Likewise.
	(add_type_duplicate): Do not walk type variants.
	(register_odr_type): New function.
	* ipa-utils.h (register_odr_type): Declare.
	(odr_type_p): New function.
	* langhooks.c (lhd_set_decl_assembler_name): Do not compute
	TYPE_DECLs
	* doc/invoke.texi (-flto-odr-type-merging): Document.
	* tree.c (need_assembler_name_p): Compute ODR names when asked
	for it.
	* tree.h (DECL_ASSEMBLER_NAME): Update comment.

	* lto.c (lto_read_decls): Register ODR types.

From-SVN: r215196
2014-09-11 23:16:42 +00:00
Jan Hubicka 4d7cf10d21 ipa-utils.h (ipa_polymorphic_call_context): Turn into class; add ctors.
* ipa-utils.h (ipa_polymorphic_call_context): Turn into class; add ctors.
	(possible_polymorphic_call_targets, dump_possible_polymorphic_call_targets,
	possible_polymorphic_call_target_p, possible_polymorphic_call_target_p): Simplify.
	(get_dynamic_type): Remove.
	* ipa-devirt.c (ipa_dummy_polymorphic_call_context): Remove.
	(clear_speculation): Bring to ipa-deivrt.h
	(get_class_context): Rename to ...
	(ipa_polymorphic_call_context::restrict_to_inner_class): ... this one.
	(contains_type_p): Update.
	(get_dynamic_type): Rename to ...
	ipa_polymorphic_call_context::get_dynamic_type(): ... this one.
	(possible_polymorphic_call_targets): UPdate.
	* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Update.
	* ipa-prop.c (ipa_analyze_call_uses): Update.

From-SVN: r214060
2014-08-16 09:10:23 +00:00
Jan Hubicka 56b1f114de ipa-utils.h (compare_virtual_tables): Declare.
* ipa-utils.h (compare_virtual_tables): Declare.
	* ipa-devirt.c (odr_subtypes_equivalent_p): New function

	* lto-symtab.c (lto_varpool_replace_node): Call compare_virtual_tables.

From-SVN: r213990
2014-08-14 23:30:46 +00:00
Jan Hubicka 7d0aa05b9e ipa-devirt.c: Include gimple-pretty-print.h
* ipa-devirt.c: Include gimple-pretty-print.h
	(referenced_from_vtable_p): Exclude DECL_EXTERNAL from
	further tests.
	(decl_maybe_in_construction_p): Fix conditional on cdtor check
	(get_polymorphic_call_info): Fix return value
	(type_change_info): New sturcture based on ipa-prop
	variant.
	(noncall_stmt_may_be_vtbl_ptr_store): New predicate
	based on ipa-prop variant.
	(extr_type_from_vtbl_ptr_store): New function
	based on ipa-prop variant.
	(record_known_type): New function.
	(check_stmt_for_type_change): New function.
	(get_dynamic_type): New function.
	* ipa-prop.c (ipa_analyze_call_uses): Use get_dynamic_type.
	* tree-ssa-pre.c: ipa-utils.h
	(eliminate_dom_walker::before_dom_children): Use ipa-devirt
	machinery; sanity check with ipa-prop devirtualization.
	* trans-mem.c (ipa_tm_insert_gettmclone_call): Clear
	polymorphic flag.

	* g++.dg/ipa/devirt-35.C: New testcase.
	* g++.dg/ipa/devirt-36.C: New testcase.

From-SVN: r213739
2014-08-07 20:58:17 +00:00
Jan Hubicka 3339f0bcb0 cgraph.c (cgraph_node::create_indirect_edge): Copy speculative data.
* cgraph.c (cgraph_node::create_indirect_edge): Copy speculative data.
	* cgraph.h (cgraph_indirect_call_info): Add speculative data.
	* gimple-fold.c (fold_gimple_assign): Fix check for virtual
	call.
	* ipa-devirt.c (ipa_dummy_polymorphic_call_context): Update
	(contains_type_p): Forward declare.
	(polymorphic_call_target_hasher::hash): Hash speculative info.
	(polymorphic_call_target_hasher::equal): Compare speculative info.
	(get_class_context): Handle speuclation.
	(contains_type_p): Update.
	(get_polymorphic_call_info_for_decl): Update.
	(walk_ssa_copies): Break out from ...
	(get_polymorphic_call_info): ... here; set speculative context
	before giving up.
	* ipa-prop.c (ipa_write_indirect_edge_info, ipa_read_indirect_edge_info):
	Stream speculative context.
	* ipa-utils.h (ipa_polymorphic_call_context): Add speculative info
	(SPECULATIVE_OFFSET, SPECULATIVE_OUTER_TYPE,
	SPECULATIVE_MAYBE_DERIVED_TYPE).
	(possible_polymorphic_call_targets overriders): Update.
	(dump_possible_polymorphic_call_targets overriders): Update.
	(dump_possible_polymorphic_call_target_p overriders): Update.

From-SVN: r213152
2014-07-29 09:39:06 +00:00
Martin Liska d52f529517 IPA C++ refactoring 1/N
* cgraph.h (symtab_node):
  (void register_symbol (void)): created from symtab_register_node
  (void remove (void)): created from symtab_remove_node
  (void dump (FILE *f)): created from dump_symtab_node
  (void DEBUG_FUNCTION debug (void)): created from debug_symtab_node
  (void DEBUG_FUNCTION verify (void)): created from verify_symtab_node
  (struct ipa_ref *add_reference (symtab_node *referred_node,
    enum ipa_ref_use use_type)): created from add_reference 
  (struct ipa_ref *add_reference (symtab_node *referred_node,
    enum ipa_ref_use use_type, gimple stmt)): created from add_reference
  (struct ipa_ref *maybe_add_reference (tree val, enum ipa_ref_use use_type,
    gimple stmt)): created from maybe_add_reference
  (bool semantically_equivalent_p (symtab_node *target)): created from
    symtab_semantically_equivalent_p
  (void remove_from_same_comdat_group (void)): created from
    remove_from_same_comdat_group
  (void add_to_same_comdat_group (symtab_node *old_node)): created from
    symtab_add_to_same_comdat_group
  (void dissolve_same_comdat_group_list (void)): created from
    symtab_dissolve_same_comdat_group_list
  (bool used_from_object_file_p (void)): created from symtab_used_from_object_file_p
  (symtab_node *ultimate_alias_target (enum availability *avail = NULL)):
    created from symtab_alias_ultimate_target
  (inline symtab_node *next_defined_symbol (void)): created from
    symtab_next_defined_symbol
  (bool resolve_alias (symtab_node *target)): created from
    symtab_resolve_alias
  (bool call_for_symbol_and_aliases (bool (*callback) (symtab_node *, void *),
    void *data, bool include_overwrite)): created from symtab_for_node_and_aliases
  (symtab_node *noninterposable_alias (void)): created from symtab_nonoverwritable_alias
  (inline symtab_node *get_alias_target (void)): created from symtab_alias_target
  (void set_section (const char *section)): created from set_section_1 
  (enum availability get_availability (void)): created from symtab_node_availability
  (void make_decl_local (void)): created from symtab_make_decl_local
  (bool real_symbol_p (void)): created from symtab_read_node
  (can_be_discarded_p (void)): created from symtab_can_be_discarded
  (inline bool comdat_local_p (void)): created from symtab_comdat_local_p
  (inline bool in_same_comdat_group_p (symtab_node *target)): created from
    symtab_in_same_comdat_p;
  (bool address_taken_from_non_vtable_p (void)): created from
    address_taken_from_non_vtable_p
  (static inline symtab_node *get (const_tree decl)): created from symtab_get_node
  (static void dump_table (FILE *)): created from dump_symtab
  (static inline DEBUG_FUNCTION void debug_symtab (void)): created from debug_symtab
  (static DEBUG_FUNCTION void verify_symtab_nodes (void)): created from verify_symtab
  (static bool used_from_object_file_p_worker (symtab_node *node)): created from
    symtab_used_from_object_file_p 
  (void dump_base (FILE *)): created from dump_symtab_base
  (bool DEBUG_FUNCTION verify_base (void)): created from verify_symtab_base
  (void unregister (void)): created from symtab_unregister_node
  (struct symbol_priority_map *priority_info (void)): created from symtab_priority_info
  (static bool set_implicit_section (symtab_node *n, void *)): created from set_implicit_section
  (static bool noninterposable_alias (symtab_node *node, void *data)): created from
    symtab_nonoverwritable_alias_1
  * cgraph.h (cgraph_node):
  (bool remove_symbol_and_inline_clones (cgraph_node *forbidden_node = NULL)):
    created from cgraph_remove_node_and_inline_clones
  (void record_stmt_references (gimple stmt)): created from ipa_record_stmt_references
  (void set_call_stmt_including_clones (gimple old_stmt, gimple new_stmt,
    bool update_speculative = true)): created from cgraph_set_call_stmt_including_clones
  (cgraph_node *function_symbol (enum availability *avail = NULL)):
    created from cgraph_function_node
  (cgraph_node *create_clone (tree decl, gcov_type count, int freq, bool update_original,
    vec<cgraph_edge *> redirect_callers, bool call_duplication_hook,
    struct cgraph_node *new_inlined_to, bitmap args_to_skip)):
    created from cgraph_create_clone 
  (cgraph_node *create_virtual_clone (vec<cgraph_edge *> redirect_callers,
    vec<ipa_replace_map *, va_gc> *tree_map, bitmap args_to_skip, const char * suffix)):
    created from cgraph_create_virtual_clone
  (cgraph_node *find_replacement (void)): created from cgraph_find_replacement_node
  (cgraph_node *create_version_clone (tree new_decl, vec<cgraph_edge *> redirect_callers,
    bitmap bbs_to_copy)): created from cgraph_copy_node_for_versioning
  (cgraph_node *create_version_clone_with_body (vec<cgraph_edge *> redirect_callers,
    vec<ipa_replace_map *, va_gc> *tree_map, bitmap args_to_skip, bool skip_return,
    bitmap bbs_to_copy, basic_block new_entry_block, const char *clone_name)):
    created from cgraph_function_version_info
  (struct cgraph_function_version_info *insert_new_function_version (void)):
    created from insert_new_cgraph_node_version
  (struct cgraph_function_version_info *function_version (void)): created from
    get_cgraph_node_version
  (void analyze (void)): created from analyze_function
  (cgraph_node * create_thunk (tree alias, tree, bool this_adjusting,
    HOST_WIDE_INT fixed_offset, HOST_WIDE_INT virtual_value, tree virtual_offset,
    tree real_alias) cgraph_add_thunk
  (inline cgraph_node *get_alias_target (void)): created from cgraph_alias_target
  (cgraph_node *ultimate_alias_target (availability *availability = NULL)):
    created from cgraph_function_or_thunk_node
  (bool expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)):
    created from expand_thunk
  (void reset (void)): created from cgraph_reset_node
  (void create_wrapper (cgraph_node *target)): created from cgraph_make_wrapper
  (void DEBUG_FUNCTION verify_node (void)): created from verify_cgraph_node
  (void remove (void)): created from cgraph_remove_node
  (void dump (FILE *f)): created from dump_cgraph_node
  (void DEBUG_FUNCTION debug (void)): created from debug_cgraph_node
  (bool get_body (void)): created from cgraph_get_body
  (void release_body (void)): created from cgraph_release_function_body
  (void unnest (void)): created from cgraph_unnest_node
  (void make_local (void)): created from cgraph_make_node_local
  (void mark_address_taken (void)): created from cgraph_mark_address_taken_node
  (struct cgraph_edge *create_edge (cgraph_node *callee, gimple call_stmt,
    gcov_type count, int freq)): created from cgraph_create_edge
  (struct cgraph_edge *create_indirect_edge (gimple call_stmt, int ecf_flags,
    gcov_type count, int freq)): created from cgraph_create_indirect_edge
  (void create_edge_including_clones (struct cgraph_node *callee, gimple old_stmt,
    gimple stmt, gcov_type count, int freq, cgraph_inline_failed_t reason)):
    created from cgraph_create_edge_including_clones
  (cgraph_edge *get_edge (gimple call_stmt)): created from cgraph_edge
  (vec<cgraph_edge *> collect_callers (void)): created from collect_callers_of_node
  (void remove_callers (void)): created from cgraph_node_remove_callers
  (void remove_callees (void)): created from cgraph_node_remove_callees
  (enum availability get_availability (void)): created from cgraph_function_body_availability
  (void set_nothrow_flag (bool nothrow)): created from cgraph_set_nothrow_flag
  (void set_const_flag (bool readonly, bool looping)): created from cgraph_set_const_flag
  (void set_pure_flag (bool pure, bool looping)): created from cgraph_set_pure_flag
  (void call_duplication_hooks (cgraph_node *node2)): created from
    cgraph_call_node_duplication_hooks
  (bool call_for_symbol_and_aliases (bool (*callback) (cgraph_node *, void *),
    void *data, bool include_overwritable)): created from cgraph_for_node_and_aliases
  (bool call_for_symbol_thunks_and_aliases (bool (*callback) (cgraph_node *node, void *data),
    void *data, bool include_overwritable)): created from cgraph_for_node_thunks_and_aliases
  (void call_function_insertion_hooks (void)):
    created from cgraph_call_function_insertion_hooks
  (inline void mark_force_output (void)): created from cgraph_mark_force_output_node
  (bool local_p (void)): created from cgraph_local_node
  (bool can_be_local_p (void)): created from cgraph_node_can_be_local_p
  (bool cannot_return_p (void)): created from cgraph_node_cannot_return
  (bool only_called_directly_p (void)): created from cgraph_only_called_directly_p
  (inline bool only_called_directly_or_aliased_p (void)):
    created from cgraph_only_called_directly_or_aliased_p
  (bool will_be_removed_from_program_if_no_direct_calls_p (void)):
    created from cgraph_will_be_removed_from_program_if_no_direct_calls
  (bool can_remove_if_no_direct_calls_and_refs_p (void)):
    created from cgraph_can_remove_if_no_direct_calls_and_refs_p
  (bool can_remove_if_no_direct_calls_p (void)):
    created from cgraph_can_remove_if_no_direct_calls_p
  (inline bool has_gimple_body_p (void)):
    created from cgraph_function_with_gimple_body_p
  (bool optimize_for_size_p (void)): created from cgraph_optimize_for_size_p
  (static void dump_cgraph (FILE *f)): created from dump_cgraph
  (static inline void debug_cgraph (void)): created from debug_cgraph
  (static void record_function_versions (tree decl1, tree decl2)):
    created from record_function_versions
  (static void delete_function_version (tree decl)):
    created from delete_function_version
  (static void add_new_function (tree fndecl, bool lowered)):
    created from cgraph_add_new_function
  (static inline cgraph_node *get (const_tree decl)): created from cgraph_get_node
  (static cgraph_node * create (tree decl)): created from cgraph_create_node
  (static cgraph_node * create_empty (void)): created from cgraph_create_empty_node
  (static cgraph_node * get_create (tree)): created from cgraph_get_create_node
  (static cgraph_node *get_for_asmname (tree asmname)):
    created from cgraph_node_for_asm
  (static cgraph_node * create_same_body_alias (tree alias, tree decl)):
    created from cgraph_same_body_alias 
  (static bool used_from_object_file_p_worker (cgraph_node *node,
    void *): new function
  (static bool non_local_p (cgraph_node *node, void *)):
    created from cgraph_non_local_node_p_1
  (static void DEBUG_FUNCTION verify_cgraph_nodes (void)):
    created from verify_cgraph
  (static bool make_local (cgraph_node *node, void *)):
    created from cgraph_make_node_local
  (static cgraph_node *create_alias (tree alias, tree target)):
    created from cgraph_create_function_alias
  (static cgraph_edge * create_edge (cgraph_node *caller, cgraph_node *callee,
    gimple call_stmt, gcov_type count, int freq, bool indir_unknown_callee)):
    created from cgraph_create_edge_1
  * cgraph.h (varpool_node):
  (void remove (void)): created from varpool_remove_node
  (void dump (FILE *f)): created from dump_varpool_node

From-SVN: r212982
2014-07-24 12:07:13 +00:00
Jan Hubicka 058d0a9059 cgraph.c (cgraph_create_indirect_edge): Update call of get_polymorphic_call_info.
* cgraph.c (cgraph_create_indirect_edge): Update call of
	get_polymorphic_call_info.
	* ipa-utils.h (get_polymorphic_call_info): Add parameter CALL.
	(possible_polymorphic_call_targets): Add parameter call.
	(decl_maybe_in_construction_p): New predicate.
	(get_polymorphic_call_info): Add parameter call;
	use decl_maybe_in_construction_p.
	* gimple-fold.c (fold_gimple_assign): Update use of
	possible_polymorphic_call_targets.
	(gimple_fold_call): Likewise.
	* ipa-prop.c: Inlcude calls.h
	(ipa_binfo_from_known_type_jfunc): Check that known type is record.
	(param_type_may_change_p): New predicate.
	(detect_type_change_from_memory_writes): Break out from ...
	(detect_type_change): ... this one; use 
	param_type_may_change_p.
	(detect_type_change_ssa): Use param_type_may_change_p.
	(compute_known_type_jump_func): Use decl_maybe_in_construction_p.

	* g++.dg/ipa/devirt-26.C: Update testcase.
	* g++.dg/ipa/imm-devirt-1.C: Update testcase.
	* g++.dg/ipa/imm-devirt-2.C: Update testcase.

From-SVN: r212304
2014-07-05 17:22:44 +00:00
Jan Hubicka d570d364e6 ipa-utils.h (method_class_type, [...]): Constify.
* ipa-utils.h (method_class_type, vtable_pointer_value_to_binfo,
	vtable_pointer_value_to_vtable): Constify.
	(contains_polymorphic_type_p): Declare.
	* ipa-devirt.c (method_class_type, vtable_pointer_value_to_binfo,
	vtable_pointer_value_to_vtable): Constify.
	(contains_polymorphic_type_p): New predicate.
	* ipa-prop.c (ipa_set_jf_known_type): Allow types containing
	polymorphic types.
	(ipa_set_ancestor_jf): Likewise.
	(detect_type_change): Return false in easy cases.
	(compute_complex_assign_jump_func): Require type to contain
	polymorphic type.
	(compute_known_type_jump_func): Likewise.

From-SVN: r212222
2014-07-02 07:48:00 +00:00
Jan Hubicka ec77d61fe3 re PR lto/59468 (ICE on invalid C++ code with LTO in gimple_get_virt_method_for_binfo, at gimple-fold.c:3224)
PR lto/59468
	* ipa-utils.h (possible_polymorphic_call_targets): Update prototype
	and wrapper.
	* ipa-devirt.c: Include demangle.h
	(odr_violation_reported): New static variable.
	(add_type_duplicate): Update odr_violations.
	(maybe_record_node): Add completep parameter; update it.
	(record_target_from_binfo): Add COMPLETEP parameter;
	update it as needed.
	(possible_polymorphic_call_targets_1): Likewise.
	(struct polymorphic_call_target_d): Add nonconstruction_targets;
	rename FINAL to COMPLETE.
	(record_targets_from_bases): Sanity check we found the binfo;
	fix COMPLETEP updating.
	(possible_polymorphic_call_targets): Add NONCONSTRUTION_TARGETSP
	parameter, fix computing of COMPLETEP.
	(dump_possible_polymorphic_call_targets): Imrove readability of dump; at
	LTO time do demangling.
	(ipa_devirt): Use nonconstruction_targets; Improve dumps.
	* gimple-fold.c (gimple_get_virt_method_for_vtable): Add can_refer
	parameter.
	(gimple_get_virt_method_for_binfo): Likewise.
	* gimple-fold.h (gimple_get_virt_method_for_binfo,
	gimple_get_virt_method_for_vtable): Update prototypes.

	PR lto/59468
	* g++.dg/ipa/devirt-27.C: New testcase.
	* g++.dg/ipa/devirt-26.C: New testcase.

From-SVN: r207702
2014-02-11 22:54:21 +00:00
Jan Hubicka 5bccb77a77 ipa-cp.c (ipa_get_indirect_edge_target_1): Do direct lookup via vtable pointer...
* ipa-cp.c (ipa_get_indirect_edge_target_1): Do direct
	lookup via vtable pointer; check for type consistency
	and turn inconsitent facts into UNREACHABLE.
	* ipa-prop.c (try_make_edge_direct_virtual_call): Likewise.
	* gimple-fold.c (gimple_get_virt_method_for_vtable): 
	Do not ICE on type inconsistent querries; return UNREACHABLE
	instead.

	* testsuite/g++.dg/ipa/devirt-25.C: New testcase.

From-SVN: r207448
2014-02-04 05:40:21 +00:00
Jan Hubicka 85942f45e9 re PR ipa/59831 (ice in cgraph_speculative_call_info with -O3)
PR ipa/59831
	* g++.dg/ipa/devirt-24.C: New testcase.

	* ipa-cp.c (ipa_get_indirect_edge_target_1): Give up on -fno-devirtualize;
	Try to devirtualize by the knowledge of virtual table pointer given by
	aggregate propagation.
	* ipa-prop.c (try_make_edge_direct_virtual_call): Likewise.
	ipa_print_node_jump_functions): Dump also offset that
	is relevant for polymorphic calls.
	(determine_known_aggregate_parts): Add arg_type parameter; use it
	instead of determining the type from pointer type.
	(ipa_compute_jump_functions_for_edge): Update call of
	determine_known_aggregate_parts.
	* gimple-fold.c (gimple_get_virt_method_for_vtable): Break out from ...
	(gimple_get_virt_method_for_binfo): ... here; simplify using
	vtable_pointer_value_to_vtable.
	* gimple-fold.h (gimple_get_virt_method_for_vtable): Declare.
	* ipa-devirt.c (subbinfo_with_vtable_at_offset): Turn OFFSET parameter
	to unsigned HOST_WIDE_INT; Use vtable_pointer_value_to_vtable.
	(vtable_pointer_value_to_vtable): Break out from ...; handle also
	POINTER_PLUS_EXPR.
	(vtable_pointer_value_to_binfo): ... here.
	* ipa-utils.h (vtable_pointer_value_to_vtable): Declare.

From-SVN: r207439
2014-02-03 20:41:30 +00:00
Jan Hubicka 390675c87d ipa-devirt.c (subbinfo_with_vtable_at_offset, [...]): New functions.
* ipa-devirt.c (subbinfo_with_vtable_at_offset,
	vtable_pointer_value_to_binfo): New functions.
	* ipa-utils.h (vtable_pointer_value_to_binfo): Declare.
	* ipa-prop.c (extr_type_from_vtbl_ptr_store): Use it.
	* g++.dg/ipa/devirt-23.C: New testcase.
	* g++.dg/ipa/devirt-20.C: Fix template.

From-SVN: r207413
2014-02-03 00:24:52 +00:00
Richard Sandiford 23a5b65a92 Update copyright years in gcc/
From-SVN: r206289
2014-01-02 22:23:26 +00:00
Jan Hubicka 61dd6a2e33 devirt-13.C: Update template.
* g++.dg/ipa/devirt-13.C: Update template.
	* ipa-utils.h (possible_polymorphic_call_targets): Determine context of
	the call.
	* gimple-fold.c (gimple_fold_call): Use ipa-devirt to devirtualize.

From-SVN: r206042
2013-12-17 10:26:59 +00:00
Jan Hubicka 68377e53bd cgraph.c (cgraph_create_indirect_edge): Use get_polymorphic_call_info.
* cgraph.c (cgraph_create_indirect_edge): Use get_polymorphic_call_info.
	* cgraph.h (cgraph_indirect_call_info): Add outer_type, maybe_in_construction
	and maybe_derived_type.
	* ipa-utils.h (ipa_polymorphic_call_context): New structure.
	(ipa_dummy_polymorphic_call_context): New global var.
	(possible_polymorphic_call_targets): Add context paramter.
	(dump_possible_polymorphic_call_targets): Likewise; update
	wrappers.
	(possible_polymorphic_call_target_p): Likewise.
	(get_polymorphic_call_info): New function.
	* ipa-devirt.c (ipa_dummy_polymorphic_call_context): New function.
	(add_type_duplicate): Remove forgotten debug output.
	(method_class_type): Add sanity check.
	(maybe_record_node): Add FINALP parameter.
	(record_binfo): Add OUTER_TYPE and OFFSET; walk the inner
	by info by get_binfo_at_offset.
	(possible_polymorphic_call_targets_1): Add OUTER_TYPE/OFFSET parameters;
	pass them to record-binfo.
	(polymorphic_call_target_d): Add context and FINAL.
	(polymorphic_call_target_hasher::hash): Hash context.
	(polymorphic_call_target_hasher::equal): Compare context.
	(free_polymorphic_call_targets_hash):
	(get_class_context): New function.
	(contains_type_p): New function.
	(get_polymorphic_call_info): New function.
	(walk_bases): New function.
	(possible_polymorphic_call_targets): Add context parameter; honnor it.
	(dump_possible_polymorphic_call_targets): Dump context.
	(possible_polymorphic_call_target_p): Add context.
	(update_type_inheritance_graph): Update comment.s
	(ipa_set_jf_known_type): Assert that compoentn type is known.
	(ipa_note_param_call): Do not tamper with offsets.
	(ipa_analyze_indirect_call_uses): When offset is being changed; clear
	outer type.
	(update_indirect_edges_after_inlining): Likewise.
	(ipa_write_indirect_edge_info): Stream new fields.
	(ipa_read_indirect_edge_info): Stream in new fields.

	* ipa/devirt9.C: Verify that the optimization happens already before.
	whole-program.

From-SVN: r205019
2013-11-19 10:05:54 +00:00
Richard Sandiford 386b1f1f41 cuintp.c (UI_From_gnu): Use tree_to_shwi rather than tree_low_cst.
gcc/ada/
	* gcc-interface/cuintp.c (UI_From_gnu): Use tree_to_shwi rather than
	tree_low_cst.

gcc/c-family/
	* c-common.c (fold_offsetof_1): Use tree_to_uhwi rather than
	tree_low_cst.
	(complete_array_type): Update comment to refer to tree_to_[su]hwi
	rather than tree_low_cst.

gcc/c/
	* c-decl.c (grokdeclarator): Update comment to refer to
	tree_to_[su]hwi rather than tree_low_cst.

gcc/cp/
	* decl.c (reshape_init_array_1): Use tree_to_uhwi rather than
	tree_low_cst.
	(grokdeclarator): Update comment to refer to tree_to_[su]hwi rather
	than tree_low_cst.

gcc/
	* expr.h: Update comments to refer to tree_to_[su]hwi rather
	than tree_low_cst.
	* fold-const.c (fold_binary_loc): Likewise.
	* expr.c (store_constructor): Use tree_to_uhwi rather than
	tree_low_cst.
	* ipa-utils.h (possible_polymorphic_call_target_p): Likewise.
	* stmt.c (emit_case_dispatch_table): Likewise.
	* tree-switch-conversion.c (emit_case_bit_tests): Likewise.

From-SVN: r204962
2013-11-18 14:52:29 +00:00
Andrew MacLeod 8e9055ae62 tree-outof-ssa.h: Remove include files.
* tree-outof-ssa.h: Remove include files.
	* tree-outof-ssa.c: Add required include files from tree-outof-ssa.h.
	* expr.c: Likewise.
	* tree-ssa-coalesce.c: Likewise.
	* cfgexpand.c: Likewise.
	* tree-ssa-ter.c: Likewise.
	* ipa-prop.h: Remove gimple.h and tree-core.h from include list.
	* lto-streamer.h: Likewise.
	* cgraphbuild.c: Add gimple.h to include list.
	* data-streamer-in.c: Likewise.
	* ipa-cp.c: Likewise.
	* tree-streamer.c: Likewise.
	* lto-compress.c: Likewise.
	* ipa-reference.c: Likewise.
	* data-streamer-out.c: Likewise.
	* lto-cgraph.c: Likewise.
	* cgraphclones.c: Likewise.
	* ipa-utils.c: Likewise.
	* data-streamer.c: Likewise.
	* ipa-split.c: Likewise.
	* lto-section-in.c: Likewise.
	* tree-streamer-out.c: Likewise.
	* ipa-prop.c: Likewise.
	* tree-streamer-in.c: Likewise.
	* symtab.c: Likewise.
	* opts-global.c: Likewise.
	* lto-opts.c: Likewise.
	* lto-section-out.c: Likewise.
	* lto-streamer.c: Likewise.
	* rtl.h: Add tree-core.h to include list.
	* expr.h: Remove tree-core.h from include list.
	* gimple.h: Likewise.
	* ipa-utils.h: Likewise.
	* streamer-hooks.h: Likewise.
	* streamer-hooks.c: Include input.h.

	* lto/lto-object.c: Add gimple.h to include list.
	* lto/lto-partition.c: Likewise.

From-SVN: r204158
2013-10-29 12:55:50 +00:00
Diego Novillo 4d64880731 Re-factor inclusion of tree.h.
This moves tree.h out of every header. This exposes dependencies of
tree.h in files that should probably not need it after tree and gimple
are separated.

After this change, no header should include tree.h directly. It should
only be included by a .c file. Unfortunately, I did not find an
automatic way of forcing this.

Tested on x86_64 with all languages enabled and using
contrib/config-list.mk.

2013-10-21  Diego Novillo  <dnovillo@google.com>

	* asan.c: Include tree.h
	* bb-reorder.c: Likewise.
	* cfgcleanup.c: Likewise.
	* cfgloopmanip.c: Likewise.
	* data-streamer-in.c: Likewise.
	* data-streamer-out.c: Likewise.
	* data-streamer.c: Likewise.
	* dwarf2cfi.c: Likewise.
	* graphite-blocking.c: Likewise.
	* graphite-clast-to-gimple.c: Likewise.
	* graphite-dependences.c: Likewise.
	* graphite-interchange.c: Likewise.
	* graphite-optimize-isl.c: Likewise.
	* graphite-poly.c: Likewise.
	* graphite-scop-detection.c: Likewise.
	* graphite-sese-to-poly.c: Likewise.
	* graphite.c: Likewise.
	* ipa-devirt.c: Likewise.
	* ipa-profile.c: Likewise.
	* ipa.c: Likewise.
	* ira.c: Likewise.
	* loop-init.c: Likewise.
	* loop-unroll.c: Likewise.
	* lower-subreg.c: Likewise.
	* lto/lto-object.c: Likewise.
	* recog.c: Likewise.
	* reginfo.c: Likewise.
	* tree-loop-distribution.c: Likewise.
	* tree-parloops.c: Likewise.
	* tree-ssa-strlen.c: Likewise.
	* tree-streamer.c: Likewise.
	* value-prof.c: Likewise.
	* target-globals.c: Likewise.
	* expr.h: Include tree-core.h instead of tree.h.
	* gimple.h: Likewise.
	* ipa-prop.h: Likewise.
	* ipa-utils.h: Likewise.
	* lto-streamer.h: Likewise.
	* streamer-hooks.h: Likewise.
	* ipa-reference.h: Include cgraph.h instead of tree.h.
	* cgraph.h: Include basic-block.h instead of tree.h.
	* tree-streamer.h: Do not include tree.h.
	* genattrtab.c (write_header): Generate inclusion of
	tree.h.
	* genautomata.c (main): Likewise.
	* genemit.c: Likewise.
	* genopinit.c: Likewise.
	* genoutput.c (output_prologue): Likewise.
	* genpeep.c: Likewise.

testsuite/ChangeLog

	* g++.dg/plugin/selfassign.c: Include tree.h.
	* gcc.dg/plugin/finish_unit_plugin.c: Likewise.
	* gcc.dg/plugin/ggcplug.c: Likewise.
	* gcc.dg/plugin/one_time_plugin.c: Likewise.
	* gcc.dg/plugin/selfassign.c: Likewise.
	* gcc.dg/plugin/start_unit_plugin.c: Likewise.

From-SVN: r203908
2013-10-21 15:36:37 -04:00
Martin Jambor 4cb1359729 ipa-utils.h (ipa_edge_within_scc): Declare.
2013-10-15  Martin Jambor  <mjambor@suse.cz>

	* ipa-utils.h (ipa_edge_within_scc): Declare.
	* ipa-cp.c (edge_within_scc): Moved...
	* ipa-utils.c (ipa_edge_within_scc): ...here.  Updated all callers.

From-SVN: r203607
2013-10-15 16:15:07 +02:00
Jan Hubicka 450ad0cd44 ipa-cp.c (ipa_get_indirect_edge_target_1): Add sanity check for ipa-devirt.
* ipa-cp.c (ipa_get_indirect_edge_target_1): Add sanity check
	for ipa-devirt.
	* ipa-utils.h (possible_polymorphic_call_target_p): New function.
	* ipa-devirt.c (possible_polymorphic_call_target_p): Be tolerant
	of external calls
	* gimple-fold.c: Include ipa-utils.h and gimple-pretty-print.h
	(gimple_fold_call): Dump inconsistent devirtualizations; add
	sanity check for type based devirtualizations.
	* ipa-prop.c: Include ipa-utils.h
	(ipa_intraprocedural_devirtualization): Add sanity check.
	(try_make_edge_direct_virtual_call): Likewise.

From-SVN: r202837
2013-09-23 16:54:34 +00:00
Jan Hubicka fc11f321bb re PR middle-end/58094 (IPA devirt testsuite errors)
PR middle-end/58094
	* cgraph.h (symtab_semantically_equivalent_p): Declare.
	* tree-tailcall.c: Include ipa-utils.h.
	(find_tail_calls): Use it.
	* ipa-pure-const.c (check_call): Likewise.
	* ipa-utils.c (recursive_call_p): New function.
	* ipa-utils.h (recursive_call_p): Dclare.
	* symtab.c (symtab_nonoverwritable_alias): Fix formatting.
	(symtab_semantically_equivalent_p): New function.
	* Makefile.in (tree-tailcall.o): Update dependencies.

From-SVN: r202316
2013-09-06 10:13:37 +00:00
Jan Hubicka 08f835dc74 Makefile.in: Add ipa-profile.o
* Makefile.in: Add ipa-profile.o
	(ipa.o, ipa-devrit.o, ipa-inline-analysis.o): Adjust dependencies.
	* cgraph.c (struct cgraph_propagate_frequency_data,
	cgraph_propagate_frequency_1, cgraph_propagate_frequency): Move to
	ipa-profile.c; replace cgraph_ by ipa_ prefix.
	* cgraph.h (cgraph_propagate_frequency): Remove.
	* ipa-inline-analysis.c: Include ipa-utils.h; drop duplicated cfgloop.h.
	(inline_update_callee_summaries): Update.
	* ipa-profile.c: New file.
	* ipa-utils.h (ipa_propagate_frequency): Declare.
	* ipa.c: Do not include pointer-set.h, hash-table.h, lto-streamer.h,
	data-streamer.h, value-prof.h
	(symtab_remove_unreachable_nodes): Update profile.
	(struct histogram_entry, histogram, histogram_pool, histogram_hash,
	account_time_size, cmp_counts, dump_histogram,
	ipa_profile_generate_summary, ipa_profile_write_summary,
	ipa_profile_read_summary, ipa_profile, gate_ipa_profile,
	pass_data_ipa_profile, pass_ipa_profile, make_pass_ipa_profile):
	Move to ipa-profile.c

From-SVN: r202154
2013-09-01 17:47:21 +00:00
Jan Hubicka 5e5812126c cgraph.c (cgraph_get_body): Update call of lto_input_function_body.
* cgraph.c (cgraph_get_body): Update call of lto_input_function_body.
	* gimple-streamer-in.c (input_gimple_stmt): Move sanity check to ...
	* tree-cfg.c (verify_gimple_label): ... here.
	* ipa-utils.c: Include lto-streamer.h, ipa-inline.h
	(ipa_merge_profiles): New function.
	* lto-streamer-in.c (lto_read_body): Take node instead of fn_decl.
	(lto_input_function_body): Likewise.
	* ipa-utils.h (ipa_merge_profiles): Declare.
	* lto-streamer.h (lto_input_function_body): Update prototype.
	(emit_label_in_global_context_p): Remove.
	* lto-symtab.c: Include ipa-utils.h
	(lto_cgraph_replace_node): Use ipa_merge_profiles.

From-SVN: r202131
2013-08-31 13:47:20 +00:00
Jan Hubicka 64cbf23d1f ipa-utils.h (method_class_type): Declare.
* ipa-utils.h (method_class_type): Declare.
	* ipa-devirt.c (method_class_type): Export.

	* cgraphunit.c (analyze_functions): Do basic devirtualization;
	do not walk base classes of anonymous types.

From-SVN: r201944
2013-08-23 15:55:22 +00:00
Jan Hubicka 0e1474e5a6 * cgraphunit.c (analyze_functions) Use update_type_inheritance_graph.
* ipa-utils.h (update_type_inheritance_graph): Declare.
	(possible_polymorphic_call_target_p): Declare.
	(possible_polymorphic_call_target_p): New.
	* ipa-devirt.c: Update toplevel comments.
	(cached_polymorphic_call_targets): Move up.
	(odr_type_d): Move ID down.
	(polymorphic_type_binfo_p): Update comment.
	(odr_hasher::remove): Likewise;
	(get_odr_type): Set anonymous_namespace.
	(dump_odr_type): Dump it.
	(dump_type_inheritance_graph): Do not ICE when there are no ODR types.
	(maybe_record_node): Record node in cached_polymorphic_call_targets.
	(record_binfo): Add comment.
	(free_polymorphic_call_targets_hash): Do not ICE when cache is not built.
	(devirt_node_removal_hook): Do not iCE when cache is freed.
	(possible_polymorphic_call_target_p): New predicate.
	(update_type_inheritance_graph): New function.

From-SVN: r201917
2013-08-22 09:32:07 +00:00
Jan Hubicka eefe9a995c Makeifle-in (ipa-devirt.o): New.
* Makeifle-in (ipa-devirt.o): New.
	(GTFILES): Add ipa-utils.h and ipa-devirt.c
	* cgraphunit.c (decide_is_symbol_needed): Do not care about virtuals.
	(analyze_functions): Look into possible targets of polymorphic call.
	* dumpfile.c (dump_files): Add type-inheritance dump.
	* dumpfile.h (TDI_inheritance): New.
	* ipa-devirt.c: New file.
	* ipa-utils.h (odr_type_d): Forward declare.
	(odr_type): New type.
	(build_type_inheritance_graph): Declare.
	(possible_polymorphic_call_targets): Declare and introduce inline
	variant when only edge is pased.
	(dump_possible_polymorphic_call_targets): Likewise.
	* timevar.def (TV_IPA_INHERITANCE, TV_IPA_VIRTUAL_CALL): New.
	* tree.c (type_in_anonymous_namespace_p): Break out from ...
	(types_same_for_odr): ... here.
	* tree.h (type_in_anonymous_namespace_p): Declare.

	* g++.dg/ipa/type-inheritance-1.C: New testcase.

From-SVN: r201836
2013-08-19 10:14:06 +00:00