From patchwork Fri Oct 25 23:10:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 286240 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5DACB2C0099 for ; Sat, 26 Oct 2013 10:10:42 +1100 (EST) 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=AOkmx05/lp5cSbpdywPBnCLQZ9kyb9kFp1QPyJcfyrO tbkhfkMIui3tJ4YqFewm0PdDlzKoHxggLs3FdLQoLPaLHlpg2tRnyKKh6cvRSE9D VavbgAnogD0u33CKA4xJuwq2lAnZB34WXKS2OTjpXhgjk0EP7Jc7xTZhRXBC8/4k = 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=gj1Aqk/60k5J+gdWnrWBG0LPNXE=; b=Gi+TUpKq7KqWwXYW6 YV0qzbavd8dkhL+CzKHtqxxDQPhsKGKGa/PHWOc+fFMzTv9Sb4x4yATuG4lWqaWz +bh973sp8wvOXNuDyje7sov4IPrhcdLVbEQf5GWohtEijQEE6tE9HAa+mUIQPUYc sDGoy4iDfsEZX8rrczvdg11k68= Received: (qmail 31264 invoked by alias); 25 Oct 2013 23:10:35 -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 31251 invoked by uid 89); 25 Oct 2013 23:10:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 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-ie0-f178.google.com Received: from mail-ie0-f178.google.com (HELO mail-ie0-f178.google.com) (209.85.223.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 25 Oct 2013 23:10:33 +0000 Received: by mail-ie0-f178.google.com with SMTP id x13so7521152ief.37 for ; Fri, 25 Oct 2013 16:10:31 -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=u2vKhmO3o5i91rSvOu9ZT+UW/r3yWD6Vwo9hBAgnkJ0=; b=NytnyPySiurJh2mh0x2AIXhpz3EIzwNhRQDJzi6dm2wkookyBRkfw5ETJrLBDaupzB uYn61fyN0bUyRgxVE3NBHIxi3WuSgmHppga9M4LdoUmrMwo/zv3ZOc+4deRUSuIIwKd1 uigY95HxKYZ7DPn1b03OHiTcpMS8cIw821KvMY62YST665q4AxXeoj7IajDb9AtpTdVt iL6yUC62r9nQrBRDeW/o8w5U47FgHQnBD/9IRp5RR7ozvkOMSM8mDnxh1qVfNSalsN3o V5BqhIoVd+i4o/UPBS/do9vpRwz2Dd5h+9zr9MsA6XUIF0gtSdkTLk9j4X6H0ChdnLso GMQg== X-Gm-Message-State: ALoCoQmP78f1dLVqmUg3KZTnzm6M5tLsJx0asC2Nu9FVXpsbbt7Fcjci0IXATOSDdJpxGPD+dLIn75Oy7KqzVB/pPkJAKmc+Tz4xD7Gfov/zjBnTTLA0vzzG/kSvUCIGwAuUCs7oK9wssK2FbP3UxMyBheMt/7DxBNc/AADDWn/SVrRkGoQXmlqsacj6qMXBBT5WsVgHuGCBd23uSKy7/91nVizd/PlrqA== MIME-Version: 1.0 X-Received: by 10.42.215.80 with SMTP id hd16mr6666906icb.17.1382742631851; Fri, 25 Oct 2013 16:10:31 -0700 (PDT) Received: by 10.64.9.133 with HTTP; Fri, 25 Oct 2013 16:10:31 -0700 (PDT) Date: Fri, 25 Oct 2013 16:10:31 -0700 Message-ID: Subject: [GOOGLE] Fix a bug when profile propagation handles infinite loop. From: Dehao Chen To: GCC Patches Cc: David Li X-IsSubscribed: yes If the propagation finds an infinite look, if the in-edge count is non-zero, then it will cause compiler go into infinite loop when building with AutoFDO. Bootstrapped and regression test on-going. OK for google-4_8 branch? Thanks, Dehao Index: gcc/auto-profile.c =================================================================== --- gcc/auto-profile.c (revision 204027) +++ gcc/auto-profile.c (working copy) @@ -1287,6 +1287,7 @@ afdo_propagate (void) { basic_block bb; bool changed = true; + int i = 0; FOR_ALL_BB (bb) { @@ -1295,7 +1296,7 @@ afdo_propagate (void) bb->flags |= BB_ANNOTATED; } - while (changed) + while (changed && i++ < PARAM_VALUE (PARAM_AUTOFDO_MAX_PROPAGATE_ITERATIONS)) { changed = false; Index: gcc/params.def =================================================================== --- gcc/params.def (revision 204027) +++ gcc/params.def (working copy) @@ -460,6 +460,14 @@ DEFPARAM(PARAM_MAX_PREDICTED_ITERATIONS, "The maximum number of loop iterations we predict statically", 100, 0, 0) +/* This parameter controls the maximum iterations that AutoFDO profile + prpagation algorithm will run for a specific CFG. */ + +DEFPARAM(PARAM_AUTOFDO_MAX_PROPAGATE_ITERATIONS, + "max-autofdo-max-propagate-iterations", + "The maximum number of AutoFDO profile propagation iterations", + 1000, 0, 0) + /* This parameter controls the probability of builtin_expect. The default value is 90%. This empirical value is obtained through the weighted probability of FDO counters (with the FDO count value as the weight)