@@ -514,6 +514,12 @@ const char* fn_attribute_to_string(gcc_jit_fn_attribute attr)
514514{
515515 switch (attr)
516516 {
517+ case GCC_JIT_FN_ATTRIBUTE_ALWAYS_INLINE:
518+ return " always_inline" ;
519+ case GCC_JIT_FN_ATTRIBUTE_INLINE:
520+ return NULL ;
521+ case GCC_JIT_FN_ATTRIBUTE_NOINLINE:
522+ return " noinline" ;
517523 case GCC_JIT_FN_ATTRIBUTE_TARGET:
518524 return " target" ;
519525 case GCC_JIT_FN_ATTRIBUTE_USED:
@@ -643,34 +649,48 @@ new_function (location *loc,
643649
644650 for (auto attr: attributes)
645651 {
646- tree ident = get_identifier (fn_attribute_to_string (attr));
647-
652+ if (attr == GCC_JIT_FN_ATTRIBUTE_ALWAYS_INLINE)
653+ {
654+ DECL_DECLARED_INLINE_P (fndecl) = 1 ;
655+ DECL_DISREGARD_INLINE_LIMITS (fndecl) = 1 ;
656+ }
657+ else if (attr == GCC_JIT_FN_ATTRIBUTE_INLINE)
658+ DECL_DECLARED_INLINE_P (fndecl) = 1 ;
659+ else if (attr == GCC_JIT_FN_ATTRIBUTE_NOINLINE)
660+ DECL_UNINLINABLE (fndecl) = 1 ;
648661 /* See handle_used_attribute in gcc/c-family/c-attribs.cc. */
649- if (attr == GCC_JIT_FN_ATTRIBUTE_USED)
662+ else if (attr == GCC_JIT_FN_ATTRIBUTE_USED)
650663 {
651664 TREE_USED (fndecl) = 1 ;
652665 DECL_PRESERVE_P (fndecl) = 1 ;
653666 }
654667
655- DECL_ATTRIBUTES (fndecl) =
656- tree_cons (ident, NULL_TREE, DECL_ATTRIBUTES (fndecl));
668+ const char * attribute = fn_attribute_to_string (attr);
669+ if (attribute)
670+ {
671+ tree ident = get_identifier (attribute);
672+ DECL_ATTRIBUTES (fndecl) =
673+ tree_cons (ident, NULL_TREE, DECL_ATTRIBUTES (fndecl));
674+ }
657675 }
658676
659677 for (auto attr: string_attributes)
660678 {
661679 gcc_jit_fn_attribute& name = std::get<0 >(attr);
662680 std::string& value = std::get<1 >(attr);
663681 tree attribute_value = build_tree_list (NULL_TREE, ::build_string (value.length () + 1 , value.c_str ()));
664- tree ident = get_identifier (fn_attribute_to_string (name));
682+ const char * attribute = fn_attribute_to_string (name);
683+ tree ident = attribute ? get_identifier (attribute) : NULL ;
665684
666685 /* See handle_target_attribute in gcc/c-family/c-attribs.cc. */
667686 if (name == GCC_JIT_FN_ATTRIBUTE_TARGET)
668687 /* We need to call valid_attribute_p so that the hook set-up some internal options. */
669- if (!targetm.target_option .valid_attribute_p (fndecl, ident, attribute_value, 0 ))
688+ if (!ident || ! targetm.target_option .valid_attribute_p (fndecl, ident, attribute_value, 0 ))
670689 continue ;
671690
672- DECL_ATTRIBUTES (fndecl) =
673- tree_cons (ident, attribute_value, DECL_ATTRIBUTES (fndecl));
691+ if (ident)
692+ DECL_ATTRIBUTES (fndecl) =
693+ tree_cons (ident, attribute_value, DECL_ATTRIBUTES (fndecl));
674694 }
675695
676696 function *func = new function (this , fndecl, kind);
0 commit comments