blob: 3a1653ff46c484def15a331e99434c8444466828 [file] [edit]
;; Test that AMDGPU PGO instrumentation generates library calls for Wave32.
;; Verifies sampling guard and __llvm_profile_instrument_gpu call with correct
;; addrspace(1) counter pointers.
; RUN: opt %s -mtriple=amdgpu-amd-amdhsa -passes=instrprof -S | FileCheck %s
@__hip_cuid_abcdef456 = addrspace(1) global i8 0
@__profn_kernel_w32 = private constant [10 x i8] c"kernel_w32"
define amdgpu_kernel void @kernel_w32() #0 {
call void @llvm.instrprof.increment(ptr @__profn_kernel_w32, i64 12345, i32 1, i32 0)
ret void
}
declare void @llvm.instrprof.increment(ptr, i64, i32, i32)
attributes #0 = { "target-cpu"="gfx1100" }
;; Per-function comdat counters + uniform counters
; CHECK: @__profc_kernel_w32 = linkonce_odr protected addrspace(1) global [1 x i64]
; CHECK: @__llvm_prf_unifcnt_kernel_w32 = linkonce_odr protected addrspace(1) global [1 x i64]
; CHECK: @__profd_kernel_w32 = linkonce_odr protected addrspace(1) global { {{.*}} i16 0, i32 0 }
;; Check wave size stored via intrinsic
; CHECK: %wavesize.i16 = trunc i32 %{{.*}} to i16
; CHECK: store i16 %wavesize.i16, ptr addrspace(1) getelementptr inbounds {{.*}} @__profd_kernel_w32
;; Check sampling guard (default sampling=3)
; CHECK: %pgo.sampled = call i32 @__llvm_profile_sampling_gpu(i32 3)
; CHECK: %pgo.matched = icmp ne i32 %pgo.sampled, 0
; CHECK: br i1 %pgo.matched, label %po_then, label %po_cont
;; Check library call
; CHECK: po_then:
; CHECK: call void @__llvm_profile_instrument_gpu(ptr addrspacecast (ptr addrspace(1) @__profc_kernel_w32 to ptr), ptr addrspacecast (ptr addrspace(1) @__llvm_prf_unifcnt_kernel_w32 to ptr), i64 1)