Skip to content

Commit 34b2b88

Browse files
committed
[asan][test] Convert some tests to use opaque pointers
1 parent 3ee3d3b commit 34b2b88

File tree

5 files changed

+39
-39
lines changed

5 files changed

+39
-39
lines changed

llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ target triple = "x86_64-unknown-linux-gnu"
1212
@blocked_global = global i32 0, align 4
1313
@_ZZ4funcvE10static_var = internal global i32 0, align 4
1414
@.str = private unnamed_addr constant [14 x i8] c"Hello, world!\00", align 1
15-
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_asan_globals.cpp, i8* null }]
15+
@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_asan_globals.cpp, ptr null }]
1616

1717
; Check that globals were instrumented:
1818

@@ -21,31 +21,31 @@ target triple = "x86_64-unknown-linux-gnu"
2121

2222
; Check emitted location descriptions:
2323
; CHECK: [[VARNAME:@___asan_gen_.[0-9]+]] = private unnamed_addr constant [7 x i8] c"global\00", align 1
24-
; NOALIAS: @__asan_global_global = {{.*}}i64 ptrtoint ({ i32, [28 x i8] }* @global to i64){{.*}} section "asan_globals"{{.*}}, !associated
25-
; NOALIAS: @__asan_global_.str = {{.*}}i64 ptrtoint ({ [14 x i8], [18 x i8] }* @{{.str|1}} to i64){{.*}} section "asan_globals"{{.*}}, !associated
26-
; ALIAS: @__asan_global_global = {{.*}}i64 ptrtoint ({ i32, [28 x i8] }* @0 to i64){{.*}} section "asan_globals"{{.*}}, !associated
27-
; ALIAS: @__asan_global_.str = {{.*}}i64 ptrtoint ({ [14 x i8], [18 x i8] }* @4 to i64){{.*}} section "asan_globals"{{.*}}, !associated
24+
; NOALIAS: @__asan_global_global = {{.*}}i64 ptrtoint (ptr @global to i64){{.*}} section "asan_globals"{{.*}}, !associated
25+
; NOALIAS: @__asan_global_.str = {{.*}}i64 ptrtoint (ptr @{{.str|1}} to i64){{.*}} section "asan_globals"{{.*}}, !associated
26+
; ALIAS: @__asan_global_global = {{.*}}i64 ptrtoint (ptr @0 to i64){{.*}} section "asan_globals"{{.*}}, !associated
27+
; ALIAS: @__asan_global_.str = {{.*}}i64 ptrtoint (ptr @4 to i64){{.*}} section "asan_globals"{{.*}}, !associated
2828

2929
; The metadata has to be inserted to llvm.compiler.used to avoid being stripped
3030
; during LTO.
31-
; CHECK: @llvm.compiler.used {{.*}} @__asan_global_global {{.*}} section "llvm.metadata"
31+
; 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"
3232

3333
; Check that location descriptors and global names were passed into __asan_register_globals:
34-
; 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))
34+
; 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))
3535

3636
; Function Attrs: nounwind sanitize_address
3737
define internal void @__cxx_global_var_init() #0 section ".text.startup" {
3838
entry:
39-
%0 = load i32, i32* @global, align 4
40-
store i32 %0, i32* @dyn_init_global, align 4
39+
%0 = load i32, ptr @global, align 4
40+
store i32 %0, ptr @dyn_init_global, align 4
4141
ret void
4242
}
4343

4444
; Function Attrs: nounwind sanitize_address
4545
define void @_Z4funcv() #1 {
4646
entry:
47-
%literal = alloca i8*, align 8
48-
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i8** %literal, align 8
47+
%literal = alloca ptr, align 8
48+
store ptr @.str, ptr %literal, align 8
4949
ret void
5050
}
5151

llvm/test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ target triple = "x86_64-apple-macosx10.11.0"
1212

1313
!llvm.asan.globals = !{!0}
1414

15-
!0 = !{[1 x i32]* @global, !1, !"global", i1 false, i1 false}
15+
!0 = !{ptr @global, !1, !"global", i1 false, i1 false}
1616
!1 = !{!"test-globals.c", i32 1, i32 5}
1717

1818

@@ -26,7 +26,7 @@ target triple = "x86_64-apple-macosx10.11.0"
2626

