From patchwork Mon Jul 11 10:22:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 646895 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 3rp1SW3frnz9t0p for ; Mon, 11 Jul 2016 20:25:14 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=iYw65PlA; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=ahcQRT6G57oOCj7wY5T2k9J1WPHQfuBxHI5A8Dnxi15eBSDedvgG/ edPuQ+NqChE9sGhWynrwuEMsTzOv/tcUA/2nLRUj6Pkn3dybmZe3zGUHEMZk0maQ CiGaK0hU9of843TNivZrv2xHKD8ua/ppPsOoExbVdyxrxTjaYQysz4= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=MoFWBwNb1+rRLa2DV5OAkknaKJ0=; b=iYw65PlAKYxNEHrFxBvx V1NU9vUWa9m1KgE8AW6rpzOFMzkF1IfnzwEAvh33AIfo8hwNfz6t7N5O3fAq6tg4 6Fmj7WcEzjc0pC07HvYMYZ4JNKKmJQosD+B4eZmLD9pbYO5IzGjgRqbYB5XAUCwx QTkDfw9+vlEW92zZ+Tm/eKw= Received: (qmail 66005 invoked by alias); 11 Jul 2016 10:25:07 -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 65986 invoked by uid 89); 11 Jul 2016 10:25:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=x86_64**, 86**, 86-*-*, x86_64-*-* X-HELO: mail-wm0-f67.google.com Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 11 Jul 2016 10:24:56 +0000 Received: by mail-wm0-f67.google.com with SMTP id o80so3636534wme.0 for ; Mon, 11 Jul 2016 03:24:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=+m9Rb0+dnGAlmfHRVPEjrqA1gofT1dvvKhkrZCvUD0A=; b=T1REDHKm4+Nu8kbUA7/v1rG/oFIiMpaBoH0bJL+3CRD7V0zNCWlMXCcQ8ZUIVqZWv6 +lPe5KpAicKOpU2n8HirIwS+6g6KzgqLPO+DKiPsyDp1yqKIjv7GhGqYD2tkHyGnASD9 LPajRqcpfXJdEvDbKq0FlSjOLe9pdkRVw/rFN1rZrmqLCs1fjnsbdrU1FEqqZNaR0/Rp nhih3SSg4TXF1JMYjEgEzboWPy0Du4wl1Tb20AIbfWSEAOM4hRM+5oMEhFvaLV6UBddu SRG0aT1T9dAW71g4ICsoa5xohXOxw/MtfOQMm6x25dbQA64TFKLh5ahS4zZh8RGTHlT1 PP+w== X-Gm-Message-State: ALyK8tKwswWwedHV5gXJE9OMqZgOu/q5XrsFWNndy1b8ri+MaEjw2tBLsTbzzmPqP1PDeg== X-Received: by 10.28.167.144 with SMTP id q138mr8453456wme.83.1468232692498; Mon, 11 Jul 2016 03:24:52 -0700 (PDT) Received: from msticlxl57.ims.intel.com (irdmzpr01-ext.ir.intel.com. [192.198.151.36]) by smtp.gmail.com with ESMTPSA id x194sm21896271wmf.13.2016.07.11.03.24.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2016 03:24:51 -0700 (PDT) Date: Mon, 11 Jul 2016 13:22:19 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, PR ipa/71633] Fix inlining into thunks Message-ID: <20160711102219.GA51593@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi, Currently when we expand thunk in inliner we assume its body has a single call. This is wrong for cases when thunk is instrumented. It means we might try to continue inlining for wrong edge. This simple patch fixes it. Bootstrapped and regtested on x86_64-unknown-linux-gnu. OK for trunk? Thanks, Ilya --- gcc/ 2016-07-11 Ilya Enkovich PR ipa/71633 * ipa-inline-transform.c (inline_call): Support instrumented thunks. gcc/testsuite/ 2016-07-11 Ilya Enkovich PR ipa/71633 * g++.dg/pr71633.C: New test. diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c index 9ac1efc..a4ae305 100644 --- a/gcc/ipa-inline-transform.c +++ b/gcc/ipa-inline-transform.c @@ -319,10 +319,14 @@ inline_call (struct cgraph_edge *e, bool update_original, to = to->global.inlined_to; if (to->thunk.thunk_p) { + struct cgraph_node *target = to->callees->callee; if (in_lto_p) to->get_untransformed_body (); to->expand_thunk (false, true); - e = to->callees; + /* When thunk is instrumented we may have multiple callees. */ + for (e = to->callees; e && e->callee != target; e = e->next_callee) + ; + gcc_assert (e); } diff --git a/gcc/testsuite/g++.dg/pr71633.C b/gcc/testsuite/g++.dg/pr71633.C new file mode 100644 index 0000000..bb69bbb --- /dev/null +++ b/gcc/testsuite/g++.dg/pr71633.C @@ -0,0 +1,28 @@ +/* PR71633 */ +// { dg-do compile { target i?86-*-* x86_64-*-* } } +/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */ + +class c1 +{ + virtual void fn1 (); +}; + +class c2 +{ + virtual int *fn2 () const; +}; + +class c3 : c1, c2 +{ + int *fn2 () const; + int *fn3 (int) const; +}; + +int *c3::fn2 () const +{ +} + +int *c3::fn3 (int p) const +{ + return fn3 (p); +}