Hello everyone,
I am trying to add checkpoints to my IR code. In order to do that I need to add this instruction:
call void @m5_checkpoint(i64 0, i64 0)
to some of the basic blocks in my benchmark.
m5_checkpoint is a function defined for checkpointing in another simulator and is not included in my benchmark source code. So I need to create this instruction and I couldn’t figure out how to do this by reading the manual. I will appreciate if anyone can help me .
Also, when you encounter questions for LLVM C++ APIs in the future, you can write desired output code and use llc to generate proper C++API code, which I think is a very neat feature of LLVM.
e.g.
clang -c -emit-llvm your_desired_output.c
llc -march=cpp your_desired_output.bc
The bc file is the bitcode version of the program IR for LLVM, you could generate it by clang:
$ clang -c -emit-llvm hello.c -o hello.bc
And llc is the LLVM bitcode compiler, which turns LLVM IR into executables. But it also supports turning IR into C++ code that uses LLVM API to generate the corresponding IR. I think it’s a good reference for using LLVM C++ API. For example if you want to understand how you should use LLVM C++ API to generate code in hello.c (and therefore hello.bc as IR), try using the following:
$ llc -march=cpp hello.bc -o hello.cpp
The hello.cpp should contain the C++ code that uses C++ API to generate corresponding IR.