1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s
4 declare i8 @next_char();
6 define void @test_no_msan() {
7 ; CHECK-LABEL: @test_no_msan(
9 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
11 ; CHECK-NEXT: br label [[WHILE_BODY_I:%.*]]
12 ; CHECK: while.body.i:
13 ; CHECK-NEXT: [[MAYBE_UNDEF:%.*]] = phi i1 [ undef, [[WHILE_BODY]] ], [ [[NEXT_MAYBE_UNDEF:%.*]], [[WHILE_BODY_I]] ]
14 ; CHECK-NEXT: [[C:%.*]] = call fastcc signext i8 @next_char()
15 ; CHECK-NEXT: [[C_10:%.*]] = icmp eq i8 [[C]], 10
16 ; CHECK-NEXT: [[C_13:%.*]] = icmp eq i8 [[C]], 13
17 ; CHECK-NEXT: [[C_10_OR_13:%.*]] = or i1 [[C_10]], [[C_13]]
18 ; CHECK-NEXT: [[NEXT_MAYBE_UNDEF]] = or i1 [[MAYBE_UNDEF]], [[C_10_OR_13]]
19 ; CHECK-NEXT: [[C_NOT_10_OR_13:%.*]] = xor i1 [[C_10_OR_13]], true
20 ; CHECK-NEXT: br i1 [[C_NOT_10_OR_13]], label [[WHILE_BODY_I]], label [[WHILE_BODY_I_BREAK:%.*]]
21 ; CHECK: while.body.i.break:
22 ; CHECK-NEXT: [[TMP0:%.*]] = freeze i1 [[MAYBE_UNDEF]]
23 ; CHECK-NEXT: br i1 [[TMP0]], label [[WHILE_BODY]], label [[SWITCH_EARLY_TEST:%.*]]
24 ; CHECK: switch.early.test:
25 ; CHECK-NEXT: switch i8 [[C]], label [[RETURN:%.*]] [
26 ; CHECK-NEXT: i8 13, label [[WHILE_BODY]]
27 ; CHECK-NEXT: i8 10, label [[WHILE_BODY]]
30 ; CHECK-NEXT: ret void
37 br label %while.body.i
40 %maybe_undef = phi i1 [ undef, %while.body ], [ %next_maybe_undef, %while.body.i ]
41 %c = call fastcc signext i8 @next_char()
42 %c_10 = icmp eq i8 %c, 10
43 %c_13 = icmp eq i8 %c, 13
44 %c_10_or_13 = or i1 %c_10, %c_13
45 %next_maybe_undef = or i1 %maybe_undef, %c_10_or_13
46 %c_not_10_or_13 = xor i1 %c_10_or_13, true
47 br i1 %c_not_10_or_13, label %while.body.i, label %while.body.i.break
50 ; NEXT_MAYBE_UNDEF is never undef if here
51 br i1 %next_maybe_undef, label %while.body, label %return
59 define void @test_msan() sanitize_memory {
60 ; CHECK-LABEL: @test_msan(
62 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
64 ; CHECK-NEXT: br label [[WHILE_BODY_I:%.*]]
65 ; CHECK: while.body.i:
66 ; CHECK-NEXT: [[MAYBE_UNDEF:%.*]] = phi i1 [ undef, [[WHILE_BODY]] ], [ [[NEXT_MAYBE_UNDEF:%.*]], [[WHILE_BODY_I]] ]
67 ; CHECK-NEXT: [[C:%.*]] = call fastcc signext i8 @next_char()
68 ; CHECK-NEXT: [[C_10:%.*]] = icmp eq i8 [[C]], 10
69 ; CHECK-NEXT: [[C_13:%.*]] = icmp eq i8 [[C]], 13
70 ; CHECK-NEXT: [[C_10_OR_13:%.*]] = or i1 [[C_10]], [[C_13]]
71 ; CHECK-NEXT: [[NEXT_MAYBE_UNDEF]] = or i1 [[MAYBE_UNDEF]], [[C_10_OR_13]]
72 ; CHECK-NEXT: [[C_NOT_10_OR_13:%.*]] = xor i1 [[C_10_OR_13]], true
73 ; CHECK-NEXT: br i1 [[C_NOT_10_OR_13]], label [[WHILE_BODY_I]], label [[WHILE_BODY_I_BREAK:%.*]]
74 ; CHECK: while.body.i.break:
75 ; CHECK-NEXT: [[TMP0:%.*]] = freeze i1 [[MAYBE_UNDEF]]
76 ; CHECK-NEXT: br i1 [[TMP0]], label [[WHILE_BODY]], label [[SWITCH_EARLY_TEST:%.*]]
77 ; CHECK: switch.early.test:
78 ; CHECK-NEXT: switch i8 [[C]], label [[RETURN:%.*]] [
79 ; CHECK-NEXT: i8 13, label [[WHILE_BODY]]
80 ; CHECK-NEXT: i8 10, label [[WHILE_BODY]]
83 ; CHECK-NEXT: ret void
90 br label %while.body.i
93 %maybe_undef = phi i1 [ undef, %while.body ], [ %next_maybe_undef, %while.body.i ]
94 %c = call fastcc signext i8 @next_char()
95 %c_10 = icmp eq i8 %c, 10
96 %c_13 = icmp eq i8 %c, 13
97 %c_10_or_13 = or i1 %c_10, %c_13
98 %next_maybe_undef = or i1 %maybe_undef, %c_10_or_13
99 %c_not_10_or_13 = xor i1 %c_10_or_13, true
100 br i1 %c_not_10_or_13, label %while.body.i, label %while.body.i.break
103 ; NEXT_MAYBE_UNDEF is never undef if here
104 br i1 %next_maybe_undef, label %while.body, label %return