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

Recognize when a function is marked pragma(inline). #587

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gcc/d/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
(build_closure): Don't set chain field for functions without context
pointer.

2018-01-21 Iain Buclaw <[email protected]>

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

2018-01-21 Iain Buclaw <[email protected]>

* decl.cc (DeclVisitor::visit(StructDeclaration)): Mark compiler
Expand Down
22 changes: 20 additions & 2 deletions gcc/d/decl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,16 @@ 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;
}
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. */
Expand Down Expand Up @@ -1240,6 +1248,16 @@ get_symbol_decl (Declaration *decl)
else
DECL_EXTERNAL (decl->csym) = 1;
}

/* Don't keep functions declared pragma(inline, true) unless
the user wants us to keep all inline functions. */
if (fd && fd->inlining == PINLINEalways && TREE_PUBLIC (decl->csym))
{
if (flag_keep_inline_functions)
mark_needed (decl->csym);

d_comdat_linkage (decl->csym);
}
}

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