This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
declare global in gimple
- From: k9119911 <xxx-protoss at yahoo dot com dot tw>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 20 Aug 2015 19:51:15 -0700 (MST)
- Subject: declare global in gimple
- Authentication-results: sourceware.org; auth=none
Hi
I am writing a gimple pass and I need to declare a global variable in my
middle-end pass.
However, there is a problem. The following is my code:
{
tree var;
var = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("global"),
integer_type_node);
TREE_PUBLIC(var) = 1;
DECL_EXTERNAL(var) = 0;
//lang_hooks.decls.pushdecl(var);
//pushdecl(var);
}
I don't want it to be externel variable. Thus I need to pushdecl it.
However, if I put lang_hooks.decls.pushdecl(var), my pass would seg-fault
when I use the compiled gcc.
And if I put pushdecl there, then I cannot compile gcc because of undefined
reference to pushdecl.
And if I don't put both, then my declared global variable is undefined
reference.
I think lang_hooks.decls.pushdecl(var) can only be used in front-end, so how
can I declare
a global variable in middle-end?
Thanks
--
View this message in context: http://gcc.1065356.n5.nabble.com/declare-global-in-gimple-tp1178703.html
Sent from the gcc - Help mailing list archive at Nabble.com.