aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-ref.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ipa-ref.c')
-rw-r--r--gcc/ipa-ref.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/ipa-ref.c b/gcc/ipa-ref.c
index 7909805..a6ffdf3 100644
--- a/gcc/ipa-ref.c
+++ b/gcc/ipa-ref.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see
#include "ggc.h"
#include "target.h"
#include "cgraph.h"
+#include "ipa-utils.h"
static const char *ipa_ref_use_name[] = {"read","write","addr","alias"};
@@ -67,6 +68,30 @@ ipa_record_reference (symtab_node referring_node,
return ref;
}
+/* If VAL is a reference to a function or a variable, add a reference from
+ REFERRING_NODE to the corresponding symbol table node. USE_TYPE specify
+ type of the use and STMT the statement (if it exists). Return the new
+ reference or NULL if none was created. */
+
+struct ipa_ref *
+ipa_maybe_record_reference (symtab_node referring_node, tree val,
+ enum ipa_ref_use use_type, gimple stmt)
+{
+ STRIP_NOPS (val);
+ if (TREE_CODE (val) != ADDR_EXPR)
+ return NULL;
+ val = get_base_var (val);
+ if (val && (TREE_CODE (val) == FUNCTION_DECL
+ || TREE_CODE (val) == VAR_DECL))
+ {
+ symtab_node referred = symtab_get_node (val);
+ gcc_checking_assert (referred);
+ return ipa_record_reference (referring_node, referred,
+ use_type, stmt);
+ }
+ return NULL;
+}
+
/* Remove reference REF. */
void