Commit 10706779 by Jan Hubicka Committed by Jan Hubicka

nonzero-3.C: New testcase.


	* g++.dg/tree-ssa/nonzero-3.C: New testcase.
	* tree-vrp.c (nonnull_arg_p): THIS pointers and references are non-zero.
	(gimple_stmt_nonzero_warnv_p): Reference return values are non-zero.

From-SVN: r222054
parent 95d81ba5
2015-04-12 Jan Hubicka <hubicka@ucw.cz>
* tree-vrp.c (nonnull_arg_p): THIS pointers and references are non-zero.
(gimple_stmt_nonzero_warnv_p): Reference return values are non-zero.
2015-04-12 Jan Hubicka <hubicka@ucw.cz>
* ipa-profie.c (ipa_profile): Check number of parameters
and possible polymorphic call targets before
devirtualizing.
......
2015-04-12 Jan Hubicka <hubicka@ucw.cz>
* g++.dg/tree-ssa/nonzero-3.C: New testcase.
2015-04-13 Richard Biener <rguenther@suse.de>
PR tree-optimization/65204
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp1 -fdelete-null-pointer-checks" } */
struct A {int a;};
struct B {int b;};
struct C:A,B {int c;
void bar();};
void foo (struct B *);
void C::bar ()
{
struct C *d = this;
foo(this);
foo(d);
}
void bar (struct C &c)
{
struct C *d = &c;
foo(&c);
foo(d);
}
/* { dg-final { scan-tree-dump-not "if \\(" "vrp1"} } */
/* { dg-final { cleanup-tree-dump "vrp1" } } */
......@@ -393,6 +393,17 @@ nonnull_arg_p (const_tree arg)
if (arg == cfun->static_chain_decl)
return true;
/* THIS argument of method is always non-NULL. */
if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE
&& arg == DECL_ARGUMENTS (current_function_decl)
&& flag_delete_null_pointer_checks)
return true;
/* Values passed by reference are always non-NULL. */
if (TREE_CODE (TREE_TYPE (arg)) == REFERENCE_TYPE
&& flag_delete_null_pointer_checks)
return true;
fntype = TREE_TYPE (current_function_decl);
for (attrs = TYPE_ATTRIBUTES (fntype); attrs; attrs = TREE_CHAIN (attrs))
{
......@@ -1216,6 +1227,10 @@ gimple_stmt_nonzero_warnv_p (gimple stmt, bool *strict_overflow_p)
&& DECL_IS_OPERATOR_NEW (fndecl)
&& !TREE_NOTHROW (fndecl))
return true;
/* References are always non-NULL. */
if (flag_delete_null_pointer_checks
&& TREE_CODE (TREE_TYPE (fndecl)) == REFERENCE_TYPE)
return true;
if (flag_delete_null_pointer_checks &&
lookup_attribute ("returns_nonnull",
TYPE_ATTRIBUTES (gimple_call_fntype (stmt))))
......
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