From patchwork Sat Dec 29 20:26:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jozef Lawrynowicz X-Patchwork-Id: 1019385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-493189-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mittosystems.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="S14+xDD2"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mittosystems.com header.i=@mittosystems.com header.b="a8mSKlC+"; dkim-atps=neutral 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 43Rw8s5nZ6z9s3q for ; Sun, 30 Dec 2018 07:26:50 +1100 (AEDT) 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=TrTf1jupdP1Gwe5DtaRNjgPqcWAv8Hz44raP1vwgfTI+R+1yC00VP YRCQJSpTPnn+WzSpzBLt7Z5wKSnm8cn+kcQxHqnjXZxD0lBjcDrm2WR96j55zRIB F1a2OpUSnl1ADba2ek6bw1Bf5tc6Z2lj+RvP9RBOdZgJ5hbIyW5Yvs= 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=7XWTPF7jKjPeJoeWeG9sgBQQiG4=; b=S14+xDD2YElx4j3JLhGI tf3+S2xaNLKgiYshcvFopYpK1Aa9uR4M+zydfBqDUuFdlzKMg6AtlaTqEuyI6+UH 9oFRO/c/jVcIjpPb2eXMy7p0kjG3rP1gPYClSrDpPUnkXD3ykUEU8Mi91V3VCSkH u6S+HJxMn5yVY5FpSa4VrhA= Received: (qmail 51460 invoked by alias); 29 Dec 2018 20:26:44 -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 51416 invoked by uid 89); 29 Dec 2018 20:26:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=naked, entering, restoring X-HELO: mail-wr1-f50.google.com Received: from mail-wr1-f50.google.com (HELO mail-wr1-f50.google.com) (209.85.221.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 29 Dec 2018 20:26:40 +0000 Received: by mail-wr1-f50.google.com with SMTP id t6so23691353wrr.12 for ; Sat, 29 Dec 2018 12:26:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mittosystems.com; s=google; h=date:from:to:subject:message-id:mime-version; bh=QdTkBgDC+AVLW1FuMloCuVisYIZQbqQxnT1i9f/2deM=; b=a8mSKlC+W2pp7UsVtDSqJchR8GSwcjd4tbY+I1/oOZk5W6E4rOKfT/AE62wqG73H2+ p6RawZvsWHdYIC6+uk8bUrxVEVvlmQf0Fb2+Ta8H5tluQ08pj+gVR77jDP0KMIR68U+H ehUvTOoBu6wXOHLwKzHGLcU9O0lz6A9t22HiYgHHeODvcUTQ/Wi6ZQ0+2H7aUZ6qXFox 90eKviMXQ5NqPh4uvXRzM2r9JBLn/EP003LF6Xi/c9o2dfPD6Orjnzeu+MBR35ZpKGg8 NlZeh1owrdxGo4fjzNwjCwlbhYgmy0R4+lKKhzdQQ6GrWvgdQ2P6N4g5UT2JstCrQNYb YxlQ== Received: from jozef-Aspire-VN7-793G ([2a01:4b00:87fd:900:bd97:6b12:529e:aee5]) by smtp.gmail.com with ESMTPSA id z206sm35194710wmc.18.2018.12.29.12.26.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Dec 2018 12:26:38 -0800 (PST) Date: Sat, 29 Dec 2018 20:26:34 +0000 From: Jozef Lawrynowicz To: gcc-patches@gcc.gnu.org Subject: [committed][MSP430] Warn that the critical function attribute has no effect on interrupt functions Message-ID: <20181229202634.17bf98ee@jozef-Aspire-VN7-793G> MIME-Version: 1.0 X-IsSubscribed: yes The attached patch fixes an issue for MSP430 where the "critical" and "interrupt" function attributes could be used together. The MSP430 hardware already performs the same tasks as the "critical" attribute when entering/exiting an ISR i.e. disabling interrupts on entry, and restoring the interrupt state on exit. Using the "critical" attribute with "interrupt" is therefore redundant and adds extra unnecessary code. A warning is now emitted, and the "critical" attribute is ignored, when using the two attributes together. Committed to trunk. From 18eb3191fee5f7cc8288cfd88a0b76259b8b547c Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Sat, 29 Dec 2018 16:27:49 +0000 Subject: [PATCH] [MSP430] Warn that the critical function attribute has no effect on interrupt functions 2018-12-29 Jozef Lawrynowicz gcc/ChangeLog: * config/msp430/msp430.c (msp430_attr): Warn when the critical and interrupt function attributes are used together. * gcc/doc/extend.texi: Update documentation on the critical attribute. gcc/testsuite/ChangeLog: * gcc.target/msp430/critical-interrupt.c: New test. --- gcc/config/msp430/msp430.c | 9 +++++++++ gcc/doc/extend.texi | 8 ++++++-- gcc/testsuite/gcc.target/msp430/critical-interrupt.c | 12 ++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/msp430/critical-interrupt.c diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index 3a41cc0..21b5819 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -1946,6 +1946,13 @@ msp430_attr (tree * node, TREE_USED (* node) = 1; DECL_PRESERVE_P (* node) = 1; } + if (is_critical_func (* node)) + { + warning (OPT_Wattributes, + "critical attribute has no effect on interrupt functions"); + DECL_ATTRIBUTES (*node) = remove_attribute (ATTR_CRIT, + DECL_ATTRIBUTES (* node)); + } } else if (TREE_NAME_EQ (name, ATTR_REENT)) { @@ -1960,6 +1967,8 @@ msp430_attr (tree * node, message = "naked functions cannot be critical"; else if (is_reentrant_func (* node)) message = "reentrant functions cannot be critical"; + else if (is_interrupt_func ( *node)) + message = "critical attribute has no effect on interrupt functions"; } else if (TREE_NAME_EQ (name, ATTR_NAKED)) { diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 1849120..27724e4 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -4978,8 +4978,12 @@ These function attributes are supported by the MSP430 back end: @cindex @code{critical} function attribute, MSP430 Critical functions disable interrupts upon entry and restore the previous interrupt state upon exit. Critical functions cannot also -have the @code{naked} or @code{reentrant} attributes. They can have -the @code{interrupt} attribute. +have the @code{naked}, @code{reentrant} or @code{interrupt} attributes. + +The MSP430 hardware ensures that interrupts are disabled on entry to +@code{interrupt} functions, and restores the previous interrupt state +on exit. The @code{critical} attribute is therefore redundant on +@code{interrupt} functions. @item interrupt @cindex @code{interrupt} function attribute, MSP430 diff --git a/gcc/testsuite/gcc.target/msp430/critical-interrupt.c b/gcc/testsuite/gcc.target/msp430/critical-interrupt.c new file mode 100644 index 0000000..3ef7a12 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/critical-interrupt.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-final { scan-assembler-not "attributes.*critical" } } */ + +void __attribute__((interrupt,critical)) +fn1 (void) +{ /* { dg-warning "critical attribute has no effect on interrupt functions" } */ +} + +void __attribute__((critical,interrupt)) +fn2 (void) +{ /* { dg-warning "critical attribute has no effect on interrupt functions" } */ +} -- 2.7.4