[GOOGLE] Fix LIPO resolved node reference fixup
Teresa Johnson
tejohnson@google.com
Fri Oct 24 17:48:00 GMT 2014
This patch makes a fix to the reference fixups performed after LIPO
node resolution, to better handle the case where we are updating the
base address of a reference.
Fixes google benchmark and passes regression tests. Ok for google/4_9?
Thanks,
Teresa
2014-10-24 Teresa Johnson <tejohnson@google.com>
Google ref b/18110567.
* cgraphbuild.c (get_base_address_expr): New function.
(fixup_ref): Update the op expression for new base address.
Index: cgraphbuild.c
===================================================================
--- cgraphbuild.c (revision 216667)
+++ cgraphbuild.c (working copy)
@@ -665,13 +665,35 @@ record_references_in_initializer (tree decl, bool
pointer_set_destroy (visited_nodes);
}
+/* Similar to get_base_address but returns the ADDR_EXPR pointing
+ to the base address corresponding to T. */
+
+static tree
+get_base_address_expr (tree t)
+{
+ while (handled_component_p (t))
+ t = TREE_OPERAND (t, 0);
+
+ if ((TREE_CODE (t) == MEM_REF
+ || TREE_CODE (t) == TARGET_MEM_REF)
+ && TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR)
+ return TREE_OPERAND (t, 0);
+
+ return NULL_TREE;
+}
+
/* Update any function decl references in base ADDR of operand OP to refer to
the resolved node. */
static bool
fixup_ref (gimple, tree addr, tree op)
{
+ tree orig_addr = addr;
addr = get_base_address (addr);
+ /* If the address was changed, update the operand OP to be the
+ ADDR_EXPR pointing to the new base address. */
+ if (orig_addr != addr)
+ op = get_base_address_expr (orig_addr);
if (addr && TREE_CODE (addr) == FUNCTION_DECL)
{
gcc_assert (TREE_CODE (op) == ADDR_EXPR);
--
Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413
More information about the Gcc-patches
mailing list