From patchwork Wed Aug 14 00:02: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: 266941 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 BDCA52C017A for ; Wed, 14 Aug 2013 10:02:13 +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=S9CiFtnzA5JO4hwBxWjQ6XUCwib3nyt8xpDALESO/pmB/F iZcjQXPjlyNS4ZDrUOXkePzCeRiOd3zJMWvIUlbWNRvai3v3fZdQPK2DK4bpaP4f t9VV43MpvNs30A02zgIW9lv+GPISwh3Kv9xUkuibgOKd93EPj+z0TY+V5tN14= 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=fJTFAKPzEbuJuRfNpRwx9lBkvxc=; b=jvSZKhQqu4y3nDoumP6V XfYDv9y53NNJzLhdRVjyb8lM0cQkrisKot80pZgPIek4hE4P7iFnYW77aWXG/GUS EM3vUQYOSc7ZsFQRs4HykUNhyEwfg9IImSzi51yr3t0u/49RCmGejGr9CFLjPxJT Bwn7cOT4qEGSbADCxb4c5uQ= Received: (qmail 23319 invoked by alias); 14 Aug 2013 00:02: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 23308 invoked by uid 89); 14 Aug 2013 00:02:07 -0000 X-Spam-SWARE-Status: No, score=-4.5 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.2 Received: from mail-ie0-f181.google.com (HELO mail-ie0-f181.google.com) (209.85.223.181) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 14 Aug 2013 00:02:06 +0000 Received: by mail-ie0-f181.google.com with SMTP id x14so11551129ief.40 for ; Tue, 13 Aug 2013 17:02:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=6IxfeJC41pnu4kuad9chL9UzjHDhNyFKBmWJzOtW9nc=; b=dOlc22RhISDROIgZeYlEpuwfhCKsE7eZm9yL8SFU1k1RzInm4uI2LWEf1LzggmJNss 4CHkBa2fTU9s3oqPcJd9W+8dABPueID/ycQd9VwHCyUCzpgYP+ynsH5uI+tTBHke4Wn1 8cdgEJTf4ZdbJ7YtUfSbbccQ2JMCVtXmxRkvIuhFXc9Ez+3dFbDOUyiSWW+AA63jxvHN QAewvN9W8ppJD1ScwXBSvAnbevI/MBGK1RTC+V+hJDZMlnFrh7pbyAOxqasFQipTXavp 3SjuwS2Cr4Xg5GzZNjuHY14TYqT69+uTVd15w8+fTRNNK+5tyTbK43h1R3yCNmtSMPf/ 03jg== X-Gm-Message-State: ALoCoQkeTF+VADXUAezKI4s+ACl7SVRagilCFF3/YwBMt25k32hhnxZljfjmEU1s/N01PDh/ilo6GujtzwXlhbU0fMzKNMv+KGC8HSiCDXN/JIWC1VZYlR0nXYCXhTS5pr2HmpMzb6fzVn++2HowxrKl8BnJHwmwDqOzHnGRKhsUh1KK5NvF6hxzrUIRTrFu2mCXa3+dC5cG/Z+pL+G4hn9ssWLIhYM+bQ== MIME-Version: 1.0 X-Received: by 10.50.119.42 with SMTP id kr10mr344831igb.20.1376438524541; Tue, 13 Aug 2013 17:02:04 -0700 (PDT) Received: by 10.231.32.72 with HTTP; Tue, 13 Aug 2013 17:02:04 -0700 (PDT) Date: Tue, 13 Aug 2013 17:02:04 -0700 Message-ID: Subject: [PATCH][i386]Fix PR 57756 From: Sriraman Tallam To: GCC Patches , David Li , Uros Bizjak , Jakub Jelinek X-Virus-Found: No X-IsSubscribed: yes Hi, I have attached a patch to fix PR57756. Description: The following program, __attribute__((always_inline,target("sse4.2"))) __inline int callee () { return 0; } __attribute__((target("sse"))) __inline int caller () { return callee(); } does not generate an error and callee is inlined into caller. This is because callee has a higher target ISA. Interchanging the position of caller and callee will generate the correct error. Also, removing the target attribute from caller will generate the error. The reason for the bug is that when the caller's target options are processed, global_options contain the ISA flags of the callee (previously processed) and doing this in i386-common.c, where opts is global_options: opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSE_SET; is not changing global options. The fix is to reset global_options to the default each time a new target option needs to be processed. Patch ok? Thanks Sri * config/i386/i386.c (ix86_valid_target_attribute_p): Restore global_options to default before modifying it. * gcc.target/i386/pr57756.c: New test. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 201701) +++ config/i386/i386.c (working copy) @@ -4879,6 +4879,10 @@ ix86_valid_target_attribute_p (tree fndecl, /* The target attributes may also change some optimization flags, so update the optimization options if necessary. */ cl_target_option_save (&cur_target, &global_options); + /* ix86_valid_target_attribute_tree sets global_options. Restore + global_options to the default before its target options can be set. */ + cl_target_option_restore (&global_options, + TREE_TARGET_OPTION (target_option_default_node)); new_target = ix86_valid_target_attribute_tree (args); new_optimize = build_optimization_node (); Index: testsuite/gcc.target/i386/pr57756.c =================================================================== --- testsuite/gcc.target/i386/pr57756.c (revision 0) +++ testsuite/gcc.target/i386/pr57756.c (revision 0) @@ -0,0 +1,20 @@ +/* callee cannot be inlined into caller because it has a higher + target ISA. */ +/* { dg-do compile } */ + +__attribute__((always_inline,target("sse4.2"))) +__inline int callee () /* { dg-error "inlining failed in call to always_inline" } */ +{ + return 0; +} + +__attribute__((target("sse"))) +__inline int caller () +{ + return callee(); /* { dg-error "called from here" } */ +} + +int main () +{ + return caller(); +}