[llvm] [SanitizerCoverage] Split test (NFC) (PR #226405)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 02:10:44 PDT 2026
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/226405
So these tests can actually be regenerated without heavy manual
editing.
>From bb4ef66aa4d3b19563210678d2a3bf959a0cf0f4 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Fri, 25 Sep 2026 11:09:01 +0200
Subject: [PATCH] [SanitizerCoverage] Split test (NFC)
So these tests can actually be regenerated without heavy manual
editing.
---
.../SanitizerCoverage/missing_dbg.ll | 94 +---------------
.../missing_dbg_stack_depth.ll | 101 ++++++++++++++++++
2 files changed, 102 insertions(+), 93 deletions(-)
create mode 100644 llvm/test/Instrumentation/SanitizerCoverage/missing_dbg_stack_depth.ll
diff --git a/llvm/test/Instrumentation/SanitizerCoverage/missing_dbg.ll b/llvm/test/Instrumentation/SanitizerCoverage/missing_dbg.ll
index 07b9a1ce496d9e..a253fef64f00d8 100644
--- a/llvm/test/Instrumentation/SanitizerCoverage/missing_dbg.ll
+++ b/llvm/test/Instrumentation/SanitizerCoverage/missing_dbg.ll
@@ -1,7 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=2 -S | FileCheck %s
-; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-stack-depth -sanitizer-coverage-stack-depth-callback-min=1 -S | FileCheck %s --check-prefix=CHECK-STACK-CALLBACK
-; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-stack-depth -S | FileCheck %s --check-prefix=CHECK-STACK-DEPTH
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
@@ -57,86 +55,6 @@ entry:
ret i32 %t
}
-define i32 @with_dbg_stack_callback(ptr %a) !dbg !8 {
-; CHECK-STACK-CALLBACK-LABEL: define i32 @with_dbg_stack_callback(
-; CHECK-STACK-CALLBACK-SAME: ptr [[A:%.*]]) !dbg [[DBG8:![0-9]+]] {
-; CHECK-STACK-CALLBACK-NEXT: entry:
-; CHECK-STACK-CALLBACK-NEXT: [[BUF:%.*]] = alloca [64 x i8], align 1
-; CHECK-STACK-CALLBACK-NEXT: call void @__sanitizer_cov_stack_depth() #[[ATTR1:[0-9]+]], !dbg [[DBG9:![0-9]+]]
-; CHECK-STACK-CALLBACK-NEXT: %t = load i32, ptr [[A]], align 4
-; CHECK-STACK-CALLBACK-NEXT: call void @external_func()
-; CHECK-STACK-CALLBACK-NEXT: ret i32 %t
-;
-entry:
- %buf = alloca [64 x i8], align 1
- %t = load i32, ptr %a, align 4
- call void @external_func()
- ret i32 %t
-}
-
-define i32 @with_dbg_stack_depth(ptr %a) !dbg !10 {
-; CHECK-STACK-DEPTH-LABEL: define i32 @with_dbg_stack_depth(
-; CHECK-STACK-DEPTH-SAME: ptr [[A:%.*]]) !dbg [[DBG10:![0-9]+]] {
-; CHECK-STACK-DEPTH-NEXT: entry:
-; CHECK-STACK-DEPTH-NEXT: [[BUF:%.*]] = alloca [64 x i8], align 1
-; CHECK-STACK-DEPTH-NEXT: [[TMP1:%.*]] = call ptr @llvm.frameaddress.p0(i32 0)
-; CHECK-STACK-DEPTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[TMP1]] to i64
-; CHECK-STACK-DEPTH-NEXT: [[TMP3:%.*]] = load i64, ptr @__sancov_lowest_stack, align 8
-; CHECK-STACK-DEPTH-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP2]], [[TMP3]]
-; CHECK-STACK-DEPTH-NEXT: br i1 [[TMP4]], label {{%.*}}, label {{%.*}}
-; CHECK-STACK-DEPTH: store i64 [[TMP2]], ptr @__sancov_lowest_stack, align 8, !dbg [[DBG11:![0-9]+]], {{.*}}!nosanitize
-; CHECK-STACK-DEPTH: %t = load i32, ptr [[A]], align 4
-; CHECK-STACK-DEPTH-NEXT: call void @external_func()
-; CHECK-STACK-DEPTH-NEXT: ret i32 %t
-;
-entry:
- %buf = alloca [64 x i8], align 1
- %t = load i32, ptr %a, align 4
- call void @external_func()
- ret i32 %t
-}
-
-define i32 @without_dbg_stack_callback(ptr %a) {
-; CHECK-STACK-CALLBACK-LABEL: define i32 @without_dbg_stack_callback(
-; CHECK-STACK-CALLBACK-SAME: ptr [[A:%.*]]) {
-; CHECK-STACK-CALLBACK-NEXT: entry:
-; CHECK-STACK-CALLBACK-NEXT: [[BUF:%.*]] = alloca [64 x i8], align 1
-; CHECK-STACK-CALLBACK-NEXT: call void @__sanitizer_cov_stack_depth() #[[ATTR1]]
-; CHECK-STACK-CALLBACK-NEXT: %t = load i32, ptr [[A]], align 4
-; CHECK-STACK-CALLBACK-NEXT: call void @external_func()
-; CHECK-STACK-CALLBACK-NEXT: ret i32 %t
-;
-entry:
- %buf = alloca [64 x i8], align 1
- %t = load i32, ptr %a, align 4
- call void @external_func()
- ret i32 %t
-}
-
-define i32 @without_dbg_stack_depth(ptr %a) {
-; CHECK-STACK-DEPTH-LABEL: define i32 @without_dbg_stack_depth(
-; CHECK-STACK-DEPTH-SAME: ptr [[A:%.*]]) {
-; CHECK-STACK-DEPTH-NEXT: entry:
-; CHECK-STACK-DEPTH-NEXT: [[BUF:%.*]] = alloca [64 x i8], align 1
-; CHECK-STACK-DEPTH-NEXT: [[TMP1:%.*]] = call ptr @llvm.frameaddress.p0(i32 0)
-; CHECK-STACK-DEPTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[TMP1]] to i64
-; CHECK-STACK-DEPTH-NEXT: [[TMP3:%.*]] = load i64, ptr @__sancov_lowest_stack, align 8
-; CHECK-STACK-DEPTH-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP2]], [[TMP3]]
-; CHECK-STACK-DEPTH-NEXT: br i1 [[TMP4]], label {{%.*}}, label {{%.*}}
-; CHECK-STACK-DEPTH: store i64 [[TMP2]], ptr @__sancov_lowest_stack, align 8, {{.*}}!nosanitize
-; CHECK-STACK-DEPTH: %t = load i32, ptr [[A]], align 4
-; CHECK-STACK-DEPTH-NEXT: call void @external_func()
-; CHECK-STACK-DEPTH-NEXT: ret i32 %t
-;
-entry:
- %buf = alloca [64 x i8], align 1
- %t = load i32, ptr %a, align 4
- call void @external_func()
- ret i32 %t
-}
-
-declare void @external_func()
-
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2}
@@ -148,23 +66,13 @@ declare void @external_func()
!5 = !{}
!6 = !DILocation(line: 192, scope: !3)
!7 = !DILocation(line: 0, scope: !3)
-!8 = distinct !DISubprogram(name: "with_dbg_stack_callback", scope: !1, file: !1, line: 200, type: !4, scopeLine: 200, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0)
-!9 = !DILocation(line: 200, scope: !8)
-!10 = distinct !DISubprogram(name: "with_dbg_stack_depth", scope: !1, file: !1, line: 210, type: !4, scopeLine: 210, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0)
-!11 = !DILocation(line: 210, scope: !10)
;.
; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C89, file: [[META1:![0-9]+]], isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None)
-; CHECK: [[META1]] = !DIFile(filename: "foo.c", directory: "")
+; CHECK: [[META1]] = !DIFile(filename: "{{.*}}foo.c", directory: {{.*}})
; CHECK: [[DBG3]] = distinct !DISubprogram(name: "foo", scope: [[META1]], file: [[META1]], line: 190, type: [[META4:![0-9]+]], scopeLine: 192, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]])
; CHECK: [[META4]] = !DISubroutineType(types: [[META5:![0-9]+]])
; CHECK: [[META5]] = !{}
; CHECK: [[DBG6]] = !DILocation(line: 192, scope: [[DBG3]])
; CHECK: [[DBG7]] = !DILocation(line: 0, scope: [[DBG3]])
;.
-; CHECK-STACK-CALLBACK: [[DBG8]] = distinct !DISubprogram(name: "with_dbg_stack_callback", scope: {{.*}}, file: {{.*}}, line: 200
-; CHECK-STACK-CALLBACK: [[DBG9]] = !DILocation(line: 200, scope: [[DBG8]])
-;.
-; CHECK-STACK-DEPTH: [[DBG10]] = distinct !DISubprogram(name: "with_dbg_stack_depth", scope: {{.*}}, file: {{.*}}, line: 210
-; CHECK-STACK-DEPTH: [[DBG11]] = !DILocation(line: 210, scope: [[DBG10]])
-;.
diff --git a/llvm/test/Instrumentation/SanitizerCoverage/missing_dbg_stack_depth.ll b/llvm/test/Instrumentation/SanitizerCoverage/missing_dbg_stack_depth.ll
new file mode 100644
index 00000000000000..fa21043ae0c16d
--- /dev/null
+++ b/llvm/test/Instrumentation/SanitizerCoverage/missing_dbg_stack_depth.ll
@@ -0,0 +1,101 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-stack-depth -sanitizer-coverage-stack-depth-callback-min=1 -S | FileCheck %s --check-prefix=CHECK-STACK-CALLBACK
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-stack-depth -S | FileCheck %s --check-prefix=CHECK-STACK-DEPTH
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+
+define i32 @with_dbg(ptr %a) !dbg !6 {
+; CHECK-STACK-CALLBACK-LABEL: define i32 @with_dbg(
+; CHECK-STACK-CALLBACK-SAME: ptr [[A:%.*]]) !dbg [[DBG3:![0-9]+]] {
+; CHECK-STACK-CALLBACK-NEXT: [[ENTRY:.*:]]
+; CHECK-STACK-CALLBACK-NEXT: [[BUF:%.*]] = alloca [64 x i8], align 1
+; CHECK-STACK-CALLBACK-NEXT: call void @__sanitizer_cov_stack_depth() #[[ATTR0:[0-9]+]], !dbg [[DBG6:![0-9]+]]
+; CHECK-STACK-CALLBACK-NEXT: [[T:%.*]] = load i32, ptr [[A]], align 4
+; CHECK-STACK-CALLBACK-NEXT: call void @external_func()
+; CHECK-STACK-CALLBACK-NEXT: ret i32 [[T]]
+;
+; CHECK-STACK-DEPTH-LABEL: define i32 @with_dbg(
+; CHECK-STACK-DEPTH-SAME: ptr [[A:%.*]]) !dbg [[DBG3:![0-9]+]] {
+; CHECK-STACK-DEPTH-NEXT: [[ENTRY:.*:]]
+; CHECK-STACK-DEPTH-NEXT: [[BUF:%.*]] = alloca [64 x i8], align 1
+; CHECK-STACK-DEPTH-NEXT: [[TMP0:%.*]] = call ptr @llvm.frameaddress.p0(i32 0), !dbg [[DBG6:![0-9]+]]
+; CHECK-STACK-DEPTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64, !dbg [[DBG6]]
+; CHECK-STACK-DEPTH-NEXT: [[TMP2:%.*]] = load i64, ptr @__sancov_lowest_stack, align 8, !dbg [[DBG6]], !nosanitize [[META5:![0-9]+]]
+; CHECK-STACK-DEPTH-NEXT: [[TMP3:%.*]] = icmp ult i64 [[TMP1]], [[TMP2]], !dbg [[DBG6]]
+; CHECK-STACK-DEPTH-NEXT: br i1 [[TMP3]], label %[[BB4:.*]], label %[[BB5:.*]], !prof [[PROF7:![0-9]+]]
+; CHECK-STACK-DEPTH: [[BB4]]:
+; CHECK-STACK-DEPTH-NEXT: store i64 [[TMP1]], ptr @__sancov_lowest_stack, align 8, !dbg [[DBG6]], !nosanitize [[META5]]
+; CHECK-STACK-DEPTH-NEXT: br label %[[BB5]]
+; CHECK-STACK-DEPTH: [[BB5]]:
+; CHECK-STACK-DEPTH-NEXT: [[T:%.*]] = load i32, ptr [[A]], align 4
+; CHECK-STACK-DEPTH-NEXT: call void @external_func()
+; CHECK-STACK-DEPTH-NEXT: ret i32 [[T]]
+;
+entry:
+ %buf = alloca [64 x i8], align 1
+ %t = load i32, ptr %a, align 4
+ call void @external_func()
+ ret i32 %t
+}
+
+define i32 @without_dbg(ptr %a) {
+; CHECK-STACK-CALLBACK-LABEL: define i32 @without_dbg(
+; CHECK-STACK-CALLBACK-SAME: ptr [[A:%.*]]) {
+; CHECK-STACK-CALLBACK-NEXT: [[ENTRY:.*:]]
+; CHECK-STACK-CALLBACK-NEXT: [[BUF:%.*]] = alloca [64 x i8], align 1
+; CHECK-STACK-CALLBACK-NEXT: call void @__sanitizer_cov_stack_depth() #[[ATTR0]]
+; CHECK-STACK-CALLBACK-NEXT: [[T:%.*]] = load i32, ptr [[A]], align 4
+; CHECK-STACK-CALLBACK-NEXT: call void @external_func()
+; CHECK-STACK-CALLBACK-NEXT: ret i32 [[T]]
+;
+; CHECK-STACK-DEPTH-LABEL: define i32 @without_dbg(
+; CHECK-STACK-DEPTH-SAME: ptr [[A:%.*]]) {
+; CHECK-STACK-DEPTH-NEXT: [[ENTRY:.*:]]
+; CHECK-STACK-DEPTH-NEXT: [[BUF:%.*]] = alloca [64 x i8], align 1
+; CHECK-STACK-DEPTH-NEXT: [[TMP0:%.*]] = call ptr @llvm.frameaddress.p0(i32 0)
+; CHECK-STACK-DEPTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64
+; CHECK-STACK-DEPTH-NEXT: [[TMP2:%.*]] = load i64, ptr @__sancov_lowest_stack, align 8, !nosanitize [[META5]]
+; CHECK-STACK-DEPTH-NEXT: [[TMP3:%.*]] = icmp ult i64 [[TMP1]], [[TMP2]]
+; CHECK-STACK-DEPTH-NEXT: br i1 [[TMP3]], label %[[BB4:.*]], label %[[BB5:.*]], !prof [[PROF7]]
+; CHECK-STACK-DEPTH: [[BB4]]:
+; CHECK-STACK-DEPTH-NEXT: store i64 [[TMP1]], ptr @__sancov_lowest_stack, align 8, !nosanitize [[META5]]
+; CHECK-STACK-DEPTH-NEXT: br label %[[BB5]]
+; CHECK-STACK-DEPTH: [[BB5]]:
+; CHECK-STACK-DEPTH-NEXT: [[T:%.*]] = load i32, ptr [[A]], align 4
+; CHECK-STACK-DEPTH-NEXT: call void @external_func()
+; CHECK-STACK-DEPTH-NEXT: ret i32 [[T]]
+;
+entry:
+ %buf = alloca [64 x i8], align 1
+ %t = load i32, ptr %a, align 4
+ call void @external_func()
+ ret i32 %t
+}
+
+declare void @external_func()
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C89, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "foo.c", directory: "")
+!2 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !DISubroutineType(types: !5)
+!5 = !{}
+!6 = distinct !DISubprogram(name: "with_dbg", scope: !1, file: !1, line: 200, type: !4, scopeLine: 200, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0)
+;.
+; CHECK-STACK-CALLBACK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C89, file: [[META1:![0-9]+]], isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None)
+; CHECK-STACK-CALLBACK: [[META1]] = !DIFile(filename: "{{.*}}foo.c", directory: {{.*}})
+; CHECK-STACK-CALLBACK: [[DBG3]] = distinct !DISubprogram(name: "with_dbg", scope: [[META1]], file: [[META1]], line: 200, type: [[META4:![0-9]+]], scopeLine: 200, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]])
+; CHECK-STACK-CALLBACK: [[META4]] = !DISubroutineType(types: [[META5:![0-9]+]])
+; CHECK-STACK-CALLBACK: [[META5]] = !{}
+; CHECK-STACK-CALLBACK: [[DBG6]] = !DILocation(line: 200, scope: [[DBG3]])
+;.
+; CHECK-STACK-DEPTH: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C89, file: [[META1:![0-9]+]], isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None)
+; CHECK-STACK-DEPTH: [[META1]] = !DIFile(filename: "{{.*}}foo.c", directory: {{.*}})
+; CHECK-STACK-DEPTH: [[DBG3]] = distinct !DISubprogram(name: "with_dbg", scope: [[META1]], file: [[META1]], line: 200, type: [[META4:![0-9]+]], scopeLine: 200, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]])
+; CHECK-STACK-DEPTH: [[META4]] = !DISubroutineType(types: [[META5]])
+; CHECK-STACK-DEPTH: [[META5]] = !{}
+; CHECK-STACK-DEPTH: [[DBG6]] = !DILocation(line: 200, scope: [[DBG3]])
+; CHECK-STACK-DEPTH: [[PROF7]] = !{!"branch_weights", i32 1, i32 1048575}
+;.
More information about the llvm-commits
mailing list