blob: 7fcba2cf3358de20476521c0c0c762ac124f473a [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"
Peter Collingbournee67e4e82014-12-05 22:32:30 +00003target triple = "x86_64-unknown-linux-gnu"
Peter Collingbourne705a1ae2014-07-15 04:41:17 +00004
5@a = common global i32 0
6@b = common global i32 0
7
8; Check that we reuse unions where possible.
9
10; CHECK-LABEL: @"dfs$f"
11define void @f(i32 %x, i32 %y) {
Peter Collingbourne9947c492014-07-15 22:13:19 +000012 ; CHECK: call{{.*}}__dfsan_union
Peter Collingbourne705a1ae2014-07-15 04:41:17 +000013 %xay = add i32 %x, %y
14 store i32 %xay, i32* @a
Peter Collingbourne9947c492014-07-15 22:13:19 +000015 ; CHECK-NOT: call{{.*}}__dfsan_union
Peter Collingbourne705a1ae2014-07-15 04:41:17 +000016 %xmy = mul i32 %x, %y
17 store i32 %xmy, i32* @b
18 ret void
19}
20
21; In this case, we compute the unions on both sides because neither block
22; dominates the other.
23
24; CHECK-LABEL: @"dfs$g"
25define void @g(i1 %p, i32 %x, i32 %y) {
26 br i1 %p, label %l1, label %l2
27
28l1:
Peter Collingbourne9947c492014-07-15 22:13:19 +000029 ; CHECK: call{{.*}}__dfsan_union
Peter Collingbourne705a1ae2014-07-15 04:41:17 +000030 %xay = add i32 %x, %y
31 store i32 %xay, i32* @a
32 br label %l3
33
34l2:
Peter Collingbourne9947c492014-07-15 22:13:19 +000035 ; CHECK: call{{.*}}__dfsan_union
Peter Collingbourne705a1ae2014-07-15 04:41:17 +000036 %xmy = mul i32 %x, %y
37 store i32 %xmy, i32* @b
38 br label %l3
39
40l3:
41 ret void
42}
Peter Collingbourne9947c492014-07-15 22:13:19 +000043
44; In this case, we know that the label for %xayax subsumes the label for %xay.
45
46; CHECK-LABEL: @"dfs$h"
47define i32 @h(i32 %x, i32 %y) {
48 ; CHECK: call{{.*}}__dfsan_union
49 %xay = add i32 %x, %y
50 ; CHECK-NOT: call{{.*}}__dfsan_union
51 %xayax = add i32 %xay, %x
52 ret i32 %xayax
53}