+/* Mark address taken in STMT. */
+
+static bool
+mark_address (gimple stmt ATTRIBUTE_UNUSED, tree addr,
+ void *data ATTRIBUTE_UNUSED)
+{
+ if (TREE_CODE (addr) == FUNCTION_DECL)
+ {
+ struct cgraph_node *node = cgraph_node (addr);
+ cgraph_mark_address_taken_node (node);
+ ipa_record_reference ((struct cgraph_node *)data, NULL,
+ node, NULL,
+ IPA_REF_ADDR, stmt);
+ }
+ else
+ {
+ addr = get_base_address (addr);
+ if (addr && TREE_CODE (addr) == VAR_DECL
+ && (TREE_STATIC (addr) || DECL_EXTERNAL (addr)))
+ {
+ struct varpool_node *vnode = varpool_node (addr);
+ int walk_subtrees;
+
+ if (lang_hooks.callgraph.analyze_expr)
+ lang_hooks.callgraph.analyze_expr (&addr, &walk_subtrees);
+ varpool_mark_needed_node (vnode);
+ if (vnode->alias && vnode->extra_name)
+ vnode = vnode->extra_name;
+ ipa_record_reference ((struct cgraph_node *)data, NULL,
+ NULL, vnode,
+ IPA_REF_ADDR, stmt);
+ }
+ }
+
+ return false;
+}
+
+/* Mark load of T. */
+
+static bool
+mark_load (gimple stmt ATTRIBUTE_UNUSED, tree t,
+ void *data ATTRIBUTE_UNUSED)
+{
+ t = get_base_address (t);
+ if (TREE_CODE (t) == VAR_DECL
+ && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
+ {
+ struct varpool_node *vnode = varpool_node (t);
+ int walk_subtrees;
+
+ if (lang_hooks.callgraph.analyze_expr)
+ lang_hooks.callgraph.analyze_expr (&t, &walk_subtrees);
+ varpool_mark_needed_node (vnode);
+ if (vnode->alias && vnode->extra_name)
+ vnode = vnode->extra_name;
+ ipa_record_reference ((struct cgraph_node *)data, NULL,
+ NULL, vnode,
+ IPA_REF_LOAD, stmt);
+ }
+ return false;
+}
+
+/* Mark store of T. */
+
+static bool
+mark_store (gimple stmt ATTRIBUTE_UNUSED, tree t,
+ void *data ATTRIBUTE_UNUSED)
+{
+ t = get_base_address (t);
+ if (TREE_CODE (t) == VAR_DECL
+ && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
+ {
+ struct varpool_node *vnode = varpool_node (t);
+ int walk_subtrees;
+
+ if (lang_hooks.callgraph.analyze_expr)
+ lang_hooks.callgraph.analyze_expr (&t, &walk_subtrees);
+ varpool_mark_needed_node (vnode);
+ if (vnode->alias && vnode->extra_name)
+ vnode = vnode->extra_name;
+ ipa_record_reference ((struct cgraph_node *)data, NULL,
+ NULL, vnode,
+ IPA_REF_STORE, NULL);
+ }
+ return false;
+}
+