+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
+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
--- /dev/null
+/* { 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" } } */
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))
{
&& 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))))