[llvm] 34b2b88 - [asan][test] Convert some tests to use opaque pointers
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 2 01:26:53 PDT 2022
Author: Fangrui Song
Date: 2022-11-02T01:26:48-07:00
New Revision: 34b2b884f1d17ca4928df75a43fd6b52e4a00ac6
URL: https://github.com/llvm/llvm-project/commit/34b2b884f1d17ca4928df75a43fd6b52e4a00ac6
DIFF: https://github.com/llvm/llvm-project/commit/34b2b884f1d17ca4928df75a43fd6b52e4a00ac6.diff
LOG: [asan][test] Convert some tests to use opaque pointers
Added:
Modified:
llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
llvm/test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
llvm/test/Instrumentation/AddressSanitizer/local_stack_base.ll
Removed:
################################################################################
diff --git a/llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll b/llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
index 69ce51d95b236..068c079151dda 100644
--- a/llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
+++ b/llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
@@ -12,7 +12,7 @@ target triple = "x86_64-unknown-linux-gnu"
@blocked_global = global i32 0, align 4
@_ZZ4funcvE10static_var = internal global i32 0, align 4
@.str = private unnamed_addr constant [14 x i8] c"Hello, world!\00", align 1
- at llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_asan_globals.cpp, i8* null }]
+ at llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_asan_globals.cpp, ptr null }]
; Check that globals were instrumented:
@@ -21,31 +21,31 @@ target triple = "x86_64-unknown-linux-gnu"
; Check emitted location descriptions:
; CHECK: [[VARNAME:@___asan_gen_.[0-9]+]] = private unnamed_addr constant [7 x i8] c"global\00", align 1
-; NOALIAS: @__asan_global_global = {{.*}}i64 ptrtoint ({ i32, [28 x i8] }* @global to i64){{.*}} section "asan_globals"{{.*}}, !associated
-; NOALIAS: @__asan_global_.str = {{.*}}i64 ptrtoint ({ [14 x i8], [18 x i8] }* @{{.str|1}} to i64){{.*}} section "asan_globals"{{.*}}, !associated
-; ALIAS: @__asan_global_global = {{.*}}i64 ptrtoint ({ i32, [28 x i8] }* @0 to i64){{.*}} section "asan_globals"{{.*}}, !associated
-; ALIAS: @__asan_global_.str = {{.*}}i64 ptrtoint ({ [14 x i8], [18 x i8] }* @4 to i64){{.*}} section "asan_globals"{{.*}}, !associated
+; NOALIAS: @__asan_global_global = {{.*}}i64 ptrtoint (ptr @global to i64){{.*}} section "asan_globals"{{.*}}, !associated
+; NOALIAS: @__asan_global_.str = {{.*}}i64 ptrtoint (ptr @{{.str|1}} to i64){{.*}} section "asan_globals"{{.*}}, !associated
+; ALIAS: @__asan_global_global = {{.*}}i64 ptrtoint (ptr @0 to i64){{.*}} section "asan_globals"{{.*}}, !associated
+; ALIAS: @__asan_global_.str = {{.*}}i64 ptrtoint (ptr @4 to i64){{.*}} section "asan_globals"{{.*}}, !associated
; The metadata has to be inserted to llvm.compiler.used to avoid being stripped
; during LTO.
-; CHECK: @llvm.compiler.used {{.*}} @__asan_global_global {{.*}} section "llvm.metadata"
+; CHECK: @llvm.compiler.used = appending global [10 x ptr] [ptr @global, ptr @dyn_init_global, ptr @blocked_global, ptr @_ZZ4funcvE10static_var, ptr @.str, ptr @__asan_global_global, ptr @__asan_global_dyn_init_global, ptr @__asan_global_blocked_global, ptr @__asan_global__ZZ4funcvE10static_var, ptr @__asan_global_.str], section "llvm.metadata"
; Check that location descriptors and global names were passed into __asan_register_globals:
-; CHECK: call void @__asan_register_elf_globals(i64 ptrtoint (i64* @___asan_globals_registered to i64), i64 ptrtoint (i64* @__start_asan_globals to i64), i64 ptrtoint (i64* @__stop_asan_globals to i64))
+; CHECK: call void @__asan_register_elf_globals(i64 ptrtoint (ptr @___asan_globals_registered to i64), i64 ptrtoint (ptr @__start_asan_globals to i64), i64 ptrtoint (ptr @__stop_asan_globals to i64))
; Function Attrs: nounwind sanitize_address
define internal void @__cxx_global_var_init() #0 section ".text.startup" {
entry:
- %0 = load i32, i32* @global, align 4
- store i32 %0, i32* @dyn_init_global, align 4
+ %0 = load i32, ptr @global, align 4
+ store i32 %0, ptr @dyn_init_global, align 4
ret void
}
; Function Attrs: nounwind sanitize_address
define void @_Z4funcv() #1 {
entry:
- %literal = alloca i8*, align 8
- store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i8** %literal, align 8
+ %literal = alloca ptr, align 8
+ store ptr @.str, ptr %literal, align 8
ret void
}
diff --git a/llvm/test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll b/llvm/test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
index 4b0d3e994d899..85dc8ae006d53 100644
--- a/llvm/test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
+++ b/llvm/test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
@@ -12,7 +12,7 @@ target triple = "x86_64-apple-macosx10.11.0"
!llvm.asan.globals = !{!0}
-!0 = !{[1 x i32]* @global, !1, !"global", i1 false, i1 false}
+!0 = !{ptr @global, !1, !"global", i1 false, i1 false}
!1 = !{!"test-globals.c", i32 1, i32 5}
@@ -26,7 +26,7 @@ target triple = "x86_64-apple-macosx10.11.0"
; The binder has to be inserted to llvm.compiler.used to avoid being stripped
; during LTO.
-; CHECK: @llvm.compiler.used {{.*}} @__asan_binder_global {{.*}} section "llvm.metadata"
+; CHECK: @llvm.compiler.used = appending global [2 x ptr] [ptr @global, ptr @__asan_binder_global], section "llvm.metadata"
; Test that there is the flag global variable:
; CHECK: @___asan_globals_registered = common hidden global i64 0
@@ -36,11 +36,11 @@ target triple = "x86_64-apple-macosx10.11.0"
; Test that __asan_register_image_globals is invoked from the constructor:
; CHECK-LABEL: define internal void @asan.module_ctor
; CHECK-NOT: ret
-; CHECK: call void @__asan_register_image_globals(i64 ptrtoint (i64* @___asan_globals_registered to i64))
+; CHECK: call void @__asan_register_image_globals(i64 ptrtoint (ptr @___asan_globals_registered to i64))
; CHECK: ret
; Test that __asan_unregister_image_globals is invoked from the destructor:
; CHECK-LABEL: define internal void @asan.module_dtor
; CHECK-NOT: ret
-; CHECK: call void @__asan_unregister_image_globals(i64 ptrtoint (i64* @___asan_globals_registered to i64))
+; CHECK: call void @__asan_unregister_image_globals(i64 ptrtoint (ptr @___asan_globals_registered to i64))
; CHECK: ret
diff --git a/llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll b/llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
index 3807ab2de00b7..5831b81370680 100644
--- a/llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
+++ b/llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
@@ -17,7 +17,7 @@ target triple = "x86_64-unknown-linux-gnu"
@blocked_global = global i32 0, align 4
@_ZZ4funcvE10static_var = internal global i32 0, align 4
@.str = private unnamed_addr constant [14 x i8] c"Hello, world!\00", align 1
- at llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_asan_globals.cpp, i8* null }]
+ at llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_asan_globals.cpp, ptr null }]
; Check that globals were instrumented:
@@ -43,29 +43,29 @@ target triple = "x86_64-unknown-linux-gnu"
; Check emitted location descriptions:
; CHECK: [[VARNAME:@___asan_gen_.[0-9]+]] = private unnamed_addr constant [7 x i8] c"global\00", align 1
-; COMDAT: @__asan_global_global = {{.*}}i64 ptrtoint ({ i32, [28 x i8] }* @global to i64){{.*}} section "asan_globals"{{.*}}, !associated
-; COMDAT: @__asan_global_.str = {{.*}}i64 ptrtoint ({ [14 x i8], [18 x i8] }* @{{.str|1}} to i64){{.*}} section "asan_globals"{{.*}}, !associated
+; COMDAT: @__asan_global_global = {{.*}}i64 ptrtoint (ptr @global to i64){{.*}} section "asan_globals"{{.*}}, !associated
+; COMDAT: @__asan_global_.str = {{.*}}i64 ptrtoint (ptr @{{.str|1}} to i64){{.*}} section "asan_globals"{{.*}}, !associated
; The metadata has to be inserted to llvm.compiler.used to avoid being stripped
; during LTO.
-; CHECK: @llvm.compiler.used {{.*}} @__asan_global_global {{.*}} section "llvm.metadata"
+; CHECK: @llvm.compiler.used {{.*}} ptr @__asan_global_global, {{.*}} section "llvm.metadata"
; Check that location descriptors and global names were passed into __asan_register_globals:
-; CHECK: call void @__asan_register_elf_globals(i64 ptrtoint (i64* @___asan_globals_registered to i64), i64 ptrtoint (i64* @__start_asan_globals to i64), i64 ptrtoint (i64* @__stop_asan_globals to i64))
+; CHECK: call void @__asan_register_elf_globals(i64 ptrtoint (ptr @___asan_globals_registered to i64), i64 ptrtoint (ptr @__start_asan_globals to i64), i64 ptrtoint (ptr @__stop_asan_globals to i64))
; Function Attrs: nounwind sanitize_address
define internal void @__cxx_global_var_init() #0 section ".text.startup" {
entry:
- %0 = load i32, i32* @global, align 4
- store i32 %0, i32* @dyn_init_global, align 4
+ %0 = load i32, ptr @global, align 4
+ store i32 %0, ptr @dyn_init_global, align 4
ret void
}
; Function Attrs: nounwind sanitize_address
define void @_Z4funcv() #1 {
entry:
- %literal = alloca i8*, align 8
- store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i8** %literal, align 8
+ %literal = alloca ptr, align 8
+ store ptr @.str, ptr %literal, align 8
ret void
}
diff --git a/llvm/test/Instrumentation/AddressSanitizer/local_alias.ll b/llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
index 6d8cc997513af..88525ae98a6a3 100644
--- a/llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
+++ b/llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
@@ -19,21 +19,21 @@ target triple = "x86_64-unknown-linux-gnu"
; CHECK-NOINDICATOR-NOT: __odr_asan_gen_a
; CHECK-NOALIAS-NOT: private alias
; CHECK-INDICATOR: @__odr_asan_gen_a = global i8 0, align 1
-; CHECK-ALIAS: @0 = private alias { [2 x i32], [24 x i8] }, { [2 x i32], [24 x i8] }* @a
+; CHECK-ALIAS: @0 = private alias { [2 x i32], [24 x i8] }, ptr @a
-; CHECK-ALIAS: @1 = private alias { [2 x i32], [24 x i8] }, { [2 x i32], [24 x i8] }* @b
-; CHECK-ALIAS: @2 = private alias { [2 x i32], [24 x i8] }, { [2 x i32], [24 x i8] }* @c
-; CHECK-ALIAS: @3 = private alias { [2 x i32], [24 x i8] }, { [2 x i32], [24 x i8] }* @d
+; CHECK-ALIAS: @1 = private alias { [2 x i32], [24 x i8] }, ptr @b
+; CHECK-ALIAS: @2 = private alias { [2 x i32], [24 x i8] }, ptr @c
+; CHECK-ALIAS: @3 = private alias { [2 x i32], [24 x i8] }, ptr @d
; Function Attrs: nounwind sanitize_address uwtable
define i32 @foo(i32 %M) #0 {
entry:
%M.addr = alloca i32, align 4
- store i32 %M, i32* %M.addr, align 4
- store volatile i32 6, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @a, i64 2, i64 0), align 4
- %0 = load i32, i32* %M.addr, align 4
+ store i32 %M, ptr %M.addr, align 4
+ store volatile i32 6, ptr getelementptr inbounds ([2 x i32], ptr @a, i64 2, i64 0), align 4
+ %0 = load i32, ptr %M.addr, align 4
%idxprom = sext i32 %0 to i64
- %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* @a, i64 0, i64 %idxprom
- %1 = load volatile i32, i32* %arrayidx, align 4
+ %arrayidx = getelementptr inbounds [2 x i32], ptr @a, i64 0, i64 %idxprom
+ %1 = load volatile i32, ptr %arrayidx, align 4
ret i32 %1
}
diff --git a/llvm/test/Instrumentation/AddressSanitizer/local_stack_base.ll b/llvm/test/Instrumentation/AddressSanitizer/local_stack_base.ll
index bccedd03341c2..43b402e1b166f 100644
--- a/llvm/test/Instrumentation/AddressSanitizer/local_stack_base.ll
+++ b/llvm/test/Instrumentation/AddressSanitizer/local_stack_base.ll
@@ -12,15 +12,15 @@ target triple = "x86_64-apple-macosx10.13.0"
define i32 @foo(i32 %i) #0 !dbg !8 {
entry:
%i.addr = alloca i32, align 4
- store i32 %i, i32* %i.addr, align 4
- call void @llvm.dbg.declare(metadata i32* %i.addr, metadata !12, metadata !DIExpression()), !dbg !13
+ store i32 %i, ptr %i.addr, align 4
+ call void @llvm.dbg.declare(metadata ptr %i.addr, metadata !12, metadata !DIExpression()), !dbg !13
; CHECK: %asan_local_stack_base = alloca i64
- ; CHECK: %[[ALLOCA:.*]] = ptrtoint i8* %MyAlloca to i64
+ ; CHECK: %[[ALLOCA:.*]] = ptrtoint ptr %MyAlloca to i64
; CHECK: %[[PHI:.*]] = phi i64 {{.*}} %[[ALLOCA]],
- ; CHECK: store i64 %[[PHI]], i64* %asan_local_stack_base
-; CHECK: call void @llvm.dbg.declare(metadata i64* %asan_local_stack_base, metadata [[VAR_I:![0-9]+]], metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 32)), !dbg [[LOC_I:![0-9]+]]
- %0 = load i32, i32* %i.addr, align 4, !dbg !14
+ ; CHECK: store i64 %[[PHI]], ptr %asan_local_stack_base
+; CHECK: call void @llvm.dbg.declare(metadata ptr %asan_local_stack_base, metadata [[VAR_I:![0-9]+]], metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 32)), !dbg [[LOC_I:![0-9]+]]
+ %0 = load i32, ptr %i.addr, align 4, !dbg !14
%add = add nsw i32 %0, 2, !dbg !15
ret i32 %add, !dbg !16
}
More information about the llvm-commits
mailing list