Commit d27ecc49 by Jan Hubicka Committed by Jan Hubicka

re PR ipa/66223 (Diagnostic of pure virtual function call broken, including __cxa_pure_virtual)

	PR ipa/66223
	* ipa-devirt.c (maybe_record_node): Do not optimize cxa_pure_virtual
	calls when sanitizing.
	(possible_polymorphic_call_target_p)" FIx formating.
	* g++.dg/ipa/devirt-51.C: New testcase.

From-SVN: r234719
parent c974c96e
2016-04-04 Jan Hubicka <hubicka@ucw.cz>
PR ipa/66223
* ipa-devirt.c (maybe_record_node): Do not optimize cxa_pure_virtual
calls when sanitizing.
(possible_polymorphic_call_target_p)" FIx formating.
2016-04-04 Bill Schmidt <wschmidt@linux.vnet.ibm.com> 2016-04-04 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Jakub Jelinek <jakub@redhat.com> Jakub Jelinek <jakub@redhat.com>
......
...@@ -2438,10 +2438,14 @@ maybe_record_node (vec <cgraph_node *> &nodes, ...@@ -2438,10 +2438,14 @@ maybe_record_node (vec <cgraph_node *> &nodes,
{ {
gcc_assert (!target_node->global.inlined_to); gcc_assert (!target_node->global.inlined_to);
gcc_assert (target_node->real_symbol_p ()); gcc_assert (target_node->real_symbol_p ());
/* When sanitizing, do not asume that cxa_pure_virutal is not called
by valid program. */
if (flag_sanitize & SANITIZE_UNDEFINED)
;
/* Only add pure virtual if it is the only possible target. This way /* Only add pure virtual if it is the only possible target. This way
we will preserve the diagnostics about pure virtual called in many we will preserve the diagnostics about pure virtual called in many
cases without disabling optimization in other. */ cases without disabling optimization in other. */
if (pure_virtual) else if (pure_virtual)
{ {
if (nodes.length ()) if (nodes.length ())
return; return;
...@@ -3374,8 +3378,7 @@ possible_polymorphic_call_target_p (tree otr_type, ...@@ -3374,8 +3378,7 @@ possible_polymorphic_call_target_p (tree otr_type,
bool final; bool final;
if (TREE_CODE (TREE_TYPE (n->decl)) == FUNCTION_TYPE if (TREE_CODE (TREE_TYPE (n->decl)) == FUNCTION_TYPE
&& ((fcode = DECL_FUNCTION_CODE (n->decl)) && ((fcode = DECL_FUNCTION_CODE (n->decl)) == BUILT_IN_UNREACHABLE
== BUILT_IN_UNREACHABLE
|| fcode == BUILT_IN_TRAP)) || fcode == BUILT_IN_TRAP))
return true; return true;
......
2016-04-04 Jan Hubicka <hubicka@ucw.cz>
PR ipa/66223
* g++.dg/ipa/devirt-51.C: New testcase.
2016-04-04 Bill Schmidt <wschmidt@linux.vnet.ibm.com> 2016-04-04 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Jakub Jelinek <jakub@redhat.com> Jakub Jelinek <jakub@redhat.com>
......
/* Be sure we do not optimize the virtual call into call of the only non-virtual
variant. Either keeping virtual call or optimizing to cxa_pure_virtual
is fine. */
/* { dg-do compile } */
/* { dg-options "-O2 -fsanitize=undefined -fdump-tree-optimized" } */
namespace {
struct B {
B* self;
B() : self( this ) { self->f(); }
void E(void);
virtual void f() = 0;
};
struct D : B
{
void f() {}
};
}
struct D e;
__attribute__ ((used))
void B::E(void)
{
this->f();
}
int main()
{
D d;
}
/* { dg-final { scan-tree-dump "cxa_pure_virtual" "optimized" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment