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
- identify the 1st argument is a constant character array
- 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