dalibocai
dalibocai

Reputation: 2347

insert a function call of char * parameter in llvm

In a llvm pass, how can I create a function of a char* parameter and insert a function call to it before the terminator instruction of a basic block? Please be specific.

Thanks, Bo

Upvotes: 0

Views: 780

Answers (1)

Richard Pennington
Richard Pennington

Reputation: 19985

The LLVM online demo should be able to help you: http://llvm.org/demo/index.cgi With it, you can not only see the LLVM IR generated for a program you type in, but you can also have it show the LLVM C++ code needed to generate the IR. For example, I tried:

void f(char *);

int main(int argc, char **argv) {
  char *p;
  int i = 1;
  if (i)
      f(p);
  return i;
}

The results are fairly easy to decipher.

Upvotes: 2

Related Questions