1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S %s | FileCheck %s
3 ; Make sure we don't speculate loads under AddressSanitizer.
4 @g = global i32 0, align 4
6 define i32 @TestNoAsan(i32 %cond) nounwind readonly uwtable {
7 ; CHECK-LABEL: @TestNoAsan(
9 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[COND:%.*]], 0
10 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @g, align 4
11 ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[TOBOOL]], i32 0, i32 [[TMP0]]
12 ; CHECK-NEXT: ret i32 [[SPEC_SELECT]]
15 %tobool = icmp eq i32 %cond, 0
16 br i1 %tobool, label %return, label %if.then
18 if.then: ; preds = %entry
19 %0 = load i32, ptr @g, align 4
22 return: ; preds = %entry, %if.then
23 %retval = phi i32 [ %0, %if.then ], [ 0, %entry ]
27 define i32 @TestAsan(i32 %cond) nounwind readonly uwtable sanitize_address {
28 ; CHECK-LABEL: @TestAsan(
30 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[COND:%.*]], 0
31 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[RETURN:%.*]], label [[IF_THEN:%.*]]
33 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @g, align 4
34 ; CHECK-NEXT: br label [[RETURN]]
36 ; CHECK-NEXT: [[RETVAL:%.*]] = phi i32 [ [[TMP0]], [[IF_THEN]] ], [ 0, [[ENTRY:%.*]] ]
37 ; CHECK-NEXT: ret i32 [[RETVAL]]
40 %tobool = icmp eq i32 %cond, 0
41 br i1 %tobool, label %return, label %if.then
43 if.then: ; preds = %entry
44 %0 = load i32, ptr @g, align 4
47 return: ; preds = %entry, %if.then
48 %retval = phi i32 [ %0, %if.then ], [ 0, %entry ]
52 define i32 @TestHWAsan(i32 %cond) nounwind readonly uwtable sanitize_hwaddress {
53 ; CHECK-LABEL: @TestHWAsan(
55 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[COND:%.*]], 0
56 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[RETURN:%.*]], label [[IF_THEN:%.*]]
58 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @g, align 4
59 ; CHECK-NEXT: br label [[RETURN]]
61 ; CHECK-NEXT: [[RETVAL:%.*]] = phi i32 [ [[TMP0]], [[IF_THEN]] ], [ 0, [[ENTRY:%.*]] ]
62 ; CHECK-NEXT: ret i32 [[RETVAL]]
65 %tobool = icmp eq i32 %cond, 0
66 br i1 %tobool, label %return, label %if.then
68 if.then: ; preds = %entry
69 %0 = load i32, ptr @g, align 4
72 return: ; preds = %entry, %if.then
73 %retval = phi i32 [ %0, %if.then ], [ 0, %entry ]