Skip to content

[NFC][ubsan] Expand lower-builtin-allow-check test #100677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions llvm/test/Transforms/lower-builtin-allow-check.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt < %s -passes='function(lower-allow-check)' -S | FileCheck %s --check-prefixes=NOPROFILE
; RUN: opt < %s -passes='function(lower-allow-check)' -lower-allow-check-random-rate=0 -S | FileCheck %s --check-prefixes=NONE
; RUN: opt < %s -passes='function(lower-allow-check)' -lower-allow-check-random-rate=1 -S | FileCheck %s --check-prefixes=ALL
; RUN: opt < %s -passes='require<profile-summary>,function(lower-allow-check)' -lower-allow-check-percentile-cutoff-hot=990000 -S | FileCheck %s --check-prefixes=HOT99
; RUN: opt < %s -passes='require<profile-summary>,function(lower-allow-check)' -lower-allow-check-percentile-cutoff-hot=700000 -S | FileCheck %s --check-prefixes=HOT70

Expand Down Expand Up @@ -36,6 +37,19 @@ define dso_local noundef i32 @simple(ptr noundef readonly %0) {
; NONE-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
; NONE-NEXT: ret i32 [[TMP5]]
;
; ALL-LABEL: define dso_local noundef i32 @simple(
; ALL-SAME: ptr noundef readonly [[TMP0:%.*]]) {
; ALL-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP0]], null
; ALL-NEXT: [[HOT:%.*]] = xor i1 true, true
; ALL-NEXT: [[TMP2:%.*]] = or i1 [[CHK]], [[HOT]]
; ALL-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
; ALL: 3:
; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22)
; ALL-NEXT: unreachable
; ALL: 4:
; ALL-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
; ALL-NEXT: ret i32 [[TMP5]]
;
; HOT99-LABEL: define dso_local noundef i32 @simple(
; HOT99-SAME: ptr noundef readonly [[TMP0:%.*]]) {
; HOT99-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
Expand Down Expand Up @@ -105,6 +119,19 @@ define dso_local noundef i32 @hot(ptr noundef readonly %0) !prof !36 {
; NONE-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
; NONE-NEXT: ret i32 [[TMP5]]
;
; ALL-LABEL: define dso_local noundef i32 @hot(
; ALL-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] {
; ALL-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP0]], null
; ALL-NEXT: [[HOT:%.*]] = xor i1 true, true
; ALL-NEXT: [[TMP2:%.*]] = or i1 [[CHK]], [[HOT]]
; ALL-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
; ALL: 3:
; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22)
; ALL-NEXT: unreachable
; ALL: 4:
; ALL-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
; ALL-NEXT: ret i32 [[TMP5]]
;
; HOT99-LABEL: define dso_local noundef i32 @hot(
; HOT99-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF16:![0-9]+]] {
; HOT99-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
Expand Down Expand Up @@ -173,6 +200,19 @@ define dso_local noundef i32 @veryHot(ptr noundef readonly %0) !prof !39 {
; NONE-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
; NONE-NEXT: ret i32 [[TMP5]]
;
; ALL-LABEL: define dso_local noundef i32 @veryHot(
; ALL-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] {
; ALL-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP0]], null
; ALL-NEXT: [[HOT:%.*]] = xor i1 true, true
; ALL-NEXT: [[TMP2:%.*]] = or i1 [[CHK]], [[HOT]]
; ALL-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
; ALL: 3:
; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22)
; ALL-NEXT: unreachable
; ALL: 4:
; ALL-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
; ALL-NEXT: ret i32 [[TMP5]]
;
; HOT99-LABEL: define dso_local noundef i32 @veryHot(
; HOT99-SAME: ptr noundef readonly [[TMP0:%.*]]) !prof [[PROF17:![0-9]+]] {
; HOT99-NEXT: [[TMP2:%.*]] = icmp eq ptr [[TMP0]], null
Expand Down Expand Up @@ -254,6 +294,25 @@ define dso_local noundef i32 @branchColdFnHot(i32 noundef %0, ptr noundef readon
; NONE-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
; NONE-NEXT: ret i32 [[TMP10]]
;
; ALL-LABEL: define dso_local noundef i32 @branchColdFnHot(
; ALL-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF17]] {
; ALL-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
; ALL-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF18:![0-9]+]]
; ALL: 4:
; ALL-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP1]], null
; ALL-NEXT: [[HOT:%.*]] = xor i1 true, true
; ALL-NEXT: [[TMP5:%.*]] = or i1 [[CHK]], [[HOT]]
; ALL-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]]
; ALL: 6:
; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22)
; ALL-NEXT: unreachable
; ALL: 7:
; ALL-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
; ALL-NEXT: br label [[TMP9]]
; ALL: 9:
; ALL-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
; ALL-NEXT: ret i32 [[TMP10]]
;
; HOT99-LABEL: define dso_local noundef i32 @branchColdFnHot(
; HOT99-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF17]] {
; HOT99-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
Expand Down Expand Up @@ -354,6 +413,25 @@ define dso_local noundef i32 @branchHotFnCold(i32 noundef %0, ptr noundef readon
; NONE-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
; NONE-NEXT: ret i32 [[TMP10]]
;
; ALL-LABEL: define dso_local noundef i32 @branchHotFnCold(
; ALL-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF16]] {
; ALL-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
; ALL-NEXT: br i1 [[TMP3]], label [[TMP9:%.*]], label [[TMP4:%.*]], !prof [[PROF19:![0-9]+]]
; ALL: 4:
; ALL-NEXT: [[CHK:%.*]] = icmp eq ptr [[TMP1]], null
; ALL-NEXT: [[HOT:%.*]] = xor i1 true, true
; ALL-NEXT: [[TMP5:%.*]] = or i1 [[CHK]], [[HOT]]
; ALL-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]]
; ALL: 6:
; ALL-NEXT: tail call void @llvm.ubsantrap(i8 22)
; ALL-NEXT: unreachable
; ALL: 7:
; ALL-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP1]], align 4
; ALL-NEXT: br label [[TMP9]]
; ALL: 9:
; ALL-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP7]] ], [ 0, [[TMP2:%.*]] ]
; ALL-NEXT: ret i32 [[TMP10]]
;
; HOT99-LABEL: define dso_local noundef i32 @branchHotFnCold(
; HOT99-SAME: i32 noundef [[TMP0:%.*]], ptr noundef readonly [[TMP1:%.*]]) !prof [[PROF16]] {
; HOT99-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP0]], 0
Expand Down Expand Up @@ -450,6 +528,11 @@ define dso_local noundef i32 @branchHotFnCold(i32 noundef %0, ptr noundef readon
; NONE: [[PROF18]] = !{!"branch_weights", i32 1000, i32 1}
; NONE: [[PROF19]] = !{!"branch_weights", i32 1, i32 1000}
;.
; ALL: [[PROF16]] = !{!"function_entry_count", i64 1000}
; ALL: [[PROF17]] = !{!"function_entry_count", i64 7000}
; ALL: [[PROF18]] = !{!"branch_weights", i32 1000, i32 1}
; ALL: [[PROF19]] = !{!"branch_weights", i32 1, i32 1000}
;.
; HOT99: [[PROF16]] = !{!"function_entry_count", i64 1000}
; HOT99: [[PROF17]] = !{!"function_entry_count", i64 7000}
; HOT99: [[PROF18]] = !{!"branch_weights", i32 1000, i32 1}
Expand Down
Loading