1; RUN: opt < %s -passes=tsan -S | FileCheck %s 2 3target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 4 5define void @Increment(ptr nocapture %0) local_unnamed_addr sanitize_thread !dbg !7 { 6 call void @llvm.dbg.value(metadata ptr %0, metadata !14, metadata !DIExpression()), !dbg !16 7 %2 = load i32, ptr %0, align 4, !dbg !17, !tbaa !18 8 call void @llvm.dbg.value(metadata i32 %2, metadata !15, metadata !DIExpression()), !dbg !16 9 %3 = add nsw i32 %2, 1, !dbg !22 10 store i32 %3, ptr %0, align 4, !dbg !23, !tbaa !18 11 ret void, !dbg !24 12} 13; CHECK-LABEL: define void @Increment 14; CHECK-NOT: __tsan_read4 15; CHECK: __tsan_write4 16; CHECK: ret void 17 18define i32 @NoAccesses(i32 %0) local_unnamed_addr sanitize_thread !dbg !25 { 19 call void @llvm.dbg.value(metadata i32 %0, metadata !29, metadata !DIExpression()), !dbg !30 20 %2 = add nsw i32 %0, 1, !dbg !31 21 ret i32 %2, !dbg !32 22} 23; CHECK-LABEL: define i32 @NoAccesses 24; CHECK-NOT: __tsan_func_entry 25; CHECK-NOT: __tsan_func_exit 26; CHECK: ret i32 27 28declare void @llvm.dbg.value(metadata, metadata, metadata) 29 30!llvm.dbg.cu = !{!0} 31!llvm.module.flags = !{!2, !3, !4, !5} 32!llvm.ident = !{!6} 33!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) 34!1 = !DIFile(filename: "test.c", directory: "/") 35!2 = !{i32 7, !"Dwarf Version", i32 4} 36!3 = !{i32 2, !"Debug Info Version", i32 3} 37!4 = !{i32 1, !"wchar_size", i32 4} 38!5 = !{i32 7, !"uwtable", i32 1} 39!6 = !{!"clang"} 40!7 = distinct !DISubprogram(name: "Increment", scope: !8, file: !8, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) 41!8 = !DIFile(filename: "test.c", directory: "") 42!9 = !DISubroutineType(types: !10) 43!10 = !{null, !11} 44!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) 45!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 46!13 = !{!14, !15} 47!14 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !8, line: 1, type: !11) 48!15 = !DILocalVariable(name: "x", scope: !7, file: !8, line: 2, type: !12) 49!16 = !DILocation(line: 0, scope: !7) 50!17 = !DILocation(line: 2, column: 11, scope: !7) 51!18 = !{!19, !19, i64 0} 52!19 = !{!"int", !20, i64 0} 53!20 = !{!"omnipotent char", !21, i64 0} 54!21 = !{!"Simple C/C++ TBAA"} 55!22 = !DILocation(line: 3, column: 10, scope: !7) 56!23 = !DILocation(line: 3, column: 6, scope: !7) 57!24 = !DILocation(line: 4, column: 1, scope: !7) 58!25 = distinct !DISubprogram(name: "NoAccesses", scope: !8, file: !8, line: 6, type: !26, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !28) 59!26 = !DISubroutineType(types: !27) 60!27 = !{!12, !12} 61!28 = !{!29} 62!29 = !DILocalVariable(name: "a", arg: 1, scope: !25, file: !8, line: 6, type: !12) 63!30 = !DILocation(line: 0, scope: !25) 64!31 = !DILocation(line: 7, column: 12, scope: !25) 65!32 = !DILocation(line: 7, column: 3, scope: !25) 66