[llvm] 5bcb199 - [test] Improve SanitizerCoverage tests
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 25 11:20:46 PST 2021
Author: Fangrui Song
Date: 2021-02-25T11:20:40-08:00
New Revision: 5bcb199a4317d30f6ada805c824e0e4be6db07bf
URL: https://github.com/llvm/llvm-project/commit/5bcb199a4317d30f6ada805c824e0e4be6db07bf
DIFF: https://github.com/llvm/llvm-project/commit/5bcb199a4317d30f6ada805c824e0e4be6db07bf.diff
LOG: [test] Improve SanitizerCoverage tests
Added:
llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard.ll
Modified:
llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
Removed:
llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-comdat.ll
llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-nocomdat.ll
################################################################################
diff --git a/llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll b/llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
index ca8f840d1aba..87739db4b072 100644
--- a/llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
+++ b/llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
@@ -2,7 +2,10 @@
; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-inline-bool-flag=1 -S -enable-new-pm=0 | FileCheck %s
; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-inline-bool-flag=1 -S | FileCheck %s
-; CHECK: @__sancov_gen_ = private global [1 x i1] zeroinitializer, section "__sancov_bools", comdat($foo), align 1, !associated !0
+; CHECK: $foo = comdat any
+; CHECK: @__sancov_gen_ = private global [1 x i1] zeroinitializer, section "__sancov_bools", comdat($foo), align 1, !associated !0
+; CHECK-NOT: @llvm.used =
+; CHECK: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast ([1 x i1]* @__sancov_gen_ to i8*)], section "llvm.metadata"
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"
target triple = "x86_64-unknown-linux-gnu"
diff --git a/llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-comdat.ll b/llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-comdat.ll
deleted file mode 100644
index afa118aca2a3..000000000000
--- a/llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-comdat.ll
+++ /dev/null
@@ -1,44 +0,0 @@
-; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc-guard -S -enable-new-pm=0 | FileCheck %s --check-prefix=CHECK_TRACE_PC_GUARD
-; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s --check-prefix=CHECK_TRACE_PC_GUARD
-
-; CHECK: @__sancov_gen_ = private global [1 x i32] zeroinitializer, section "__sancov_guards", comdat($foo), align 4{{$}}
-; CHECK-NEXT: @__sancov_gen_.1 = private global [1 x i32] zeroinitializer, section "__sancov_guards", comdat($CallViaVptr), align 4{{$}}
-
-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"
-target triple = "x86_64-unknown-linux-gnu"
-define void @foo(i32* %a) sanitize_address {
-entry:
- %tobool = icmp eq i32* %a, null
- br i1 %tobool, label %if.end, label %if.then
-
- if.then: ; preds = %entry
- store i32 0, i32* %a, align 4
- br label %if.end
-
- if.end: ; preds = %entry, %if.then
- ret void
-}
-
-%struct.StructWithVptr = type { i32 (...)** }
-
-define void @CallViaVptr(%struct.StructWithVptr* %foo) uwtable sanitize_address {
-entry:
- %0 = bitcast %struct.StructWithVptr* %foo to void (%struct.StructWithVptr*)***
- %vtable = load void (%struct.StructWithVptr*)**, void (%struct.StructWithVptr*)*** %0, align 8
- %1 = load void (%struct.StructWithVptr*)*, void (%struct.StructWithVptr*)** %vtable, align 8
- tail call void %1(%struct.StructWithVptr* %foo)
- tail call void %1(%struct.StructWithVptr* %foo)
- tail call void asm sideeffect "", ""()
- ret void
-}
-
-; CHECK_TRACE_PC_GUARD-LABEL: define void @foo
-; CHECK_TRACE_PC_GUARD: call void @__sanitizer_cov_trace_pc
-; CHECK_TRACE_PC_GUARD: ret void
-
-; CHECK_TRACE_PC_GUARD-LABEL: define void @CallViaVptr
-; CHECK_TRACE_PC_GUARD: call void @__sanitizer_cov_trace_pc_indir
-; CHECK_TRACE_PC_GUARD: call void @__sanitizer_cov_trace_pc_indir
-; CHECK_TRACE_PC_GUARD: ret void
-
-; CHECK_TRACE_PC_GUARD-LABEL: define internal void @sancov.module_ctor_trace_pc_guard() comdat
diff --git a/llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-nocomdat.ll b/llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-nocomdat.ll
deleted file mode 100644
index ab0ede16a79b..000000000000
--- a/llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-nocomdat.ll
+++ /dev/null
@@ -1,44 +0,0 @@
-; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc-guard -S -enable-new-pm=0 | FileCheck %s --check-prefix=CHECK_TRACE_PC_GUARD
-; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s --check-prefix=CHECK_TRACE_PC_GUARD
-
-; CHECK: @__sancov_gen_ = private global [1 x i1] zeroinitializer, section "__DATA,__sancov_bools", align 1, !associated !0
-; CHECK-NEXT: @__sancov_gen_.1 = private global [1 x i1] zeroinitializer, section "__DATA,__sancov_bools", align 1, !associated !1
-
-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"
-target triple = "x86_64-apple-darwin10.0.0"
-define void @foo(i32* %a) sanitize_address {
-entry:
- %tobool = icmp eq i32* %a, null
- br i1 %tobool, label %if.end, label %if.then
-
- if.then: ; preds = %entry
- store i32 0, i32* %a, align 4
- br label %if.end
-
- if.end: ; preds = %entry, %if.then
- ret void
-}
-
-%struct.StructWithVptr = type { i32 (...)** }
-
-define void @CallViaVptr(%struct.StructWithVptr* %foo) uwtable sanitize_address {
-entry:
- %0 = bitcast %struct.StructWithVptr* %foo to void (%struct.StructWithVptr*)***
- %vtable = load void (%struct.StructWithVptr*)**, void (%struct.StructWithVptr*)*** %0, align 8
- %1 = load void (%struct.StructWithVptr*)*, void (%struct.StructWithVptr*)** %vtable, align 8
- tail call void %1(%struct.StructWithVptr* %foo)
- tail call void %1(%struct.StructWithVptr* %foo)
- tail call void asm sideeffect "", ""()
- ret void
-}
-
-; CHECK_TRACE_PC_GUARD-LABEL: define void @foo
-; CHECK_TRACE_PC_GUARD: call void @__sanitizer_cov_trace_pc
-; CHECK_TRACE_PC_GUARD: ret void
-
-; CHECK_TRACE_PC_GUARD-LABEL: define void @CallViaVptr
-; CHECK_TRACE_PC_GUARD: call void @__sanitizer_cov_trace_pc_indir
-; CHECK_TRACE_PC_GUARD: call void @__sanitizer_cov_trace_pc_indir
-; CHECK_TRACE_PC_GUARD: ret void
-
-; CHECK_TRACE_PC_GUARD-LABEL: define internal void @sancov.module_ctor_trace_pc_guard() {
diff --git a/llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard.ll b/llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard.ll
new file mode 100644
index 000000000000..ffaef122c13f
--- /dev/null
+++ b/llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard.ll
@@ -0,0 +1,55 @@
+; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc-guard -mtriple=x86_64 -S -enable-new-pm=0 | FileCheck %s --check-prefixes=CHECK,ELF
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc-guard -mtriple=x86_64 -S | FileCheck %s --check-prefixes=CHECK,ELF
+
+; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc-guard -mtriple=aarch64-apple-darwin -S -enable-new-pm=0 | FileCheck %s --check-prefixes=CHECK,MACHO
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc-guard -mtriple=aarch64-apple-darwin -S | FileCheck %s --check-prefixes=CHECK,MACHO
+
+; ELF: $foo = comdat any
+; ELF: $CallViaVptr = comdat any
+; ELF: @__sancov_gen_ = private global [3 x i32] zeroinitializer, section "__sancov_guards", comdat($foo), align 4, !associated !0
+; ELF-NEXT: @__sancov_gen_.1 = private global [1 x i32] zeroinitializer, section "__sancov_guards", comdat($CallViaVptr), align 4, !associated !1
+
+; MACHO: @__sancov_gen_ = private global [3 x i32] zeroinitializer, section "__DATA,__sancov_guards", align 4, !associated !0
+; MACHO-NEXT: @__sancov_gen_.1 = private global [1 x i32] zeroinitializer, section "__DATA,__sancov_guards", align 4, !associated !1
+
+; ELF-NOT: @llvm.used =
+; MACHO: @llvm.used = appending global [2 x i8*] [i8* bitcast ([3 x i32]* @__sancov_gen_ to i8*), i8* bitcast ([1 x i32]* @__sancov_gen_.1 to i8*)], section "llvm.metadata"
+; CHECK: @llvm.compiler.used = appending global [2 x i8*] [i8* bitcast ([3 x i32]* @__sancov_gen_ to i8*), i8* bitcast ([1 x i32]* @__sancov_gen_.1 to i8*)], section "llvm.metadata"
+
+; CHECK-LABEL: define void @foo
+; CHECK: call void @__sanitizer_cov_trace_pc
+; CHECK: ret void
+
+define void @foo(i32* %a) sanitize_address {
+entry:
+ %tobool = icmp eq i32* %a, null
+ br i1 %tobool, label %if.end, label %if.then
+
+ if.then: ; preds = %entry
+ store i32 0, i32* %a, align 4
+ br label %if.end
+
+ if.end: ; preds = %entry, %if.then
+ ret void
+}
+
+; CHECK-LABEL: define void @CallViaVptr
+; CHECK: call void @__sanitizer_cov_trace_pc_indir
+; CHECK: call void @__sanitizer_cov_trace_pc_indir
+; CHECK: ret void
+
+%struct.StructWithVptr = type { i32 (...)** }
+
+define void @CallViaVptr(%struct.StructWithVptr* %foo) uwtable sanitize_address {
+entry:
+ %0 = bitcast %struct.StructWithVptr* %foo to void (%struct.StructWithVptr*)***
+ %vtable = load void (%struct.StructWithVptr*)**, void (%struct.StructWithVptr*)*** %0, align 8
+ %1 = load void (%struct.StructWithVptr*)*, void (%struct.StructWithVptr*)** %vtable, align 8
+ tail call void %1(%struct.StructWithVptr* %foo)
+ tail call void %1(%struct.StructWithVptr* %foo)
+ tail call void asm sideeffect "", ""()
+ ret void
+}
+
+; ELF-LABEL: define internal void @sancov.module_ctor_trace_pc_guard() comdat {
+; MACHO-LABEL: define internal void @sancov.module_ctor_trace_pc_guard() {
More information about the llvm-commits
mailing list