This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

declare global in gimple


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]