Home | History | Annotate | Download | only in ThreadSanitizer
      1 ; RUN: opt < %s -tsan -S | FileCheck %s
      2 
      3 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"
      4 
      5 define i16 @test_unaligned_read2(i16* %a) sanitize_thread {
      6 entry:
      7   %tmp1 = load i16, i16* %a, align 1
      8   ret i16 %tmp1
      9 }
     10 
     11 ; CHECK-LABEL: define i16 @test_unaligned_read2(i16* %a)
     12 ; CHECK:        call void @__tsan_func_entry(i8* %0)
     13 ; CHECK-NEXT:   %1 = bitcast i16* %a to i8*
     14 ; CHECK-NEXT:   call void @__tsan_unaligned_read2(i8* %1)
     15 ; CHECK-NEXT:   %tmp1 = load i16, i16* %a, align 1
     16 ; CHECK-NEXT:   call void @__tsan_func_exit()
     17 ; CHECK: ret i16
     18 
     19 define i32 @test_unaligned_read4(i32* %a) sanitize_thread {
     20 entry:
     21   %tmp1 = load i32, i32* %a, align 2
     22   ret i32 %tmp1
     23 }
     24 
     25 ; CHECK-LABEL: define i32 @test_unaligned_read4(i32* %a)
     26 ; CHECK:        call void @__tsan_func_entry(i8* %0)
     27 ; CHECK-NEXT:   %1 = bitcast i32* %a to i8*
     28 ; CHECK-NEXT:   call void @__tsan_unaligned_read4(i8* %1)
     29 ; CHECK-NEXT:   %tmp1 = load i32, i32* %a, align 2
     30 ; CHECK-NEXT:   call void @__tsan_func_exit()
     31 ; CHECK: ret i32
     32 
     33 define i64 @test_unaligned_read8(i64* %a) sanitize_thread {
     34 entry:
     35   %tmp1 = load i64, i64* %a, align 4
     36   ret i64 %tmp1
     37 }
     38 
     39 ; CHECK-LABEL: define i64 @test_unaligned_read8(i64* %a)
     40 ; CHECK:        call void @__tsan_func_entry(i8* %0)
     41 ; CHECK-NEXT:   %1 = bitcast i64* %a to i8*
     42 ; CHECK-NEXT:   call void @__tsan_unaligned_read8(i8* %1)
     43 ; CHECK-NEXT:   %tmp1 = load i64, i64* %a, align 4
     44 ; CHECK-NEXT:   call void @__tsan_func_exit()
     45 ; CHECK: ret i64
     46 
     47 define i128 @test_unaligned_read16(i128* %a) sanitize_thread {
     48 entry:
     49   %tmp1 = load i128, i128* %a, align 1
     50   ret i128 %tmp1
     51 }
     52 
     53 ; CHECK-LABEL: define i128 @test_unaligned_read16(i128* %a)
     54 ; CHECK:        call void @__tsan_func_entry(i8* %0)
     55 ; CHECK-NEXT:   %1 = bitcast i128* %a to i8*
     56 ; CHECK-NEXT:   call void @__tsan_unaligned_read16(i8* %1)
     57 ; CHECK-NEXT:   %tmp1 = load i128, i128* %a, align 1
     58 ; CHECK-NEXT:   call void @__tsan_func_exit()
     59 ; CHECK: ret i128
     60 
     61 define i128 @test_aligned_read16(i128* %a) sanitize_thread {
     62 entry:
     63   %tmp1 = load i128, i128* %a, align 8
     64   ret i128 %tmp1
     65 }
     66 
     67 ; CHECK-LABEL: define i128 @test_aligned_read16(i128* %a)
     68 ; CHECK:        call void @__tsan_func_entry(i8* %0)
     69 ; CHECK-NEXT:   %1 = bitcast i128* %a to i8*
     70 ; CHECK-NEXT:   call void @__tsan_read16(i8* %1)
     71 ; CHECK-NEXT:   %tmp1 = load i128, i128* %a, align 8
     72 ; CHECK-NEXT:   call void @__tsan_func_exit()
     73 ; CHECK: ret i128
     74 
     75 define void @test_unaligned_write2(i16* %a) sanitize_thread {
     76 entry:
     77   store i16 1, i16* %a, align 1
     78   ret void
     79 }
     80 
     81 ; CHECK-LABEL: define void @test_unaligned_write2(i16* %a)
     82 ; CHECK:        call void @__tsan_func_entry(i8* %0)
     83 ; CHECK-NEXT:   %1 = bitcast i16* %a to i8*
     84 ; CHECK-NEXT:   call void @__tsan_unaligned_write2(i8* %1)
     85 ; CHECK-NEXT:   store i16 1, i16* %a, align 1
     86 ; CHECK-NEXT:   call void @__tsan_func_exit()
     87 ; CHECK: ret void
     88 
     89 define void @test_unaligned_write4(i32* %a) sanitize_thread {
     90 entry:
     91   store i32 1, i32* %a, align 1
     92   ret void
     93 }
     94 
     95 ; CHECK-LABEL: define void @test_unaligned_write4(i32* %a)
     96 ; CHECK:        call void @__tsan_func_entry(i8* %0)
     97 ; CHECK-NEXT:   %1 = bitcast i32* %a to i8*
     98 ; CHECK-NEXT:   call void @__tsan_unaligned_write4(i8* %1)
     99 ; CHECK-NEXT:   store i32 1, i32* %a, align 1
    100 ; CHECK-NEXT:   call void @__tsan_func_exit()
    101 ; CHECK: ret void
    102 
    103 define void @test_unaligned_write8(i64* %a) sanitize_thread {
    104 entry:
    105   store i64 1, i64* %a, align 1
    106   ret void
    107 }
    108 
    109 ; CHECK-LABEL: define void @test_unaligned_write8(i64* %a)
    110 ; CHECK:        call void @__tsan_func_entry(i8* %0)
    111 ; CHECK-NEXT:   %1 = bitcast i64* %a to i8*
    112 ; CHECK-NEXT:   call void @__tsan_unaligned_write8(i8* %1)
    113 ; CHECK-NEXT:   store i64 1, i64* %a, align 1
    114 ; CHECK-NEXT:   call void @__tsan_func_exit()
    115 ; CHECK: ret void
    116 
    117 define void @test_unaligned_write16(i128* %a) sanitize_thread {
    118 entry:
    119   store i128 1, i128* %a, align 1
    120   ret void
    121 }
    122 
    123 ; CHECK-LABEL: define void @test_unaligned_write16(i128* %a)
    124 ; CHECK:        call void @__tsan_func_entry(i8* %0)
    125 ; CHECK-NEXT:   %1 = bitcast i128* %a to i8*
    126 ; CHECK-NEXT:   call void @__tsan_unaligned_write16(i8* %1)
    127 ; CHECK-NEXT:   store i128 1, i128* %a, align 1
    128 ; CHECK-NEXT:   call void @__tsan_func_exit()
    129 ; CHECK: ret void
    130 
    131 define void @test_aligned_write16(i128* %a) sanitize_thread {
    132 entry:
    133   store i128 1, i128* %a, align 8
    134   ret void
    135 }
    136 
    137 ; CHECK-LABEL: define void @test_aligned_write16(i128* %a)
    138 ; CHECK:        call void @__tsan_func_entry(i8* %0)
    139 ; CHECK-NEXT:   %1 = bitcast i128* %a to i8*
    140 ; CHECK-NEXT:   call void @__tsan_write16(i8* %1)
    141 ; CHECK-NEXT:   store i128 1, i128* %a, align 8
    142 ; CHECK-NEXT:   call void @__tsan_func_exit()
    143 ; CHECK: ret void
    144