X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gcc%2Fcgraphclones.c;h=15f7e119d18ea1ad6ad18c827e4d4bd6cfa41364;hb=d273c40a5568a1e2d048209826bdb778b4b75bde;hp=10ae2a98f75d3c562683028c8e9fc875ecb01f90;hpb=a5544970246db337977bb8b69ab120e9ef209317;p=gcc.git diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c index 10ae2a98f75..15f7e119d18 100644 --- a/gcc/cgraphclones.c +++ b/gcc/cgraphclones.c @@ -648,7 +648,7 @@ cgraph_node::create_virtual_clone (vec redirect_callers, DECL_ARGUMENTS (new_decl) = NULL; DECL_INITIAL (new_decl) = NULL; DECL_RESULT (new_decl) = NULL; - /* We can not do DECL_RESULT (new_decl) = NULL; here because of LTO partitioning + /* We cannot do DECL_RESULT (new_decl) = NULL; here because of LTO partitioning sometimes storing only clone decl instead of original. */ /* Generate a new name for the new version. */ @@ -1012,6 +1012,11 @@ cgraph_node::create_version_clone (tree new_decl, If non-NULL BLOCK_TO_COPY determine what basic blocks to copy. If non_NULL NEW_ENTRY determine new entry BB of the clone. + If TARGET_ATTRIBUTES is non-null, when creating a new declaration, + add the attributes to DECL_ATTRIBUTES. And call valid_attribute_p + that will promote value of the attribute DECL_FUNCTION_SPECIFIC_TARGET + of the declaration. + Return the new version's cgraph node. */ cgraph_node * @@ -1019,7 +1024,7 @@ cgraph_node::create_version_clone_with_body (vec redirect_callers, vec *tree_map, bitmap args_to_skip, bool skip_return, bitmap bbs_to_copy, basic_block new_entry_block, - const char *suffix) + const char *suffix, tree target_attributes) { tree old_decl = decl; cgraph_node *new_version_node = NULL; @@ -1044,6 +1049,19 @@ cgraph_node::create_version_clone_with_body DECL_VIRTUAL_P (new_decl) = 0; + if (target_attributes) + { + DECL_ATTRIBUTES (new_decl) = target_attributes; + + location_t saved_loc = input_location; + tree v = TREE_VALUE (target_attributes); + input_location = DECL_SOURCE_LOCATION (new_decl); + bool r = targetm.target_option.valid_attribute_p (new_decl, NULL, v, 0); + input_location = saved_loc; + if (!r) + return NULL; + } + /* When the old decl was a con-/destructor make sure the clone isn't. */ DECL_STATIC_CONSTRUCTOR (new_decl) = 0; DECL_STATIC_DESTRUCTOR (new_decl) = 0;