From patchwork Fri Jun 7 18:16:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriraman Tallam X-Patchwork-Id: 249782 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 CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id C077E2C00A6 for ; Sat, 8 Jun 2013 04:16:15 +1000 (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:content-type; q= dns; s=default; b=ZhbADc4mOh0VOdvXiMBQoAmIu2B7iR4+vAmHHA5nBBYDTt UZtqXMbhgmSJQuvBC2bHIR/W4gM0hWzQzVMTr10NnP8Gby/1DjEOHQM+/yEzDW8j VlGaE9hRiHZ9zQgyGvHuLhoXMqaa/7/lYG/dTIegeZg2OcLNuVkwYuwzwAeuI= 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:content-type; s= default; bh=UVLXzTnyspZfqysfFqf+PAdI5lA=; b=jzSNA3esFK1j8Din8bLJ 6KSDCy8SYeGk/jICberbfh3lnDi33ZpHCecyldzRLfHEJoR+ISrITnSVHaMdMpu4 iI7RFa2byqGE3TeZblMWOtaz4uxoJk4BcE84yiApQDZLQ0fm9qILcXU72hzDPq9W xnVxl9yrnCIV1P23Dh9/o4c= Received: (qmail 7552 invoked by alias); 7 Jun 2013 18:16: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 7543 invoked by uid 89); 7 Jun 2013 18:16:07 -0000 X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.1 Received: from mail-ie0-f170.google.com (HELO mail-ie0-f170.google.com) (209.85.223.170) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 07 Jun 2013 18:16:05 +0000 Received: by mail-ie0-f170.google.com with SMTP id e14so11705343iej.29 for ; Fri, 07 Jun 2013 11:16:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :x-gm-message-state; bh=hhfOrrwmmZ83wCNOvu/fBqW24TRwv2e6GKSObdqrBKM=; b=DnZLeodxTdEnBm6oDvR2Cm2M9fbRVAaDHEstixTXpqV2ELmWenIn+GSx+DfXelsPhy 3FY+9DC7MRF2Q/2bqieXEnBoXyhZs1yExuLQPZ7GENxo6DskvNcQE3T/zOTrw0N2Y7Yk 28ksi8z3oTwvkAvCUrpnkfeMmTERQsTAseFnuRnS/Jzn09lmIYWd1LlLGjaTTySjnAhl zVuJFVEzqTR1X52KZucI3oJwB3//YZSYhq36bbJaLJpU64L9RkwJgqCiYxfOyTBlyFGK m2eg7CXVf0uNXGfljVfYlNS11xgAemXidsCYE74Z1ON80m3YQj2N0vniMmol7yMz6z+W vQhw== MIME-Version: 1.0 X-Received: by 10.50.70.99 with SMTP id l3mr1978328igu.91.1370628964317; Fri, 07 Jun 2013 11:16:04 -0700 (PDT) Received: by 10.231.63.2 with HTTP; Fri, 7 Jun 2013 11:16:04 -0700 (PDT) Date: Fri, 7 Jun 2013 11:16:04 -0700 Message-ID: Subject: PR57548 - Call to multiversioned function from global namespace From: Sriraman Tallam To: GCC Patches , Jason Merrill , Richard Guenther X-Gm-Message-State: ALoCoQnA0LgS8vUgqwiv9hSJnUHT+83imnXQ74oFNRW+MX3Mbjs01veKY8jV1QSibvG8jKM35KQNGJnhbWkN/03eh+7NiHDXb1W8NEBI1NYC4q66pgsk6hYSJLRUYyR926s6uzzxfh78jofAfpDrRcJL9y0znkQmS+//5tq5bv+Aql6LUkwQ6v210nhrhAv4lGTxQIKYAAJA X-Virus-Found: No X-IsSubscribed: yes Hi, See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57548 The ICE here is because of a multi-versioned function called from global namespace and has no caller. This ICEs in target hook ix86_can_inline_p as caller is 0x0. The following simple patch attached fixes this problem. * cp/call.c (build_over_call): Check if current_function_decl is NULL. * testsuite/g++.dg/ext/pr57548.C: New test. Ok to submit? Thanks Sri This patch fixes PR 57548. The problem here is that the caller to fum not from a function and current_function_decl is NULL when processing the call. The simple fix in call.c to check current_function_decl before calling can_inline_p target hook. * cp/call.c (build_over_call): Check if current_function_decl is NULL. * testsuite/g++.dg/ext/pr57548.C: New test. Index: cp/call.c =================================================================== --- cp/call.c (revision 199662) +++ cp/call.c (working copy) @@ -7053,7 +7053,8 @@ build_over_call (struct z_candidate *cand, int fla otherwise the call should go through the dispatcher. */ if (DECL_FUNCTION_VERSIONED (fn) - && !targetm.target_option.can_inline_p (current_function_decl, fn)) + && (current_function_decl == NULL + || !targetm.target_option.can_inline_p (current_function_decl, fn))) { fn = get_function_version_dispatcher (fn); if (fn == NULL) Index: testsuite/g++.dg/ext/pr57548.C =================================================================== --- testsuite/g++.dg/ext/pr57548.C (revision 0) +++ testsuite/g++.dg/ext/pr57548.C (revision 0) @@ -0,0 +1,25 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-ifunc "" } */ + +int fum (); // Extra declaration that is merged with the second one. +int fum () __attribute__ ((target("default"))); + + +int fum () __attribute__((target( "mmx"))); +int fum () __attribute__((target( "popcnt"))); +int fum () __attribute__((target( "sse"))); +int fum () __attribute__((target( "sse2"))); +int fum () __attribute__((target( "sse3"))); +int fum () __attribute__((target( "ssse3"))); +int fum () __attribute__((target( "sse4.1"))); +int fum () __attribute__((target( "sse4.2"))); +int fum () __attribute__((target( "avx"))); +int fum () __attribute__((target( "avx2"))); + +int fum () __attribute__((target("arch=core2"))); +int fum () __attribute__((target("arch=corei7"))); +int fum () __attribute__((target("arch=atom"))); + +int (*p)() = &fum; + +int j = fum();