2727
; The binder has to be inserted to llvm.compiler.used to avoid being stripped
2828
; during LTO.
29-
; CHECK: @llvm.compiler.used {{.*}} @__asan_binder_global {{.*}} section "llvm.metadata"
29+
; CHECK: @llvm.compiler.used = appending global [2 x ptr] [ptr @global, ptr @__asan_binder_global], section "llvm.metadata"
3030

3131
; Test that there is the flag global variable:
3232
; CHECK: @___asan_globals_registered = common hidden global i64 0
@@ -36,11 +36,11 @@ target triple = "x86_64-apple-macosx10.11.0"
3636
; Test that __asan_register_image_globals is invoked from the constructor:
3737
; CHECK-LABEL: define internal void @asan.module_ctor
3838
; CHECK-NOT: ret
39-
; CHECK: call void @__asan_register_image_globals(i64 ptrtoint (i64* @___asan_globals_registered to i64))
39+
; CHECK: call void @__asan_register_image_globals(i64 ptrtoint (ptr @___asan_globals_registered to i64))
4040
; CHECK: ret
4141

4242
; Test that __asan_unregister_image_globals is invoked from the destructor:
4343
; CHECK-LABEL: define internal void @asan.module_dtor
4444
; CHECK-NOT: ret
45-
; CHECK: call void @__asan_unregister_image_globals(i64 ptrtoint (i64* @___asan_globals_registered to i64))
45+
; CHECK: call void @__asan_unregister_image_globals(i64 ptrtoint (ptr @___asan_globals_registered to i64))
4646
; CHECK: ret

llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ target triple = "x86_64-unknown-linux-gnu"
1717
@blocked_global = global i32 0, align 4
1818
@_ZZ4funcvE10static_var = internal global i32 0, align 4
1919
@.str = private unnamed_addr constant [14 x i8] c"Hello, world!\00", align 1
20-
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_asan_globals.cpp, i8* null }]
20+
@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_asan_globals.cpp, ptr null }]
2121

2222
; Check that globals were instrumented:
2323

@@ -43,29 +43,29 @@ target triple = "x86_64-unknown-linux-gnu"
4343

4444
; Check emitted location descriptions:
4545
; CHECK: [[VARNAME:@___asan_gen_.[0-9]+]] = private unnamed_addr constant [7 x i8] c"global\00", align 1
46-
; COMDAT: @__asan_global_global = {{.*}}i64 ptrtoint ({ i32, [28 x i8] }* @global to i64){{.*}} section "asan_globals"{{.*}}, !associated
47-
; COMDAT: @__asan_global_.str = {{.*}}i64 ptrtoint ({ [14 x i8], [18 x i8] }* @{{.str|1}} to i64){{.*}} section "asan_globals"{{.*}}, !associated
46+
; COMDAT: @__asan_global_global = {{.*}}i64 ptrtoint (ptr @global to i64){{.*}} section "asan_globals"{{.*}}, !associated
47+
; COMDAT: @__asan_global_.str = {{.*}}i64 ptrtoint (ptr @{{.str|1}} to i64){{.*}} section "asan_globals"{{.*}}, !associated
4848

4949
; The metadata has to be inserted to llvm.compiler.used to avoid being stripped
5050
; during LTO.
51-
; CHECK: @llvm.compiler.used {{.*}} @__asan_global_global {{.*}} section "llvm.metadata"
51+
; CHECK: @llvm.compiler.used {{.*}} ptr @__asan_global_global, {{.*}} section "llvm.metadata"
5252

5353
; Check that location descriptors and global names were passed into __asan_register_globals:
54-
; 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))
54+
; 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))
5555

5656
; Function Attrs: nounwind sanitize_address
5757
define internal void @__cxx_global_var_init() #0 section ".text.startup" {
5858
entry:
59-
%0 = load i32, i32* @global, align 4
60-
store i32 %0, i32* @dyn_init_global, align 4
59+
%0 = load i32, ptr @global, align 4
60+
store i32 %0, ptr @dyn_init_global, align 4
6161
ret void
6262
}
6363

6464
; Function Attrs: nounwind sanitize_address
6565
define void @_Z4funcv() #1 {
6666
entry:
67-
%literal = alloca i8*, align 8
68-
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i8** %literal, align 8
67+
%literal = alloca ptr, align 8
68+
store ptr @.str, ptr %literal, align 8
6969
ret void
7070
}
7171

