Home | History | Annotate | Download | only in MemorySanitizer
      1 ; RUN: opt < %s -msan -msan-check-access-address=0 -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 target triple = "x86_64-unknown-linux-gnu"
      5 
      6 ; Check instrumentation mul when one of the operands is a constant.
      7 
      8 define i64 @MulConst(i64 %x) sanitize_memory {
      9 entry:
     10   %y = mul i64 %x, 42949672960000
     11   ret i64 %y
     12 }
     13 
     14 ; 42949672960000 = 2**32 * 10000
     15 ; 36 trailing zero bits
     16 ; 68719476736 = 2**36
     17 
     18 ; CHECK-LABEL: @MulConst(
     19 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
     20 ; CHECK: [[B:%.*]] = mul i64 [[A]], 68719476736
     21 ; CHECK: store i64 [[B]], i64* {{.*}} @__msan_retval_tls
     22 
     23 
     24 define i64 @MulZero(i64 %x) sanitize_memory {
     25 entry:
     26   %y = mul i64 %x, 0
     27   ret i64 %y
     28 }
     29 
     30 ; CHECK-LABEL: @MulZero(
     31 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
     32 ; CHECK: [[B:%.*]] = mul i64 [[A]], 0{{$}}
     33 ; CHECK: store i64 [[B]], i64* {{.*}} @__msan_retval_tls
     34 
     35 
     36 define i64 @MulNeg(i64 %x) sanitize_memory {
     37 entry:
     38   %y = mul i64 %x, -16
     39   ret i64 %y
     40 }
     41 
     42 ; CHECK-LABEL: @MulNeg(
     43 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
     44 ; CHECK: [[B:%.*]] = mul i64 [[A]], 16
     45 ; CHECK: store i64 [[B]], i64* {{.*}} @__msan_retval_tls
     46 
     47 
     48 define i64 @MulNeg2(i64 %x) sanitize_memory {
     49 entry:
     50   %y = mul i64 %x, -48
     51   ret i64 %y
     52 }
     53 
     54 ; CHECK-LABEL: @MulNeg2(
     55 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
     56 ; CHECK: [[B:%.*]] = mul i64 [[A]], 16
     57 ; CHECK: store i64 [[B]], i64* {{.*}} @__msan_retval_tls
     58 
     59 
     60 define i64 @MulOdd(i64 %x) sanitize_memory {
     61 entry:
     62   %y = mul i64 %x, 12345
     63   ret i64 %y
     64 }
     65 
     66 ; CHECK-LABEL: @MulOdd(
     67 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
     68 ; CHECK: [[B:%.*]] = mul i64 [[A]], 1
     69 ; CHECK: store i64 [[B]], i64* {{.*}} @__msan_retval_tls
     70 
     71 
     72 define i64 @MulLarge(i64 %x) sanitize_memory {
     73 entry:
     74   %y = mul i64 %x, -9223372036854775808
     75   ret i64 %y
     76 }
     77 
     78 ; -9223372036854775808 = 0x7000000000000000
     79 
     80 ; CHECK-LABEL: @MulLarge(
     81 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
     82 ; CHECK: [[B:%.*]] = mul i64 [[A]], -9223372036854775808
     83 ; CHECK: store i64 [[B]], i64* {{.*}} @__msan_retval_tls
     84 
     85 define <4 x i32> @MulVectorConst(<4 x i32> %x) sanitize_memory {
     86 entry:
     87   %y = mul <4 x i32> %x, <i32 3072, i32 0, i32 -16, i32 -48>
     88   ret <4 x i32> %y
     89 }
     90 
     91 ; CHECK-LABEL: @MulVectorConst(
     92 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
     93 ; CHECK: [[B:%.*]] = mul <4 x i32> [[A]], <i32 1024, i32 0, i32 16, i32 16>
     94 ; CHECK: store <4 x i32> [[B]], <4 x i32>* {{.*}} @__msan_retval_tls
     95