(The profile format change is split into a standalone change into https://github.com/llvm/llvm-project/pull/81691) * For InstrFDO value profiling, implement instrumentation and lowering for virtual table address. * This is controlled by `-enable-vtable-value-profiling` and off by default. * When the option is on, raw profiles will carry serialized `VTableProfData` structs and compressed vtables as payloads. * Implement profile reader and writer support * Raw profile reader is used by `llvm-profdata` but not compiler. Raw profile reader will construct InstrProfSymtab with symbol names, and map profiled runtime address to vtable symbols. * Indexed profile reader is used by `llvm-profdata` and compiler. When initialized, the reader stores a pointer to the beginning of in-memory compressed vtable names and the length of string. When used in `llvm-profdata`, reader decompress the string to show symbols of a profiled site. When used in compiler, string decompression doesn't happen since IR is used to construct InstrProfSymtab. * Indexed profile writer collects the list of vtable names, and stores that to index profiles. * Text profile reader and writer support are added but mostly follow the implementation for indirect-call value type. * `llvm-profdata show -show-vtables <args> <profile>` is implemented. rfc in https://discourse.llvm.org/t/rfc-dynamic-type-profiling-and-optimizations-in-llvm/74600#pick-instrumentation-points-and-instrument-runtime-types-7
35 lines
1.3 KiB
LLVM
35 lines
1.3 KiB
LLVM
; RUN: opt < %s -passes=pgo-instr-gen -enable-vtable-value-profiling -S 2>&1 | FileCheck %s
|
|
|
|
; Test that unsupported warning is emitted for non-ELF object files.
|
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
|
target triple = "arm64-apple-macosx14.0.0"
|
|
|
|
; CHECK: warning: {{.*}} VTable value profiling is presently not supported for non-ELF object formats
|
|
|
|
@_ZTV4Base = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN4Base4funcEi] }, !type !0, !type !1
|
|
@_ZTV7Derived = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN7Derived4funcEi] }, !type !0, !type !1, !type !2, !type !3
|
|
|
|
@llvm.compiler.used = appending global [2 x ptr] [ptr @_ZTV4Base, ptr @_ZTV7Derived], section "llvm.metadata"
|
|
|
|
define i32 @_Z4funci(i32 %a) {
|
|
entry:
|
|
%call = call ptr @_Z10createTypev()
|
|
%vtable = load ptr, ptr %call
|
|
%0 = call i1 @llvm.public.type.test(ptr %vtable, metadata !"_ZTS7Derived")
|
|
call void @llvm.assume(i1 %0)
|
|
%1 = load ptr, ptr %vtable
|
|
%call1 = call i32 %1(ptr %call, i32 %a)
|
|
ret i32 %call1
|
|
}
|
|
|
|
declare ptr @_Z10createTypev()
|
|
declare i1 @llvm.public.type.test(ptr, metadata)
|
|
declare void @llvm.assume(i1)
|
|
declare i32 @_ZN4Base4funcEi(ptr, i32)
|
|
declare i32 @_ZN7Derived4funcEi(ptr , i32)
|
|
|
|
!0 = !{i64 16, !"_ZTS4Base"}
|
|
!1 = !{i64 16, !"_ZTSM4BaseFiiE.virtual"}
|
|
!2 = !{i64 16, !"_ZTS7Derived"}
|
|
!3 = !{i64 16, !"_ZTSM7DerivedFiiE.virtual"}
|