From patchwork Sun Apr 26 08:40:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1276964 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=hlVwdGu2; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4991Zy75B9z9sPF for ; Sun, 26 Apr 2020 18:40:58 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8FBB13938C0D; Sun, 26 Apr 2020 08:40:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8FBB13938C0D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587890456; bh=1QF9JpfhG7Wad48C9ng79ShSexVsf4uiKEwp0pr9nyo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hlVwdGu2SXLZ0sAD/7aff+qqns/FyYsvbzpywiutuMico1i1+qw1RWv8fIIQSA+vp 7ENY3OvVBgjzlleg6lBoPKBJOWSJ2ur4F0t19YbUPxoJrwacIBX5lonv9bMd6yE7dc ktA+1zX2qwKOreee7Go8E4Wl1hE0+ONMPlyOwIbQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050::465:101]) by sourceware.org (Postfix) with ESMTPS id A0BA6385DC1B for ; Sun, 26 Apr 2020 08:40:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A0BA6385DC1B Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4991Zq3cHtzKmtj; Sun, 26 Apr 2020 10:40:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id y2dPFOGe04ZD; Sun, 26 Apr 2020 10:40:48 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Recognize pragma(inline) in the code generator. Date: Sun, 26 Apr 2020 10:40:46 +0200 Message-Id: <20200426084046.4819-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 84D501772 X-Rspamd-Score: 1.30 / 15.00 / 15.00 X-Spam-Status: No, score=-26.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch adds recognition of pragma(inline) in the code generator. Pragma inline affects whether functions are inlined or not. If at the declaration level, it affects the functions declared in the block it controls. If inside a function, it affects the function it is enclosed by. Support has been in the front-end for some time, but the information was not leveraged by the code generation pass. Bootstrapped and regression tested on x86_64-linux-gnu, and committed to mainline. Regards Iain. --- gcc/d/ChangeLog: * decl.cc (get_symbol_decl): Set DECL_DECLARED_INLINE_P or DECL_UNINLINABLE for declarations with pragma(inline). * toir.cc (IRVisitor::visit (GccAsmStatement *)): Set ASM_INLINE_P if in function decorated with pragma(inline). --- gcc/d/decl.cc | 7 +++++++ gcc/d/toir.cc | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 042c10c2943..845fc5cf877 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -1277,6 +1277,13 @@ get_symbol_decl (Declaration *decl) DECL_NO_INLINE_WARNING_P (decl->csym) = 1; } + /* In [pragma/inline], functions decorated with 'pragma(inline)' affects + whether they are inlined or not. */ + if (fd->inlining == PINLINEalways) + DECL_DECLARED_INLINE_P (decl->csym) = 1; + else if (fd->inlining == PINLINEnever) + DECL_UNINLINABLE (decl->csym) = 1; + /* Function was declared 'naked'. */ if (fd->naked) { diff --git a/gcc/d/toir.cc b/gcc/d/toir.cc index 6aaf10bf4e4..074cde0e0da 100644 --- a/gcc/d/toir.cc +++ b/gcc/d/toir.cc @@ -1423,7 +1423,8 @@ public: outputs, inputs, clobbers, labels); SET_EXPR_LOCATION (exp, make_location_t (s->loc)); - /* If the extended syntax was not used, mark the ASM_EXPR. */ + /* If the extended syntax was not used, mark the ASM_EXPR as being an + ASM_INPUT expression instead of an ASM_OPERAND with no operands. */ if (s->args == NULL && s->clobbers == NULL) ASM_INPUT_P (exp) = 1; @@ -1431,6 +1432,11 @@ public: optimization, this could be unset when building in release mode. */ ASM_VOLATILE_P (exp) = 1; + /* If the function has been annotated with 'pragma(inline)', then mark + the asm expression as being inline as well. */ + if (this->func_->inlining == PINLINEalways) + ASM_INLINE_P (exp) = 1; + add_stmt (exp); }