LLVM Discussion Forums

How can I create some sample function in FunctionPass?

I want to create some sample function in FunctionPass(Optimizer) like below.

void sampleFunc(char * string, int size){
for(int i=0; i<size; i++){
string ^= string[i];

I don’t know how can i approach it.

can you give me some advice?

I don’t think you can create a Function inside a FunctionPass, you should use a ModulePass for this.
Otherwise the process for creating a function is in Chapter 3 of the Kaleidoscope tutorial, feel to ask specific questions if you encounter issues.