* [C++] make TYPE_DECLs public for builtin type and templates
@ 2014-06-30 22:28 Jan Hubicka
2014-07-01 23:10 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Jan Hubicka @ 2014-06-30 22:28 UTC (permalink / raw)
To: gcc-patches, jason
Jason,
I made a verifier that types not considered anonymous are not built
from types that are anonymous and that public types have TREE_PUBLIC
flag on their TYPE_DECLS (as that seem to be what tree.h says).
This catches two cases in C++ FE and several other cases elsewhere.
Does something like this make sense? I think bulitin_types are
generally public, but I am not quite sure about templates.
Honza
* decl.c (record_builtin_type): Make builting types public.
* pt.c (reduce_template_parm_level): Make TYPE_DECL public.
Index: decl.c
===================================================================
--- decl.c (revision 212098)
+++ decl.c (working copy)
@@ -3591,6 +3591,7 @@ record_builtin_type (enum rid rid_index,
tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, tname, type);
DECL_ARTIFICIAL (tdecl) = 1;
SET_IDENTIFIER_GLOBAL_VALUE (tname, tdecl);
+ TREE_PUBLIC (tdecl) = true;
}
if (rname)
{
@@ -3598,6 +3599,7 @@ record_builtin_type (enum rid rid_index,
{
tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, rname, type);
DECL_ARTIFICIAL (tdecl) = 1;
+ TREE_PUBLIC (tdecl) = true;
}
SET_IDENTIFIER_GLOBAL_VALUE (rname, tdecl);
}
Index: pt.c
===================================================================
--- pt.c (revision 212098)
+++ pt.c (working copy)
@@ -3623,6 +3623,8 @@ reduce_template_parm_level (tree index,
TREE_CODE (orig_decl), DECL_NAME (orig_decl), type);
TREE_CONSTANT (decl) = TREE_CONSTANT (orig_decl);
TREE_READONLY (decl) = TREE_READONLY (orig_decl);
+ if (TREE_CODE (decl) == TYPE_DECL)
+ TREE_PUBLIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
SET_DECL_TEMPLATE_PARM_P (decl);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [C++] make TYPE_DECLs public for builtin type and templates
2014-06-30 22:28 [C++] make TYPE_DECLs public for builtin type and templates Jan Hubicka
@ 2014-07-01 23:10 ` Jason Merrill
2014-07-02 2:42 ` Jan Hubicka
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2014-07-01 23:10 UTC (permalink / raw)
To: Jan Hubicka, gcc-patches
On 06/30/2014 03:27 PM, Jan Hubicka wrote:
> This catches two cases in C++ FE and several other cases elsewhere.
> Does something like this make sense? I think bulitin_types are
> generally public, but I am not quite sure about templates.
Template parms have no linkage, but they certainly don't prevent a
template from being public. So I guess setting TREE_PUBLIC makes sense.
> I also wonder if I should copy
> PUBLIC flag from component type in complex numbers - can we produce complex
> number from anonymous type?
Only from built-in types I think, but it wouldn't hurt to copy
TREE_PUBLIC from component_type.
> Finally type_in_anonymous_namespace_p needs to be extended into two cases where
> the type is considered nonanonymous by lack of DECL_NAME.
I would think the right fix is to avoid calling it for non-class types?
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [C++] make TYPE_DECLs public for builtin type and templates
2014-07-01 23:10 ` Jason Merrill
@ 2014-07-02 2:42 ` Jan Hubicka
2014-07-06 18:41 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Jan Hubicka @ 2014-07-02 2:42 UTC (permalink / raw)
To: Jason Merrill; +Cc: Jan Hubicka, gcc-patches
> On 06/30/2014 03:27 PM, Jan Hubicka wrote:
> >This catches two cases in C++ FE and several other cases elsewhere.
> >Does something like this make sense? I think bulitin_types are
> >generally public, but I am not quite sure about templates.
>
> Template parms have no linkage, but they certainly don't prevent a
> template from being public. So I guess setting TREE_PUBLIC makes
> sense.
>
> >I also wonder if I should copy
> >PUBLIC flag from component type in complex numbers - can we produce complex
> >number from anonymous type?
>
> Only from built-in types I think, but it wouldn't hurt to copy
> TREE_PUBLIC from component_type.
OK, I updated my copy of the patch.
>
> >Finally type_in_anonymous_namespace_p needs to be extended into two cases where
> >the type is considered nonanonymous by lack of DECL_NAME.
>
> I would think the right fix is to avoid calling it for non-class types?
I am trying to make LTO tree streaming to not unify types that are known to be local
to a compilation unit. This allows better TBAA to be preserved, since two anonymous
namespace types from two different unit are not the same.
I want to avoid the overhead of SCC hashing and canonical type computation for these
and here I want the concept of anonymous namespace types to be closed upwards.
That is if I have type that is not considered anonymous it should not be built from
non-anonymous types.
So here I need to test anonymity of non-class types...
Thanks for looking into this!
Honza
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [C++] make TYPE_DECLs public for builtin type and templates
2014-07-02 2:42 ` Jan Hubicka
@ 2014-07-06 18:41 ` Jason Merrill
0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2014-07-06 18:41 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches
On 07/01/2014 07:40 PM, Jan Hubicka wrote:
> I want to avoid the overhead of SCC hashing and canonical type computation for these
> and here I want the concept of anonymous namespace types to be closed upwards.
> That is if I have type that is not considered anonymous it should not be built from
> non-anonymous types.
>
> So here I need to test anonymity of non-class types...
OK. If you want to cover all compound types, you have more code to
write, to cover pointer/reference/offset types and parameter types of
function/method types.
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-06 18:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-30 22:28 [C++] make TYPE_DECLs public for builtin type and templates Jan Hubicka
2014-07-01 23:10 ` Jason Merrill
2014-07-02 2:42 ` Jan Hubicka
2014-07-06 18:41 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).