summaryrefslogtreecommitdiff
path: root/gcc/gimple.c
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2013-12-05 03:18:18 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2013-12-05 03:18:18 +0000
commit30b1026191d4801513bbe669a1b549e0e3d0df3d (patch)
tree065fb58430d1417a0032a8917f79040a59ad7213 /gcc/gimple.c
parent4ab071d26abb1ae0f1327b78fdb306c956a4fbd7 (diff)
downloadgcc-30b1026191d4801513bbe669a1b549e0e3d0df3d.tar.gz
* common.opt: Split up -fisolate-erroneous-paths into
-fisolate-erroneous-paths-dereference and -fisolate-erroneous-paths-attribute. * invoke.texi: Corresponding changes. * gimple.c (infer_nonnull_range): Add and use new arguments to control what kind of statements can be used to infer a non-null range. * gimple.h (infer_nonnull_range): Update prototype. * tree-vrp.c (infer_value_range): Corresponding changes. * opts.c (default_options_table): Update due to option split. * gimple-ssa-isolate-paths.c: Fix trailing whitespace. (find_implicit_erroneous_behaviour): Pass additional arguments to infer_nonnull_range. (find_explicit_erroneous_behaviour): Similarly. (gate_isolate_erroneous_paths): Check both of the new options. testsuite/ * gcc.dg/pr38984.c: Use -fno-isolate-erroneous-paths-dereference. * gcc.dg/tree-ssa/isolate-2.c: Explicitly turn on -fisolate-erroneous-paths-attribute. * gcc.dg/tree-ssa/isolate-4.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205689 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple.c')
-rw-r--r--gcc/gimple.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 7bc87bc34ee..f11362a6b16 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2502,10 +2502,16 @@ check_loadstore (gimple stmt ATTRIBUTE_UNUSED, tree op, void *data)
return false;
}
-/* If OP can be inferred to be non-zero after STMT executes, return true. */
+/* If OP can be inferred to be non-NULL after STMT executes, return true.
+
+ DEREFERENCE is TRUE if we can use a pointer dereference to infer a
+ non-NULL range, FALSE otherwise.
+
+ ATTRIBUTE is TRUE if we can use attributes to infer a non-NULL range
+ for function arguments and return values. FALSE otherwise. */
bool
-infer_nonnull_range (gimple stmt, tree op)
+infer_nonnull_range (gimple stmt, tree op, bool dereference, bool attribute)
{
/* We can only assume that a pointer dereference will yield
non-NULL if -fdelete-null-pointer-checks is enabled. */
@@ -2514,11 +2520,13 @@ infer_nonnull_range (gimple stmt, tree op)
|| gimple_code (stmt) == GIMPLE_ASM)
return false;
- if (walk_stmt_load_store_ops (stmt, (void *)op,
- check_loadstore, check_loadstore))
+ if (dereference
+ && walk_stmt_load_store_ops (stmt, (void *)op,
+ check_loadstore, check_loadstore))
return true;
- if (is_gimple_call (stmt) && !gimple_call_internal_p (stmt))
+ if (attribute
+ && is_gimple_call (stmt) && !gimple_call_internal_p (stmt))
{
tree fntype = gimple_call_fntype (stmt);
tree attrs = TYPE_ATTRIBUTES (fntype);
@@ -2557,7 +2565,8 @@ infer_nonnull_range (gimple stmt, tree op)
/* If this function is marked as returning non-null, then we can
infer OP is non-null if it is used in the return statement. */
- if (gimple_code (stmt) == GIMPLE_RETURN
+ if (attribute
+ && gimple_code (stmt) == GIMPLE_RETURN
&& gimple_return_retval (stmt)
&& operand_equal_p (gimple_return_retval (stmt), op, 0)
&& lookup_attribute ("returns_nonnull",