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
This commit is contained in:
Jan Hubicka 2015-03-09 01:29:14 +01:00 committed by Jan Hubicka
parent e1e8e374f4
commit 609570b49e
7 changed files with 639 additions and 283 deletions

View File

@ -1,3 +1,36 @@
2015-03-08 Jan Hubicka <hubicka@ucw.cz>
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.
2015-03-05 Jan Hubicka <hubicka@ucw.cz>
PR ipa/65334

File diff suppressed because it is too large Load Diff

View File

@ -80,7 +80,7 @@ bool type_known_to_have_no_deriavations_p (tree);
bool contains_polymorphic_type_p (const_tree);
void register_odr_type (tree);
bool types_must_be_same_for_odr (tree, tree);
bool types_odr_comparable (tree, tree);
bool types_odr_comparable (tree, tree, bool strict = false);
cgraph_node *try_speculative_devirtualization (tree, HOST_WIDE_INT,
ipa_polymorphic_call_context);

View File

@ -1,3 +1,9 @@
2015-03-08 Jan Hubicka <hubicka@ucw.cz>
PR lto/65316
* g++.dg/lto/pr65316_0.C: New testcase.
* g++.dg/lto/pr65316_1.C: New testcase.
2015-03-08 John David Anglin <danglin@gcc.gnu.org>
PR target/62247

View File

@ -0,0 +1,142 @@
// { dg-lto-do link }
// { dg-lto-options { { -flto -std=c++11 -g2 -fno-lto-odr-type-merging -O2 } } }
// { dg-extra-ld-options "-r -nostdlib -O2 -fno-lto-odr-type-merging" }
namespace std
{
typedef long unsigned int size_t;
}
extern "C"
{
typedef struct
{
} __mbstate_t;
}
namespace std __attribute__ ((__visibility__ ("default")))
{
template < class _CharT > struct char_traits;
}
typedef __mbstate_t mbstate_t;
namespace std __attribute__ ((__visibility__ ("default")))
{
template < typename _CharT, typename _Traits =
char_traits < _CharT > >class basic_ostream;
typedef basic_ostream < char >ostream;
}
using namespace std;
class Cstring
{
public:
Cstring (const char *str, int l = 0);
};
extern ostream & operator << (ostream & os, const Cstring & string);
class Foo_Log_Handler
{
virtual int write_message (const char *msg, size_t msg_len, int channel,
int level) = 0;
};
class Foo_Log_Handler_Stream:public Foo_Log_Handler
{
virtual int write_message (const char *msg, size_t msg_len, int channel,
int level) override;
Cstring m_filename;
};
namespace std __attribute__ ((__visibility__ ("default")))
{
template <> struct char_traits <char >
{
typedef mbstate_t state_type;
};
enum _Ios_Fmtflags
{
};
enum _Ios_Iostate
{
};
class ios_base
{
public:
typedef _Ios_Iostate iostate;
};
}
namespace std __attribute__ ((__visibility__ ("default")))
{
template < typename _CharT > class __ctype_abstract_base
{
};
template < typename _CharT > class ctype
{
public:
typedef char char_type;
mutable char _M_widen_ok;
char_type widen (char __c) const
{
if (_M_widen_ok)
return this->do_widen (__c);
}
virtual char_type do_widen (char __c) const
{
}
};
template < typename _Facet >
inline const _Facet & __check_facet (const _Facet * __f)
{
}
template < typename _CharT, typename _Traits > class basic_ios:public
ios_base
{
typedef _CharT char_type;
typedef ctype < _CharT > __ctype_type;
const __ctype_type *_M_ctype;
public:
iostate rdstate ()const
{
}
bool good () const
{
}
char_type widen (char __c) const
{
return __check_facet (_M_ctype).widen (__c);
}
};
template < typename _CharT, typename _Traits > class basic_ostream:virtual public basic_ios < _CharT,
_Traits
>
{
public:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef basic_ostream < _CharT, _Traits > __ostream_type;
__ostream_type & operator<< (__ostream_type & (*__pf) (__ostream_type &))
{
return __pf (*this);
}
__ostream_type & put (char_type __c);
};
template < typename _CharT,
typename _Traits > inline basic_ostream < _CharT,
_Traits > &endl (basic_ostream < _CharT, _Traits > &__os)
{
return flush (__os.put (__os.widen ('\n')));
}
template < typename _CharT,
typename _Traits > inline basic_ostream < _CharT,
_Traits > &flush (basic_ostream < _CharT, _Traits > &__os)
{
}
extern ostream cerr;
}
int
Foo_Log_Handler_Stream::write_message (const char *msg, size_t msg_len, int,
int level)
{
{
{
cerr << "FATAL: cannot write into log file: " << m_filename << endl;
}
}
}

View File

View File

@ -4470,7 +4470,8 @@ extern tree block_ultimate_origin (const_tree);
extern tree get_binfo_at_offset (tree, HOST_WIDE_INT, tree);
extern bool virtual_method_call_p (tree);
extern tree obj_type_ref_class (tree ref);
extern bool types_same_for_odr (const_tree type1, const_tree type2);
extern bool types_same_for_odr (const_tree type1, const_tree type2,
bool strict=false);
extern bool contains_bitfld_component_ref_p (const_tree);
extern bool type_in_anonymous_namespace_p (const_tree);
extern bool block_may_fallthru (const_tree);