2017-11-01 20:26:47 +00:00
; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=new-pm-pgo-sample-use-pipeline -profile-file=%S/Inputs/function_metadata.prof -S | FileCheck %s
2017-02-28 18:09:44 +00:00
; Tests whether the functions in the inline stack are added to the
; function_entry_count metadata.
declare void @foo ( )
2017-11-01 20:26:47 +00:00
define void @foo_available ( ) !dbg !11 {
ret void
}
; CHECK: define void @test({{.*}} !prof ![[ENTRY_TEST:[0-9]+]]
2017-09-19 21:18:14 +00:00
define void @test ( void ( ) * ) !dbg !7 {
%2 = alloca void ( ) *
store void ( ) * %0 , void ( ) * * %2
%3 = load void ( ) * , void ( ) * * %2
; CHECK: call {{.*}}, !prof ![[PROF:[0-9]+]]
2017-02-28 18:09:44 +00:00
call void @foo ( ) , !dbg !18
2017-09-19 21:18:14 +00:00
call void %3 ( ) , !dbg !19
2017-02-28 18:09:44 +00:00
ret void
}
2017-11-01 20:26:47 +00:00
; CHECK: define void @test_liveness({{.*}} !prof ![[ENTRY_TEST_LIVENESS:[0-9]+]]
define void @test_liveness ( ) !dbg !12 {
call void @foo ( ) , !dbg !20
ret void
}
2017-10-01 05:24:51 +00:00
; GUIDs of foo, bar, foo1, foo2 and foo3 should be included in the metadata to
2018-08-07 18:13:10 +00:00
; make sure hot inline stacks are imported. The total count of baz is lower
; than the hot cutoff threshold and its GUID should not be included in the
; metadata.
; CHECK: ![[ENTRY_TEST]] = !{!"function_entry_count", i64 1, i64 2494702099028631698, i64 6699318081062747564, i64 7682762345278052905, i64 -7908226060800700466, i64 -2012135647395072713}
2017-11-01 20:26:47 +00:00
; Check GUIDs for both foo and foo_available are included in the metadata to
; make sure the liveness analysis can capture the dependency from test_liveness
; to foo_available.
; CHECK: ![[ENTRY_TEST_LIVENESS]] = !{!"function_entry_count", i64 1, i64 4005816710939881937, i64 6699318081062747564}
2017-02-28 18:09:44 +00:00
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !8 , !9 }
!llvm.ident = ! { !10 }
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , producer: "clang version 3.5 " , isOptimized: false , emissionKind: N o D e b u g , file: !1 , enums: !2 , retainedTypes: !2 , globals: !2 , imports: !2 )
!1 = !DIFile ( filename: "calls.cc" , directory: "." )
!2 = ! { }
!6 = !DISubroutineType ( types: !2 )
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 02:40:45 +00:00
!7 = distinct !DISubprogram ( name: "test" , line: 7 , isLocal: false , isDefinition: true , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , scopeLine: 7 , file: !1 , scope: !1 , type: !6 , retainedNodes: !2 )
2017-02-28 18:09:44 +00:00
!8 = ! { i32 2 , !"Dwarf Version" , i32 4 }
!9 = ! { i32 1 , !"Debug Info Version" , i32 3 }
!10 = ! { !"clang version 3.5 " }
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 02:40:45 +00:00
!11 = distinct !DISubprogram ( name: "foo_available" , line: 7 , isLocal: false , isDefinition: true , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , scopeLine: 7 , file: !1 , scope: !1 , type: !6 , retainedNodes: !2 )
!12 = distinct !DISubprogram ( name: "test_liveness" , line: 7 , isLocal: false , isDefinition: true , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , scopeLine: 7 , file: !1 , scope: !1 , type: !6 , retainedNodes: !2 )
2017-02-28 18:09:44 +00:00
!15 = !DILexicalBlockFile ( discriminator: 1 , file: !1 , scope: !7 )
!17 = distinct !DILexicalBlock ( line: 10 , column: 0 , file: !1 , scope: !7 )
!18 = !DILocation ( line: 10 , scope: !17 )
2017-09-19 21:18:14 +00:00
!19 = !DILocation ( line: 11 , scope: !17 )
2017-11-01 20:26:47 +00:00
!20 = !DILocation ( line: 8 , scope: !12 )