Other optimization passes

In this recipe, we will look at some more transformational passes, which are more like of utility passes. We will look at the strip-debug-symbols pass and the prune-eh pass.

Getting ready…

The opt tool must be installed.

How to do it…

  1. Write a test case for checking the strip-debug pass, which strips off the debug symbols from the test code:
    $ cat teststripdebug.ll
    @x = common global i32 0                          ; <i32*> [#uses=0]
    
    define void @foo() nounwind readnone optsize ssp {
    entry:
      tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !5, metadata !{}), !dbg !10
      ret void, !dbg !11
    }
    
    declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
    
    !llvm.dbg.cu = !{!2}
    !llvm.module.flags = !{!13}
    !llvm.dbg.sp = !{!0} ...

Get LLVM Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.