1 ; RUN: opt -simplifycfg -S %s | FileCheck %s 2 ; Make sure we don't speculate loads under ThreadSanitizer. 3 @g = global i32 0, align 4 4 5 define i32 @TestNoTsan(i32 %cond) nounwind readonly uwtable { 6 entry: 7 %tobool = icmp eq i32 %cond, 0 8 br i1 %tobool, label %return, label %if.then 9 10 if.then: ; preds = %entry 11 %0 = load i32* @g, align 4 12 br label %return 13 14 return: ; preds = %entry, %if.then 15 %retval = phi i32 [ %0, %if.then ], [ 0, %entry ] 16 ret i32 %retval 17 ; CHECK-LABEL: @TestNoTsan 18 ; CHECK: %[[LOAD:[^ ]*]] = load 19 ; CHECK: select{{.*}}[[LOAD]] 20 ; CHECK: ret i32 21 } 22 23 define i32 @TestTsan(i32 %cond) nounwind readonly uwtable sanitize_thread { 24 entry: 25 %tobool = icmp eq i32 %cond, 0 26 br i1 %tobool, label %return, label %if.then 27 28 if.then: ; preds = %entry 29 %0 = load i32* @g, align 4 30 br label %return 31 32 return: ; preds = %entry, %if.then 33 %retval = phi i32 [ %0, %if.then ], [ 0, %entry ] 34 ret i32 %retval 35 ; CHECK-LABEL: @TestTsan 36 ; CHECK: br i1 37 ; CHECK: load i32* @g 38 ; CHECK: br label 39 ; CHECK: ret i32 40 } 41