[LLVMdev] Problem about the type of Function's arguement in llvm
Jianfei Hu
hujianfei258 at gmail.com
Sun Apr 22 05:36:38 PDT 2012
in the tutorial of official llvm doc, chapter 3, it deals with arguement
of function as follow:
for (Function::arg_iterator AI = F->arg_begin(); Idx != Args.size();
++AI, ++Idx) {
AI->setName(Args[Idx]);
// NamedValues is map<string, Value*>
NamedValues[Args[Idx]] = AI;
and when it try to get the value of arguement, it simply does:
Value *VariableExprAST::Codegen() {
Value *V = NamedValues[Name];
return V ? V : ErrorV("Unknown variable name");
}
It means that we can access value of arguement directly.
However, in llvm.org/demo and the chapter 6 of tutorial, it deals with
arguemnt:
1. allocate memory for arguement
2. then store the arguemnt into the memory.
3. CreateLoad() to load the arguement when accessing the value of arguement.
I have several problems:
Which way should I follow to get the vale of arguement?
When I tried to use CreateLoad(arguement), the program gives a segmentation
error.
Does this result from the wrong type of argument, unsuitable to be the
params of CreateLoad()?
If it is, what's the type of Function->arg_begin() ? (The source code is
too nested for me to find the original type of that)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120422/62c5a10e/attachment.html>
More information about the llvm-dev
mailing list