Commit 13bdca74 by Martin Liska Committed by Martin Liska

Reduce lookup_attribute memory footprint.

2017-09-12  Martin Liska  <mliska@suse.cz>

	* attribs.c (private_lookup_attribute): New function.
	* attribs.h (private_lookup_attribute): Declared here.
	(lookup_attribute): Called from this place.

From-SVN: r252022
parent 29545149
2017-09-12 Martin Liska <mliska@suse.cz>
* attribs.c (private_lookup_attribute): New function.
* attribs.h (private_lookup_attribute): Declared here.
(lookup_attribute): Called from this place.
2017-09-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/82157
......
......@@ -1584,3 +1584,25 @@ attribute_list_contained (const_tree l1, const_tree l2)
return 1;
}
/* The backbone of lookup_attribute(). ATTR_LEN is the string length
of ATTR_NAME, and LIST is not NULL_TREE.
The function is called from lookup_attribute in order to optimize
for size. */
tree
private_lookup_attribute (const char *attr_name, size_t attr_len, tree list)
{
while (list)
{
tree attr = get_attribute_name (list);
size_t ident_len = IDENTIFIER_LENGTH (attr);
if (cmp_attribs (attr_name, attr_len, IDENTIFIER_POINTER (attr),
ident_len))
break;
list = TREE_CHAIN (list);
}
return list;
}
......@@ -87,6 +87,14 @@ extern tree handle_dll_attribute (tree *, tree, tree, int, bool *);
extern int attribute_list_equal (const_tree, const_tree);
extern int attribute_list_contained (const_tree, const_tree);
/* The backbone of lookup_attribute(). ATTR_LEN is the string length
of ATTR_NAME, and LIST is not NULL_TREE.
The function is called from lookup_attribute in order to optimize
for size. */
extern tree private_lookup_attribute (const char *attr_name, size_t attr_len,
tree list);
/* For a given IDENTIFIER_NODE, strip leading and trailing '_' characters
so that we have a canonical form of attribute names. */
......@@ -151,17 +159,7 @@ lookup_attribute (const char *attr_name, tree list)
/* Do the strlen() before calling the out-of-line implementation.
In most cases attr_name is a string constant, and the compiler
will optimize the strlen() away. */
while (list)
{
tree attr = get_attribute_name (list);
size_t ident_len = IDENTIFIER_LENGTH (attr);
if (cmp_attribs (attr_name, attr_len, IDENTIFIER_POINTER (attr),
ident_len))
break;
list = TREE_CHAIN (list);
}
return list;
return private_lookup_attribute (attr_name, attr_len, list);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment