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
121 lines
4.9 KiB
LLVM
121 lines
4.9 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
|
|
; RUN: opt -passes=tailcallelim -S %s -o - | FileCheck %s --check-prefixes=CHECK,ENABLED
|
|
; RUN: opt -passes=tailcallelim -tre-disable-entrycount-recompute -S %s -o - | FileCheck %s --check-prefixes=CHECK,DISABLED
|
|
|
|
; Test that tail call elimination correctly adjusts function entry counts
|
|
; when eliminating tail recursive calls.
|
|
|
|
; Basic test: eliminate a tail call and adjust entry count
|
|
define i32 @test_basic_entry_count_adjustment(i32 %n) !prof !0 {
|
|
; CHECK-LABEL: @test_basic_entry_count_adjustment(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: br label [[TAILRECURSE:%.*]]
|
|
; CHECK: tailrecurse:
|
|
; CHECK-NEXT: [[N_TR:%.*]] = phi i32 [ [[N:%.*]], [[ENTRY:%.*]] ], [ [[SUB:%.*]], [[IF_THEN:%.*]] ]
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N_TR]], 0
|
|
; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN]], label [[IF_ELSE:%.*]], !prof [[PROF1:![0-9]+]]
|
|
; CHECK: if.then:
|
|
; CHECK-NEXT: [[SUB]] = sub i32 [[N_TR]], 1
|
|
; CHECK-NEXT: br label [[TAILRECURSE]]
|
|
; CHECK: if.else:
|
|
; CHECK-NEXT: ret i32 0
|
|
;
|
|
entry:
|
|
%cmp = icmp sgt i32 %n, 0
|
|
br i1 %cmp, label %if.then, label %if.else, !prof !1
|
|
|
|
if.then: ; preds = %entry
|
|
%sub = sub i32 %n, 1
|
|
%call = tail call i32 @test_basic_entry_count_adjustment(i32 %sub)
|
|
ret i32 %call
|
|
|
|
if.else: ; preds = %entry
|
|
ret i32 0
|
|
}
|
|
|
|
; Test multiple tail calls in different blocks with different frequencies
|
|
define i32 @test_multiple_blocks_entry_count(i32 %n, i32 %flag) !prof !2 {
|
|
; CHECK-LABEL: @test_multiple_blocks_entry_count(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: br label [[TAILRECURSE:%.*]]
|
|
; CHECK: tailrecurse:
|
|
; CHECK-NEXT: [[N_TR:%.*]] = phi i32 [ [[N:%.*]], [[ENTRY:%.*]] ], [ [[SUB1:%.*]], [[BLOCK1:%.*]] ], [ [[SUB2:%.*]], [[BLOCK2:%.*]] ]
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N_TR]], 0
|
|
; CHECK-NEXT: br i1 [[CMP]], label [[CHECK_FLAG:%.*]], label [[BASE_CASE:%.*]], !prof [[PROF3:![0-9]+]]
|
|
; CHECK: check.flag:
|
|
; CHECK-NEXT: [[CMP_FLAG:%.*]] = icmp eq i32 [[FLAG:%.*]], 1
|
|
; CHECK-NEXT: br i1 [[CMP_FLAG]], label [[BLOCK1]], label [[BLOCK2]], !prof [[PROF4:![0-9]+]]
|
|
; CHECK: block1:
|
|
; CHECK-NEXT: [[SUB1]] = sub i32 [[N_TR]], 1
|
|
; CHECK-NEXT: br label [[TAILRECURSE]]
|
|
; CHECK: block2:
|
|
; CHECK-NEXT: [[SUB2]] = sub i32 [[N_TR]], 2
|
|
; CHECK-NEXT: br label [[TAILRECURSE]]
|
|
; CHECK: base.case:
|
|
; CHECK-NEXT: ret i32 1
|
|
;
|
|
entry:
|
|
%cmp = icmp sgt i32 %n, 0
|
|
br i1 %cmp, label %check.flag, label %base.case, !prof !3
|
|
check.flag:
|
|
%cmp.flag = icmp eq i32 %flag, 1
|
|
br i1 %cmp.flag, label %block1, label %block2, !prof !4
|
|
block1: ; preds = %check.flag
|
|
%sub1 = sub i32 %n, 1
|
|
%call1 = tail call i32 @test_multiple_blocks_entry_count(i32 %sub1, i32 %flag)
|
|
ret i32 %call1
|
|
block2: ; preds = %check.flag
|
|
%sub2 = sub i32 %n, 2
|
|
%call2 = tail call i32 @test_multiple_blocks_entry_count(i32 %sub2, i32 %flag)
|
|
ret i32 %call2
|
|
base.case: ; preds = %entry
|
|
ret i32 1
|
|
}
|
|
|
|
define i32 @test_no_entry_count(i32 %n) {
|
|
; CHECK-LABEL: @test_no_entry_count(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: br label [[TAILRECURSE:%.*]]
|
|
; CHECK: tailrecurse:
|
|
; CHECK-NEXT: [[N_TR:%.*]] = phi i32 [ [[N:%.*]], [[ENTRY:%.*]] ], [ [[SUB:%.*]], [[IF_THEN:%.*]] ]
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N_TR]], 0
|
|
; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN]], label [[IF_ELSE:%.*]]
|
|
; CHECK: if.then:
|
|
; CHECK-NEXT: [[SUB]] = sub i32 [[N_TR]], 1
|
|
; CHECK-NEXT: br label [[TAILRECURSE]]
|
|
; CHECK: if.else:
|
|
; CHECK-NEXT: ret i32 0
|
|
;
|
|
entry:
|
|
%cmp = icmp sgt i32 %n, 0
|
|
br i1 %cmp, label %if.then, label %if.else
|
|
|
|
if.then: ; preds = %entry
|
|
%sub = sub i32 %n, 1
|
|
%call = tail call i32 @test_no_entry_count(i32 %sub)
|
|
ret i32 %call
|
|
|
|
if.else: ; preds = %entry
|
|
ret i32 0
|
|
}
|
|
|
|
; Function entry count metadata
|
|
!0 = !{!"function_entry_count", i64 1000}
|
|
!1 = !{!"branch_weights", i32 800, i32 200}
|
|
!2 = !{!"function_entry_count", i64 2000}
|
|
!3 = !{!"branch_weights", i32 3, i32 1}
|
|
!4 = !{!"branch_weights", i32 100, i32 900}
|
|
;.
|
|
; ENABLED: [[META0:![0-9]+]] = !{!"function_entry_count", i64 200}
|
|
; ENABLED: [[PROF1]] = !{!"branch_weights", i32 800, i32 200}
|
|
; ENABLED: [[META2:![0-9]+]] = !{!"function_entry_count", i64 500}
|
|
; ENABLED: [[PROF3]] = !{!"branch_weights", i32 3, i32 1}
|
|
; ENABLED: [[PROF4]] = !{!"branch_weights", i32 100, i32 900}
|
|
;.
|
|
; DISABLED: [[META0:![0-9]+]] = !{!"function_entry_count", i64 1000}
|
|
; DISABLED: [[PROF1]] = !{!"branch_weights", i32 800, i32 200}
|
|
; DISABLED: [[META2:![0-9]+]] = !{!"function_entry_count", i64 2000}
|
|
; DISABLED: [[PROF3]] = !{!"branch_weights", i32 3, i32 1}
|
|
; DISABLED: [[PROF4]] = !{!"branch_weights", i32 100, i32 900}
|
|
;.
|