1 ; RUN: opt < %s -passes=dfsan -dfsan-track-origins=1 -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"
5 ; CHECK: @__dfsan_arg_tls = external thread_local(initialexec) global [[TLS_ARR:\[100 x i64\]]]
6 define i32 @phiop(i32 %a, i32 %b, i1 %c) {
9 ; CHECK: [[BO:%.*]] = load i32, ptr getelementptr inbounds ([200 x i32], ptr @__dfsan_arg_origin_tls, i64 0, i64 1), align 4
10 ; CHECK: [[AO:%.*]] = load i32, ptr @__dfsan_arg_origin_tls, align 4
11 ; CHECK: [[BS:%.*]] = load i8, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__dfsan_arg_tls to i64), i64 2) to ptr), align [[ALIGN:2]]
12 ; CHECK: [[AS:%.*]] = load i8, ptr @__dfsan_arg_tls, align [[ALIGN]]
13 ; CHECK: br i1 %c, label %next, label %done
15 ; CHECK: br i1 %c, label %T, label %F
17 ; CHECK: [[BS_NE:%.*]] = icmp ne i8 [[BS]], 0
18 ; CHECK: [[BAO_T:%.*]] = select i1 [[BS_NE]], i32 [[BO]], i32 [[AO]]
19 ; CHECK: br label %done
21 ; CHECK: [[AS_NE:%.*]] = icmp ne i8 [[AS]], 0
22 ; CHECK: [[BAO_F:%.*]] = select i1 [[AS_NE]], i32 [[AO]], i32 [[BO]]
23 ; CHECK: br label %done
25 ; CHECK: [[PO:%.*]] = phi i32 [ [[BAO_T]], %T ], [ [[BAO_F]], %F ], [ [[AO]], %entry ]
26 ; CHECK: store i32 [[PO]], ptr @__dfsan_retval_origin_tls, align 4
29 br i1 %c, label %next, label %done
31 br i1 %c, label %T, label %F
36 %diff = sub i32 %b, %a
39 %r = phi i32 [%sum, %T], [%diff, %F], [%a, %entry]