llvm/test/Instrumentation/AddressSanitizer/local_alias.ll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ target triple = "x86_64-unknown-linux-gnu"
1919
; CHECK-NOINDICATOR-NOT: __odr_asan_gen_a
2020
; CHECK-NOALIAS-NOT: private alias
2121
; CHECK-INDICATOR: @__odr_asan_gen_a = global i8 0, align 1
22-
; CHECK-ALIAS: @0 = private alias { [2 x i32], [24 x i8] }, { [2 x i32], [24 x i8] }* @a
22+
; CHECK-ALIAS: @0 = private alias { [2 x i32], [24 x i8] }, ptr @a
2323

24-
; CHECK-ALIAS: @1 = private alias { [2 x i32], [24 x i8] }, { [2 x i32], [24 x i8] }* @b
25-
; CHECK-ALIAS: @2 = private alias { [2 x i32], [24 x i8] }, { [2 x i32], [24 x i8] }* @c
26-
; CHECK-ALIAS: @3 = private alias { [2 x i32], [24 x i8] }, { [2 x i32], [24 x i8] }* @d
24+
; CHECK-ALIAS: @1 = private alias { [2 x i32], [24 x i8] }, ptr @b
25+
; CHECK-ALIAS: @2 = private alias { [2 x i32], [24 x i8] }, ptr @c
26+
; CHECK-ALIAS: @3 = private alias { [2 x i32], [24 x i8] }, ptr @d
2727

2828
; Function Attrs: nounwind sanitize_address uwtable
2929
define i32 @foo(i32 %M) #0 {
3030
entry:
3131
%M.addr = alloca i32, align 4
32-
store i32 %M, i32* %M.addr, align 4
33-
store volatile i32 6, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @a, i64 2, i64 0), align 4
34-
%0 = load i32, i32* %M.addr, align 4
32+
store i32 %M, ptr %M.addr, align 4
33+
store volatile i32 6, ptr getelementptr inbounds ([2 x i32], ptr @a, i64 2, i64 0), align 4
34+
%0 = load i32, ptr %M.addr, align 4
3535
%idxprom = sext i32 %0 to i64
36-
%arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* @a, i64 0, i64 %idxprom
37-
%1 = load volatile i32, i32* %arrayidx, align 4
36+
%arrayidx = getelementptr inbounds [2 x i32], ptr @a, i64 0, i64 %idxprom
37+
%1 = load volatile i32, ptr %arrayidx, align 4
3838
ret i32 %1
3939
}

llvm/test/Instrumentation/AddressSanitizer/local_stack_base.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ target triple = "x86_64-apple-macosx10.13.0"
1212
define i32 @foo(i32 %i) #0 !dbg !8 {
1313
entry:
1414
%i.addr = alloca i32, align 4
15-
store i32 %i, i32* %i.addr, align 4
16-
call void @llvm.dbg.declare(metadata i32* %i.addr, metadata !12, metadata !DIExpression()), !dbg !13
15+
store i32 %i, ptr %i.addr, align 4
16+
call void @llvm.dbg.declare(metadata ptr %i.addr, metadata !12, metadata !DIExpression()), !dbg !13
1717

1818
; CHECK: %asan_local_stack_base = alloca i64
19-
; CHECK: %[[ALLOCA:.*]] = ptrtoint i8* %MyAlloca to i64
19+
; CHECK: %[[ALLOCA:.*]] = ptrtoint ptr %MyAlloca to i64
2020
; CHECK: %[[PHI:.*]] = phi i64 {{.*}} %[[ALLOCA]],
21-
; CHECK: store i64 %[[PHI]], i64* %asan_local_stack_base
22-
; 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]+]]
23-
%0 = load i32, i32* %i.addr, align 4, !dbg !14
21+
; CHECK: store i64 %[[PHI]], ptr %asan_local_stack_base
22+
; 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]+]]
23+
%0 = load i32, ptr %i.addr, align 4, !dbg !14
2424
%add = add nsw i32 %0, 2, !dbg !15
2525
ret i32 %add, !dbg !16
2626
}

0 commit comments

Comments
 (0)