[LLVMdev] Outputting constant char array from llvm pass
Kangkook Jee
aixer77 at gmail.com
Fri Jun 21 19:16:27 PDT 2013
Hi, all
I want to know how a llvm pass output constant char array defined from the input
source. Here's an example that I want to do.
== test input source ==
char* msg = "hello, world\n";
void msg_out(char * in) {
printf("msg: %s \n", in);
}
main () {
...
msg_out(msg);
...
}
== llvm pass snippet ==
...
const CallInst* ci = dyn_cast<CallInst>(val);
const Function* func = ci->getCalledFunction();
if (func->getName() == "msg_out") {
errs() << ci->getOperand(0);
}
...
With the source, the above llvm pass would print the following output.
== output ==
i8* getelementptr inbounds ([8 x i8]* @10, i32 0, i32 0)
However, what I want to implement instead is
i) identify the 1st argument is a constant character array
ii) if so, print out "hello, world\n"
Can anyone let me know how to implement this?
Thanks a lot for your help in advance!
/Kangkook
More information about the llvm-dev
mailing list