Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

93 lines
3.5 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes=jump-table-to-switch -S | FileCheck %s
;; Test that when target functions lack !guid metadata, the pass correctly
;; computes GUIDs from the target function names (not the caller's name)
;; for matching against value profile data. This is a regression test for
;; a bug where the caller function was used instead of the callee when
;; computing PGO function names for GUID lookup.
@jt = constant [2 x ptr] [ptr @jt_target_0, ptr @jt_target_1]
;; Note: these functions intentionally do NOT have !guid metadata,
;; forcing the pass to compute GUIDs via getIRPGOFuncName.
define i32 @jt_target_0() {
; CHECK-LABEL: define i32 @jt_target_0() {
; CHECK-NEXT: ret i32 10
;
ret i32 10
}
define i32 @jt_target_1() {
; CHECK-LABEL: define i32 @jt_target_1() {
; CHECK-NEXT: ret i32 20
;
ret i32 20
}
define i32 @caller(i32 %idx) {
; CHECK-LABEL: define i32 @caller(
; CHECK-SAME: i32 [[IDX:%.*]]) {
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @jt, i32 0, i32 [[IDX]]
; CHECK-NEXT: [[FPTR:%.*]] = load ptr, ptr [[GEP]], align 8
; CHECK-NEXT: switch i32 [[IDX]], label %[[DEFAULT_SWITCH_CASE_UNREACHABLE:.*]] [
; CHECK-NEXT: i32 0, label %[[CALL0:.*]]
; CHECK-NEXT: i32 1, label %[[CALL1:.*]]
; CHECK-NEXT: ], !prof [[PROF0:![0-9]+]]
; CHECK: [[DEFAULT_SWITCH_CASE_UNREACHABLE]]:
; CHECK-NEXT: unreachable
; CHECK: [[CALL0]]:
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @jt_target_0()
; CHECK-NEXT: br [[DOTTAIL:label %.*]]
; CHECK: [[CALL1]]:
; CHECK-NEXT: [[TMP2:%.*]] = call i32 @jt_target_1()
; CHECK-NEXT: br [[DOTTAIL]]
; CHECK: [[_TAIL:.*:]]
; CHECK-NEXT: [[TMP3:%.*]] = phi i32 [ [[TMP1]], %[[CALL0]] ], [ [[TMP2]], %[[CALL1]] ]
; CHECK-NEXT: ret i32 [[TMP3]]
;
%gep = getelementptr inbounds [2 x ptr], ptr @jt, i32 0, i32 %idx
%fptr = load ptr, ptr %gep
%r = call i32 %fptr(), !prof !0
ret i32 %r
}
define i32 @caller_only_zero_guids(i32 %idx) {
; CHECK-LABEL: define i32 @caller_only_zero_guids(
; CHECK-SAME: i32 [[IDX:%.*]]) {
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @jt, i32 0, i32 [[IDX]]
; CHECK-NEXT: [[FPTR:%.*]] = load ptr, ptr [[GEP]], align 8
; CHECK-NEXT: switch i32 [[IDX]], label %[[DEFAULT_SWITCH_CASE_UNREACHABLE:.*]] [
; CHECK-NEXT: i32 0, label %[[CALL_0:.*]]
; CHECK-NEXT: i32 1, label %[[CALL_1:.*]]
; CHECK-NEXT: ], !prof [[PROF1:![0-9]+]]
; CHECK: [[DEFAULT_SWITCH_CASE_UNREACHABLE]]:
; CHECK-NEXT: unreachable
; CHECK: [[CALL_0]]:
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @jt_target_0()
; CHECK-NEXT: br [[DOTTAIL:label %.*]]
; CHECK: [[CALL_1]]:
; CHECK-NEXT: [[TMP2:%.*]] = call i32 @jt_target_1()
; CHECK-NEXT: br [[DOTTAIL]]
; CHECK: [[_TAIL:.*:]]
; CHECK-NEXT: [[TMP3:%.*]] = phi i32 [ [[TMP1]], %[[CALL_0]] ], [ [[TMP2]], %[[CALL_1]] ]
; CHECK-NEXT: ret i32 [[TMP3]]
;
%gep = getelementptr inbounds [2 x ptr], ptr @jt, i32 0, i32 %idx
%fptr = load ptr, ptr %gep
%r = call i32 %fptr(), !prof !1
ret i32 %r
}
;; VP metadata: GUID 11912887233601027218 = MD5("jt_target_0"), count 100
;; GUID 18156790114353049777 = MD5("jt_target_1"), count 50
!0 = !{!"VP", i32 0, i64 150, i64 11912887233601027218, i64 100, i64 18156790114353049777, i64 50}
;; VP metadata with only a zero value.
!1 = !{!"VP", i32 0, i64 150, i64 0, i64 40}
;.
; CHECK: [[PROF0]] = !{!"branch_weights", i32 0, i32 100, i32 50}
; CHECK: [[PROF1]] = !{!"unknown", !"jump-table-to-switch"}
;.