Using bugpoint
In this recipe, you will learn about a useful tool provided by LLVM infrastructure, known as bugpoint. Bugpoint allows us to narrow down the source of problems in the LLVM's tools and passes. It is helpful in debugging optimizer crashes, miscompilations by optimizers, or bad native code generation. Using this, we can get a small test case for our problem and work on that.
Getting ready
You need to build and install LLVM.
How to do it…
Perform the following steps:
Write the test cases using the bugpoint tool:
$ cat crash-narrowfunctiontest.ll define i32 @foo() { ret i32 1 } define i32 @test() { call i32 @test() ret i32 %1 } define i32 @bar() { ret i32 2 }
Use bugpoint in this test case to view the results :
$ bugpoint -load path-to-llvm/build/./lib/BugpointPasses.so crash-narrowfunctiontest.ll -output-prefix crash-narrowfunctiontest.ll.tmp -bugpoint-cras hcalls -silence-passes Read input file : 'crash-narrowfunctiontest.ll' *** All input ok Running selected passes on...