O'Reilly logo

LLVM Cookbook by Suyog Sarda, Mayur Pandey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. 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 }
    
  2. Use bugpoint in this test case to view the results :
    $ bugpoint -load path-to-llvm/build/./lib/BugpointPasses.so ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required