1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=newgvn -S %s | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 declare noalias i8* @_Znam(i64) #1
6 define i32 @TestNoAsan() {
7 ; CHECK-LABEL: @TestNoAsan(
8 ; CHECK-NEXT: [[TMP1:%.*]] = tail call noalias ptr @_Znam(i64 2)
9 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i64 1
10 ; CHECK-NEXT: store i8 0, ptr [[TMP2]], align 1
11 ; CHECK-NEXT: store i8 0, ptr [[TMP1]], align 1
12 ; CHECK-NEXT: [[TMP3:%.*]] = load i16, ptr [[TMP1]], align 4
13 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i16 [[TMP3]], 0
14 ; CHECK-NEXT: br i1 [[TMP4]], label [[TMP9:%.*]], label [[TMP5:%.*]]
16 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i64 2
17 ; CHECK-NEXT: [[TMP7:%.*]] = load i16, ptr [[TMP6]], align 2
18 ; CHECK-NEXT: [[TMP8:%.*]] = sext i16 [[TMP7]] to i32
19 ; CHECK-NEXT: br label [[TMP9]]
21 ; CHECK-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP5]] ], [ 0, [[TMP0:%.*]] ]
22 ; CHECK-NEXT: ret i32 [[TMP10]]
24 %1 = tail call noalias ptr @_Znam(i64 2)
25 %2 = getelementptr inbounds i8, ptr %1, i64 1
26 store i8 0, ptr %2, align 1
27 store i8 0, ptr %1, align 1
28 %3 = load i16, ptr %1, align 4
29 %4 = icmp eq i16 %3, 0
30 br i1 %4, label %9, label %5
32 ; <label>:5 ; preds = %0
33 %6 = getelementptr inbounds i8, ptr %1, i64 2
34 %7 = load i16, ptr %6, align 2
35 %8 = sext i16 %7 to i32
38 ; <label>:9 ; preds = %0, %5
39 %10 = phi i32 [ %8, %5 ], [ 0, %0 ]
43 define i32 @TestAsan() sanitize_address {
44 ; CHECK-LABEL: @TestAsan(
45 ; CHECK-NEXT: [[TMP1:%.*]] = tail call noalias ptr @_Znam(i64 2)
46 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i64 1
47 ; CHECK-NEXT: store i8 0, ptr [[TMP2]], align 1
48 ; CHECK-NEXT: store i8 0, ptr [[TMP1]], align 1
49 ; CHECK-NEXT: [[TMP3:%.*]] = load i16, ptr [[TMP1]], align 4
50 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i16 [[TMP3]], 0
51 ; CHECK-NEXT: br i1 [[TMP4]], label [[TMP9:%.*]], label [[TMP5:%.*]]
53 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i64 2
54 ; CHECK-NEXT: [[TMP7:%.*]] = load i16, ptr [[TMP6]], align 2
55 ; CHECK-NEXT: [[TMP8:%.*]] = sext i16 [[TMP7]] to i32
56 ; CHECK-NEXT: br label [[TMP9]]
58 ; CHECK-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP5]] ], [ 0, [[TMP0:%.*]] ]
59 ; CHECK-NEXT: ret i32 [[TMP10]]
61 %1 = tail call noalias ptr @_Znam(i64 2)
62 %2 = getelementptr inbounds i8, ptr %1, i64 1
63 store i8 0, ptr %2, align 1
64 store i8 0, ptr %1, align 1
65 %3 = load i16, ptr %1, align 4
66 %4 = icmp eq i16 %3, 0
67 br i1 %4, label %9, label %5
69 ; <label>:5 ; preds = %0
70 %6 = getelementptr inbounds i8, ptr %1, i64 2
71 %7 = load i16, ptr %6, align 2
72 %8 = sext i16 %7 to i32
75 ; <label>:9 ; preds = %0, %5
76 %10 = phi i32 [ %8, %5 ], [ 0, %0 ]
80 define i32 @TestHWAsan() sanitize_hwaddress {
81 ; CHECK-LABEL: @TestHWAsan(
82 ; CHECK-NEXT: [[TMP1:%.*]] = tail call noalias ptr @_Znam(i64 2)
83 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i64 1
84 ; CHECK-NEXT: store i8 0, ptr [[TMP2]], align 1
85 ; CHECK-NEXT: store i8 0, ptr [[TMP1]], align 1
86 ; CHECK-NEXT: [[TMP3:%.*]] = load i16, ptr [[TMP1]], align 4
87 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i16 [[TMP3]], 0
88 ; CHECK-NEXT: br i1 [[TMP4]], label [[TMP9:%.*]], label [[TMP5:%.*]]
90 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i64 2
91 ; CHECK-NEXT: [[TMP7:%.*]] = load i16, ptr [[TMP6]], align 2
92 ; CHECK-NEXT: [[TMP8:%.*]] = sext i16 [[TMP7]] to i32
93 ; CHECK-NEXT: br label [[TMP9]]
95 ; CHECK-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP8]], [[TMP5]] ], [ 0, [[TMP0:%.*]] ]
96 ; CHECK-NEXT: ret i32 [[TMP10]]
98 %1 = tail call noalias ptr @_Znam(i64 2)
99 %2 = getelementptr inbounds i8, ptr %1, i64 1
100 store i8 0, ptr %2, align 1
101 store i8 0, ptr %1, align 1
102 %3 = load i16, ptr %1, align 4
103 %4 = icmp eq i16 %3, 0
104 br i1 %4, label %9, label %5
106 ; <label>:5 ; preds = %0
107 %6 = getelementptr inbounds i8, ptr %1, i64 2
108 %7 = load i16, ptr %6, align 2
109 %8 = sext i16 %7 to i32
112 ; <label>:9 ; preds = %0, %5
113 %10 = phi i32 [ %8, %5 ], [ 0, %0 ]