static void
initialize_cold_section_name (void)
{
- const char *name;
const char *stripped_name;
- char *buffer;
+ char *name, *buffer;
+ tree dsn;
gcc_assert (cfun && current_function_decl);
if (cfun->unlikely_text_section_name)
return;
- if (flag_function_sections && DECL_SECTION_NAME (current_function_decl))
+ dsn = DECL_SECTION_NAME (current_function_decl);
+ if (flag_function_sections && dsn)
{
- name = alloca (TREE_STRING_LENGTH (DECL_SECTION_NAME
- (current_function_decl)));
- strcpy ((char *) name, TREE_STRING_POINTER (DECL_SECTION_NAME
- (current_function_decl)));
+ name = alloca (TREE_STRING_LENGTH (dsn) + 1);
+ memcpy (name, TREE_STRING_POINTER (dsn), TREE_STRING_LENGTH (dsn) + 1);
+
stripped_name = targetm.strip_name_encoding (name);
+
buffer = ACONCAT ((stripped_name, "_unlikely", NULL));
cfun->unlikely_text_section_name = ggc_strdup (buffer);
}
doing partitioning, if the entire function was decided by
choose_function_section (predict.c) to be cold. */
- int i;
- int len;
- char *s;
-
initialize_cold_section_name ();
- /* The following is necessary, because 'strcmp
- (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)), blah)' always
- fails, presumably because TREE_STRING_POINTER is declared to
- be an array of size 1 of char. */
-
- len = TREE_STRING_LENGTH (DECL_SECTION_NAME (decl));
- s = (char *) xmalloc (len + 1);
-
- for (i = 0; i < len; i ++)
- s[i] = (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)))[i];
- s[len] = '\0';
-
if (cfun->unlikely_text_section_name
- && (strcmp (s, cfun->unlikely_text_section_name) == 0))
+ && strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)),
+ cfun->unlikely_text_section_name) == 0)
first_function_block_is_cold = true;
}
/* The value of the constant. */
tree value;
+
+ /* Hash of value. Computing the hash from value each time
+ hashfn is called can't work properly, as that means recursive
+ use of the hash table during hash table expansion. */
+ hashval_t hash;
};
static GTY((param_is (struct constant_descriptor_tree)))
static hashval_t
const_desc_hash (const void *ptr)
{
- return const_hash_1 (((struct constant_descriptor_tree *)ptr)->value);
+ return ((struct constant_descriptor_tree *)ptr)->hash;
}
static hashval_t
static int
const_desc_eq (const void *p1, const void *p2)
{
- return compare_constant (((struct constant_descriptor_tree *)p1)->value,
- ((struct constant_descriptor_tree *)p2)->value);
+ const struct constant_descriptor_tree *c1 = p1;
+ const struct constant_descriptor_tree *c2 = p2;
+ if (c1->hash != c2->hash)
+ return 0;
+ return compare_constant (c1->value, c2->value);
}
/* Compare t1 and t2, and return 1 only if they are known to result in
/* Look up EXP in the table of constant descriptors. If we didn't find
it, create a new one. */
key.value = exp;
- loc = htab_find_slot (const_desc_htab, &key, INSERT);
+ key.hash = const_hash_1 (exp);
+ loc = htab_find_slot_with_hash (const_desc_htab, &key, key.hash, INSERT);
desc = *loc;
if (desc == 0)
{
desc = build_constant_desc (exp);
+ desc->hash = key.hash;
*loc = desc;
}
struct constant_descriptor_tree key;
key.value = exp;
- desc = htab_find (const_desc_htab, &key);
+ key.hash = const_hash_1 (exp);
+ desc = htab_find_with_hash (const_desc_htab, &key, key.hash);
return (desc ? desc->rtl : NULL_RTX);
}
assemble_name (asm_out_file, name);
fprintf (asm_out_file, "\n");
#else
- warning (0, "visibility attribute not supported in this configuration; ignored");
+ warning (OPT_Wattributes, "visibility attribute not supported "
+ "in this configuration; ignored");
#endif
}