1; RUN: opt -passes="function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument)" -S < %s | FileCheck %s
2
3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-unknown-linux-gnu"
5
6define i32 @f(i32 %x) #0 !dbg !7 {
7entry:
8  %x.addr = alloca i32, align 4
9  store i32 %x, i32* %x.addr, align 4
10  ret i32 42, !dbg !12
11
12; CHECK-LABEL: define i32 @f(i32 %x)
13; CHECK: call i8* @llvm.returnaddress(i32 0), !dbg ![[ENTRYLOC:[0-9]+]]
14; CHECK: call void @__cyg_profile_func_enter{{.*}}, !dbg ![[ENTRYLOC]]
15
16; CHECK: call i8* @llvm.returnaddress(i32 0), !dbg ![[EXITLOC:[0-9]+]]
17; CHECK: call void @__cyg_profile_func_exit{{.*}}, !dbg ![[EXITLOC]]
18; CHECK: ret i32 42, !dbg ![[EXITLOC]]
19}
20
21; CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "f"
22; CHECK: ![[ENTRYLOC]] = !DILocation(line: 2, scope: ![[SP]])
23; CHECK: ![[EXITLOC]] = !DILocation(line: 4, column: 3, scope: ![[SP]])
24
25attributes #0 = { "instrument-function-entry"="__cyg_profile_func_enter" "instrument-function-exit"="__cyg_profile_func_exit" }
26
27!llvm.dbg.cu = !{!0}
28!llvm.module.flags = !{!3, !4, !5}
29!llvm.ident = !{!6}
30
31!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 (trunk 319007) (llvm/trunk 319050)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
32!1 = !DIFile(filename: "a.c", directory: "/tmp")
33!2 = !{}
34!3 = !{i32 2, !"Dwarf Version", i32 4}
35!4 = !{i32 2, !"Debug Info Version", i32 3}
36!5 = !{i32 1, !"wchar_size", i32 4}
37!6 = !{!"clang version 6.0.0 (trunk 319007) (llvm/trunk 319050)"}
38!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
39!8 = !DISubroutineType(types: !9)
40!9 = !{!10, !10}
41!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
42!11 = !DILocalVariable(name: "x", arg: 1, scope: !7, file: !1, line: 2, type: !10)
43!12 = !DILocation(line: 4, column: 3, scope: !7)
44