I’m in need of a benchmark that can be compiled to IR or bytecode. I found the test-suite project (https://llvm.org/docs/TestSuiteMakefileGuide.html) and thought a benchmark in that project might work. However, I’m having trouble figuring out how to actually compile any of the benchmarks to IR or bytecode. Using cmake and make I can compile them to binaries, but at no point do I see any bytecode being produced.
The Makefiles in this project have rules for compiling and linking bytecode. Are there options I need to be passing to cmake or make?
Alternatively, are there other known benchmarks (and associated makefiles) that compile to IR/bytecode? I can go through the work of setting up benchmarks to compile to bc/IR, but I figured someone has likely already done this!
Thanks for the help,
Gus Smith, Penn State
There is no immediate support for this in the test-suite cmake buildsystem. There is something in the Makefile system indeed, but it lacks documentation and I’m not aware of any examples of how to use it.
I would recommend to use
CMAKE_C_FLAGS=--save-temps=obj cmake ... in the test-suite. The --save-temps=obj flag will make clang place a bitcode file next to each .o file.
Matthias – thanks for the response! That tip worked great for creating the .bc files. For posterity, this is the exact command I used:
cmake -DCMAKE_C_COMPILER=/path/to/llvm/build/bin/clang -DCMAKE_CXX_COMPILER=/path/to/llvm/build/bin/clang++ -DCMAKE_C_FLAGS=–save-temps=obj -DCMAKE_CXX_FLAGS=–save-temps=obj …
So now, I’ve got a bunch of .bc files sitting around in my build folder. For the SingleSource benchmarks, this is great, but eventually for bigger benchmarks I’ll need to get them linked all together. Does anyone have any clever ideas on how to do this other than just manually running
llvm-link to manually link all of them? Even that may not be feasible for bigger benchmarks.
Though I’ve used CMake/make for a while now, I’m unfamiliar with the order in which it actually compiles and links. However, I was thinking I might be able to force the “compile” step to take C/C++ files and produce .bc files, and the “link” step to take .bc files and link them together to produce a single .bc (instead of linking .o files to make a binary). I thought this might be achieved through manipulation of CMAKE_C[++]_FLAGS and other settings.