From patchwork Sat Mar 16 13:29:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 228210 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]) by ozlabs.org (Postfix) with SMTP id BF7A02C00B8 for ; Sun, 17 Mar 2013 00:30:16 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1364045418; h=Comment: DomainKey-Signature:Received:Received:Received:Received:From:To: Cc:Subject:Date:Message-Id:In-Reply-To:References:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=+Y2KnlmaigZlbmTrDBwjvalUaXg=; b=f5UIjvPXOWt0dJwnLsPNiAfCDWYYemYJIaViFTMXgzMpf4wcQ2oyDBQdGi4gWg 7+F2nuIcqK+fO96kXyUxUzsHApWCVeiqwvWM+CI7i1KtmBrdvXdvo6/SRvvkRI0f th0eR6snA8rrjTCVHgxAgmJ+pfEMKnKsstcf8v0p7oo3k= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=wLXJ/c6CPgzKmKWQm3VY3GAiGQgaoaa+EvOkzwQGFEEUK81WwwG4Je1mBboJFU Cuwr6gE748BzoSnWuY/4BrPVzqHjY7lTy2noHYhOu/sShXlTgreSSnnoX/sM+0Ou 4i2hCfTIBmu7M8CvK84TjE3Z7ueIiMf0jJxpNBCtuZBCI=; Received: (qmail 8423 invoked by alias); 16 Mar 2013 13:29:55 -0000 Received: (qmail 8388 invoked by uid 22791); 16 Mar 2013 13:29:53 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from two.firstfloor.org (HELO one.firstfloor.org) (193.170.194.197) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 16 Mar 2013 13:29:48 +0000 Received: by one.firstfloor.org (Postfix, from userid 503) id 5BE3786759; Sat, 16 Mar 2013 14:29:43 +0100 (CET) From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, rth@redhat.com, Andi Kleen Subject: [PATCH 4/4] Add warning for non-constant memory models Date: Sat, 16 Mar 2013 14:29:29 +0100 Message-Id: <1363440569-17331-4-git-send-email-andi@firstfloor.org> In-Reply-To: <1363440569-17331-1-git-send-email-andi@firstfloor.org> References: <1363440569-17331-1-git-send-email-andi@firstfloor.org> 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 From: Andi Kleen Non constant memory models drop HLE attribute bits. Since we had problems with this even in gcc code itself, like libstdc++ passing variables when not optimizing, add a warning for this case. Passed bootstrap and test on x86_64-linux. gcc/: 2013-03-15 Andi Kleen PR target/55947 * gcc/builtins.c (get_memmodel): Warn for non constant memory model. --- gcc/builtins.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gcc/builtins.c b/gcc/builtins.c index 68b6a2c..c4efc4c 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5280,10 +5280,14 @@ get_memmodel (tree exp) rtx op; unsigned HOST_WIDE_INT val; - /* If the parameter is not a constant, it's a run time value so we'll just - convert it to MEMMODEL_SEQ_CST to avoid annoying runtime checking. */ + /* Warn about non constant memory models, as we drop target specific + bits (like HLE). */ if (TREE_CODE (exp) != INTEGER_CST) - return MEMMODEL_SEQ_CST; + { + warning (OPT_Winvalid_memory_model, + "Non constant memory model: Assuming __ATOMIC_SEQ_CST"); + return MEMMODEL_SEQ_CST; + } op = expand_normal (exp);