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 ThreadSanitizer.
4 @g = global i32 0, align 4
6 define i32 @TestNoTsan(i32 %cond) nounwind readonly uwtable {
7 ; CHECK-LABEL: @TestNoTsan(
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 @TestTsan(i32 %cond) nounwind readonly uwtable sanitize_thread {
28 ; CHECK-LABEL: @TestTsan(
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 ]