blob: 2b31081776b71fe6145f501aa067f36686dca33f [file] [log] [blame]
Peter Collingbourne705a1ae2014-07-15 04:41:17 +00001; RUN: opt < %s -dfsan -S | FileCheck %s
2target 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
4@a = common global i32 0
5@b = common global i32 0
6
7; Check that we reuse unions where possible.
8
9; CHECK-LABEL: @"dfs$f"
10define void @f(i32 %x, i32 %y) {
Peter Collingbourne9947c492014-07-15 22:13:19 +000011 ; CHECK: call{{.*}}__dfsan_union
Peter Collingbourne705a1ae2014-07-15 04:41:17 +000012 %xay = add i32 %x, %y
13 store i32 %xay, i32* @a
Peter Collingbourne9947c492014-07-15 22:13:19 +000014 ; CHECK-NOT: call{{.*}}__dfsan_union
Peter Collingbourne705a1ae2014-07-15 04:41:17 +000015 %xmy = mul i32 %x, %y
16 store i32 %xmy, i32* @b
17 ret void
18}
19
20; In this case, we compute the unions on both sides because neither block
21; dominates the other.
22
23; CHECK-LABEL: @"dfs$g"
24define void @g(i1 %p, i32 %x, i32 %y) {
25 br i1 %p, label %l1, label %l2
26
27l1:
Peter Collingbourne9947c492014-07-15 22:13:19 +000028 ; CHECK: call{{.*}}__dfsan_union
Peter Collingbourne705a1ae2014-07-15 04:41:17 +000029 %xay = add i32 %x, %y
30 store i32 %xay, i32* @a
31 br label %l3
32
33l2:
Peter Collingbourne9947c492014-07-15 22:13:19 +000034 ; CHECK: call{{.*}}__dfsan_union
Peter Collingbourne705a1ae2014-07-15 04:41:17 +000035 %xmy = mul i32 %x, %y
36 store i32 %xmy, i32* @b
37 br label %l3
38
39l3:
40 ret void
41}
Peter Collingbourne9947c492014-07-15 22:13:19 +000042
43; In this case, we know that the label for %xayax subsumes the label for %xay.
44
45; CHECK-LABEL: @"dfs$h"
46define i32 @h(i32 %x, i32 %y) {
47 ; CHECK: call{{.*}}__dfsan_union
48 %xay = add i32 %x, %y
49 ; CHECK-NOT: call{{.*}}__dfsan_union
50 %xayax = add i32 %xay, %x
51 ret i32 %xayax
52}