Skip to content
Merged
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
19 changes: 19 additions & 0 deletions gcc/jit/jit-playback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ const char* fn_attribute_to_string(gcc_jit_fn_attribute attr)
{
switch (attr)
{
case GCC_JIT_FN_ATTRIBUTE_ALIAS:
return "alias";
case GCC_JIT_FN_ATTRIBUTE_ALWAYS_INLINE:
return "always_inline";
case GCC_JIT_FN_ATTRIBUTE_INLINE:
Expand All @@ -535,6 +537,8 @@ const char* fn_attribute_to_string(gcc_jit_fn_attribute attr)
return "pure";
case GCC_JIT_FN_ATTRIBUTE_CONST:
return "const";
case GCC_JIT_FN_ATTRIBUTE_WEAK:
return "weak";
}
return NULL;
}
Expand Down Expand Up @@ -682,6 +686,9 @@ new_function (location *loc,
/* See handle_const_attribute in gcc/c-family/c-attribs.cc. */
else if (attr == GCC_JIT_FN_ATTRIBUTE_CONST)
TREE_READONLY (fndecl) = 1;
/* See handle_weak_attribute in gcc/c-family/c-attribs.cc. */
else if (attr == GCC_JIT_FN_ATTRIBUTE_WEAK)
declare_weak (fndecl);

const char* attribute = fn_attribute_to_string (attr);
if (attribute)
Expand All @@ -706,6 +713,15 @@ new_function (location *loc,
if (!ident || !targetm.target_option.valid_attribute_p (fndecl, ident, attribute_value, 0))
continue;

/* See handle_alias_ifunc_attribute in gcc/c-family/c-attribs.cc. */
if (name == GCC_JIT_FN_ATTRIBUTE_ALIAS)
{
tree id = get_identifier (value.c_str ());
/* This counts as a use of the object pointed to. */
TREE_USED (id) = 1;
DECL_INITIAL (fndecl) = error_mark_node;
}

if (ident)
DECL_ATTRIBUTES (fndecl) =
tree_cons (ident, attribute_value, DECL_ATTRIBUTES (fndecl));
Expand Down Expand Up @@ -2282,6 +2298,9 @@ postprocess ()

current_function_decl = NULL;
}
else
/* Add to cgraph to output aliases: */
rest_of_decl_compilation (m_inner_fndecl, true, 0);
}

/* Don't leak vec's internal buffer (in non-GC heap) when we are
Expand Down
2 changes: 2 additions & 0 deletions gcc/jit/libgccjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -2097,6 +2097,7 @@ gcc_jit_type_set_packed (gcc_jit_type *type);
/* Function attributes. */
enum gcc_jit_fn_attribute
{
GCC_JIT_FN_ATTRIBUTE_ALIAS,
GCC_JIT_FN_ATTRIBUTE_ALWAYS_INLINE,
GCC_JIT_FN_ATTRIBUTE_INLINE,
GCC_JIT_FN_ATTRIBUTE_NOINLINE,
Expand All @@ -2107,6 +2108,7 @@ enum gcc_jit_fn_attribute
GCC_JIT_FN_ATTRIBUTE_RETURNS_TWICE,
GCC_JIT_FN_ATTRIBUTE_PURE,
GCC_JIT_FN_ATTRIBUTE_CONST,
GCC_JIT_FN_ATTRIBUTE_WEAK,
};

/* Add an attribute to a function. */
Expand Down