Home | History | Annotate | Download | only in DataFlowSanitizer
      1 ; RUN: opt < %s -dfsan -dfsan-args-abi -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s
      2 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"
      3 target triple = "x86_64-unknown-linux-gnu"
      4 
      5 ; CHECK: i32 @discard(i32 %a, i32 %b)
      6 define i32 @discard(i32 %a, i32 %b) {
      7   ret i32 0
      8 }
      9 
     10 ; CHECK: i32 @functional(i32 %a, i32 %b)
     11 define i32 @functional(i32 %a, i32 %b) {
     12   %c = add i32 %a, %b
     13   ret i32 %c
     14 }
     15 
     16 ; CHECK: define i32 (i32, i32)* @discardg(i32)
     17 ; CHECK: %[[CALL:.*]] = call { i32 (i32, i32)*, i16 } @"dfs$g"(i32 %0, i16 0)
     18 ; CHECK: %[[XVAL:.*]] = extractvalue { i32 (i32, i32)*, i16 } %[[CALL]], 0
     19 ; CHECK: ret {{.*}} %[[XVAL]]
     20 @discardg = alias i32 (i32, i32)* (i32), i32 (i32, i32)* (i32)* @g
     21 
     22 declare void @custom1(i32 %a, i32 %b)
     23 
     24 ; CHECK: define linkonce_odr { i32, i16 } @"dfsw$custom2"(i32, i32, i16, i16)
     25 ; CHECK: %[[LABELRETURN2:.*]] = alloca i16
     26 ; CHECK: %[[RV:.*]] = call i32 @__dfsw_custom2
     27 ; CHECK: %[[RVSHADOW:.*]] = load i16, i16* %[[LABELRETURN2]]
     28 ; CHECK: insertvalue {{.*}}[[RV]], 0
     29 ; CHECK: insertvalue {{.*}}[[RVSHADOW]], 1
     30 ; CHECK: ret { i32, i16 }
     31 declare i32 @custom2(i32 %a, i32 %b)
     32 
     33 ; CHECK: define linkonce_odr void @"dfsw$custom3"(i32, i16, i16*, ...)
     34 ; CHECK: call void @__dfsan_vararg_wrapper(i8*
     35 ; CHECK: unreachable
     36 declare void @custom3(i32 %a, ...)
     37 
     38 declare i32 @custom4(i32 %a, ...)
     39 
     40 declare void @customcb(i32 (i32)* %cb)
     41 
     42 declare i32 @cb(i32)
     43 
     44 ; CHECK: @"dfs$f"
     45 define void @f(i32 %x) {
     46   ; CHECK: %[[LABELVA2:.*]] = alloca [2 x i16]
     47   ; CHECK: %[[LABELVA1:.*]] = alloca [2 x i16]
     48   ; CHECK: %[[LABELRETURN:.*]] = alloca i16
     49 
     50   ; CHECK: call void @__dfsw_custom1(i32 1, i32 2, i16 0, i16 0)
     51   call void @custom1(i32 1, i32 2)
     52 
     53   ; CHECK: call i32 @__dfsw_custom2(i32 1, i32 2, i16 0, i16 0, i16* %[[LABELRETURN]])
     54   call i32 @custom2(i32 1, i32 2)
     55 
     56   ; CHECK: call void @__dfsw_customcb({{.*}} @"dfst0$customcb", i8* bitcast ({{.*}} @"dfs$cb" to i8*), i16 0)
     57   call void @customcb(i32 (i32)* @cb)
     58 
     59   ; CHECK: %[[LABELVA1_0:.*]] = getelementptr inbounds [2 x i16], [2 x i16]* %[[LABELVA1]], i32 0, i32 0
     60   ; CHECK: store i16 0, i16* %[[LABELVA1_0]]
     61   ; CHECK: %[[LABELVA1_1:.*]] = getelementptr inbounds [2 x i16], [2 x i16]* %[[LABELVA1]], i32 0, i32 1
     62   ; CHECK: store i16 %{{.*}}, i16* %[[LABELVA1_1]]
     63   ; CHECK: %[[LABELVA1_0A:.*]] = getelementptr inbounds [2 x i16], [2 x i16]* %[[LABELVA1]], i32 0, i32 0
     64   ; CHECK: call void (i32, i16, i16*, ...) @__dfsw_custom3(i32 1, i16 0, i16* %[[LABELVA1_0A]], i32 2, i32 %{{.*}})
     65   call void (i32, ...) @custom3(i32 1, i32 2, i32 %x)
     66 
     67   ; CHECK: %[[LABELVA2_0:.*]] = getelementptr inbounds [2 x i16], [2 x i16]* %[[LABELVA2]], i32 0, i32 0
     68   ; CHECK: %[[LABELVA2_0A:.*]] = getelementptr inbounds [2 x i16], [2 x i16]* %[[LABELVA2]], i32 0, i32 0
     69   ; CHECK: call i32 (i32, i16, i16*, i16*, ...) @__dfsw_custom4(i32 1, i16 0, i16* %[[LABELVA2_0A]], i16* %[[LABELRETURN]], i32 2, i32 3)
     70   call i32 (i32, ...) @custom4(i32 1, i32 2, i32 3)
     71 
     72   ret void
     73 }
     74 
     75 ; CHECK: @"dfs$g"
     76 define i32 (i32, i32)* @g(i32) {
     77   ; CHECK: ret {{.*}} @"dfsw$custom2"
     78   ret i32 (i32, i32)* @custom2
     79 }
     80 
     81 ; CHECK: define { i32, i16 } @"dfs$adiscard"(i32, i32, i16, i16)
     82 ; CHECK: %[[CALL:.*]] = call i32 @discard(i32 %0, i32 %1)
     83 ; CHECK: %[[IVAL0:.*]] = insertvalue { i32, i16 } undef, i32 %[[CALL]], 0
     84 ; CHECK: %[[IVAL1:.*]] = insertvalue { i32, i16 } %[[IVAL0]], i16 0, 1
     85 ; CHECK: ret { i32, i16 } %[[IVAL1]]
     86 @adiscard = alias i32 (i32, i32), i32 (i32, i32)* @discard
     87 
     88 ; CHECK: declare void @__dfsw_custom1(i32, i32, i16, i16)
     89 ; CHECK: declare i32 @__dfsw_custom2(i32, i32, i16, i16, i16*)
     90 
     91 ; CHECK-LABEL: define linkonce_odr i32 @"dfst0$customcb"(i32 (i32)*, i32, i16, i16*)
     92 ; CHECK: %[[BC:.*]] = bitcast i32 (i32)* %0 to { i32, i16 } (i32, i16)*
     93 ; CHECK: %[[CALL:.*]] = call { i32, i16 } %[[BC]](i32 %1, i16 %2)
     94 ; CHECK: %[[XVAL0:.*]] = extractvalue { i32, i16 } %[[CALL]], 0
     95 ; CHECK: %[[XVAL1:.*]] = extractvalue { i32, i16 } %[[CALL]], 1
     96 ; CHECK: store i16 %[[XVAL1]], i16* %3
     97 ; CHECK: ret i32 %[[XVAL0]]
     98 
     99 ; CHECK: declare void @__dfsw_custom3(i32, i16, i16*, ...)
    100 ; CHECK: declare i32 @__dfsw_custom4(i32, i16, i16*, i16*, ...)
    101