public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/gccgo] d: Recognize pragma(inline) in the code generator.
@ 2020-07-12 17:33 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2020-07-12 17:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:67e3020b219fd83a42903e8a62e7d32e712791ff

commit 67e3020b219fd83a42903e8a62e7d32e712791ff
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Mar 31 00:19:18 2020 +0200

    d: Recognize 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.
    
    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).

Diff:
---
 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);
   }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-12 17:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-12 17:33 [gcc/devel/gccgo] d: Recognize pragma(inline) in the code generator Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).