Using the ppprofiler pass with LLVM tools
Recall the ppprofiler pass that we developed as a plugin out of the LLVM tree in the Developing the ppprofiler pass as a plugin section. Here, we’ll learn how to use this pass with LLVM tools, such as opt and clang, as they can load plugins.
Let’s look at opt first.
Run the pass plugin in opt
To play around with the new plugin, you need a file containing LLVM IR. The easiest way to do this is to translate a C program, such as a basic “Hello World” style program:
#include <stdio.h>
int main(int argc, char *argv[]) {
puts("Hello");
return 0;
} Compile this file, hello.c, with clang:
$ clang -S -emit-llvm -O1 hello.c
You will get a very simple IR file called hello.ll that contains the following code:
$ cat hello.ll @.str = private unnamed_addr constant [6 x i8] c"Hello\00", align 1 define dso_local...