2017-01-28 19:22:05 +08:00
; RUN: opt -S -strip-debug < %s | FileCheck %s
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.12.0"
; CHECK-LABEL: _Z5test1v
; CHECK-NOT: br {{.*}} !llvm.loop
define void @_Z5test1v ( ) !dbg !7 {
entry:
br label %while.body , !dbg !9
while.body:
call void @_Z3barv ( ) , !dbg !10
br label %while.body , !dbg !11 , !llvm.loop !13
return:
ret void , !dbg !14
}
declare void @_Z3barv ( )
2017-04-01 01:51:12 +08:00
declare i1 @_Z3bazv ( )
2017-01-28 19:22:05 +08:00
; CHECK-LABEL: _Z5test2v
; CHECK: br {{.*}} !llvm.loop [[LOOP:![0-9]+]]
define void @_Z5test2v ( ) !dbg !15 {
entry:
br label %while.body , !dbg !16
while.body:
call void @_Z3barv ( ) , !dbg !17
br label %while.body , !dbg !18 , !llvm.loop !19
return:
ret void , !dbg !21
}
2017-03-19 21:54:57 +08:00
; CHECK-LABEL: _Z5test3v
define void @_Z5test3v ( ) !dbg !22 {
entry:
br label %while.body , !dbg !23
while.body:
2017-04-01 01:51:12 +08:00
%c = call i1 @_Z3bazv ( )
br i1 %c , label %if , label %then
if:
2017-03-19 21:54:57 +08:00
call void @_Z3barv ( ) , !dbg !24
2017-04-01 01:51:12 +08:00
; CHECK: br {{.*}} !llvm.loop [[LOOP2:![0-9]+]]
br label %while.body , !dbg !25 , !llvm.loop !26
then:
; CHECK: br {{.*}} !llvm.loop [[LOOP2]]
2017-03-19 21:54:57 +08:00
br label %while.body , !dbg !25 , !llvm.loop !26
return:
ret void , !dbg !28
}
; CHECK-LABEL: _Z5test4v
; CHECK-NOT: br {{.*}} !llvm.loop
define void @_Z5test4v ( ) !dbg !30 {
entry:
br label %while.body , !dbg !31
while.body:
call void @_Z3barv ( ) , !dbg !32
br label %while.body , !dbg !33 , !llvm.loop !34
return:
ret void , !dbg !36
}
2017-01-28 19:22:05 +08:00
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !3 , !4 , !5 }
!llvm.ident = ! { !6 }
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !1 , producer: "clang version 4.0.0" , isOptimized: false , runtimeVersion: 0 , emissionKind: L i n e T a b l e s O n l y , enums: !2 )
!1 = !DIFile ( filename: "test.cpp" , directory: "/tmp" )
!2 = ! { }
!3 = ! { i32 2 , !"Dwarf Version" , i32 4 }
!4 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!5 = ! { i32 1 , !"PIC Level" , i32 2 }
!6 = ! { !"clang version 4.0.0" }
[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 10:40:45 +08:00
!7 = distinct !DISubprogram ( name: "test1" , scope: !1 , file: !1 , line: 3 , type: !8 , isLocal: false , isDefinition: true , scopeLine: 3 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , retainedNodes: !2 )
2017-01-28 19:22:05 +08:00
!8 = !DISubroutineType ( types: !2 )
!9 = !DILocation ( line: 4 , column: 3 , scope: !7 )
!10 = !DILocation ( line: 5 , column: 5 , scope: !7 )
!11 = !DILocation ( line: 4 , column: 3 , scope: !12 )
!12 = !DILexicalBlockFile ( scope: !7 , file: !1 , discriminator: 1 )
!13 = distinct ! { !13 , !9 }
!14 = !DILocation ( line: 6 , column: 1 , scope: !7 )
[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 10:40:45 +08:00
!15 = distinct !DISubprogram ( name: "test2" , scope: !1 , file: !1 , line: 8 , type: !8 , isLocal: false , isDefinition: true , scopeLine: 8 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , retainedNodes: !2 )
2017-01-28 19:22:05 +08:00
!16 = !DILocation ( line: 8 , column: 14 , scope: !15 )
!17 = !DILocation ( line: 11 , column: 5 , scope: !15 )
!18 = !DILocation ( line: 10 , column: 3 , scope: !15 )
!19 = distinct ! { !19 , !16 , !20 }
!20 = ! { !"llvm.loop.unroll.enable" }
!21 = !DILocation ( line: 12 , column: 1 , scope: !15 )
[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 10:40:45 +08:00
!22 = distinct !DISubprogram ( name: "test3" , scope: !1 , file: !1 , line: 8 , type: !8 , isLocal: false , isDefinition: true , scopeLine: 8 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , retainedNodes: !2 )
2017-03-19 21:54:57 +08:00
!23 = !DILocation ( line: 8 , column: 14 , scope: !22 )
!24 = !DILocation ( line: 11 , column: 5 , scope: !22 )
!25 = !DILocation ( line: 10 , column: 3 , scope: !22 )
!26 = distinct ! { !26 , !23 , !29 , !27 }
!27 = ! { !"llvm.loop.unroll.enable" }
!28 = !DILocation ( line: 12 , column: 1 , scope: !22 )
!29 = !DILocation ( line: 12 , column: 1 , scope: !22 )
[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 10:40:45 +08:00
!30 = distinct !DISubprogram ( name: "test4" , scope: !1 , file: !1 , line: 8 , type: !8 , isLocal: false , isDefinition: true , scopeLine: 8 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , retainedNodes: !2 )
2017-03-19 21:54:57 +08:00
!31 = !DILocation ( line: 8 , column: 14 , scope: !30 )
!32 = !DILocation ( line: 11 , column: 5 , scope: !30 )
!33 = !DILocation ( line: 10 , column: 3 , scope: !30 )
!34 = distinct ! { !34 , !31 , !35 }
!35 = !DILocation ( line: 12 , column: 1 , scope: !30 )
!36 = !DILocation ( line: 12 , column: 1 , scope: !30 )
2017-01-28 19:22:05 +08:00
; CHECK-NOT: !DICompileUnit
; CHECK-NOT: !DIFile
; CHECK-NOT: !DISubprogram
; CHECK-NOT: !DISubroutineType
; CHECK-NOT: !DILocation
; CHECK-NOT: !DILexicalBlockFile
; CHECK: [[LOOP]] = distinct !{[[LOOP]], [[LOOP_UNROLL:![0-9]+]]}
; CHECK-NEXT: [[LOOP_UNROLL]] = !{!"llvm.loop.unroll.enable"}
2017-03-19 21:54:57 +08:00
; CHECK: [[LOOP2]] = distinct !{[[LOOP2]], [[LOOP_UNROLL]]}
2017-01-28 19:22:05 +08:00
; CHECK-NOT: !DILocation