Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Recognize when a function is marked pragma(inline).
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Dec 22, 2017
1 parent 23ec9a7 commit 6e51be1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
4 changes: 4 additions & 0 deletions gcc/d/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2017-12-22 Iain Buclaw <[email protected]>

* decls.cc (get_symbol_decl): Handle pragma(inline) attributes.

2017-12-19 Iain Buclaw <[email protected]>

* d-codegen.cc (build_target_expr): Update signature.
Expand Down
40 changes: 25 additions & 15 deletions gcc/d/decl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1120,22 +1120,24 @@ get_symbol_decl (Declaration *decl)
d_keep (newfntype);
}

/* Miscellaneous function flags. */
if (fd->isMember2 () || fd->isFuncLiteralDeclaration ())
/* In [pragma/inline], The attribute pragma(inline) affects whether a
function should be inlined or not. */
if (fd->inlining == PINLINEnever)
DECL_UNINLINABLE (decl->csym) = 1;
else if (fd->inlining == PINLINEalways)
{
DECL_DECLARED_INLINE_P (decl->csym) = 1;
DECL_DISREGARD_INLINE_LIMITS (decl->csym) = 1;
DECL_COMDAT (decl->csym) = 1;
}
else if (fd->isMember2 () || fd->isFuncLiteralDeclaration ())
{
/* See grokmethod in cp/decl.c. Maybe we shouldn't be setting inline
flags without reason or proper handling. */
DECL_DECLARED_INLINE_P (decl->csym) = 1;
DECL_NO_INLINE_WARNING_P (decl->csym) = 1;
}

/* Function was declared 'naked'. */
if (fd->naked)
{
DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl->csym) = 1;
DECL_UNINLINABLE (decl->csym) = 1;
}

/* Vector array operations are always compiler generated. */
if (fd->isArrayOp)
{
Expand Down Expand Up @@ -1219,12 +1221,6 @@ get_symbol_decl (Declaration *decl)
DECL_EXTERNAL (decl->csym) = 1;

d_comdat_linkage (decl->csym);

/* Normally the backend only emits COMDAT things when they are needed.
If this decl is meant to be externally visible, then make sure that
to mark it so that it is indeed needed. */
if (TREE_PUBLIC (decl->csym))
mark_needed (decl->csym);
}
else
{
Expand All @@ -1234,6 +1230,20 @@ get_symbol_decl (Declaration *decl)
else
DECL_EXTERNAL (decl->csym) = 1;
}

/* Normally the backend only emits COMDAT things when they are needed.
If this decl is meant to be externally visible, then make sure that
to mark it so that it is indeed needed. */
if (TREE_PUBLIC (decl->csym) && (fd != NULL || ti != NULL))
{
/* Don't keep functions declared pragma(inline, true) unless
the user wants us to keep all inline functions. */
if (fd && fd->inlining == PINLINEalways
&& !flag_keep_inline_functions)
DECL_COMDAT (decl->csym) = 1;
else if (ti)
mark_needed (decl->csym);
}
}

/* Symbol is going in thread local storage. */
Expand Down

0 comments on commit 6e51be1

Please sign in to comment.