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 5define i32 @TestNoTsan(i32 %cond) nounwind readonly uwtable { 6entry: 7 %tobool = icmp eq i32 %cond, 0 8 br i1 %tobool, label %return, label %if.then 9 10if.then: ; preds = %entry 11 %0 = load i32, i32* @g, align 4 12 br label %return 13 14return: ; 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 23define i32 @TestTsan(i32 %cond) nounwind readonly uwtable sanitize_thread { 24entry: 25 %tobool = icmp eq i32 %cond, 0 26 br i1 %tobool, label %return, label %if.then 27 28if.then: ; preds = %entry 29 %0 = load i32, i32* @g, align 4 30 br label %return 31 32return: ; 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, i32* @g 38; CHECK: br label 39; CHECK: ret i32 40} 41