hello guys,
recently, i successfully get and modify global variable by execution engine.
the functions i used are listed here:
int m=1;
EE->updateGlobalMapping(p->M->getGlobalVariable("x",true),&m);
EE->recompileAndRelinkFunction(EntryFn);
x is the global variable in the module.
but how to modify the local variable in the module?
Dong Chen <jameschennerd@gmail.com> writes:
hello guys,
recently, i successfully get and modify global variable by execution engine.
the functions i used are listed here:
int m=1;
EE->updateGlobalMapping(p->M->getGlobalVariable("x",true),&m);
EE->recompileAndRelinkFunction(EntryFn);
x is the global variable in the module.
but how to modify the local variable in the module?
A local variable does not exists until the function that defines it is
executed, so pretending to get and modify it as you do for the global
makes no sense.
hello Óscar Fuentes,
thanks for your reply, if i use the API provided by parser.h and the program
*.ll i parsed contains local variable, i can get a module have local
variable without defines it first.
i think that module is a structure like AST(i am not sure whether i was
right), this must be a traversal method. am i right or do i misunderstand
something?
Dong Chen <jameschennerd@gmail.com> writes:
hello Óscar Fuentes,
thanks for your reply, if i use the API provided by parser.h and the program
*.ll i parsed contains local variable, i can get a module have local
variable without defines it first.
i think that module is a structure like AST(i am not sure whether i was
right), this must be a traversal method. am i right or do i misunderstand
something?
Yes, you can traverse the functions and the basic blocks inside those
functions, but how do you detect a local variable? LLVM IR is in SSA
form plus memory loads/stores. A local variable, as you see it in the
original source code (C, C++ or other language) might not clearly map to
a local variable in LLVM IR, depending on how you generate the IR and/or
the passes you run on it.
hi Óscar Fuentes,
i am new to llvm, so i still have several questions. thanks for you help.
(1)what is SSA form(static single assignment)?
(2)how to traverse the basic blocks? if the module is gained by parser, what
will the basic blocks contain?
i will be on the line, thank you very much
Dong Chen <jameschennerd@gmail.com> writes:
i am new to llvm, so i still have several questions. thanks for you help.
(1)what is SSA form(static single assignment)?
Yes.
(2)how to traverse the basic blocks? if the module is gained by parser, what
will the basic blocks contain?
Once the LLVM IR bytecode is loaded (or the LLVM assembler is parsed)
you have the same C++ objects that you previously generated when you
emitted the IR from your compiler. As for traversing those C++ objects
for examining the IR or transforming it, see
hi Óscar Fuentes ,
thanks for your reply, but there are still a lot of concepts i don't
understand. there seems to be some document to guide you but hard to
understand. can you show me some basic and easy to learn document or
websites?
thank you
Dong Chen <jameschennerd@gmail.com> writes:
thanks for your reply, but there are still a lot of concepts i don't
understand. there seems to be some document to guide you but hard to
understand. can you show me some basic and easy to learn document or
websites?
What's missing from About — LLVM 16.0.0git documentation ?
hello Óscar Fuentes,
can i change a local variable's value through iterator? have you ever tried
that?