diff options
author | Stephen Hines <srhines@google.com> | 2014-12-01 14:51:49 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-12-02 16:08:10 -0800 |
commit | 37ed9c199ca639565f6ce88105f9e39e898d82d0 (patch) | |
tree | 8fb36d3910e3ee4c4e1b7422f4f017108efc52f5 /test/Instrumentation | |
parent | d2327b22152ced7bc46dc629fc908959e8a52d03 (diff) | |
download | external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.zip external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.gz external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.bz2 |
Update aosp/master LLVM for rebase to r222494.
Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
Diffstat (limited to 'test/Instrumentation')
35 files changed, 3997 insertions, 228 deletions
diff --git a/test/Instrumentation/AddressSanitizer/X86/asm_cfi.ll b/test/Instrumentation/AddressSanitizer/X86/asm_cfi.ll new file mode 100644 index 0000000..6bfb153 --- /dev/null +++ b/test/Instrumentation/AddressSanitizer/X86/asm_cfi.ll @@ -0,0 +1,54 @@ +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asm-instrumentation=address -asan-instrument-assembly | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; CHECK-LABEL: mov8b_rbp +; CHECK: pushq %rbp +; CHECK-NOT: .cfi_adjust_cfa_offset 8 +; CHECK: movq %rbp, %rbp +; CHECK: .cfi_remember_state +; CHECK: .cfi_def_cfa_register %rbp +; CHECK: leaq -128(%rsp) +; CHECK: callq __asan_report_load8@PLT +; CHECK: leaq 128(%rsp) +; CHECK: popq %rbp +; CHECK: .cfi_restore_state +; CHECK-NOT: .cfi_adjust_cfa_offset -8 +; CHECK: retq +define void @mov8b_rbp(i64* %dst, i64* %src) #0 { +entry: + tail call void asm sideeffect "movq ($0), %rax \0A\09movq %rax, ($1) \0A\09", "r,r,~{rax},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %src, i64* %dst) + ret void +} + +; CHECK-LABEL: mov8b_rsp +; CHECK: pushq %rbp +; CHECK: .cfi_adjust_cfa_offset 8 +; CHECK: movq %rsp, %rbp +; CHECK: .cfi_remember_state +; CHECK: .cfi_def_cfa_register %rbp +; CHECK: leaq -128(%rsp) +; CHECK: callq __asan_report_load8@PLT +; CHECK: leaq 128(%rsp) +; CHECK: popq %rbp +; CHECK: .cfi_restore_state +; CHECK: .cfi_adjust_cfa_offset -8 +; CHECK: retq +define void @mov8b_rsp(i64* %dst, i64* %src) #1 { +entry: + tail call void asm sideeffect "movq ($0), %rax \0A\09movq %rax, ($1) \0A\09", "r,r,~{rax},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %src, i64* %dst) + ret void +} + +; CHECK-LABEL: mov8b_rsp_no_cfi +; CHECK-NOT: .cfi{{[a-z_]+}} +define void @mov8b_rsp_no_cfi(i64* %dst, i64* %src) #2 { +entry: + tail call void asm sideeffect "movq ($0), %rax \0A\09movq %rax, ($1) \0A\09", "r,r,~{rax},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %src, i64* %dst) + ret void +} + +attributes #0 = { nounwind sanitize_address uwtable "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" } +attributes #1 = { nounwind sanitize_address uwtable "no-frame-pointer-elim"="false" } +attributes #2 = { nounwind sanitize_address "no-frame-pointer-elim"="false" } diff --git a/test/Instrumentation/AddressSanitizer/X86/asm_cfi.s b/test/Instrumentation/AddressSanitizer/X86/asm_cfi.s new file mode 100644 index 0000000..417d7f3 --- /dev/null +++ b/test/Instrumentation/AddressSanitizer/X86/asm_cfi.s @@ -0,0 +1,52 @@ +# The test verifies that correct DWARF directives are emitted when +# assembly files are instrumented. + +# RUN: llvm-mc %s -triple=i386-unknown-linux-gnu -asm-instrumentation=address -asan-instrument-assembly | FileCheck %s + +# CHECK-LABEL: load4b_cfa_rbp +# CHECK: pushl %ebx +# CHECK-NOT: .cfi_adjust_cfa_offset 8 +# CHECK: movl %ebp, %ebx +# CHECK: .cfi_remember_state +# CHECK: .cfi_def_cfa_register %ebx +# CHECK: popl %ebx +# CHECK: .cfi_restore_state +# CHECK-NOT: .cfi_adjust_cfa_offset -8 +# CHECK: retl + + .text + .globl load4b_cfa_rbp + .type load4b_cfa_rbp,@function +swap_cfa_rbp: # @swap_cfa_rbp + .cfi_startproc + pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset %ebp, -8 + movl %esp, %ebp + .cfi_def_cfa_register %ebp + movl 8(%ebp), %eax + popl %ebp + retl + .cfi_endproc + +# CHECK-LABEL: load4b_cfa_rsp +# CHECK: pushl %ebx +# CHECK: .cfi_adjust_cfa_offset 4 +# CHECK: movl %esp, %ebx +# CHECK: .cfi_remember_state +# CHECK: .cfi_def_cfa_register %ebx +# CHECK: popl %ebx +# CHECK: .cfi_restore_state +# CHECK: retl + + .globl load4b_cfa_rsp + .type load4b_cfa_rsp,@function +swap_cfa_rsp: # @swap_cfa_rsp + .cfi_startproc + pushl %ebp + .cfi_offset %ebp, 0 + movl %esp, %ebp + movl 8(%ebp), %eax + popl %ebp + retl + .cfi_endproc diff --git a/test/Instrumentation/AddressSanitizer/X86/asm_mov.ll b/test/Instrumentation/AddressSanitizer/X86/asm_mov.ll index ad5e02e..7f5d3b0 100644 --- a/test/Instrumentation/AddressSanitizer/X86/asm_mov.ll +++ b/test/Instrumentation/AddressSanitizer/X86/asm_mov.ll @@ -6,8 +6,8 @@ target triple = "x86_64-unknown-linux-gnu" ; CHECK-LABEL: mov1b ; CHECK: leaq -128(%rsp), %rsp ; CHECK-NEXT: pushq %rax -; CHECK-NEXT: pushq %rcx ; CHECK-NEXT: pushq %rdi +; CHECK-NEXT: pushq %rcx ; CHECK-NEXT: pushfq ; CHECK-NEXT: leaq {{.*}}, %rdi ; CHECK-NEXT: movq %rdi, %rax @@ -26,8 +26,8 @@ target triple = "x86_64-unknown-linux-gnu" ; CHECK-NEXT: callq __asan_report_load1@PLT ; CHECK-NEXT: [[A]]: ; CHECK-NEXT: popfq -; CHECK-NEXT: popq %rdi ; CHECK-NEXT: popq %rcx +; CHECK-NEXT: popq %rdi ; CHECK-NEXT: popq %rax ; CHECK-NEXT: leaq 128(%rsp), %rsp @@ -81,8 +81,10 @@ entry: ; CHECK-LABEL: mov8b ; CHECK: leaq -128(%rsp), %rsp ; CHECK-NEXT: pushq %rax +; CHECK-NEXT: pushq %rdi ; CHECK-NEXT: pushfq -; CHECK-NEXT: leaq {{.*}}, %rax +; CHECK-NEXT: leaq {{.*}}, %rdi +; CHECK-NEXT: movq %rdi, %rax ; CHECK-NEXT: shrq $3, %rax ; CHECK-NEXT: cmpb $0, 2147450880(%rax) ; CHECK-NEXT: je [[A:.*]] @@ -92,13 +94,16 @@ entry: ; CHECK-NEXT: callq __asan_report_load8@PLT ; CHECK-NEXT: [[A]]: ; CHECK-NEXT: popfq +; CHECK-NEXT: popq %rdi ; CHECK-NEXT: popq %rax ; CHECK-NEXT: leaq 128(%rsp), %rsp ; CHECK: leaq -128(%rsp), %rsp ; CHECK-NEXT: pushq %rax +; CHECK-NEXT: pushq %rdi ; CHECK-NEXT: pushfq -; CHECK-NEXT: leaq {{.*}}, %rax +; CHECK-NEXT: leaq {{.*}}, %rdi +; CHECK-NEXT: movq %rdi, %rax ; CHECK-NEXT: shrq $3, %rax ; CHECK-NEXT: cmpb $0, 2147450880(%rax) ; CHECK-NEXT: je [[A:.*]] @@ -108,6 +113,7 @@ entry: ; CHECK-NEXT: callq __asan_report_store8@PLT ; CHECK-NEXT: [[A]]: ; CHECK-NEXT: popfq +; CHECK-NEXT: popq %rdi ; CHECK-NEXT: popq %rax ; CHECK-NEXT: leaq 128(%rsp), %rsp diff --git a/test/Instrumentation/AddressSanitizer/X86/asm_mov.s b/test/Instrumentation/AddressSanitizer/X86/asm_mov.s index 74a788c..14fc056 100644 --- a/test/Instrumentation/AddressSanitizer/X86/asm_mov.s +++ b/test/Instrumentation/AddressSanitizer/X86/asm_mov.s @@ -10,13 +10,13 @@ # CHECK: callq __asan_report_load1@PLT # CHECK: leaq 128(%rsp), %rsp # -# CHECK-NEXT: movb (%rsi), %al +# CHECK: movb (%rsi), %al # -# CHECK-NEXT: leaq -128(%rsp), %rsp +# CHECK: leaq -128(%rsp), %rsp # CHECK: callq __asan_report_store1@PLT # CHECK: leaq 128(%rsp), %rsp # -# CHECK-NEXT: movb %al, (%rdi) +# CHECK: movb %al, (%rdi) mov1b: # @mov1b .cfi_startproc # BB#0: @@ -39,13 +39,13 @@ mov1b: # @mov1b # CHECK: callq __asan_report_load16@PLT # CHECK: leaq 128(%rsp), %rsp # -# CHECK-NEXT: movaps (%rsi), %xmm0 +# CHECK: movaps (%rsi), %xmm0 # -# CHECK-NEXT: leaq -128(%rsp), %rsp +# CHECK: leaq -128(%rsp), %rsp # CHECK: callq __asan_report_store16@PLT # CHECK: leaq 128(%rsp), %rsp # -# CHECK-NEXT: movaps %xmm0, (%rdi) +# CHECK: movaps %xmm0, (%rdi) mov16b: # @mov16b .cfi_startproc # BB#0: diff --git a/test/Instrumentation/AddressSanitizer/X86/asm_mov_no_instrumentation.s b/test/Instrumentation/AddressSanitizer/X86/asm_mov_no_instrumentation.s index e3a1541..5d5de5d 100644 --- a/test/Instrumentation/AddressSanitizer/X86/asm_mov_no_instrumentation.s +++ b/test/Instrumentation/AddressSanitizer/X86/asm_mov_no_instrumentation.s @@ -5,6 +5,8 @@ .align 16, 0x90 .type mov1b,@function # CHECK-LABEL: mov1b +# CHECK: movb (%rsi), %al +# CHECK: movb %al, (%rdi) # CHECK-NOT: callq __asan_report_load1@PLT # CHECK-NOT: callq __asan_report_store1@PLT mov1b: # @mov1b diff --git a/test/Instrumentation/AddressSanitizer/X86/asm_rep_movs.ll b/test/Instrumentation/AddressSanitizer/X86/asm_rep_movs.ll new file mode 100644 index 0000000..c3c2435 --- /dev/null +++ b/test/Instrumentation/AddressSanitizer/X86/asm_rep_movs.ll @@ -0,0 +1,87 @@ +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2 -asm-instrumentation=address -asan-instrument-assembly | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; CHECK-LABEL: rep_movs_1b +; CHECK: pushfq +; CHECK-NEXT: testq %rcx, %rcx +; CHECK-NEXT: je [[B:.*]] + +; CHECK: leaq -128(%rsp), %rsp +; CHECK-NEXT: pushq %rax +; CHECK-NEXT: pushq %rdx +; CHECK-NEXT: pushq %rbx +; CHECK-NEXT: pushfq + +; CHECK: leaq (%rsi), %rdx +; CHECK: movq %rdx, %rdi +; CHECK-NEXT: callq __asan_report_load1@PLT + +; CHECK: leaq -1(%rsi,%rcx), %rdx +; CHECK: movq %rdx, %rdi +; CHECK-NEXT: callq __asan_report_load1@PLT + +; CHECK: leaq (%rdi), %rdx +; CHECK: movq %rdx, %rdi +; CHECK-NEXT: callq __asan_report_store1@PLT + +; CHECK: leaq -1(%rdi,%rcx), %rdx +; CHECK: movq %rdx, %rdi +; CHECK-NEXT: callq __asan_report_store1@PLT + +; CHECK: popfq +; CHECK-NEXT: popq %rbx +; CHECK-NEXT: popq %rdx +; CHECK-NEXT: popq %rax +; CHECK-NEXT: leaq 128(%rsp), %rsp + +; CHECK: [[B]]: +; CHECK-NEXT: popfq + +; CHECK: rep +; CHECK-NEXT: movsb (%rsi), %es:(%rdi) + +; Function Attrs: nounwind sanitize_address uwtable +define void @rep_movs_1b(i8* %dst, i8* %src, i64 %n) #0 { +entry: + tail call void asm sideeffect "rep movsb \0A\09", "{si},{di},{cx},~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %src, i8* %dst, i64 %n) #1 + ret void +} + +; CHECK-LABEL: rep_movs_8b +; CHECK: pushfq +; CHECK-NEXT: testq %rcx, %rcx +; CHECK-NEXT: je [[Q:.*]] + +; CHECK: leaq (%rsi), %rdx +; CHECK: movq %rdx, %rdi +; CHECK-NEXT: callq __asan_report_load8@PLT + +; CHECK: leaq -1(%rsi,%rcx,8), %rdx +; CHECK: movq %rdx, %rdi +; CHECK-NEXT: callq __asan_report_load8@PLT + +; CHECK: leaq (%rdi), %rdx +; CHECK: movq %rdx, %rdi +; CHECK-NEXT: callq __asan_report_store8@PLT + +; CHECK: leaq -1(%rdi,%rcx,8), %rdx +; CHECK: movq %rdx, %rdi +; CHECK-NEXT: callq __asan_report_store8@PLT + +; CHECK: [[Q]]: +; CHECK-NEXT: popfq + +; CHECK: rep +; CHECK-NEXT: movsq (%rsi), %es:(%rdi) + +; Function Attrs: nounwind sanitize_address uwtable +define void @rep_movs_8b(i64* %dst, i64* %src, i64 %n) #0 { +entry: + tail call void asm sideeffect "rep movsq \0A\09", "{si},{di},{cx},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %src, i64* %dst, i64 %n) #1 + ret void +} + +attributes #0 = { nounwind sanitize_address uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind } diff --git a/test/Instrumentation/AddressSanitizer/X86/asm_rsp_mem_op.s b/test/Instrumentation/AddressSanitizer/X86/asm_rsp_mem_op.s new file mode 100644 index 0000000..e40ecde --- /dev/null +++ b/test/Instrumentation/AddressSanitizer/X86/asm_rsp_mem_op.s @@ -0,0 +1,45 @@ +# The test verifies that memory references through %rsp are correctly +# adjusted after instrumentation. + +# RUN: llvm-mc %s -triple=x86_64-unknown-linux-gnu -asm-instrumentation=address -asan-instrument-assembly | FileCheck %s + +# CHECK-LABEL: rsp_access +# CHECK: leaq -128(%rsp), %rsp +# CHECK: pushq %rax +# CHECK: pushq %rdi +# CHECK: pushfq +# CHECK: leaq 160(%rsp), %rdi +# CHECK: callq __asan_report_load8@PLT +# CHECK: popfq +# CHECK: popq %rdi +# CHECK: popq %rax +# CHECK: leaq 128(%rsp), %rsp +# CHECK: movq 8(%rsp), %rax +# CHECK: retq + + .text + .globl rsp_access + .type rsp_access,@function +rsp_access: + movq 8(%rsp), %rax + retq + +# CHECK-LABEL: rsp_32bit_access +# CHECK: leaq -128(%rsp), %rsp +# CHECK: pushq %rax +# CHECK: pushq %rdi +# CHECK: pushfq +# CHECK: leaq 2147483647(%rsp), %rdi +# CHECK: leaq 145(%rdi), %rdi +# CHECK: callq __asan_report_load8@PLT +# CHECK: popfq +# CHECK: popq %rdi +# CHECK: popq %rax +# CHECK: leaq 128(%rsp), %rsp +# CHECK: movq 2147483640(%rsp), %rax +# CHECK: retq + .globl rsp_32bit_access + .type rsp_32bit_access,@function +rsp_32bit_access: + movq 2147483640(%rsp), %rax + retq diff --git a/test/Instrumentation/AddressSanitizer/X86/asm_swap_intel.s b/test/Instrumentation/AddressSanitizer/X86/asm_swap_intel.s index ca3c54c..093c96b 100644 --- a/test/Instrumentation/AddressSanitizer/X86/asm_swap_intel.s +++ b/test/Instrumentation/AddressSanitizer/X86/asm_swap_intel.s @@ -10,25 +10,25 @@ # CHECK: callq __asan_report_load8@PLT # CHECK: leaq 128(%rsp), %rsp # -# CHECK-NEXT: movq (%rcx), %rax +# CHECK: movq (%rcx), %rax # -# CHECK-NEXT: leaq -128(%rsp), %rsp +# CHECK: leaq -128(%rsp), %rsp # CHECK: callq __asan_report_load8@PLT # CHECK: leaq 128(%rsp), %rsp # -# CHECK-NEXT: movq (%rdx), %rbx +# CHECK: movq (%rdx), %rbx # -# CHECK-NEXT: leaq -128(%rsp), %rsp +# CHECK: leaq -128(%rsp), %rsp # CHECK: callq __asan_report_store8@PLT # CHECK: leaq 128(%rsp), %rsp # -# CHECK-NEXT: movq %rbx, (%rcx) +# CHECK: movq %rbx, (%rcx) # -# CHECK-NEXT: leaq -128(%rsp), %rsp +# CHECK: leaq -128(%rsp), %rsp # CHECK: callq __asan_report_store8@PLT # CHECK: leaq 128(%rsp), %rsp # -# CHECK-NEXT: movq %rax, (%rdx) +# CHECK: movq %rax, (%rdx) swap: # @swap .cfi_startproc # BB#0: diff --git a/test/Instrumentation/AddressSanitizer/basic.ll b/test/Instrumentation/AddressSanitizer/basic.ll index 7d1aa0b..d9997e2 100644 --- a/test/Instrumentation/AddressSanitizer/basic.ll +++ b/test/Instrumentation/AddressSanitizer/basic.ll @@ -6,7 +6,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3 target triple = "x86_64-unknown-linux-gnu" define i32 @test_load(i32* %a) sanitize_address { -; CHECK: @test_load +; CHECK-LABEL: @test_load ; CHECK-NOT: load ; CHECK: %[[LOAD_ADDR:[^ ]*]] = ptrtoint i32* %a to i64 ; CHECK: lshr i64 %[[LOAD_ADDR]], 3 @@ -14,7 +14,7 @@ define i32 @test_load(i32* %a) sanitize_address { ; CHECK: %[[LOAD_SHADOW_PTR:[^ ]*]] = inttoptr ; CHECK: %[[LOAD_SHADOW:[^ ]*]] = load i8* %[[LOAD_SHADOW_PTR]] ; CHECK: icmp ne i8 -; CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}} +; CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}!prof ![[PROF:[0-9]+]] ; ; First instrumentation block refines the shadow test. ; CHECK: and i64 %[[LOAD_ADDR]], 7 @@ -39,7 +39,7 @@ entry: } define void @test_store(i32* %a) sanitize_address { -; CHECK: @test_store +; CHECK-LABEL: @test_store ; CHECK-NOT: store ; CHECK: %[[STORE_ADDR:[^ ]*]] = ptrtoint i32* %a to i64 ; CHECK: lshr i64 %[[STORE_ADDR]], 3 @@ -84,7 +84,7 @@ entry: ret void } -; CHECK: define void @alloca_test() +; CHECK-LABEL: define void @alloca_test() ; CHECK: = alloca ; CHECK-NOT: = alloca ; CHECK: ret void @@ -95,7 +95,7 @@ entry: ret void } -; CHECK: LongDoubleTest +; CHECK-LABEL: LongDoubleTest ; CHECK: __asan_report_store_n ; CHECK: __asan_report_store_n ; CHECK: ret void @@ -108,7 +108,7 @@ define void @i40test(i40* %a, i40* %b) nounwind uwtable sanitize_address { ret void } -; CHECK: i40test +; CHECK-LABEL: i40test ; CHECK: __asan_report_load_n{{.*}}, i64 5) ; CHECK: __asan_report_load_n{{.*}}, i64 5) ; CHECK: __asan_report_store_n{{.*}}, i64 5) @@ -134,7 +134,7 @@ define void @i80test(i80* %a, i80* %b) nounwind uwtable sanitize_address { ret void } -; CHECK: i80test +; CHECK-LABEL: i80test ; CHECK: __asan_report_load_n{{.*}}, i64 10) ; CHECK: __asan_report_load_n{{.*}}, i64 10) ; CHECK: __asan_report_store_n{{.*}}, i64 10) @@ -147,7 +147,7 @@ entry: %tmp1 = load i32* %a ret i32 %tmp1 } -; CHECK: @f_available_externally +; CHECK-LABEL: @f_available_externally ; CHECK-NOT: __asan_report ; CHECK: ret i32 @@ -169,3 +169,5 @@ define void @memintr_test(i8* %a, i8* %b) nounwind uwtable sanitize_address { ; CHECK: __asan_memcpy ; CHECK: ret void +; PROF +; CHECK: ![[PROF]] = metadata !{metadata !"branch_weights", i32 1, i32 100000} diff --git a/test/Instrumentation/AddressSanitizer/coverage-dbg.ll b/test/Instrumentation/AddressSanitizer/coverage-dbg.ll deleted file mode 100644 index 3f7998d..0000000 --- a/test/Instrumentation/AddressSanitizer/coverage-dbg.ll +++ /dev/null @@ -1,67 +0,0 @@ -; Test that coverage instrumentation does not lose debug location. - -; RUN: opt < %s -asan -asan-module -asan-coverage=1 -S | FileCheck %s - -; C++ source: -; 1: struct A { -; 2: int f(); -; 3: int x; -; 4: }; -; 5: -; 6: int A::f() { -; 7: return x; -; 8: } -; clang++ ../1.cc -O3 -g -S -emit-llvm -fno-strict-aliasing -; and add sanitize_address to @_ZN1A1fEv - -; Test that __sanitizer_cov call has !dbg pointing to the opening { of A::f(). -; CHECK: call void @__sanitizer_cov(), !dbg [[A:!.*]] -; CHECK: [[A]] = metadata !{i32 6, i32 0, metadata !{{.*}}, null} - - -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - -%struct.A = type { i32 } - -; Function Attrs: nounwind readonly uwtable -define i32 @_ZN1A1fEv(%struct.A* nocapture readonly %this) #0 align 2 { -entry: - tail call void @llvm.dbg.value(metadata !{%struct.A* %this}, i64 0, metadata !15), !dbg !20 - %x = getelementptr inbounds %struct.A* %this, i64 0, i32 0, !dbg !21 - %0 = load i32* %x, align 4, !dbg !21 - ret i32 %0, !dbg !21 -} - -; Function Attrs: nounwind readnone -declare void @llvm.dbg.value(metadata, i64, metadata) #1 - -attributes #0 = { sanitize_address nounwind readonly uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { nounwind readnone } - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!17, !18} -!llvm.ident = !{!19} - -!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.5.0 (210251)", i1 true, metadata !"", i32 0, metadata !2, metadata !3, metadata !12, metadata !2, metadata !2, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [/code/llvm/build0/../1.cc] [DW_LANG_C_plus_plus] -!1 = metadata !{metadata !"../1.cc", metadata !"/code/llvm/build0"} -!2 = metadata !{} -!3 = metadata !{metadata !4} -!4 = metadata !{i32 786451, metadata !1, null, metadata !"A", i32 1, i64 32, i64 32, i32 0, i32 0, null, metadata !5, i32 0, null, null, metadata !"_ZTS1A"} ; [ DW_TAG_structure_type ] [A] [line 1, size 32, align 32, offset 0] [def] [from ] -!5 = metadata !{metadata !6, metadata !8} -!6 = metadata !{i32 786445, metadata !1, metadata !"_ZTS1A", metadata !"x", i32 3, i64 32, i64 32, i64 0, i32 0, metadata !7} ; [ DW_TAG_member ] [x] [line 3, size 32, align 32, offset 0] [from int] -!7 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] -!8 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1A", metadata !"f", metadata !"f", metadata !"_ZN1A1fEv", i32 2, metadata !9, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 true, null, null, i32 0, null, i32 2} ; [ DW_TAG_subprogram ] [line 2] [f] -!9 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !10, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] -!10 = metadata !{metadata !7, metadata !11} -!11 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1A", metadata !"f", metadata !"f", metadata !"_ZN1A1fEv", i32 6, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 true, i32 (%struct.A*)* @_ZN1A1fEv, null, metadata !8, metadata !14, i32 6} ; [ DW_TAG_subprogram ] [line 6] [def] [f] -!14 = metadata !{metadata !15} -!15 = metadata !{i32 786689, metadata !13, metadata !"this", null, i32 16777216, metadata !16, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [this] [line 0] -!16 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS1A] -!17 = metadata !{i32 2, metadata !"Dwarf Version", i32 4} -!18 = metadata !{i32 2, metadata !"Debug Info Version", i32 1} -!19 = metadata !{metadata !"clang version 3.5.0 (210251)"} -!20 = metadata !{i32 0, i32 0, metadata !13, null} -!21 = metadata !{i32 7, i32 0, metadata !13, null} diff --git a/test/Instrumentation/AddressSanitizer/coverage.ll b/test/Instrumentation/AddressSanitizer/coverage.ll deleted file mode 100644 index 79bb5c1..0000000 --- a/test/Instrumentation/AddressSanitizer/coverage.ll +++ /dev/null @@ -1,60 +0,0 @@ -; RUN: opt < %s -asan -asan-module -asan-coverage=0 -S | FileCheck %s --check-prefix=CHECK0 -; RUN: opt < %s -asan -asan-module -asan-coverage=1 -S | FileCheck %s --check-prefix=CHECK1 -; RUN: opt < %s -asan -asan-module -asan-coverage=2 -S | FileCheck %s --check-prefix=CHECK2 -; RUN: opt < %s -asan -asan-module -asan-coverage=2 -asan-coverage-block-threshold=10 -S | FileCheck %s --check-prefix=CHECK2 -; RUN: opt < %s -asan -asan-module -asan-coverage=2 -asan-coverage-block-threshold=1 -S | FileCheck %s --check-prefix=CHECK1 - -; RUN: opt < %s -asan -asan-module -asan-coverage=0 -asan-globals=0 -S | \ -; RUN: FileCheck %s --check-prefix=CHECK0 -; RUN: opt < %s -asan -asan-module -asan-coverage=1 -asan-globals=0 -S | \ -; RUN: FileCheck %s --check-prefix=CHECK1 -; RUN: opt < %s -asan -asan-module -asan-coverage=2 -asan-globals=0 -S | \ -; RUN: FileCheck %s --check-prefix=CHECK2 -; RUN: opt < %s -asan -asan-module -asan-coverage=2 -asan-coverage-block-threshold=10 \ -; RUN: -asan-globals=0 -S | FileCheck %s --check-prefix=CHECK2 -; RUN: opt < %s -asan -asan-module -asan-coverage=2 -asan-coverage-block-threshold=1 \ -; RUN: -asan-globals=0 -S | FileCheck %s --check-prefix=CHECK1 - -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 -} - -; CHECK0-NOT: call void @__sanitizer_cov( -; CHECK0-NOT: call void @__sanitizer_cov_module_init( - -; CHECK1-LABEL: define void @foo -; CHECK1: %0 = load atomic i8* @__asan_gen_cov_foo monotonic, align 1 -; CHECK1: %1 = icmp eq i8 0, %0 -; CHECK1: br i1 %1, label %2, label %3 -; CHECK1: call void @__sanitizer_cov -; CHECK1-NOT: call void @__sanitizer_cov -; CHECK1: store atomic i8 1, i8* @__asan_gen_cov_foo monotonic, align 1 - -; CHECK1-LABEL: define internal void @asan.module_ctor -; CHECK1-NOT: ret -; CHECK1: call void @__sanitizer_cov_module_init(i64 1) -; CHECK1: ret - - -; CHECK2-LABEL: define void @foo -; CHECK2: call void @__sanitizer_cov -; CHECK2: call void @__sanitizer_cov -; CHECK2: call void @__sanitizer_cov -; CHECK2-NOT: call void @__sanitizer_cov -; CHECK2: ret void - -; CHECK2-LABEL: define internal void @asan.module_ctor -; CHECK2-NOT: ret -; CHECK2: call void @__sanitizer_cov_module_init(i64 3) -; CHECK2: ret diff --git a/test/Instrumentation/AddressSanitizer/debug_info.ll b/test/Instrumentation/AddressSanitizer/debug_info.ll index 336b98b..ea51551 100644 --- a/test/Instrumentation/AddressSanitizer/debug_info.ll +++ b/test/Instrumentation/AddressSanitizer/debug_info.ll @@ -11,8 +11,8 @@ entry: %p.addr = alloca i32, align 4 %r = alloca i32, align 4 store i32 %p, i32* %p.addr, align 4 - call void @llvm.dbg.declare(metadata !{i32* %p.addr}, metadata !10), !dbg !11 - call void @llvm.dbg.declare(metadata !{i32* %r}, metadata !12), !dbg !14 + call void @llvm.dbg.declare(metadata !{i32* %p.addr}, metadata !10, metadata !{metadata !"0x102"}), !dbg !11 + call void @llvm.dbg.declare(metadata !{i32* %r}, metadata !12, metadata !{metadata !"0x102"}), !dbg !14 %0 = load i32* %p.addr, align 4, !dbg !14 %add = add nsw i32 %0, 1, !dbg !14 store i32 %add, i32* %r, align 4, !dbg !14 @@ -24,39 +24,39 @@ entry: ; CHECK: entry: ; Verify that llvm.dbg.declare calls are in the entry basic block. ; CHECK-NOT: %entry -; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ARG_ID:[0-9]+]]) +; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ARG_ID:[0-9]+]], metadata ![[OPDEREF:[0-9]+]]) ; CHECK-NOT: %entry -; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[VAR_ID:[0-9]+]]) +; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[VAR_ID:[0-9]+]], metadata ![[OPDEREF:[0-9]+]]) -declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!17} -!0 = metadata !{i32 786449, metadata !16, i32 4, metadata !"clang version 3.3 (trunk 169314)", i1 true, metadata !"", i32 0, metadata !1, metadata !1, metadata !3, metadata !1, null, metadata !""} ; [ DW_TAG_compile_unit ] [/usr/local/google/llvm_cmake_clang/tmp/debuginfo/a.cc] [DW_LANG_C_plus_plus] +!0 = metadata !{metadata !"0x11\004\00clang version 3.3 (trunk 169314)\001\00\000\00\000", metadata !16, metadata !1, metadata !1, metadata !3, metadata !1, null} ; [ DW_TAG_compile_unit ] [/usr/local/google/llvm_cmake_clang/tmp/debuginfo/a.cc] [DW_LANG_C_plus_plus] !1 = metadata !{i32 0} !3 = metadata !{metadata !5} -!5 = metadata !{i32 786478, metadata !16, metadata !6, metadata !"zzz", metadata !"zzz", metadata !"_Z3zzzi", i32 1, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z3zzzi, null, null, metadata !1, i32 1} ; [ DW_TAG_subprogram ] [line 1] [def] [zzz] -!6 = metadata !{i32 786473, metadata !16} ; [ DW_TAG_file_type ] -!7 = metadata !{i32 786453, i32 0, null, i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!5 = metadata !{metadata !"0x2e\00zzz\00zzz\00_Z3zzzi\001\000\001\000\006\00256\000\001", metadata !16, metadata !6, metadata !7, null, i32 (i32)* @_Z3zzzi, null, null, metadata !1} ; [ DW_TAG_subprogram ] [line 1] [def] [zzz] +!6 = metadata !{metadata !"0x29", metadata !16} ; [ DW_TAG_file_type ] +!7 = metadata !{metadata !"0x15\00\000\000\000\000\000\000", i32 0, null, null, metadata !8, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] !8 = metadata !{metadata !9, metadata !9} -!9 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] -!10 = metadata !{i32 786689, metadata !5, metadata !"p", metadata !6, i32 16777217, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [p] [line 1] +!9 = metadata !{metadata !"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!10 = metadata !{metadata !"0x101\00p\0016777217\000", metadata !5, metadata !6, metadata !9} ; [ DW_TAG_arg_variable ] [p] [line 1] !11 = metadata !{i32 1, i32 0, metadata !5, null} -!12 = metadata !{i32 786688, metadata !13, metadata !"r", metadata !6, i32 2, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [r] [line 2] +!12 = metadata !{metadata !"0x100\00r\002\000", metadata !13, metadata !6, metadata !9} ; [ DW_TAG_auto_variable ] [r] [line 2] ; Verify that debug descriptors for argument and local variable will be replaced ; with descriptors that end with OpDeref (encoded as 2). -; CHECK: ![[ARG_ID]] = {{.*}}metadata ![[OPDEREF:[0-9]+]]} ; [ DW_TAG_arg_variable ] [p] [line 1] -; CHECK: ![[OPDEREF]] = metadata !{i64 2} -; CHECK: ![[VAR_ID]] = {{.*}}metadata ![[OPDEREF]]} ; [ DW_TAG_auto_variable ] [r] [line 2] +; CHECK: ![[ARG_ID]] = {{.*}} ; [ DW_TAG_arg_variable ] [p] [line 1] +; CHECK: ![[OPDEREF]] = metadata !{metadata !"0x102\006"} +; CHECK: ![[VAR_ID]] = {{.*}} ; [ DW_TAG_auto_variable ] [r] [line 2] ; Verify that there are no more variable descriptors. ; CHECK-NOT: DW_TAG_arg_variable ; CHECK-NOT: DW_TAG_auto_variable -!13 = metadata !{i32 786443, metadata !16, metadata !5, i32 1, i32 0, i32 0} ; [ DW_TAG_lexical_block ] [/usr/local/google/llvm_cmake_clang/tmp/debuginfo/a.cc] +!13 = metadata !{metadata !"0xb\001\000\000", metadata !16, metadata !5} ; [ DW_TAG_lexical_block ] [/usr/local/google/llvm_cmake_clang/tmp/debuginfo/a.cc] !14 = metadata !{i32 2, i32 0, metadata !13, null} !15 = metadata !{i32 3, i32 0, metadata !13, null} !16 = metadata !{metadata !"a.cc", metadata !"/usr/local/google/llvm_cmake_clang/tmp/debuginfo"} -!17 = metadata !{i32 1, metadata !"Debug Info Version", i32 1} +!17 = metadata !{i32 1, metadata !"Debug Info Version", i32 2} diff --git a/test/Instrumentation/AddressSanitizer/do-not-instrument-cstring.ll b/test/Instrumentation/AddressSanitizer/do-not-instrument-cstring.ll new file mode 100644 index 0000000..de6a4de --- /dev/null +++ b/test/Instrumentation/AddressSanitizer/do-not-instrument-cstring.ll @@ -0,0 +1,7 @@ +; RUN: opt < %s -asan -asan-module -S | FileCheck %s + +target datalayout = "e" + +@foo = private global [19 x i8] c"scannerWithString:\00", section "__TEXT,__objc_methname,cstring_literals" + +; CHECK: @foo = private global [19 x i8] c"scannerWithString:\00", section "__TEXT,__objc_methname,cstring_literals"
\ No newline at end of file diff --git a/test/Instrumentation/AddressSanitizer/do-not-touch-comdat-global.ll b/test/Instrumentation/AddressSanitizer/do-not-touch-comdat-global.ll new file mode 100644 index 0000000..8d14e83 --- /dev/null +++ b/test/Instrumentation/AddressSanitizer/do-not-touch-comdat-global.ll @@ -0,0 +1,14 @@ +; This test checks that we instrument regular globals, but do not touch +; the COMDAT ones. +; RUN: opt < %s -asan -asan-module -S | FileCheck %s +target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32" +target triple = "i686-pc-windows-msvc" +; no action should be taken for these globals +$global_noinst = comdat largest +@aliasee = private unnamed_addr constant [2 x i8] [i8 1, i8 2], comdat $global_noinst +@global_noinst = unnamed_addr alias [2 x i8]* @aliasee +; CHECK-NOT: {{asan_gen.*global_noinst}} +; CHECK-DAG: @global_noinst = unnamed_addr alias [2 x i8]* @aliasee +@global_inst = private constant [2 x i8] [i8 1, i8 2] +; CHECK-DAG: {{asan_gen.*global_inst}} +; CHECK: @asan.module_ctor diff --git a/test/Instrumentation/AddressSanitizer/global_metadata.ll b/test/Instrumentation/AddressSanitizer/global_metadata.ll index 9641c3e..fd5a8c6 100644 --- a/test/Instrumentation/AddressSanitizer/global_metadata.ll +++ b/test/Instrumentation/AddressSanitizer/global_metadata.ll @@ -11,20 +11,18 @@ target triple = "x86_64-unknown-linux-gnu" @.str = private unnamed_addr constant [14 x i8] c"Hello, world!\00", align 1 @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_asan_globals.cpp, i8* null }] -; Sanitizer location descriptors: -@.str1 = private unnamed_addr constant [22 x i8] c"/tmp/asan-globals.cpp\00", align 1 -@.asan_loc_descr = private unnamed_addr constant { [22 x i8]*, i32, i32 } { [22 x i8]* @.str1, i32 5, i32 5 } -@.asan_loc_descr1 = private unnamed_addr constant { [22 x i8]*, i32, i32 } { [22 x i8]* @.str1, i32 7, i32 5 } -@.asan_loc_descr2 = private unnamed_addr constant { [22 x i8]*, i32, i32 } { [22 x i8]* @.str1, i32 12, i32 14 } -@.asan_loc_descr4 = private unnamed_addr constant { [22 x i8]*, i32, i32 } { [22 x i8]* @.str1, i32 14, i32 25 } - -; Check that globals were instrumented, but sanitizer location descriptors weren't: +; Check that globals were instrumented: ; CHECK: @global = global { i32, [60 x i8] } zeroinitializer, align 32 ; CHECK: @.str = internal unnamed_addr constant { [14 x i8], [50 x i8] } { [14 x i8] c"Hello, world!\00", [50 x i8] zeroinitializer }, align 32 -; CHECK: @.asan_loc_descr = private unnamed_addr constant { [22 x i8]*, i32, i32 } { [22 x i8]* @.str1, i32 5, i32 5 } -; Check that location decriptors were passed into __asan_register_globals: -; CHECK: i64 ptrtoint ({ [22 x i8]*, i32, i32 }* @.asan_loc_descr to i64) +; Check emitted location descriptions: +; CHECK: [[VARNAME:@__asan_gen_[0-9]+]] = private unnamed_addr constant [7 x i8] c"global\00", align 1 +; CHECK: [[FILENAME:@__asan_gen_[0-9]+]] = private unnamed_addr constant [22 x i8] c"/tmp/asan-globals.cpp\00", align 1 +; CHECK: [[LOCDESCR:@__asan_gen_[0-9]+]] = private unnamed_addr constant { [22 x i8]*, i32, i32 } { [22 x i8]* [[FILENAME]], i32 5, i32 5 } + +; Check that location decriptors and global names were passed into __asan_register_globals: +; CHECK: i64 ptrtoint ([7 x i8]* [[VARNAME]] to i64) +; CHECK: i64 ptrtoint ({ [22 x i8]*, i32, i32 }* [[LOCDESCR]] to i64) ; Function Attrs: nounwind sanitize_address define internal void @__cxx_global_var_init() #0 section ".text.startup" { @@ -55,9 +53,15 @@ attributes #1 = { nounwind sanitize_address "less-precise-fpmad"="false" "no-fra !llvm.asan.globals = !{!0, !1, !2, !3, !4} !llvm.ident = !{!5} -!0 = metadata !{i32* @global, { [22 x i8]*, i32, i32 }* @.asan_loc_descr, i1 false, i1 false} -!1 = metadata !{i32* @dyn_init_global, { [22 x i8]*, i32, i32 }* @.asan_loc_descr1, i1 true, i1 false} -!2 = metadata !{i32* @blacklisted_global, null, i1 false, i1 true} -!3 = metadata !{i32* @_ZZ4funcvE10static_var, { [22 x i8]*, i32, i32 }* @.asan_loc_descr2, i1 false, i1 false} -!4 = metadata !{[14 x i8]* @.str, { [22 x i8]*, i32, i32 }* @.asan_loc_descr4, i1 false, i1 false} +!0 = metadata !{i32* @global, metadata !6, metadata !"global", i1 false, i1 false} +!1 = metadata !{i32* @dyn_init_global, metadata !7, metadata !"dyn_init_global", i1 true, i1 false} +!2 = metadata !{i32* @blacklisted_global, null, null, i1 false, i1 true} +!3 = metadata !{i32* @_ZZ4funcvE10static_var, metadata !8, metadata !"static_var", i1 false, i1 false} +!4 = metadata !{[14 x i8]* @.str, metadata !9, metadata !"<string literal>", i1 false, i1 false} + !5 = metadata !{metadata !"clang version 3.5.0 (211282)"} + +!6 = metadata !{metadata !"/tmp/asan-globals.cpp", i32 5, i32 5} +!7 = metadata !{metadata !"/tmp/asan-globals.cpp", i32 7, i32 5} +!8 = metadata !{metadata !"/tmp/asan-globals.cpp", i32 12, i32 14} +!9 = metadata !{metadata !"/tmp/asan-globals.cpp", i32 14, i32 25} diff --git a/test/Instrumentation/AddressSanitizer/instrument_global.ll b/test/Instrumentation/AddressSanitizer/instrument_global.ll index 816ab29..80791d9 100644 --- a/test/Instrumentation/AddressSanitizer/instrument_global.ll +++ b/test/Instrumentation/AddressSanitizer/instrument_global.ll @@ -69,7 +69,7 @@ entry: !llvm.asan.globals = !{!0} -!0 = metadata !{[10 x i32]* @GlobDy, null, i1 true, i1 false} +!0 = metadata !{[10 x i32]* @GlobDy, null, null, i1 true, i1 false} ; CHECK-LABEL: define internal void @asan.module_ctor ; CHECK-NOT: ret diff --git a/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll b/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll index 83ff53f..c2bb0aa 100644 --- a/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll +++ b/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll @@ -7,10 +7,10 @@ target triple = "x86_64-unknown-linux-gnu" @YYY = global i32 0, align 4 ; W/o dynamic initializer. ; Clang will emit the following metadata identifying @xxx as dynamically ; initialized. -!0 = metadata !{i32* @xxx, null, i1 true, i1 false} -!1 = metadata !{i32* @XXX, null, i1 true, i1 false} -!2 = metadata !{i32* @yyy, null, i1 false, i1 false} -!3 = metadata !{i32* @YYY, null, i1 false, i1 false} +!0 = metadata !{i32* @xxx, null, null, i1 true, i1 false} +!1 = metadata !{i32* @XXX, null, null, i1 true, i1 false} +!2 = metadata !{i32* @yyy, null, null, i1 false, i1 false} +!3 = metadata !{i32* @YYY, null, null, i1 false, i1 false} !llvm.asan.globals = !{!0, !1, !2, !3} define i32 @initializer() uwtable { @@ -25,29 +25,39 @@ entry: ret void } -@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@llvm.global_ctors = appending global [2 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @__late_ctor }, { i32, void ()* } { i32 0, void ()* @__early_ctor }] -define internal void @_GLOBAL__I_a() sanitize_address section ".text.startup" { +define internal void @__late_ctor() sanitize_address section ".text.startup" { entry: call void @__cxx_global_var_init() ret void } ; Clang indicated that @xxx was dynamically initailized. -; __asan_{before,after}_dynamic_init should be called from _GLOBAL__I_a +; __asan_{before,after}_dynamic_init should be called from __late_ctor -; CHECK: define internal void @_GLOBAL__I_a +; CHECK-LABEL: define internal void @__late_ctor ; CHECK-NOT: ret ; CHECK: call void @__asan_before_dynamic_init ; CHECK: call void @__cxx_global_var_init ; CHECK: call void @__asan_after_dynamic_init ; CHECK: ret +; CTOR with priority 0 should not be instrumented. +define internal void @__early_ctor() sanitize_address section ".text.startup" { +entry: + call void @__cxx_global_var_init() + ret void +} +; CHECK-LABEL: define internal void @__early_ctor +; CHECK-NOT: __asan +; CHECK: ret + ; Check that xxx is instrumented. define void @touch_xxx() sanitize_address { store i32 0, i32 *@xxx, align 4 ret void -; CHECK: define void @touch_xxx +; CHECK-LABEL: touch_xxx ; CHECK: call void @__asan_report_store4 ; CHECK: ret void } diff --git a/test/Instrumentation/AddressSanitizer/ubsan.ll b/test/Instrumentation/AddressSanitizer/ubsan.ll new file mode 100644 index 0000000..22e4172 --- /dev/null +++ b/test/Instrumentation/AddressSanitizer/ubsan.ll @@ -0,0 +1,52 @@ +; ASan shouldn't instrument code added by UBSan. + +; RUN: opt < %s -asan -asan-module -S | FileCheck %s + +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" + +%struct.A = type { i32 (...)** } +declare void @__ubsan_handle_dynamic_type_cache_miss(i8*, i64, i64) uwtable +@__ubsan_vptr_type_cache = external global [128 x i64] +@.src = private unnamed_addr constant [19 x i8] c"tmp/ubsan/vptr.cpp\00", align 1 +@0 = private unnamed_addr constant { i16, i16, [4 x i8] } { i16 -1, i16 0, [4 x i8] c"'A'\00" } +@_ZTI1A = external constant i8* +@1 = private unnamed_addr global { { [19 x i8]*, i32, i32 }, { i16, i16, [4 x i8] }*, i8*, i8 } { { [19 x i8]*, i32, i32 } { [19 x i8]* @.src, i32 2, i32 18 }, { i16, i16, [4 x i8] }* @0, i8* bitcast (i8** @_ZTI1A to i8*), i8 4 } + +define void @_Z3BarP1A(%struct.A* %a) uwtable sanitize_address { +; CHECK-LABEL: define void @_Z3BarP1A +entry: + %0 = bitcast %struct.A* %a to void (%struct.A*)*** + %vtable = load void (%struct.A*)*** %0, align 8 +; CHECK: __asan_report_load8 + %1 = load void (%struct.A*)** %vtable, align 8 +; CHECK: __asan_report_load8 + %2 = ptrtoint void (%struct.A*)** %vtable to i64 + %3 = xor i64 %2, -303164226014115343, !nosanitize !0 + %4 = mul i64 %3, -7070675565921424023, !nosanitize !0 + %5 = lshr i64 %4, 47, !nosanitize !0 + %6 = xor i64 %4, %2, !nosanitize !0 + %7 = xor i64 %6, %5, !nosanitize !0 + %8 = mul i64 %7, -7070675565921424023, !nosanitize !0 + %9 = lshr i64 %8, 47, !nosanitize !0 + %10 = xor i64 %9, %8, !nosanitize !0 + %11 = mul i64 %10, -7070675565921424023, !nosanitize !0 + %12 = and i64 %11, 127, !nosanitize !0 + %13 = getelementptr inbounds [128 x i64]* @__ubsan_vptr_type_cache, i64 0, i64 %12, !nosanitize !0 +; CHECK-NOT: __asan_report_load8 + %14 = load i64* %13, align 8, !nosanitize !0 + %15 = icmp eq i64 %14, %11, !nosanitize !0 + br i1 %15, label %cont, label %handler.dynamic_type_cache_miss, !nosanitize !0 + +handler.dynamic_type_cache_miss: ; preds = %entry + %16 = ptrtoint %struct.A* %a to i64, !nosanitize !0 + tail call void @__ubsan_handle_dynamic_type_cache_miss(i8* bitcast ({ { [19 x i8]*, i32, i32 }, { i16, i16, [4 x i8] }*, i8*, i8 }* @1 to i8*), i64 %16, i64 %11) #2, !nosanitize !0 + br label %cont, !nosanitize !0 + +cont: ; preds = %handler.dynamic_type_cache_miss, %entry + tail call void %1(%struct.A* %a) +; CHECK: ret void + ret void +} + +!0 = metadata !{} diff --git a/test/Instrumentation/DataFlowSanitizer/Inputs/debuglist.txt b/test/Instrumentation/DataFlowSanitizer/Inputs/debuglist.txt new file mode 100644 index 0000000..daf7b5f --- /dev/null +++ b/test/Instrumentation/DataFlowSanitizer/Inputs/debuglist.txt @@ -0,0 +1,2 @@ +fun:main=uninstrumented +fun:main=discard diff --git a/test/Instrumentation/DataFlowSanitizer/abilist.ll b/test/Instrumentation/DataFlowSanitizer/abilist.ll index 66ddc14..ebf55d9 100644 --- a/test/Instrumentation/DataFlowSanitizer/abilist.ll +++ b/test/Instrumentation/DataFlowSanitizer/abilist.ll @@ -12,16 +12,38 @@ define i32 @functional(i32 %a, i32 %b) { ret i32 %c } +; CHECK: define i32 (i32, i32)* @discardg(i32) +; CHECK: %[[CALL:.*]] = call { i32 (i32, i32)*, i16 } @"dfs$g"(i32 %0, i16 0) +; CHECK: %[[XVAL:.*]] = extractvalue { i32 (i32, i32)*, i16 } %[[CALL]], 0 +; CHECK: ret {{.*}} %[[XVAL]] +@discardg = alias i32 (i32, i32)* (i32)* @g + declare void @custom1(i32 %a, i32 %b) +; CHECK: define linkonce_odr { i32, i16 } @"dfsw$custom2"(i32, i32, i16, i16) +; CHECK: %[[LABELRETURN2:.*]] = alloca i16 +; CHECK: %[[RV:.*]] = call i32 @__dfsw_custom2 +; CHECK: %[[RVSHADOW:.*]] = load i16* %[[LABELRETURN2]] +; CHECK: insertvalue {{.*}}[[RV]], 0 +; CHECK: insertvalue {{.*}}[[RVSHADOW]], 1 +; CHECK: ret { i32, i16 } declare i32 @custom2(i32 %a, i32 %b) +; CHECK: define linkonce_odr void @"dfsw$custom3"(i32, i16, i16*, ...) +; CHECK: call void @__dfsan_vararg_wrapper(i8* +; CHECK: unreachable +declare void @custom3(i32 %a, ...) + +declare i32 @custom4(i32 %a, ...) + declare void @customcb(i32 (i32)* %cb) declare i32 @cb(i32) ; CHECK: @"dfs$f" -define void @f() { +define void @f(i32 %x) { + ; CHECK: %[[LABELVA2:.*]] = alloca [2 x i16] + ; CHECK: %[[LABELVA1:.*]] = alloca [2 x i16] ; CHECK: %[[LABELRETURN:.*]] = alloca i16 ; CHECK: call void @__dfsw_custom1(i32 1, i32 2, i16 0, i16 0) @@ -33,22 +55,21 @@ define void @f() { ; CHECK: call void @__dfsw_customcb({{.*}} @"dfst0$customcb", i8* bitcast ({{.*}} @"dfs$cb" to i8*), i16 0) call void @customcb(i32 (i32)* @cb) - ret void -} + ; CHECK: %[[LABELVA1_0:.*]] = getelementptr inbounds [2 x i16]* %[[LABELVA1]], i32 0, i32 0 + ; CHECK: store i16 0, i16* %[[LABELVA1_0]] + ; CHECK: %[[LABELVA1_1:.*]] = getelementptr inbounds [2 x i16]* %[[LABELVA1]], i32 0, i32 1 + ; CHECK: store i16 %{{.*}}, i16* %[[LABELVA1_1]] + ; CHECK: %[[LABELVA1_0A:.*]] = getelementptr inbounds [2 x i16]* %[[LABELVA1]], i32 0, i32 0 + ; CHECK: call void (i32, i16, i16*, ...)* @__dfsw_custom3(i32 1, i16 0, i16* %[[LABELVA1_0A]], i32 2, i32 %{{.*}}) + call void (i32, ...)* @custom3(i32 1, i32 2, i32 %x) -; CHECK: define i32 (i32, i32)* @discardg(i32) -; CHECK: %[[CALL:.*]] = call { i32 (i32, i32)*, i16 } @"dfs$g"(i32 %0, i16 0) -; CHECK: %[[XVAL:.*]] = extractvalue { i32 (i32, i32)*, i16 } %[[CALL]], 0 -; CHECK: ret {{.*}} %[[XVAL]] -@discardg = alias i32 (i32, i32)* (i32)* @g + ; CHECK: %[[LABELVA2_0:.*]] = getelementptr inbounds [2 x i16]* %[[LABELVA2]], i32 0, i32 0 + ; CHECK: %[[LABELVA2_0A:.*]] = getelementptr inbounds [2 x i16]* %[[LABELVA2]], i32 0, i32 0 + ; CHECK: call i32 (i32, i16, i16*, i16*, ...)* @__dfsw_custom4(i32 1, i16 0, i16* %[[LABELVA2_0A]], i16* %[[LABELRETURN]], i32 2, i32 3) + call i32 (i32, ...)* @custom4(i32 1, i32 2, i32 3) -; CHECK: define linkonce_odr { i32, i16 } @"dfsw$custom2"(i32, i32, i16, i16) -; CHECK: %[[LABELRETURN2:.*]] = alloca i16 -; CHECK: %[[RV:.*]] = call i32 @__dfsw_custom2 -; CHECK: %[[RVSHADOW:.*]] = load i16* %[[LABELRETURN2]] -; CHECK: insertvalue {{.*}}[[RV]], 0 -; CHECK: insertvalue {{.*}}[[RVSHADOW]], 1 -; CHECK: ret { i32, i16 } + ret void +} ; CHECK: @"dfs$g" define i32 (i32, i32)* @g(i32) { @@ -73,3 +94,6 @@ define i32 (i32, i32)* @g(i32) { ; CHECK: %[[XVAL1:.*]] = extractvalue { i32, i16 } %[[CALL]], 1 ; CHECK: store i16 %[[XVAL1]], i16* %3 ; CHECK: ret i32 %[[XVAL0]] + +; CHECK: declare void @__dfsw_custom3(i32, i16, i16*, ...) +; CHECK: declare i32 @__dfsw_custom4(i32, i16, i16*, i16*, ...) diff --git a/test/Instrumentation/DataFlowSanitizer/debug-nonzero-labels.ll b/test/Instrumentation/DataFlowSanitizer/debug-nonzero-labels.ll index 6bcd5c5..eb28c2c 100644 --- a/test/Instrumentation/DataFlowSanitizer/debug-nonzero-labels.ll +++ b/test/Instrumentation/DataFlowSanitizer/debug-nonzero-labels.ll @@ -3,13 +3,16 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3 declare i32 @g() -; CHECK: define { i32, i16 } @"dfs$f"(i32, i16) -define i32 @f(i32) { +; CHECK: define { i32, i16 } @"dfs$f"(i32, i32, i16, i16) +define i32 @f(i32, i32) { ; CHECK: [[LOCALLABELALLOCA:%.*]] = alloca i16 - ; CHECK: [[ARGCMP:%.*]] = icmp ne i16 %1, 0 - ; CHECK: br i1 [[ARGCMP]] %i = alloca i32 - store i32 %0, i32* %i + ; CHECK: [[ARGCMP1:%.*]] = icmp ne i16 %3, 0 + ; CHECK: br i1 [[ARGCMP1]] + ; CHECK: [[ARGCMP2:%.*]] = icmp ne i16 %2, 0 + ; CHECK: br i1 [[ARGCMP2]] + %x = add i32 %0, %1 + store i32 %x, i32* %i ; CHECK: [[CALL:%.*]] = call { i32, i16 } @"dfs$g"() ; CHECK: [[CALLLABEL:%.*]] = extractvalue { i32, i16 } [[CALL]], 1 ; CHECK: [[CALLCMP:%.*]] = icmp ne i16 [[CALLLABEL]], 0 diff --git a/test/Instrumentation/DataFlowSanitizer/debug.ll b/test/Instrumentation/DataFlowSanitizer/debug.ll new file mode 100644 index 0000000..cfc9dd9 --- /dev/null +++ b/test/Instrumentation/DataFlowSanitizer/debug.ll @@ -0,0 +1,36 @@ +; RUN: opt < %s -dfsan -dfsan-abilist=%S/Inputs/debuglist.txt -S | FileCheck %s + +; CHECK: i32 ()* @main, {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [main] + +; Generated from a simple source file compiled with clang -g: +; int main() { +; } + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: nounwind uwtable +define i32 @main() #0 { +entry: + ret i32 0, !dbg !12 +} + +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!9, !10} +!llvm.ident = !{!11} + +!0 = metadata !{metadata !"0x11\004\00clang version 3.6.0 \000\00\000\00\001", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/debug.cpp] [DW_LANG_C_plus_plus] +!1 = metadata !{metadata !"debug.cpp", metadata !"/tmp/dbginfo"} +!2 = metadata !{} +!3 = metadata !{metadata !4} +!4 = metadata !{metadata !"0x2e\00main\00main\00\001\000\001\000\000\00256\000\001", metadata !1, metadata !5, metadata !6, null, i32 ()* @main, null, null, metadata !2} ; [ DW_TAG_subprogram ] [line 1] [def] [main] +!5 = metadata !{metadata !"0x29", metadata !1} ; [ DW_TAG_file_type ] [/tmp/dbginfo/debug.cpp] +!6 = metadata !{metadata !"0x15\00\000\000\000\000\000\000", null, null, null, metadata !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = metadata !{metadata !8} +!8 = metadata !{metadata !"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!9 = metadata !{i32 2, metadata !"Dwarf Version", i32 4} +!10 = metadata !{i32 2, metadata !"Debug Info Version", i32 2} +!11 = metadata !{metadata !"clang version 3.6.0 "} +!12 = metadata !{i32 2, i32 1, metadata !4, null} diff --git a/test/Instrumentation/DataFlowSanitizer/load.ll b/test/Instrumentation/DataFlowSanitizer/load.ll index 6cd5151..8324224 100644 --- a/test/Instrumentation/DataFlowSanitizer/load.ll +++ b/test/Instrumentation/DataFlowSanitizer/load.ll @@ -2,6 +2,18 @@ ; RUN: opt < %s -dfsan -dfsan-combine-pointer-labels-on-load=0 -S | FileCheck %s --check-prefix=NO_COMBINE_PTR_LABEL 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 {} @load0({}* %p) { + ; COMBINE_PTR_LABEL: @"dfs$load0" + ; COMBINE_PTR_LABEL: load + ; COMBINE_PTR_LABEL-NOT: load + + ; NO_COMBINE_PTR_LABEL: @"dfs$load0" + ; NO_COMBINE_PTR_LABEL: load + ; NO_COMBINE_PTR_LABEL-NOT: load + %a = load {}* %p + ret {} %a +} + define i8 @load8(i8* %p) { ; COMBINE_PTR_LABEL: @"dfs$load8" ; COMBINE_PTR_LABEL: load i16* @@ -152,4 +164,4 @@ define i64 @load64(i64* %p) { %a = load i64* %p ret i64 %a -}
\ No newline at end of file +} diff --git a/test/Instrumentation/DataFlowSanitizer/store.ll b/test/Instrumentation/DataFlowSanitizer/store.ll index 8060537..d14bdb6 100644 --- a/test/Instrumentation/DataFlowSanitizer/store.ll +++ b/test/Instrumentation/DataFlowSanitizer/store.ll @@ -2,6 +2,19 @@ ; RUN: opt < %s -dfsan -dfsan-combine-pointer-labels-on-store=0 -S | FileCheck %s --check-prefix=NO_COMBINE_PTR_LABEL 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 void @store0({} %v, {}* %p) { + ; COMBINE_PTR_LABEL: @"dfs$store0" + ; COMBINE_PTR_LABEL: store + ; COMBINE_PTR_LABEL-NOT: store + + ; NO_COMBINE_PTR_LABEL: @"dfs$store0" + ; NO_COMBINE_PTR_LABEL: store + ; NO_COMBINE_PTR_LABEL-NOT: store + + store {} %v, {}* %p + ret void +} + define void @store8(i8 %v, i8* %p) { ; NO_COMBINE_PTR_LABEL: @"dfs$store8" ; NO_COMBINE_PTR_LABEL: load i16* {{.*}} @__dfsan_arg_tls diff --git a/test/Instrumentation/DataFlowSanitizer/union-large.ll b/test/Instrumentation/DataFlowSanitizer/union-large.ll new file mode 100644 index 0000000..a388f73 --- /dev/null +++ b/test/Instrumentation/DataFlowSanitizer/union-large.ll @@ -0,0 +1,3013 @@ +; RUN: opt < %s -dfsan -S | FileCheck %s +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" + +; Check that we use dfsan_union in large functions instead of __dfsan_union. + +; CHECK-LABEL: @"dfs$foo" +define i32 @foo(i32 %a, i32 %b) { +bb0: + br label %bb1 + +bb1: + br label %bb2 + +bb2: + br label %bb3 + +bb3: + br label %bb4 + +bb4: + br label %bb5 + +bb5: + br label %bb6 + +bb6: + br label %bb7 + +bb7: + br label %bb8 + +bb8: + br label %bb9 + +bb9: + br label %bb10 + +bb10: + br label %bb11 + +bb11: + br label %bb12 + +bb12: + br label %bb13 + +bb13: + br label %bb14 + +bb14: + br label %bb15 + +bb15: + br label %bb16 + +bb16: + br label %bb17 + +bb17: + br label %bb18 + +bb18: + br label %bb19 + +bb19: + br label %bb20 + +bb20: + br label %bb21 + +bb21: + br label %bb22 + +bb22: + br label %bb23 + +bb23: + br label %bb24 + +bb24: + br label %bb25 + +bb25: + br label %bb26 + +bb26: + br label %bb27 + +bb27: + br label %bb28 + +bb28: + br label %bb29 + +bb29: + br label %bb30 + +bb30: + br label %bb31 + +bb31: + br label %bb32 + +bb32: + br label %bb33 + +bb33: + br label %bb34 + +bb34: + br label %bb35 + +bb35: + br label %bb36 + +bb36: + br label %bb37 + +bb37: + br label %bb38 + +bb38: + br label %bb39 + +bb39: + br label %bb40 + +bb40: + br label %bb41 + +bb41: + br label %bb42 + +bb42: + br label %bb43 + +bb43: + br label %bb44 + +bb44: + br label %bb45 + +bb45: + br label %bb46 + +bb46: + br label %bb47 + +bb47: + br label %bb48 + +bb48: + br label %bb49 + +bb49: + br label %bb50 + +bb50: + br label %bb51 + +bb51: + br label %bb52 + +bb52: + br label %bb53 + +bb53: + br label %bb54 + +bb54: + br label %bb55 + +bb55: + br label %bb56 + +bb56: + br label %bb57 + +bb57: + br label %bb58 + +bb58: + br label %bb59 + +bb59: + br label %bb60 + +bb60: + br label %bb61 + +bb61: + br label %bb62 + +bb62: + br label %bb63 + +bb63: + br label %bb64 + +bb64: + br label %bb65 + +bb65: + br label %bb66 + +bb66: + br label %bb67 + +bb67: + br label %bb68 + +bb68: + br label %bb69 + +bb69: + br label %bb70 + +bb70: + br label %bb71 + +bb71: + br label %bb72 + +bb72: + br label %bb73 + +bb73: + br label %bb74 + +bb74: + br label %bb75 + +bb75: + br label %bb76 + +bb76: + br label %bb77 + +bb77: + br label %bb78 + +bb78: + br label %bb79 + +bb79: + br label %bb80 + +bb80: + br label %bb81 + +bb81: + br label %bb82 + +bb82: + br label %bb83 + +bb83: + br label %bb84 + +bb84: + br label %bb85 + +bb85: + br label %bb86 + +bb86: + br label %bb87 + +bb87: + br label %bb88 + +bb88: + br label %bb89 + +bb89: + br label %bb90 + +bb90: + br label %bb91 + +bb91: + br label %bb92 + +bb92: + br label %bb93 + +bb93: + br label %bb94 + +bb94: + br label %bb95 + +bb95: + br label %bb96 + +bb96: + br label %bb97 + +bb97: + br label %bb98 + +bb98: + br label %bb99 + +bb99: + br label %bb100 + +bb100: + br label %bb101 + +bb101: + br label %bb102 + +bb102: + br label %bb103 + +bb103: + br label %bb104 + +bb104: + br label %bb105 + +bb105: + br label %bb106 + +bb106: + br label %bb107 + +bb107: + br label %bb108 + +bb108: + br label %bb109 + +bb109: + br label %bb110 + +bb110: + br label %bb111 + +bb111: + br label %bb112 + +bb112: + br label %bb113 + +bb113: + br label %bb114 + +bb114: + br label %bb115 + +bb115: + br label %bb116 + +bb116: + br label %bb117 + +bb117: + br label %bb118 + +bb118: + br label %bb119 + +bb119: + br label %bb120 + +bb120: + br label %bb121 + +bb121: + br label %bb122 + +bb122: + br label %bb123 + +bb123: + br label %bb124 + +bb124: + br label %bb125 + +bb125: + br label %bb126 + +bb126: + br label %bb127 + +bb127: + br label %bb128 + +bb128: + br label %bb129 + +bb129: + br label %bb130 + +bb130: + br label %bb131 + +bb131: + br label %bb132 + +bb132: + br label %bb133 + +bb133: + br label %bb134 + +bb134: + br label %bb135 + +bb135: + br label %bb136 + +bb136: + br label %bb137 + +bb137: + br label %bb138 + +bb138: + br label %bb139 + +bb139: + br label %bb140 + +bb140: + br label %bb141 + +bb141: + br label %bb142 + +bb142: + br label %bb143 + +bb143: + br label %bb144 + +bb144: + br label %bb145 + +bb145: + br label %bb146 + +bb146: + br label %bb147 + +bb147: + br label %bb148 + +bb148: + br label %bb149 + +bb149: + br label %bb150 + +bb150: + br label %bb151 + +bb151: + br label %bb152 + +bb152: + br label %bb153 + +bb153: + br label %bb154 + +bb154: + br label %bb155 + +bb155: + br label %bb156 + +bb156: + br label %bb157 + +bb157: + br label %bb158 + +bb158: + br label %bb159 + +bb159: + br label %bb160 + +bb160: + br label %bb161 + +bb161: + br label %bb162 + +bb162: + br label %bb163 + +bb163: + br label %bb164 + +bb164: + br label %bb165 + +bb165: + br label %bb166 + +bb166: + br label %bb167 + +bb167: + br label %bb168 + +bb168: + br label %bb169 + +bb169: + br label %bb170 + +bb170: + br label %bb171 + +bb171: + br label %bb172 + +bb172: + br label %bb173 + +bb173: + br label %bb174 + +bb174: + br label %bb175 + +bb175: + br label %bb176 + +bb176: + br label %bb177 + +bb177: + br label %bb178 + +bb178: + br label %bb179 + +bb179: + br label %bb180 + +bb180: + br label %bb181 + +bb181: + br label %bb182 + +bb182: + br label %bb183 + +bb183: + br label %bb184 + +bb184: + br label %bb185 + +bb185: + br label %bb186 + +bb186: + br label %bb187 + +bb187: + br label %bb188 + +bb188: + br label %bb189 + +bb189: + br label %bb190 + +bb190: + br label %bb191 + +bb191: + br label %bb192 + +bb192: + br label %bb193 + +bb193: + br label %bb194 + +bb194: + br label %bb195 + +bb195: + br label %bb196 + +bb196: + br label %bb197 + +bb197: + br label %bb198 + +bb198: + br label %bb199 + +bb199: + br label %bb200 + +bb200: + br label %bb201 + +bb201: + br label %bb202 + +bb202: + br label %bb203 + +bb203: + br label %bb204 + +bb204: + br label %bb205 + +bb205: + br label %bb206 + +bb206: + br label %bb207 + +bb207: + br label %bb208 + +bb208: + br label %bb209 + +bb209: + br label %bb210 + +bb210: + br label %bb211 + +bb211: + br label %bb212 + +bb212: + br label %bb213 + +bb213: + br label %bb214 + +bb214: + br label %bb215 + +bb215: + br label %bb216 + +bb216: + br label %bb217 + +bb217: + br label %bb218 + +bb218: + br label %bb219 + +bb219: + br label %bb220 + +bb220: + br label %bb221 + +bb221: + br label %bb222 + +bb222: + br label %bb223 + +bb223: + br label %bb224 + +bb224: + br label %bb225 + +bb225: + br label %bb226 + +bb226: + br label %bb227 + +bb227: + br label %bb228 + +bb228: + br label %bb229 + +bb229: + br label %bb230 + +bb230: + br label %bb231 + +bb231: + br label %bb232 + +bb232: + br label %bb233 + +bb233: + br label %bb234 + +bb234: + br label %bb235 + +bb235: + br label %bb236 + +bb236: + br label %bb237 + +bb237: + br label %bb238 + +bb238: + br label %bb239 + +bb239: + br label %bb240 + +bb240: + br label %bb241 + +bb241: + br label %bb242 + +bb242: + br label %bb243 + +bb243: + br label %bb244 + +bb244: + br label %bb245 + +bb245: + br label %bb246 + +bb246: + br label %bb247 + +bb247: + br label %bb248 + +bb248: + br label %bb249 + +bb249: + br label %bb250 + +bb250: + br label %bb251 + +bb251: + br label %bb252 + +bb252: + br label %bb253 + +bb253: + br label %bb254 + +bb254: + br label %bb255 + +bb255: + br label %bb256 + +bb256: + br label %bb257 + +bb257: + br label %bb258 + +bb258: + br label %bb259 + +bb259: + br label %bb260 + +bb260: + br label %bb261 + +bb261: + br label %bb262 + +bb262: + br label %bb263 + +bb263: + br label %bb264 + +bb264: + br label %bb265 + +bb265: + br label %bb266 + +bb266: + br label %bb267 + +bb267: + br label %bb268 + +bb268: + br label %bb269 + +bb269: + br label %bb270 + +bb270: + br label %bb271 + +bb271: + br label %bb272 + +bb272: + br label %bb273 + +bb273: + br label %bb274 + +bb274: + br label %bb275 + +bb275: + br label %bb276 + +bb276: + br label %bb277 + +bb277: + br label %bb278 + +bb278: + br label %bb279 + +bb279: + br label %bb280 + +bb280: + br label %bb281 + +bb281: + br label %bb282 + +bb282: + br label %bb283 + +bb283: + br label %bb284 + +bb284: + br label %bb285 + +bb285: + br label %bb286 + +bb286: + br label %bb287 + +bb287: + br label %bb288 + +bb288: + br label %bb289 + +bb289: + br label %bb290 + +bb290: + br label %bb291 + +bb291: + br label %bb292 + +bb292: + br label %bb293 + +bb293: + br label %bb294 + +bb294: + br label %bb295 + +bb295: + br label %bb296 + +bb296: + br label %bb297 + +bb297: + br label %bb298 + +bb298: + br label %bb299 + +bb299: + br label %bb300 + +bb300: + br label %bb301 + +bb301: + br label %bb302 + +bb302: + br label %bb303 + +bb303: + br label %bb304 + +bb304: + br label %bb305 + +bb305: + br label %bb306 + +bb306: + br label %bb307 + +bb307: + br label %bb308 + +bb308: + br label %bb309 + +bb309: + br label %bb310 + +bb310: + br label %bb311 + +bb311: + br label %bb312 + +bb312: + br label %bb313 + +bb313: + br label %bb314 + +bb314: + br label %bb315 + +bb315: + br label %bb316 + +bb316: + br label %bb317 + +bb317: + br label %bb318 + +bb318: + br label %bb319 + +bb319: + br label %bb320 + +bb320: + br label %bb321 + +bb321: + br label %bb322 + +bb322: + br label %bb323 + +bb323: + br label %bb324 + +bb324: + br label %bb325 + +bb325: + br label %bb326 + +bb326: + br label %bb327 + +bb327: + br label %bb328 + +bb328: + br label %bb329 + +bb329: + br label %bb330 + +bb330: + br label %bb331 + +bb331: + br label %bb332 + +bb332: + br label %bb333 + +bb333: + br label %bb334 + +bb334: + br label %bb335 + +bb335: + br label %bb336 + +bb336: + br label %bb337 + +bb337: + br label %bb338 + +bb338: + br label %bb339 + +bb339: + br label %bb340 + +bb340: + br label %bb341 + +bb341: + br label %bb342 + +bb342: + br label %bb343 + +bb343: + br label %bb344 + +bb344: + br label %bb345 + +bb345: + br label %bb346 + +bb346: + br label %bb347 + +bb347: + br label %bb348 + +bb348: + br label %bb349 + +bb349: + br label %bb350 + +bb350: + br label %bb351 + +bb351: + br label %bb352 + +bb352: + br label %bb353 + +bb353: + br label %bb354 + +bb354: + br label %bb355 + +bb355: + br label %bb356 + +bb356: + br label %bb357 + +bb357: + br label %bb358 + +bb358: + br label %bb359 + +bb359: + br label %bb360 + +bb360: + br label %bb361 + +bb361: + br label %bb362 + +bb362: + br label %bb363 + +bb363: + br label %bb364 + +bb364: + br label %bb365 + +bb365: + br label %bb366 + +bb366: + br label %bb367 + +bb367: + br label %bb368 + +bb368: + br label %bb369 + +bb369: + br label %bb370 + +bb370: + br label %bb371 + +bb371: + br label %bb372 + +bb372: + br label %bb373 + +bb373: + br label %bb374 + +bb374: + br label %bb375 + +bb375: + br label %bb376 + +bb376: + br label %bb377 + +bb377: + br label %bb378 + +bb378: + br label %bb379 + +bb379: + br label %bb380 + +bb380: + br label %bb381 + +bb381: + br label %bb382 + +bb382: + br label %bb383 + +bb383: + br label %bb384 + +bb384: + br label %bb385 + +bb385: + br label %bb386 + +bb386: + br label %bb387 + +bb387: + br label %bb388 + +bb388: + br label %bb389 + +bb389: + br label %bb390 + +bb390: + br label %bb391 + +bb391: + br label %bb392 + +bb392: + br label %bb393 + +bb393: + br label %bb394 + +bb394: + br label %bb395 + +bb395: + br label %bb396 + +bb396: + br label %bb397 + +bb397: + br label %bb398 + +bb398: + br label %bb399 + +bb399: + br label %bb400 + +bb400: + br label %bb401 + +bb401: + br label %bb402 + +bb402: + br label %bb403 + +bb403: + br label %bb404 + +bb404: + br label %bb405 + +bb405: + br label %bb406 + +bb406: + br label %bb407 + +bb407: + br label %bb408 + +bb408: + br label %bb409 + +bb409: + br label %bb410 + +bb410: + br label %bb411 + +bb411: + br label %bb412 + +bb412: + br label %bb413 + +bb413: + br label %bb414 + +bb414: + br label %bb415 + +bb415: + br label %bb416 + +bb416: + br label %bb417 + +bb417: + br label %bb418 + +bb418: + br label %bb419 + +bb419: + br label %bb420 + +bb420: + br label %bb421 + +bb421: + br label %bb422 + +bb422: + br label %bb423 + +bb423: + br label %bb424 + +bb424: + br label %bb425 + +bb425: + br label %bb426 + +bb426: + br label %bb427 + +bb427: + br label %bb428 + +bb428: + br label %bb429 + +bb429: + br label %bb430 + +bb430: + br label %bb431 + +bb431: + br label %bb432 + +bb432: + br label %bb433 + +bb433: + br label %bb434 + +bb434: + br label %bb435 + +bb435: + br label %bb436 + +bb436: + br label %bb437 + +bb437: + br label %bb438 + +bb438: + br label %bb439 + +bb439: + br label %bb440 + +bb440: + br label %bb441 + +bb441: + br label %bb442 + +bb442: + br label %bb443 + +bb443: + br label %bb444 + +bb444: + br label %bb445 + +bb445: + br label %bb446 + +bb446: + br label %bb447 + +bb447: + br label %bb448 + +bb448: + br label %bb449 + +bb449: + br label %bb450 + +bb450: + br label %bb451 + +bb451: + br label %bb452 + +bb452: + br label %bb453 + +bb453: + br label %bb454 + +bb454: + br label %bb455 + +bb455: + br label %bb456 + +bb456: + br label %bb457 + +bb457: + br label %bb458 + +bb458: + br label %bb459 + +bb459: + br label %bb460 + +bb460: + br label %bb461 + +bb461: + br label %bb462 + +bb462: + br label %bb463 + +bb463: + br label %bb464 + +bb464: + br label %bb465 + +bb465: + br label %bb466 + +bb466: + br label %bb467 + +bb467: + br label %bb468 + +bb468: + br label %bb469 + +bb469: + br label %bb470 + +bb470: + br label %bb471 + +bb471: + br label %bb472 + +bb472: + br label %bb473 + +bb473: + br label %bb474 + +bb474: + br label %bb475 + +bb475: + br label %bb476 + +bb476: + br label %bb477 + +bb477: + br label %bb478 + +bb478: + br label %bb479 + +bb479: + br label %bb480 + +bb480: + br label %bb481 + +bb481: + br label %bb482 + +bb482: + br label %bb483 + +bb483: + br label %bb484 + +bb484: + br label %bb485 + +bb485: + br label %bb486 + +bb486: + br label %bb487 + +bb487: + br label %bb488 + +bb488: + br label %bb489 + +bb489: + br label %bb490 + +bb490: + br label %bb491 + +bb491: + br label %bb492 + +bb492: + br label %bb493 + +bb493: + br label %bb494 + +bb494: + br label %bb495 + +bb495: + br label %bb496 + +bb496: + br label %bb497 + +bb497: + br label %bb498 + +bb498: + br label %bb499 + +bb499: + br label %bb500 + +bb500: + br label %bb501 + +bb501: + br label %bb502 + +bb502: + br label %bb503 + +bb503: + br label %bb504 + +bb504: + br label %bb505 + +bb505: + br label %bb506 + +bb506: + br label %bb507 + +bb507: + br label %bb508 + +bb508: + br label %bb509 + +bb509: + br label %bb510 + +bb510: + br label %bb511 + +bb511: + br label %bb512 + +bb512: + br label %bb513 + +bb513: + br label %bb514 + +bb514: + br label %bb515 + +bb515: + br label %bb516 + +bb516: + br label %bb517 + +bb517: + br label %bb518 + +bb518: + br label %bb519 + +bb519: + br label %bb520 + +bb520: + br label %bb521 + +bb521: + br label %bb522 + +bb522: + br label %bb523 + +bb523: + br label %bb524 + +bb524: + br label %bb525 + +bb525: + br label %bb526 + +bb526: + br label %bb527 + +bb527: + br label %bb528 + +bb528: + br label %bb529 + +bb529: + br label %bb530 + +bb530: + br label %bb531 + +bb531: + br label %bb532 + +bb532: + br label %bb533 + +bb533: + br label %bb534 + +bb534: + br label %bb535 + +bb535: + br label %bb536 + +bb536: + br label %bb537 + +bb537: + br label %bb538 + +bb538: + br label %bb539 + +bb539: + br label %bb540 + +bb540: + br label %bb541 + +bb541: + br label %bb542 + +bb542: + br label %bb543 + +bb543: + br label %bb544 + +bb544: + br label %bb545 + +bb545: + br label %bb546 + +bb546: + br label %bb547 + +bb547: + br label %bb548 + +bb548: + br label %bb549 + +bb549: + br label %bb550 + +bb550: + br label %bb551 + +bb551: + br label %bb552 + +bb552: + br label %bb553 + +bb553: + br label %bb554 + +bb554: + br label %bb555 + +bb555: + br label %bb556 + +bb556: + br label %bb557 + +bb557: + br label %bb558 + +bb558: + br label %bb559 + +bb559: + br label %bb560 + +bb560: + br label %bb561 + +bb561: + br label %bb562 + +bb562: + br label %bb563 + +bb563: + br label %bb564 + +bb564: + br label %bb565 + +bb565: + br label %bb566 + +bb566: + br label %bb567 + +bb567: + br label %bb568 + +bb568: + br label %bb569 + +bb569: + br label %bb570 + +bb570: + br label %bb571 + +bb571: + br label %bb572 + +bb572: + br label %bb573 + +bb573: + br label %bb574 + +bb574: + br label %bb575 + +bb575: + br label %bb576 + +bb576: + br label %bb577 + +bb577: + br label %bb578 + +bb578: + br label %bb579 + +bb579: + br label %bb580 + +bb580: + br label %bb581 + +bb581: + br label %bb582 + +bb582: + br label %bb583 + +bb583: + br label %bb584 + +bb584: + br label %bb585 + +bb585: + br label %bb586 + +bb586: + br label %bb587 + +bb587: + br label %bb588 + +bb588: + br label %bb589 + +bb589: + br label %bb590 + +bb590: + br label %bb591 + +bb591: + br label %bb592 + +bb592: + br label %bb593 + +bb593: + br label %bb594 + +bb594: + br label %bb595 + +bb595: + br label %bb596 + +bb596: + br label %bb597 + +bb597: + br label %bb598 + +bb598: + br label %bb599 + +bb599: + br label %bb600 + +bb600: + br label %bb601 + +bb601: + br label %bb602 + +bb602: + br label %bb603 + +bb603: + br label %bb604 + +bb604: + br label %bb605 + +bb605: + br label %bb606 + +bb606: + br label %bb607 + +bb607: + br label %bb608 + +bb608: + br label %bb609 + +bb609: + br label %bb610 + +bb610: + br label %bb611 + +bb611: + br label %bb612 + +bb612: + br label %bb613 + +bb613: + br label %bb614 + +bb614: + br label %bb615 + +bb615: + br label %bb616 + +bb616: + br label %bb617 + +bb617: + br label %bb618 + +bb618: + br label %bb619 + +bb619: + br label %bb620 + +bb620: + br label %bb621 + +bb621: + br label %bb622 + +bb622: + br label %bb623 + +bb623: + br label %bb624 + +bb624: + br label %bb625 + +bb625: + br label %bb626 + +bb626: + br label %bb627 + +bb627: + br label %bb628 + +bb628: + br label %bb629 + +bb629: + br label %bb630 + +bb630: + br label %bb631 + +bb631: + br label %bb632 + +bb632: + br label %bb633 + +bb633: + br label %bb634 + +bb634: + br label %bb635 + +bb635: + br label %bb636 + +bb636: + br label %bb637 + +bb637: + br label %bb638 + +bb638: + br label %bb639 + +bb639: + br label %bb640 + +bb640: + br label %bb641 + +bb641: + br label %bb642 + +bb642: + br label %bb643 + +bb643: + br label %bb644 + +bb644: + br label %bb645 + +bb645: + br label %bb646 + +bb646: + br label %bb647 + +bb647: + br label %bb648 + +bb648: + br label %bb649 + +bb649: + br label %bb650 + +bb650: + br label %bb651 + +bb651: + br label %bb652 + +bb652: + br label %bb653 + +bb653: + br label %bb654 + +bb654: + br label %bb655 + +bb655: + br label %bb656 + +bb656: + br label %bb657 + +bb657: + br label %bb658 + +bb658: + br label %bb659 + +bb659: + br label %bb660 + +bb660: + br label %bb661 + +bb661: + br label %bb662 + +bb662: + br label %bb663 + +bb663: + br label %bb664 + +bb664: + br label %bb665 + +bb665: + br label %bb666 + +bb666: + br label %bb667 + +bb667: + br label %bb668 + +bb668: + br label %bb669 + +bb669: + br label %bb670 + +bb670: + br label %bb671 + +bb671: + br label %bb672 + +bb672: + br label %bb673 + +bb673: + br label %bb674 + +bb674: + br label %bb675 + +bb675: + br label %bb676 + +bb676: + br label %bb677 + +bb677: + br label %bb678 + +bb678: + br label %bb679 + +bb679: + br label %bb680 + +bb680: + br label %bb681 + +bb681: + br label %bb682 + +bb682: + br label %bb683 + +bb683: + br label %bb684 + +bb684: + br label %bb685 + +bb685: + br label %bb686 + +bb686: + br label %bb687 + +bb687: + br label %bb688 + +bb688: + br label %bb689 + +bb689: + br label %bb690 + +bb690: + br label %bb691 + +bb691: + br label %bb692 + +bb692: + br label %bb693 + +bb693: + br label %bb694 + +bb694: + br label %bb695 + +bb695: + br label %bb696 + +bb696: + br label %bb697 + +bb697: + br label %bb698 + +bb698: + br label %bb699 + +bb699: + br label %bb700 + +bb700: + br label %bb701 + +bb701: + br label %bb702 + +bb702: + br label %bb703 + +bb703: + br label %bb704 + +bb704: + br label %bb705 + +bb705: + br label %bb706 + +bb706: + br label %bb707 + +bb707: + br label %bb708 + +bb708: + br label %bb709 + +bb709: + br label %bb710 + +bb710: + br label %bb711 + +bb711: + br label %bb712 + +bb712: + br label %bb713 + +bb713: + br label %bb714 + +bb714: + br label %bb715 + +bb715: + br label %bb716 + +bb716: + br label %bb717 + +bb717: + br label %bb718 + +bb718: + br label %bb719 + +bb719: + br label %bb720 + +bb720: + br label %bb721 + +bb721: + br label %bb722 + +bb722: + br label %bb723 + +bb723: + br label %bb724 + +bb724: + br label %bb725 + +bb725: + br label %bb726 + +bb726: + br label %bb727 + +bb727: + br label %bb728 + +bb728: + br label %bb729 + +bb729: + br label %bb730 + +bb730: + br label %bb731 + +bb731: + br label %bb732 + +bb732: + br label %bb733 + +bb733: + br label %bb734 + +bb734: + br label %bb735 + +bb735: + br label %bb736 + +bb736: + br label %bb737 + +bb737: + br label %bb738 + +bb738: + br label %bb739 + +bb739: + br label %bb740 + +bb740: + br label %bb741 + +bb741: + br label %bb742 + +bb742: + br label %bb743 + +bb743: + br label %bb744 + +bb744: + br label %bb745 + +bb745: + br label %bb746 + +bb746: + br label %bb747 + +bb747: + br label %bb748 + +bb748: + br label %bb749 + +bb749: + br label %bb750 + +bb750: + br label %bb751 + +bb751: + br label %bb752 + +bb752: + br label %bb753 + +bb753: + br label %bb754 + +bb754: + br label %bb755 + +bb755: + br label %bb756 + +bb756: + br label %bb757 + +bb757: + br label %bb758 + +bb758: + br label %bb759 + +bb759: + br label %bb760 + +bb760: + br label %bb761 + +bb761: + br label %bb762 + +bb762: + br label %bb763 + +bb763: + br label %bb764 + +bb764: + br label %bb765 + +bb765: + br label %bb766 + +bb766: + br label %bb767 + +bb767: + br label %bb768 + +bb768: + br label %bb769 + +bb769: + br label %bb770 + +bb770: + br label %bb771 + +bb771: + br label %bb772 + +bb772: + br label %bb773 + +bb773: + br label %bb774 + +bb774: + br label %bb775 + +bb775: + br label %bb776 + +bb776: + br label %bb777 + +bb777: + br label %bb778 + +bb778: + br label %bb779 + +bb779: + br label %bb780 + +bb780: + br label %bb781 + +bb781: + br label %bb782 + +bb782: + br label %bb783 + +bb783: + br label %bb784 + +bb784: + br label %bb785 + +bb785: + br label %bb786 + +bb786: + br label %bb787 + +bb787: + br label %bb788 + +bb788: + br label %bb789 + +bb789: + br label %bb790 + +bb790: + br label %bb791 + +bb791: + br label %bb792 + +bb792: + br label %bb793 + +bb793: + br label %bb794 + +bb794: + br label %bb795 + +bb795: + br label %bb796 + +bb796: + br label %bb797 + +bb797: + br label %bb798 + +bb798: + br label %bb799 + +bb799: + br label %bb800 + +bb800: + br label %bb801 + +bb801: + br label %bb802 + +bb802: + br label %bb803 + +bb803: + br label %bb804 + +bb804: + br label %bb805 + +bb805: + br label %bb806 + +bb806: + br label %bb807 + +bb807: + br label %bb808 + +bb808: + br label %bb809 + +bb809: + br label %bb810 + +bb810: + br label %bb811 + +bb811: + br label %bb812 + +bb812: + br label %bb813 + +bb813: + br label %bb814 + +bb814: + br label %bb815 + +bb815: + br label %bb816 + +bb816: + br label %bb817 + +bb817: + br label %bb818 + +bb818: + br label %bb819 + +bb819: + br label %bb820 + +bb820: + br label %bb821 + +bb821: + br label %bb822 + +bb822: + br label %bb823 + +bb823: + br label %bb824 + +bb824: + br label %bb825 + +bb825: + br label %bb826 + +bb826: + br label %bb827 + +bb827: + br label %bb828 + +bb828: + br label %bb829 + +bb829: + br label %bb830 + +bb830: + br label %bb831 + +bb831: + br label %bb832 + +bb832: + br label %bb833 + +bb833: + br label %bb834 + +bb834: + br label %bb835 + +bb835: + br label %bb836 + +bb836: + br label %bb837 + +bb837: + br label %bb838 + +bb838: + br label %bb839 + +bb839: + br label %bb840 + +bb840: + br label %bb841 + +bb841: + br label %bb842 + +bb842: + br label %bb843 + +bb843: + br label %bb844 + +bb844: + br label %bb845 + +bb845: + br label %bb846 + +bb846: + br label %bb847 + +bb847: + br label %bb848 + +bb848: + br label %bb849 + +bb849: + br label %bb850 + +bb850: + br label %bb851 + +bb851: + br label %bb852 + +bb852: + br label %bb853 + +bb853: + br label %bb854 + +bb854: + br label %bb855 + +bb855: + br label %bb856 + +bb856: + br label %bb857 + +bb857: + br label %bb858 + +bb858: + br label %bb859 + +bb859: + br label %bb860 + +bb860: + br label %bb861 + +bb861: + br label %bb862 + +bb862: + br label %bb863 + +bb863: + br label %bb864 + +bb864: + br label %bb865 + +bb865: + br label %bb866 + +bb866: + br label %bb867 + +bb867: + br label %bb868 + +bb868: + br label %bb869 + +bb869: + br label %bb870 + +bb870: + br label %bb871 + +bb871: + br label %bb872 + +bb872: + br label %bb873 + +bb873: + br label %bb874 + +bb874: + br label %bb875 + +bb875: + br label %bb876 + +bb876: + br label %bb877 + +bb877: + br label %bb878 + +bb878: + br label %bb879 + +bb879: + br label %bb880 + +bb880: + br label %bb881 + +bb881: + br label %bb882 + +bb882: + br label %bb883 + +bb883: + br label %bb884 + +bb884: + br label %bb885 + +bb885: + br label %bb886 + +bb886: + br label %bb887 + +bb887: + br label %bb888 + +bb888: + br label %bb889 + +bb889: + br label %bb890 + +bb890: + br label %bb891 + +bb891: + br label %bb892 + +bb892: + br label %bb893 + +bb893: + br label %bb894 + +bb894: + br label %bb895 + +bb895: + br label %bb896 + +bb896: + br label %bb897 + +bb897: + br label %bb898 + +bb898: + br label %bb899 + +bb899: + br label %bb900 + +bb900: + br label %bb901 + +bb901: + br label %bb902 + +bb902: + br label %bb903 + +bb903: + br label %bb904 + +bb904: + br label %bb905 + +bb905: + br label %bb906 + +bb906: + br label %bb907 + +bb907: + br label %bb908 + +bb908: + br label %bb909 + +bb909: + br label %bb910 + +bb910: + br label %bb911 + +bb911: + br label %bb912 + +bb912: + br label %bb913 + +bb913: + br label %bb914 + +bb914: + br label %bb915 + +bb915: + br label %bb916 + +bb916: + br label %bb917 + +bb917: + br label %bb918 + +bb918: + br label %bb919 + +bb919: + br label %bb920 + +bb920: + br label %bb921 + +bb921: + br label %bb922 + +bb922: + br label %bb923 + +bb923: + br label %bb924 + +bb924: + br label %bb925 + +bb925: + br label %bb926 + +bb926: + br label %bb927 + +bb927: + br label %bb928 + +bb928: + br label %bb929 + +bb929: + br label %bb930 + +bb930: + br label %bb931 + +bb931: + br label %bb932 + +bb932: + br label %bb933 + +bb933: + br label %bb934 + +bb934: + br label %bb935 + +bb935: + br label %bb936 + +bb936: + br label %bb937 + +bb937: + br label %bb938 + +bb938: + br label %bb939 + +bb939: + br label %bb940 + +bb940: + br label %bb941 + +bb941: + br label %bb942 + +bb942: + br label %bb943 + +bb943: + br label %bb944 + +bb944: + br label %bb945 + +bb945: + br label %bb946 + +bb946: + br label %bb947 + +bb947: + br label %bb948 + +bb948: + br label %bb949 + +bb949: + br label %bb950 + +bb950: + br label %bb951 + +bb951: + br label %bb952 + +bb952: + br label %bb953 + +bb953: + br label %bb954 + +bb954: + br label %bb955 + +bb955: + br label %bb956 + +bb956: + br label %bb957 + +bb957: + br label %bb958 + +bb958: + br label %bb959 + +bb959: + br label %bb960 + +bb960: + br label %bb961 + +bb961: + br label %bb962 + +bb962: + br label %bb963 + +bb963: + br label %bb964 + +bb964: + br label %bb965 + +bb965: + br label %bb966 + +bb966: + br label %bb967 + +bb967: + br label %bb968 + +bb968: + br label %bb969 + +bb969: + br label %bb970 + +bb970: + br label %bb971 + +bb971: + br label %bb972 + +bb972: + br label %bb973 + +bb973: + br label %bb974 + +bb974: + br label %bb975 + +bb975: + br label %bb976 + +bb976: + br label %bb977 + +bb977: + br label %bb978 + +bb978: + br label %bb979 + +bb979: + br label %bb980 + +bb980: + br label %bb981 + +bb981: + br label %bb982 + +bb982: + br label %bb983 + +bb983: + br label %bb984 + +bb984: + br label %bb985 + +bb985: + br label %bb986 + +bb986: + br label %bb987 + +bb987: + br label %bb988 + +bb988: + br label %bb989 + +bb989: + br label %bb990 + +bb990: + br label %bb991 + +bb991: + br label %bb992 + +bb992: + br label %bb993 + +bb993: + br label %bb994 + +bb994: + br label %bb995 + +bb995: + br label %bb996 + +bb996: + br label %bb997 + +bb997: + br label %bb998 + +bb998: + br label %bb999 + +bb999: + br label %bb1000 + +bb1000: + ; CHECK: call{{.*}}@dfsan_union + ; CHECK-NOT: phi + %ab = mul i32 %a, %b + ret i32 %ab +} diff --git a/test/Instrumentation/DataFlowSanitizer/union.ll b/test/Instrumentation/DataFlowSanitizer/union.ll new file mode 100644 index 0000000..2b31081 --- /dev/null +++ b/test/Instrumentation/DataFlowSanitizer/union.ll @@ -0,0 +1,52 @@ +; RUN: opt < %s -dfsan -S | FileCheck %s +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" + +@a = common global i32 0 +@b = common global i32 0 + +; Check that we reuse unions where possible. + +; CHECK-LABEL: @"dfs$f" +define void @f(i32 %x, i32 %y) { + ; CHECK: call{{.*}}__dfsan_union + %xay = add i32 %x, %y + store i32 %xay, i32* @a + ; CHECK-NOT: call{{.*}}__dfsan_union + %xmy = mul i32 %x, %y + store i32 %xmy, i32* @b + ret void +} + +; In this case, we compute the unions on both sides because neither block +; dominates the other. + +; CHECK-LABEL: @"dfs$g" +define void @g(i1 %p, i32 %x, i32 %y) { + br i1 %p, label %l1, label %l2 + +l1: + ; CHECK: call{{.*}}__dfsan_union + %xay = add i32 %x, %y + store i32 %xay, i32* @a + br label %l3 + +l2: + ; CHECK: call{{.*}}__dfsan_union + %xmy = mul i32 %x, %y + store i32 %xmy, i32* @b + br label %l3 + +l3: + ret void +} + +; In this case, we know that the label for %xayax subsumes the label for %xay. + +; CHECK-LABEL: @"dfs$h" +define i32 @h(i32 %x, i32 %y) { + ; CHECK: call{{.*}}__dfsan_union + %xay = add i32 %x, %y + ; CHECK-NOT: call{{.*}}__dfsan_union + %xayax = add i32 %xay, %x + ret i32 %xayax +} diff --git a/test/Instrumentation/MemorySanitizer/array_types.ll b/test/Instrumentation/MemorySanitizer/array_types.ll new file mode 100644 index 0000000..fa3835f --- /dev/null +++ b/test/Instrumentation/MemorySanitizer/array_types.ll @@ -0,0 +1,89 @@ +; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s +; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s + +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" +target triple = "x86_64-unknown-linux-gnu" + +define [2 x i32] @InsertValue(i32 %x, i32 %y) sanitize_memory { +entry: + %a = insertvalue [2 x i32] undef, i32 %x, 0 + %b = insertvalue [2 x i32] %a, i32 %y, 1 + ret [2 x i32] %b +} + +; CHECK-LABEL: @InsertValue( +; CHECK-DAG: [[Sy:%.*]] = load i32* {{.*}}@__msan_param_tls to i64), i64 8) to i32*) +; CHECK-DAG: [[Sx:%.*]] = load i32* {{.*}}@__msan_param_tls to i32*) +; CHECK: [[A:%.*]] = insertvalue [2 x i32] [i32 -1, i32 -1], i32 [[Sx]], 0 +; CHECK: [[B:%.*]] = insertvalue [2 x i32] [[A]], i32 [[Sy]], 1 +; CHECK: store [2 x i32] [[B]], [2 x i32]* {{.*}}@__msan_retval_tls +; CHECK: ret [2 x i32] + + +define [2 x double] @InsertValueDouble(double %x, double %y) sanitize_memory { +entry: + %a = insertvalue [2 x double] undef, double %x, 0 + %b = insertvalue [2 x double] %a, double %y, 1 + ret [2 x double] %b +} + +; CHECK-LABEL: @InsertValueDouble( +; CHECK-DAG: [[Sy:%.*]] = load i64* {{.*}}@__msan_param_tls to i64), i64 8) to i64*) +; CHECK-DAG: [[Sx:%.*]] = load i64* getelementptr {{.*}}@__msan_param_tls, i32 0, i32 0 +; CHECK: [[A:%.*]] = insertvalue [2 x i64] [i64 -1, i64 -1], i64 [[Sx]], 0 +; CHECK: [[B:%.*]] = insertvalue [2 x i64] [[A]], i64 [[Sy]], 1 +; CHECK: store [2 x i64] [[B]], [2 x i64]* {{.*}}@__msan_retval_tls +; CHECK: ret [2 x double] + + +define i32 @ExtractValue([2 x i32] %a) sanitize_memory { +entry: + %x = extractvalue [2 x i32] %a, 1 + ret i32 %x +} + +; CHECK-LABEL: @ExtractValue( +; CHECK: [[Sa:%.*]] = load [2 x i32]* {{.*}}@__msan_param_tls to [2 x i32]*) +; CHECK: [[Sx:%.*]] = extractvalue [2 x i32] [[Sa]], 1 +; CHECK: store i32 [[Sx]], i32* {{.*}}@__msan_retval_tls +; CHECK: ret i32 + + +; Regression test for PR20493. + +%MyStruct = type { i32, i32, [3 x i32] } + +define i32 @ArrayInStruct(%MyStruct %s) sanitize_memory { + %x = extractvalue %MyStruct %s, 2, 1 + ret i32 %x +} + +; CHECK-LABEL: @ArrayInStruct( +; CHECK: [[Ss:%.*]] = load { i32, i32, [3 x i32] }* {{.*}}@__msan_param_tls to { i32, i32, [3 x i32] }*) +; CHECK: [[Sx:%.*]] = extractvalue { i32, i32, [3 x i32] } [[Ss]], 2, 1 +; CHECK: store i32 [[Sx]], i32* {{.*}}@__msan_retval_tls +; CHECK: ret i32 + + +define i32 @ArrayOfStructs([3 x { i32, i32 }] %a) sanitize_memory { + %x = extractvalue [3 x { i32, i32 }] %a, 2, 1 + ret i32 %x +} + +; CHECK-LABEL: @ArrayOfStructs( +; CHECK: [[Ss:%.*]] = load [3 x { i32, i32 }]* {{.*}}@__msan_param_tls to [3 x { i32, i32 }]*) +; CHECK: [[Sx:%.*]] = extractvalue [3 x { i32, i32 }] [[Ss]], 2, 1 +; CHECK: store i32 [[Sx]], i32* {{.*}}@__msan_retval_tls +; CHECK: ret i32 + + +define <8 x i16> @ArrayOfVectors([3 x <8 x i16>] %a) sanitize_memory { + %x = extractvalue [3 x <8 x i16>] %a, 1 + ret <8 x i16> %x +} + +; CHECK-LABEL: @ArrayOfVectors( +; CHECK: [[Ss:%.*]] = load [3 x <8 x i16>]* {{.*}}@__msan_param_tls to [3 x <8 x i16>]*) +; CHECK: [[Sx:%.*]] = extractvalue [3 x <8 x i16>] [[Ss]], 1 +; CHECK: store <8 x i16> [[Sx]], <8 x i16>* {{.*}}@__msan_retval_tls +; CHECK: ret <8 x i16> diff --git a/test/Instrumentation/MemorySanitizer/byval-alignment.ll b/test/Instrumentation/MemorySanitizer/byval-alignment.ll new file mode 100644 index 0000000..43e204a --- /dev/null +++ b/test/Instrumentation/MemorySanitizer/byval-alignment.ll @@ -0,0 +1,20 @@ +; Test that copy alignment for byval arguments is limited by param-tls slot alignment. + +; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.S = type { i64, i64, i64, [8 x i8] } + +; CHECK: [[A:%.*]] = bitcast i64* {{.*}} add {{.*}} ptrtoint {{.*}} @__msan_param_tls {{.*}} i64 8) +; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[A]], i8* {{.*}}, i64 32, i32 8, i1 false) + +define void @Caller() sanitize_memory { +entry: + %agg.tmp = alloca %struct.S, align 16 + call void @Callee(i32 1, %struct.S* byval align 16 %agg.tmp) + ret void +} + +declare void @Callee(i32, %struct.S* byval align 16) diff --git a/test/Instrumentation/MemorySanitizer/check-constant-shadow.ll b/test/Instrumentation/MemorySanitizer/check-constant-shadow.ll new file mode 100644 index 0000000..11e4410 --- /dev/null +++ b/test/Instrumentation/MemorySanitizer/check-constant-shadow.ll @@ -0,0 +1,15 @@ +; RUN: opt < %s -msan -msan-check-constant-shadow=1 -S | FileCheck %s + +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" +target triple = "x86_64-unknown-linux-gnu" + +; Test that returning a literal undef from main() triggers an MSan warning. + +define i32 @main() nounwind uwtable sanitize_memory { +entry: + ret i32 undef +} + +; CHECK-LABEL: @main +; CHECK: call void @__msan_warning_noreturn +; CHECK: ret i32 undef diff --git a/test/Instrumentation/MemorySanitizer/msan_basic.ll b/test/Instrumentation/MemorySanitizer/msan_basic.ll index 51693cd..0faf45d 100644 --- a/test/Instrumentation/MemorySanitizer/msan_basic.ll +++ b/test/Instrumentation/MemorySanitizer/msan_basic.ll @@ -766,6 +766,24 @@ cond.end: ; preds = %cond.false, %cond.t ; CHECK: ret i32 [[A]] +; Test that there are no __msan_param_origin_tls stores when +; argument shadow is a compile-time zero constant (which is always the case +; in functions missing sanitize_memory attribute). + +define i32 @NoSanitizeMemoryParamTLS(i32* nocapture readonly %x) { +entry: + %0 = load i32* %x, align 4 + %call = tail call i32 @NoSanitizeMemoryParamTLSHelper(i32 %0) + ret i32 %call +} + +declare i32 @NoSanitizeMemoryParamTLSHelper(i32 %x) + +; CHECK-LABEL: define i32 @NoSanitizeMemoryParamTLS( +; CHECK-NOT: __msan_param_origin_tls +; CHECK: ret i32 + + ; Test argument shadow alignment define <2 x i64> @ArgumentShadowAlignment(i64 %a, <2 x i64> %b) sanitize_memory { diff --git a/test/Instrumentation/MemorySanitizer/store-origin.ll b/test/Instrumentation/MemorySanitizer/store-origin.ll index 0bd9777..bde4e90 100644 --- a/test/Instrumentation/MemorySanitizer/store-origin.ll +++ b/test/Instrumentation/MemorySanitizer/store-origin.ll @@ -11,14 +11,14 @@ target triple = "x86_64-unknown-linux-gnu" ; Function Attrs: nounwind define void @Store(i32* nocapture %p, i32 %x) #0 { entry: - tail call void @llvm.dbg.value(metadata !{i32* %p}, i64 0, metadata !11), !dbg !16 - tail call void @llvm.dbg.value(metadata !{i32 %x}, i64 0, metadata !12), !dbg !16 + tail call void @llvm.dbg.value(metadata !{i32* %p}, i64 0, metadata !11, metadata !{metadata !"0x102"}), !dbg !16 + tail call void @llvm.dbg.value(metadata !{i32 %x}, i64 0, metadata !12, metadata !{metadata !"0x102"}), !dbg !16 store i32 %x, i32* %p, align 4, !dbg !17, !tbaa !18 ret void, !dbg !22 } ; Function Attrs: nounwind readnone -declare void @llvm.dbg.value(metadata, i64, metadata) #1 +declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 attributes #0 = { nounwind sanitize_memory "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } attributes #1 = { nounwind readnone } @@ -27,21 +27,21 @@ attributes #1 = { nounwind readnone } !llvm.module.flags = !{!13, !14} !llvm.ident = !{!15} -!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.5.0 (204220)", i1 true, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [/tmp/build0/../2.cc] [DW_LANG_C99] +!0 = metadata !{metadata !"0x11\0012\00clang version 3.5.0 (204220)\001\00\000\00\001", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [/tmp/build0/../2.cc] [DW_LANG_C99] !1 = metadata !{metadata !"../2.cc", metadata !"/tmp/build0"} !2 = metadata !{} !3 = metadata !{metadata !4} -!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"Store", metadata !"Store", metadata !"", i32 1, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 true, void (i32*, i32)* @Store, null, null, metadata !10, i32 1} ; [ DW_TAG_subprogram ] [line 1] [def] [Store] -!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/tmp/build0/../2.cc] -!6 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!4 = metadata !{metadata !"0x2e\00Store\00Store\00\001\000\001\000\006\00256\001\001", metadata !1, metadata !5, metadata !6, null, void (i32*, i32)* @Store, null, null, metadata !10} ; [ DW_TAG_subprogram ] [line 1] [def] [Store] +!5 = metadata !{metadata !"0x29", metadata !1} ; [ DW_TAG_file_type ] [/tmp/build0/../2.cc] +!6 = metadata !{metadata !"0x15\00\000\000\000\000\000\000", i32 0, null, null, metadata !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] !7 = metadata !{null, metadata !8, metadata !9} -!8 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !9} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int] -!9 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!8 = metadata !{metadata !"0xf\00\000\0064\0064\000\000", null, null, metadata !9} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int] +!9 = metadata !{metadata !"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] !10 = metadata !{metadata !11, metadata !12} -!11 = metadata !{i32 786689, metadata !4, metadata !"p", metadata !5, i32 16777217, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [p] [line 1] -!12 = metadata !{i32 786689, metadata !4, metadata !"x", metadata !5, i32 33554433, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [x] [line 1] +!11 = metadata !{metadata !"0x101\00p\0016777217\000", metadata !4, metadata !5, metadata !8} ; [ DW_TAG_arg_variable ] [p] [line 1] +!12 = metadata !{metadata !"0x101\00x\0033554433\000", metadata !4, metadata !5, metadata !9} ; [ DW_TAG_arg_variable ] [x] [line 1] !13 = metadata !{i32 2, metadata !"Dwarf Version", i32 4} -!14 = metadata !{i32 1, metadata !"Debug Info Version", i32 1} +!14 = metadata !{i32 1, metadata !"Debug Info Version", i32 2} !15 = metadata !{metadata !"clang version 3.5.0 (204220)"} !16 = metadata !{i32 1, i32 0, metadata !4, null} !17 = metadata !{i32 2, i32 0, metadata !4, null} diff --git a/test/Instrumentation/SanitizerCoverage/coverage-dbg.ll b/test/Instrumentation/SanitizerCoverage/coverage-dbg.ll new file mode 100644 index 0000000..eea93b8 --- /dev/null +++ b/test/Instrumentation/SanitizerCoverage/coverage-dbg.ll @@ -0,0 +1,67 @@ +; Test that coverage instrumentation does not lose debug location. + +; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -S | FileCheck %s + +; C++ source: +; 1: struct A { +; 2: int f(); +; 3: int x; +; 4: }; +; 5: +; 6: int A::f() { +; 7: return x; +; 8: } +; clang++ ../1.cc -O3 -g -S -emit-llvm -fno-strict-aliasing +; and add sanitize_address to @_ZN1A1fEv + +; Test that __sanitizer_cov call has !dbg pointing to the opening { of A::f(). +; CHECK: call void @__sanitizer_cov(), !dbg [[A:!.*]] +; CHECK: [[A]] = metadata !{i32 6, i32 0, metadata !{{.*}}, null} + + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.A = type { i32 } + +; Function Attrs: nounwind readonly uwtable +define i32 @_ZN1A1fEv(%struct.A* nocapture readonly %this) #0 align 2 { +entry: + tail call void @llvm.dbg.value(metadata !{%struct.A* %this}, i64 0, metadata !15, metadata !{metadata !"0x102"}), !dbg !20 + %x = getelementptr inbounds %struct.A* %this, i64 0, i32 0, !dbg !21 + %0 = load i32* %x, align 4, !dbg !21 + ret i32 %0, !dbg !21 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 + +attributes #0 = { sanitize_address nounwind readonly uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!17, !18} +!llvm.ident = !{!19} + +!0 = metadata !{metadata !"0x11\004\00clang version 3.5.0 (210251)\001\00\000\00\001", metadata !1, metadata !2, metadata !3, metadata !12, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [/code/llvm/build0/../1.cc] [DW_LANG_C_plus_plus] +!1 = metadata !{metadata !"../1.cc", metadata !"/code/llvm/build0"} +!2 = metadata !{} +!3 = metadata !{metadata !4} +!4 = metadata !{metadata !"0x13\00A\001\0032\0032\000\000\000", metadata !1, null, null, metadata !5, null, null, metadata !"_ZTS1A"} ; [ DW_TAG_structure_type ] [A] [line 1, size 32, align 32, offset 0] [def] [from ] +!5 = metadata !{metadata !6, metadata !8} +!6 = metadata !{metadata !"0xd\00x\003\0032\0032\000\000", metadata !1, metadata !"_ZTS1A", metadata !7} ; [ DW_TAG_member ] [x] [line 3, size 32, align 32, offset 0] [from int] +!7 = metadata !{metadata !"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!8 = metadata !{metadata !"0x2e\00f\00f\00_ZN1A1fEv\002\000\000\000\006\00256\001\002", metadata !1, metadata !"_ZTS1A", metadata !9, null, null, null, i32 0, null} ; [ DW_TAG_subprogram ] [line 2] [f] +!9 = metadata !{metadata !"0x15\00\000\000\000\000\000\000", i32 0, null, null, metadata !10, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!10 = metadata !{metadata !7, metadata !11} +!11 = metadata !{metadata !"0xf\00\000\0064\0064\000\001088", null, null, metadata !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A] +!12 = metadata !{metadata !13} +!13 = metadata !{metadata !"0x2e\00f\00f\00_ZN1A1fEv\006\000\001\000\006\00256\001\006", metadata !1, metadata !"_ZTS1A", metadata !9, null, i32 (%struct.A*)* @_ZN1A1fEv, null, metadata !8, metadata !14} ; [ DW_TAG_subprogram ] [line 6] [def] [f] +!14 = metadata !{metadata !15} +!15 = metadata !{metadata !"0x101\00this\0016777216\001088", metadata !13, null, metadata !16} ; [ DW_TAG_arg_variable ] [this] [line 0] +!16 = metadata !{metadata !"0xf\00\000\0064\0064\000\000", null, null, metadata !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS1A] +!17 = metadata !{i32 2, metadata !"Dwarf Version", i32 4} +!18 = metadata !{i32 2, metadata !"Debug Info Version", i32 2} +!19 = metadata !{metadata !"clang version 3.5.0 (210251)"} +!20 = metadata !{i32 0, i32 0, metadata !13, null} +!21 = metadata !{i32 7, i32 0, metadata !13, null} diff --git a/test/Instrumentation/SanitizerCoverage/coverage.ll b/test/Instrumentation/SanitizerCoverage/coverage.ll new file mode 100644 index 0000000..da0498d --- /dev/null +++ b/test/Instrumentation/SanitizerCoverage/coverage.ll @@ -0,0 +1,89 @@ +; RUN: opt < %s -sancov -sanitizer-coverage-level=0 -S | FileCheck %s --check-prefix=CHECK0 +; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -S | FileCheck %s --check-prefix=CHECK1 +; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -S | FileCheck %s --check-prefix=CHECK2 +; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-block-threshold=10 -S | FileCheck %s --check-prefix=CHECK2 +; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-block-threshold=1 -S | FileCheck %s --check-prefix=CHECK1 +; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-block-threshold=10 -S | FileCheck %s --check-prefix=CHECK3 +; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -S | FileCheck %s --check-prefix=CHECK4 + +; RUN: opt < %s -sancov -sanitizer-coverage-level=0 -S | FileCheck %s --check-prefix=CHECK0 +; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -S | FileCheck %s --check-prefix=CHECK1 +; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -S | FileCheck %s --check-prefix=CHECK2 +; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-block-threshold=10 \ +; RUN: -S | FileCheck %s --check-prefix=CHECK2 +; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-block-threshold=1 \ +; RUN: -S | FileCheck %s --check-prefix=CHECK1 + +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 +} + +; CHECK0-NOT: call void @__sanitizer_cov( +; CHECK0-NOT: call void @__sanitizer_cov_module_init( + +; CHECK1-LABEL: define void @foo +; CHECK1: %0 = load atomic i8* @__sancov_gen_cov_foo monotonic, align 1 +; CHECK1: %1 = icmp eq i8 0, %0 +; CHECK1: br i1 %1, label %2, label %3 +; CHECK1: call void @__sanitizer_cov +; CHECK1-NOT: call void @__sanitizer_cov +; CHECK1: store atomic i8 1, i8* @__sancov_gen_cov_foo monotonic, align 1 + +; CHECK1-LABEL: define internal void @sancov.module_ctor +; CHECK1-NOT: ret +; CHECK1: call void @__sanitizer_cov_module_init(i64 2) +; CHECK1: ret + + +; CHECK2-LABEL: define void @foo +; CHECK2: call void @__sanitizer_cov +; CHECK2: call void @__sanitizer_cov +; CHECK2: call void @__sanitizer_cov +; CHECK2-NOT: call void @__sanitizer_cov +; CHECK2: ret void + +; CHECK2-LABEL: define internal void @sancov.module_ctor +; CHECK2-NOT: ret +; CHECK2: call void @__sanitizer_cov_module_init(i64 4) +; CHECK2: ret + +; CHECK3-LABEL: define void @foo +; CHECK3: call void @__sanitizer_cov +; CHECK3: call void @__sanitizer_cov +; CHECK3: call void @__sanitizer_cov +; CHECK3-NOT: ret void +; CHECK3: call void @__sanitizer_cov +; CHECK3-NOT: call void @__sanitizer_cov +; CHECK3: 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*)*** %0, align 8 + %1 = load 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 +} + +; We expect to see two calls to __sanitizer_cov_indir_call16 +; with different values of second argument. +; CHECK4-LABEL: define void @CallViaVptr +; CHECK4: call void @__sanitizer_cov_indir_call16({{.*}},[[CACHE:.*]]) +; CHECK4-NOT: call void @__sanitizer_cov_indir_call16({{.*}},[[CACHE]]) +; CHECK4: ret void diff --git a/test/Instrumentation/SanitizerCoverage/coverage2-dbg.ll b/test/Instrumentation/SanitizerCoverage/coverage2-dbg.ll new file mode 100644 index 0000000..9b26329 --- /dev/null +++ b/test/Instrumentation/SanitizerCoverage/coverage2-dbg.ll @@ -0,0 +1,75 @@ +; Test that coverage instrumentation does not lose debug location. + +; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -S | FileCheck %s + +; C++ source: +; 1: void foo(int *a) { +; 2: if (a) +; 3: *a = 0; +; 4: } +; clang++ if.cc -O3 -g -S -emit-llvm +; and add sanitize_address to @_Z3fooPi + + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Check that __sanitizer_cov call has !dgb pointing to the beginning +; of appropriate basic blocks. +; CHECK-LABEL:_Z3fooPi +; CHECK: call void @__sanitizer_cov(), !dbg [[A:!.*]] +; CHECK: call void @__sanitizer_cov(), !dbg [[B:!.*]] +; CHECK: call void @__sanitizer_cov(), !dbg [[C:!.*]] +; CHECK: ret void +; CHECK: [[A]] = metadata !{i32 1, i32 0, metadata !{{.*}}, null} +; CHECK: [[B]] = metadata !{i32 3, i32 5, metadata !{{.*}}, null} +; CHECK: [[C]] = metadata !{i32 4, i32 1, metadata !{{.*}}, null} + +define void @_Z3fooPi(i32* %a) #0 { +entry: + tail call void @llvm.dbg.value(metadata !{i32* %a}, i64 0, metadata !11, metadata !{metadata !"0x102"}), !dbg !15 + %tobool = icmp eq i32* %a, null, !dbg !16 + br i1 %tobool, label %if.end, label %if.then, !dbg !16 + +if.then: ; preds = %entry + store i32 0, i32* %a, align 4, !dbg !18, !tbaa !19 + br label %if.end, !dbg !18 + +if.end: ; preds = %entry, %if.then + ret void, !dbg !23 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 + +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" sanitize_address} +attributes #1 = { nounwind readnone } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!12, !13} +!llvm.ident = !{!14} + +!0 = metadata !{metadata !"0x11\004\00clang version 3.6.0 (217079)\001\00\000\00\001", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [FOO/if.cc] [DW_LANG_C_plus_plus] +!1 = metadata !{metadata !"if.cc", metadata !"FOO"} +!2 = metadata !{} +!3 = metadata !{metadata !4} +!4 = metadata !{metadata !"0x2e\00foo\00foo\00_Z3fooPi\001\000\001\000\006\00256\001\001", metadata !1, metadata !5, metadata !6, null, void (i32*)* @_Z3fooPi, null, null, metadata !10} ; [ DW_TAG_subprogram ] [line 1] [def] [foo] +!5 = metadata !{metadata !"0x29", metadata !1} ; [ DW_TAG_file_type ] [FOO/if.cc] +!6 = metadata !{metadata !"0x15\00\000\000\000\000\000\000", i32 0, null, null, metadata !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = metadata !{null, metadata !8} +!8 = metadata !{metadata !"0xf\00\000\0064\0064\000\000", null, null, metadata !9} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int] +!9 = metadata !{metadata !"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!10 = metadata !{metadata !11} +!11 = metadata !{metadata !"0x101\00a\0016777217\000", metadata !4, metadata !5, metadata !8} ; [ DW_TAG_arg_variable ] [a] [line 1] +!12 = metadata !{i32 2, metadata !"Dwarf Version", i32 4} +!13 = metadata !{i32 2, metadata !"Debug Info Version", i32 2} +!14 = metadata !{metadata !"clang version 3.6.0 (217079)"} +!15 = metadata !{i32 1, i32 15, metadata !4, null} +!16 = metadata !{i32 2, i32 7, metadata !17, null} +!17 = metadata !{metadata !"0xb\002\007\000", metadata !1, metadata !4} ; [ DW_TAG_lexical_block ] [FOO/if.cc] +!18 = metadata !{i32 3, i32 5, metadata !17, null} +!19 = metadata !{metadata !20, metadata !20, i64 0} +!20 = metadata !{metadata !"int", metadata !21, i64 0} +!21 = metadata !{metadata !"omnipotent char", metadata !22, i64 0} +!22 = metadata !{metadata !"Simple C/C++ TBAA"} +!23 = metadata !{i32 4, i32 1, metadata !4, null} diff --git a/test/Instrumentation/SanitizerCoverage/tracing.ll b/test/Instrumentation/SanitizerCoverage/tracing.ll new file mode 100644 index 0000000..c39cb1c --- /dev/null +++ b/test/Instrumentation/SanitizerCoverage/tracing.ll @@ -0,0 +1,33 @@ +; Test -sanitizer-coverage-experimental-tracing +; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-experimental-tracing -S | FileCheck %s --check-prefix=CHECK1 +; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-experimental-tracing -S | FileCheck %s --check-prefix=CHECK3 + +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 +} + +; CHECK1-LABEL: define void @foo +; CHECK1: call void @__sanitizer_cov_trace_func_enter +; CHECK1: call void @__sanitizer_cov_trace_basic_block +; CHECK1: call void @__sanitizer_cov_trace_basic_block +; CHECK1-NOT: call void @__sanitizer_cov_trace_basic_block +; CHECK1: ret void + +; CHECK3-LABEL: define void @foo +; CHECK3: call void @__sanitizer_cov_trace_func_enter +; CHECK3: call void @__sanitizer_cov_trace_basic_block +; CHECK3: call void @__sanitizer_cov_trace_basic_block +; CHECK3: call void @__sanitizer_cov_trace_basic_block +; CHECK3-NOT: call void @__sanitizer_cov_trace_basic_block +; CHECK3: ret void |