[llvm-dev] Compiling a benchmark to IR (either from test-suite, or other benchmarks)

Gus Smith via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 27 08:20:26 PST 2018

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_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

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


On Mon, Feb 26, 2018 at 1:04 PM, Matthias Braun <mbraun at apple.com> wrote:

> 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
> On Feb 26, 2018, at 9:42 AM, Gus Smith via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
> Hello all.
> 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
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

*Gus Smith*
Penn State University
M.S./B.S. Computer Science and Engineering '18

Microsystems Design Lab - Researcher

(570)817-9340 | hfs5022 at psu.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180227/fea3aee2/attachment.html>

More information about the llvm-dev mailing list