diff options
author | Ian Lance Taylor <iant@golang.org> | 2022-02-11 15:02:44 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2022-02-11 15:02:44 -0800 |
commit | 9a510fb0970d3d9a4201bce8965cabe67850386b (patch) | |
tree | 43d7fd2bbfd7ad8c9625a718a5e8718889351994 /gcc/pointer-query.h | |
parent | a6d3012b274f38b20e2a57162106f625746af6c6 (diff) | |
parent | 8dc2499aa62f768c6395c9754b8cabc1ce25c494 (diff) | |
download | gcc-9a510fb0970d3d9a4201bce8965cabe67850386b.zip gcc-9a510fb0970d3d9a4201bce8965cabe67850386b.tar.gz gcc-9a510fb0970d3d9a4201bce8965cabe67850386b.tar.bz2 |
Merge from trunk revision 8dc2499aa62f768c6395c9754b8cabc1ce25c494
Diffstat (limited to 'gcc/pointer-query.h')
-rw-r--r-- | gcc/pointer-query.h | 80 |
1 files changed, 48 insertions, 32 deletions
diff --git a/gcc/pointer-query.h b/gcc/pointer-query.h index c8215b6..801a240 100644 --- a/gcc/pointer-query.h +++ b/gcc/pointer-query.h @@ -1,6 +1,6 @@ /* Definitions of the pointer_query and related classes. - Copyright (C) 2020-2021 Free Software Foundation, Inc. + Copyright (C) 2020-2022 Free Software Foundation, Inc. This file is part of GCC. @@ -61,12 +61,15 @@ class pointer_query; struct access_ref { /* Set the bounds of the reference. */ - access_ref (range_query *query = nullptr, tree = NULL_TREE, - gimple * = nullptr, bool = false); + access_ref (); /* Return the PHI node REF refers to or null if it doesn't. */ gphi *phi () const; + /* Merge the result for a pointer with *THIS. */ + void merge_ref (vec<access_ref> *all_refs, tree, gimple *, int, bool, + ssa_name_limit_t &, pointer_query &); + /* Return the object to which REF refers. */ tree get_ref (vec<access_ref> *, access_ref * = nullptr, int = 1, ssa_name_limit_t * = nullptr, pointer_query * = nullptr) const; @@ -119,7 +122,10 @@ struct access_ref /* Issue an informational message describing the target of an access with the given mode. */ - void inform_access (access_mode) const; + void inform_access (access_mode, int = 1) const; + + /* Dump *THIS to a file. */ + void dump (FILE *) const; /* Reference to the accessed object(s). */ tree ref; @@ -129,11 +135,6 @@ struct access_ref offset_int sizrng[2]; /* The minimum and maximum offset computed. */ offset_int offmax[2]; - /* Range of the bound of the access: denotes that the access - is at least BNDRNG[0] bytes but no more than BNDRNG[1]. - For string functions the size of the actual access is - further constrained by the length of the string. */ - offset_int bndrng[2]; /* Used to fold integer expressions when called from front ends. */ tree (*eval)(tree); @@ -158,19 +159,19 @@ class pointer_query { DISABLE_COPY_AND_ASSIGN (pointer_query); -public: /* Type of the two-level cache object defined by clients of the class to have pointer SSA_NAMEs cached for speedy access. */ struct cache_type { /* 1-based indices into cache. */ - vec<unsigned> indices; + auto_vec<unsigned> indices; /* The cache itself. */ - vec<access_ref> access_refs; + auto_vec<access_ref> access_refs; }; - /* Construct an object with the given Ranger instance and cache. */ - explicit pointer_query (range_query * = nullptr, cache_type * = nullptr); +public: + /* Construct an object with the given Ranger instance. */ + explicit pointer_query (range_query * = nullptr); /* Retrieve the access_ref for a variable from cache if it's there. */ const access_ref* get_ref (tree, int = 1) const; @@ -189,8 +190,6 @@ public: /* A Ranger instance. May be null to use global ranges. */ range_query *rvals; - /* Cache of SSA_NAMEs. May be null to disable caching. */ - cache_type *var_cache; /* Cache performance counters. */ mutable unsigned hits; @@ -198,6 +197,10 @@ public: mutable unsigned failures; mutable unsigned depth; mutable unsigned max_depth; + +private: + /* Cache of SSA_NAMEs. May be null to disable caching. */ + cache_type var_cache; }; /* Describes a pair of references used in an access by built-in @@ -206,23 +209,18 @@ struct access_data { /* Set the access to at most MAXWRITE and MAXREAD bytes, and at least 1 when MINWRITE or MINREAD, respectively, is set. */ - access_data (range_query *query, gimple *stmt, access_mode mode, - tree maxwrite = NULL_TREE, bool minwrite = false, - tree maxread = NULL_TREE, bool minread = false) - : stmt (stmt), call (), - dst (query, maxwrite, stmt, minwrite), - src (query, maxread, stmt, minread), - mode (mode) { } + access_data (range_query *, gimple *, access_mode, + tree = NULL_TREE, bool = false, + tree = NULL_TREE, bool = false); /* Set the access to at most MAXWRITE and MAXREAD bytes, and at least 1 when MINWRITE or MINREAD, respectively, is set. */ - access_data (range_query *query, tree expr, access_mode mode, - tree maxwrite = NULL_TREE, bool minwrite = false, - tree maxread = NULL_TREE, bool minread = false) - : stmt (), call (expr), - dst (query, maxwrite, nullptr, minwrite), - src (query, maxread, nullptr, minread), - mode (mode) { } + access_data (range_query *, tree, access_mode, + tree = NULL_TREE, bool = false, + tree = NULL_TREE, bool = false); + + /* Constructor helper. */ + static void set_bound (offset_int[2], tree, bool, range_query *, gimple *); /* Access statement. */ gimple *stmt; @@ -230,9 +228,19 @@ struct access_data tree call; /* Destination and source of the access. */ access_ref dst, src; + + /* Range of the bound of the access: denotes that the access is at + least XXX_BNDRNG[0] bytes but no more than XXX_BNDRNG[1]. For + string functions the size of the actual access is further + constrained by the length of the string. */ + offset_int dst_bndrng[2]; + offset_int src_bndrng[2]; + /* Read-only for functions like memcmp or strlen, write-only for memset, read-write for memcpy or strcat. */ access_mode mode; + /* The object size type. */ + int ostype; }; enum size_range_flags @@ -263,8 +271,13 @@ inline tree compute_objsize (tree ptr, int ostype, access_ref *pref) } /* Legacy/transitional API. Should not be used in new code. */ -extern tree compute_objsize (tree, int, tree * = nullptr, tree * = nullptr, - range_query * = nullptr); +extern tree compute_objsize (tree, gimple *, int, tree * = nullptr, + tree * = nullptr, range_query * = nullptr); +inline tree compute_objsize (tree ptr, int ostype, tree *pdecl = nullptr, + tree *poff = nullptr, range_query *rvals = nullptr) +{ + return compute_objsize (ptr, nullptr, ostype, pdecl, poff, rvals); +} /* Return the field at the constant offset. */ extern tree field_at_offset (tree, tree, HOST_WIDE_INT, @@ -275,4 +288,7 @@ extern tree array_elt_at_offset (tree, HOST_WIDE_INT, HOST_WIDE_INT * = nullptr, HOST_WIDE_INT * = nullptr); +/* Helper to build an array type that can be printed. */ +extern tree build_printable_array_type (tree, unsigned HOST_WIDE_INT); + #endif // GCC_POINTER_QUERY_H |