This patch introduces the new .bb_addr_map section feature which allows us to emit the bits needed for mapping binary profiles to basic blocks into a separate section. The format of the emitted data is represented as follows. It includes a header for every function: | Address of the function | -> 8 bytes (pointer size) | Number of basic blocks in this function (>0) | -> ULEB128 The header is followed by a BB record for every basic block. These records are ordered in the same order as MachineBasicBlocks are placed in the function. Each BB Info is structured as follows: | Offset of the basic block relative to function begin | -> ULEB128 | Binary size of the basic block | -> ULEB128 | BB metadata | -> ULEB128 [ MBB.isReturn() OR MBB.hasTailCall() << 1 OR MBB.isEHPad() << 2 ] The new feature will replace the existing "BB labels" functionality with -basic-block-sections=labels. The .bb_addr_map section scrubs the specially-encoded BB symbols from the binary and makes it friendly to profilers and debuggers. Furthermore, the new feature reduces the binary size overhead from 70% bloat to only 12%. For more information and results please refer to the RFC: https://lists.llvm.org/pipermail/llvm-dev/2020-July/143512.html Reviewed By: MaskRay, snehasish Differential Revision: https://reviews.llvm.org/D85408
57 lines
1.4 KiB
LLVM
57 lines
1.4 KiB
LLVM
; Check the basic block sections labels option
|
|
; RUN: llc < %s -mtriple=x86_64 -function-sections -basic-block-sections=labels | FileCheck %s
|
|
|
|
define void @_Z3bazb(i1 zeroext) personality i32 (...)* @__gxx_personality_v0 {
|
|
br i1 %0, label %2, label %7
|
|
|
|
2:
|
|
%3 = invoke i32 @_Z3barv()
|
|
to label %7 unwind label %5
|
|
br label %9
|
|
|
|
5:
|
|
landingpad { i8*, i32 }
|
|
catch i8* null
|
|
br label %9
|
|
|
|
7:
|
|
%8 = call i32 @_Z3foov()
|
|
br label %9
|
|
|
|
9:
|
|
ret void
|
|
}
|
|
|
|
declare i32 @_Z3barv() #1
|
|
|
|
declare i32 @_Z3foov() #1
|
|
|
|
declare i32 @__gxx_personality_v0(...)
|
|
|
|
; CHECK-LABEL: _Z3bazb:
|
|
; CHECK-LABEL: .Lfunc_begin0:
|
|
; CHECK-LABEL: .LBB_END0_0:
|
|
; CHECK-LABEL: .LBB0_1:
|
|
; CHECK-LABEL: .LBB_END0_1:
|
|
; CHECK-LABEL: .LBB0_2:
|
|
; CHECK-LABEL: .LBB_END0_2:
|
|
; CHECK-LABEL: .LBB0_3:
|
|
; CHECK-LABEL: .LBB_END0_3:
|
|
; CHECK-LABEL: .Lfunc_end0:
|
|
|
|
; CHECK: .section .bb_addr_map,"o",@progbits,.text
|
|
; CHECK-NEXT: .quad .Lfunc_begin0
|
|
; CHECK-NEXT: .byte 4
|
|
; CHECK-NEXT: .uleb128 .Lfunc_begin0-.Lfunc_begin0
|
|
; CHECK-NEXT: .uleb128 .LBB_END0_0-.Lfunc_begin0
|
|
; CHECK-NEXT: .byte 0
|
|
; CHECK-NEXT: .uleb128 .LBB0_1-.Lfunc_begin0
|
|
; CHECK-NEXT: .uleb128 .LBB_END0_1-.LBB0_1
|
|
; CHECK-NEXT: .byte 0
|
|
; CHECK-NEXT: .uleb128 .LBB0_2-.Lfunc_begin0
|
|
; CHECK-NEXT: .uleb128 .LBB_END0_2-.LBB0_2
|
|
; CHECK-NEXT: .byte 1
|
|
; CHECK-NEXT: .uleb128 .LBB0_3-.Lfunc_begin0
|
|
; CHECK-NEXT: .uleb128 .LBB_END0_3-.LBB0_3
|
|
; CHECK-NEXT: .byte 5
|