From patchwork Fri Oct 24 17:21:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teresa Johnson X-Patchwork-Id: 402926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1958E140077 for ; Sat, 25 Oct 2014 04:21:20 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=sLd/z6lIWPyBww3K4a3mFPs56BlE1pkwnFPvYaFtsRe 8K6koq7pHmEisG7SuKqBeGQ6Zkvw0CMb8WigGNeFVpzQ6l6++e+11i2X30PaBHX4 Bsr1o+759aJ4Fgfz9onIn1Q3Do5RPCobtxVnwSSGfH1oaTnyrj4/xxyoeD1LJVHA = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=nOqXGIHiFhGeYMX4v7Li/BJR9mA=; b=ImrRsD1t/naxafXgY 8P2YN2jO/oapoqlh72CnCJUxBi6AQBgZ8CsW8oZSORPIH5KyWgNo3M0FT3UQ47nJ Ip36rmGafAXjR8Xi5jB05ANFXhgsr8PQJlt5UA9Uxfc+8qkVxVOuokm+ounXnVxp b5tV5ndcyNdGK24mR49Nxvqe0U= Received: (qmail 17204 invoked by alias); 24 Oct 2014 17:21:13 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 17187 invoked by uid 89); 24 Oct 2014 17:21:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qg0-f49.google.com Received: from mail-qg0-f49.google.com (HELO mail-qg0-f49.google.com) (209.85.192.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 24 Oct 2014 17:21:11 +0000 Received: by mail-qg0-f49.google.com with SMTP id e89so1316358qgf.22 for ; Fri, 24 Oct 2014 10:21:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=uCyo+r35ccvBjRMF5MEmdFZx51iJxhIcJQhMrs+ceGI=; b=SPVmsEwm9YYVMQImT6FiPbG1uO/dE2QExqDb2Ea5hB42HUDZNATtDXn0En3/hceZUu aYqzcLQqX/83wDPHOwSM5LN9PhflFU+gnYfa5mnDaavDkMje4gd9c44ygwF+PY6PVQvJ VAUGz/tnBRwy1myyPa9rXGi/xGaH+JUJYrnfFNZmVRUtLwQfsyOCvJMy1nZ8F57tLUIz rCBqcnqd/tWoT3Bl7pNQymgasvyolAXlcE4Zy+OdsuwIc49uzmuAINl9PWYuBWHs8dba ApwnL9jBeYdJ679Cu0SgUCrjWlKhfqVWyJsI84K9LXQNbVvXeLNeG7ViYrAHoEkMFY1R 5Cgw== X-Gm-Message-State: ALoCoQmbMNKE/zMgpFcvI3lRTnV5Ioq66TRRmlYI71N4AGhX2rC++u3l6zJGszuI6t57A8vXGA2n MIME-Version: 1.0 X-Received: by 10.224.60.135 with SMTP id p7mr7916456qah.97.1414171268960; Fri, 24 Oct 2014 10:21:08 -0700 (PDT) Received: by 10.229.190.1 with HTTP; Fri, 24 Oct 2014 10:21:08 -0700 (PDT) Date: Fri, 24 Oct 2014 10:21:08 -0700 Message-ID: Subject: [GOOGLE] Fix LIPO resolved node reference fixup From: Teresa Johnson To: David Li Cc: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes 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 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);