1; RUN: opt < %s -tsan -S | FileCheck %s 2 3target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 4 5declare void @escape(i32*) 6 7@sink = global i32* null, align 4 8 9define void @captured0() nounwind uwtable sanitize_thread { 10entry: 11 %ptr = alloca i32, align 4 12 ; escapes due to call 13 call void @escape(i32* %ptr) 14 store i32 42, i32* %ptr, align 4 15 ret void 16} 17; CHECK-LABEL: define void @captured0 18; CHECK: __tsan_write 19; CHECK: ret void 20 21define void @captured1() nounwind uwtable sanitize_thread { 22entry: 23 %ptr = alloca i32, align 4 24 ; escapes due to store into global 25 store i32* %ptr, i32** @sink, align 8 26 store i32 42, i32* %ptr, align 4 27 ret void 28} 29; CHECK-LABEL: define void @captured1 30; CHECK: __tsan_write 31; CHECK: __tsan_write 32; CHECK: ret void 33 34define void @captured2() nounwind uwtable sanitize_thread { 35entry: 36 %ptr = alloca i32, align 4 37 %tmp = alloca i32*, align 8 38 ; transitive escape 39 store i32* %ptr, i32** %tmp, align 8 40 %0 = load i32*, i32** %tmp, align 8 41 store i32* %0, i32** @sink, align 8 42 store i32 42, i32* %ptr, align 4 43 ret void 44} 45; CHECK-LABEL: define void @captured2 46; CHECK: __tsan_write 47; CHECK: __tsan_write 48; CHECK: ret void 49 50define void @notcaptured0() nounwind uwtable sanitize_thread { 51entry: 52 %ptr = alloca i32, align 4 53 store i32 42, i32* %ptr, align 4 54 ; escapes due to call 55 call void @escape(i32* %ptr) 56 ret void 57} 58; CHECK-LABEL: define void @notcaptured0 59; CHECK: __tsan_write 60; CHECK: ret void 61 62define void @notcaptured1() nounwind uwtable sanitize_thread { 63entry: 64 %ptr = alloca i32, align 4 65 store i32 42, i32* %ptr, align 4 66 ; escapes due to store into global 67 store i32* %ptr, i32** @sink, align 8 68 ret void 69} 70; CHECK-LABEL: define void @notcaptured1 71; CHECK: __tsan_write 72; CHECK: __tsan_write 73; CHECK: ret void 74 75define void @notcaptured2() nounwind uwtable sanitize_thread { 76entry: 77 %ptr = alloca i32, align 4 78 %tmp = alloca i32*, align 8 79 store i32 42, i32* %ptr, align 4 80 ; transitive escape 81 store i32* %ptr, i32** %tmp, align 8 82 %0 = load i32*, i32** %tmp, align 8 83 store i32* %0, i32** @sink, align 8 84 ret void 85} 86; CHECK-LABEL: define void @notcaptured2 87; CHECK: __tsan_write 88; CHECK: __tsan_write 89; CHECK: ret void 90 91 92