xref: /llvm-project/llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll (revision 62b21c6ced918c7fec97b557e3087e3ffdf71494)
1; RUN: opt -jmc-instrumenter -mtriple=x86_64-pc-windows-msvc  -S < %s | FileCheck %s
2; RUN: opt -jmc-instrumenter -mtriple=aarch64-pc-windows-msvc -S < %s | FileCheck %s
3; RUN: opt -jmc-instrumenter -mtriple=arm-pc-windows-msvc     -S < %s | FileCheck %s
4; RUN: opt -passes=jmc-instrumenter -mtriple=x86_64-pc-windows-msvc  -S < %s | FileCheck %s
5; RUN: opt -passes=jmc-instrumenter -mtriple=aarch64-pc-windows-msvc -S < %s | FileCheck %s
6; RUN: opt -passes=jmc-instrumenter -mtriple=arm-pc-windows-msvc     -S < %s | FileCheck %s
7
8; CHECK: $__JustMyCode_Default = comdat any
9
10; CHECK: @"__7DF23CF5_x@c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !0
11; CHECK: @llvm.used = appending global [1 x ptr] [ptr @__JustMyCode_Default], section "llvm.metadata"
12; CHECK: @"__A8764FDD_x@c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !5
13; CHECK: @"__0C712A50_x@c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !9
14; CHECK: @"__A3605329_x@c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !12
15
16; CHECK: define void @l1() !dbg !19 {
17; CHECK:   call void @__CheckForDebuggerJustMyCode(ptr noundef @"__7DF23CF5_x@c")
18; CHECK:   ret void
19; CHECK: }
20
21; CHECK: define void @l2() !dbg !23 {
22; CHECK:   call void @__CheckForDebuggerJustMyCode(ptr noundef @"__7DF23CF5_x@c")
23; CHECK:   ret void
24; CHECK: }
25
26; CHECK: define void @w1() !dbg !25 {
27; CHECK:   call void @__CheckForDebuggerJustMyCode(ptr noundef @"__A8764FDD_x@c")
28; CHECK:   ret void
29; CHECK: }
30
31; CHECK: define void @w2() !dbg !26 {
32; CHECK:   call void @__CheckForDebuggerJustMyCode(ptr noundef @"__A8764FDD_x@c")
33; CHECK:   ret void
34; CHECK: }
35
36; CHECK: define void @w3() !dbg !28 {
37; CHECK:   call void @__CheckForDebuggerJustMyCode(ptr noundef @"__A8764FDD_x@c")
38; CHECK:   ret void
39; CHECK: }
40
41; CHECK: define void @w4() !dbg !30 {
42; CHECK:   call void @__CheckForDebuggerJustMyCode(ptr noundef @"__A8764FDD_x@c")
43; CHECK:   ret void
44; CHECK: }
45
46; CHECK: define void @w5() !dbg !32 {
47; CHECK:   call void @__CheckForDebuggerJustMyCode(ptr noundef @"__0C712A50_x@c")
48; CHECK:   ret void
49; CHECK: }
50
51; CHECK: define void @w6() !dbg !33 {
52; CHECK:   call void @__CheckForDebuggerJustMyCode(ptr noundef @"__A3605329_x@c")
53; CHECK:   ret void
54; CHECK: }
55
56; CHECK: define void @w7() !dbg !34 {
57; CHECK:   call void @__CheckForDebuggerJustMyCode(ptr noundef @"__0C712A50_x@c")
58; CHECK:   ret void
59; CHECK: }
60
61; CHECK: define void @__JustMyCode_Default(ptr noundef %0) unnamed_addr comdat {
62; CHECK:   ret void
63; CHECK: }
64
65; CHECK: declare void @__CheckForDebuggerJustMyCode(ptr noundef) unnamed_addr
66
67; CHECK: !llvm.linker.options = !{!18}
68
69; CHECK: !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
70; CHECK: !1 = distinct !DIGlobalVariable(name: "__7DF23CF5_x@c", scope: !2, file: !3, type: !8, isLocal: true, isDefinition: true)
71; CHECK: !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
72; CHECK: !3 = !DIFile(filename: "a/x.c", directory: "/tmp")
73; CHECK: !4 = !{!0, !5, !9, !12}
74; CHECK: !5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
75; CHECK: !6 = distinct !DIGlobalVariable(name: "__A8764FDD_x@c", scope: !2, file: !7, type: !8, isLocal: true, isDefinition: true)
76; CHECK: !7 = !DIFile(filename: "./x.c", directory: "C:\\\\a\\\\b\\\\")
77; CHECK: !8 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char, flags: DIFlagArtificial)
78; CHECK: !9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
79; CHECK: !10 = distinct !DIGlobalVariable(name: "__0C712A50_x@c", scope: !2, file: !11, type: !8, isLocal: true, isDefinition: true)
80; CHECK: !11 = !DIFile(filename: "./b/.\\../b/x.c", directory: "a\\d/p")
81; CHECK: !12 = !DIGlobalVariableExpression(var: !13, expr: !DIExpression())
82; CHECK: !13 = distinct !DIGlobalVariable(name: "__A3605329_x@c", scope: !2, file: !14, type: !8, isLocal: true, isDefinition: true)
83; CHECK: !14 = !DIFile(filename: "./b/./../b/x.c", directory: "a/d/p")
84; CHECK: !15 = !{i32 2, !"CodeView", i32 1}
85; CHECK: !16 = !{i32 2, !"Debug Info Version", i32 3}
86; CHECK: !17 = !{!"clang"}
87; CHECK: !18 = !{!"/alternatename:__CheckForDebuggerJustMyCode=__JustMyCode_Default"}
88; CHECK: !19 = distinct !DISubprogram(name: "f", scope: !3, file: !3, line: 1, type: !20, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22)
89; CHECK: !20 = !DISubroutineType(types: !21)
90; CHECK: !21 = !{null}
91; CHECK: !22 = !{}
92; CHECK: !23 = distinct !DISubprogram(name: "f", scope: !24, file: !24, line: 1, type: !20, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22)
93; CHECK: !24 = !DIFile(filename: "x.c", directory: "/tmp/a")
94; CHECK: !25 = distinct !DISubprogram(name: "f", scope: !7, file: !7, line: 1, type: !20, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22)
95; CHECK: !26 = distinct !DISubprogram(name: "f", scope: !27, file: !27, line: 1, type: !20, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22)
96; CHECK: !27 = !DIFile(filename: "./b\\x.c", directory: "C:\\\\a\\\\")
97; CHECK: !28 = distinct !DISubprogram(name: "f", scope: !29, file: !29, line: 1, type: !20, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22)
98; CHECK: !29 = !DIFile(filename: "./b/x.c", directory: "C:\\\\a\\\\")
99; CHECK: !30 = distinct !DISubprogram(name: "f", scope: !31, file: !31, line: 1, type: !20, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22)
100; CHECK: !31 = !DIFile(filename: "./b/./../b/x.c", directory: "C:/a")
101; CHECK: !32 = distinct !DISubprogram(name: "f", scope: !11, file: !11, line: 1, type: !20, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22)
102; CHECK: !33 = distinct !DISubprogram(name: "f", scope: !14, file: !14, line: 1, type: !20, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22)
103; CHECK: !34 = distinct !DISubprogram(name: "f", scope: !35, file: !35, line: 1, type: !20, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22)
104; CHECK: !35 = !DIFile(filename: "./b/./../b\\x.c", directory: "a/d/p")
105
106; All use the same flag
107define void @l1() !dbg !20 {
108  ret void
109}
110define void @l2() !dbg !21 {
111  ret void
112}
113
114; All use the same flag
115define void @w1() !dbg !22 {
116  ret void
117}
118define void @w2() !dbg !23 {
119  ret void
120}
121define void @w3() !dbg !24 {
122  ret void
123}
124define void @w4() !dbg !25 {
125  ret void
126}
127
128; Test relative paths
129define void @w5() !dbg !26 {
130  ret void
131}
132define void @w6() !dbg !27 {
133  ret void
134}
135define void @w7() !dbg !28 {
136  ret void
137}
138
139!llvm.dbg.cu = !{!0}
140!llvm.module.flags = !{!17, !18}
141!llvm.ident = !{!19}
142
143!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
144!1 = !DIFile(filename: "a/x.c", directory: "/tmp")
145!2 = !DIFile(filename: "x.c", directory: "/tmp/a")
146!3 = !DIFile(filename: "./x.c", directory: "C:\\\\a\\\\b\\\\")
147!4 = !DIFile(filename: "./b\\x.c", directory: "C:\\\\a\\\\")
148!5 = !DIFile(filename: "./b/x.c", directory: "C:\\\\a\\\\")
149!6 = !DIFile(filename: "./b/./../b/x.c", directory: "C:/a")
150!7 = !DIFile(filename: "./b/.\\../b/x.c", directory: "a\\d/p")
151!8 = !DIFile(filename: "./b/./../b/x.c", directory: "a/d/p")
152!9 = !DIFile(filename: "./b/./../b\\x.c", directory: "a/d/p")
153!17 = !{i32 2, !"CodeView", i32 1}
154!18 = !{i32 2, !"Debug Info Version", i32 3}
155!19 = !{!"clang"}
156!20 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
157!21 = distinct !DISubprogram(name: "f", scope: !2, file: !2, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
158!22 = distinct !DISubprogram(name: "f", scope: !3, file: !3, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
159!23 = distinct !DISubprogram(name: "f", scope: !4, file: !4, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
160!24 = distinct !DISubprogram(name: "f", scope: !5, file: !5, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
161!25 = distinct !DISubprogram(name: "f", scope: !6, file: !6, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
162!26 = distinct !DISubprogram(name: "f", scope: !7, file: !7, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
163!27 = distinct !DISubprogram(name: "f", scope: !8, file: !8, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
164!28 = distinct !DISubprogram(name: "f", scope: !9, file: !9, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
165!31 = !DISubroutineType(types: !32)
166!32 = !{null}
167!33 = !{}
168