2013-02-13 09:14:49 +08:00
; RUN: llc %s -mtriple=x86_64-apple-darwin -filetype=obj -o %t -enable-misched
2017-09-12 07:05:20 +08:00
; RUN: llvm-dwarfdump -v %t | FileCheck %s
2013-02-13 09:14:49 +08:00
; rdar://13183203
; Make sure when misched is enabled, we still have location information for
; function parameters.
; CHECK: .debug_info contents:
; CHECK: DW_TAG_compile_unit
2014-06-14 06:18:23 +08:00
; CHECK: DW_TAG_subprogram
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "Proc8"
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_location
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "Array1Par"
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_location
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "Array2Par"
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_location
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "IntParI1"
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_location
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "IntParI2"
2013-02-13 09:14:49 +08:00
2016-12-22 08:45:21 +08:00
source_filename = "test/DebugInfo/X86/misched-dbg-value.ll"
2013-02-13 09:14:49 +08:00
%struct.Record = type { %struct.Record * , i32 , i32 , i32 , [ 31 x i8 ] }
2016-12-22 08:45:21 +08:00
@Version = global [ 4 x i8 ] c "1.1\00" , align 1 , !dbg !0
@IntGlob = common global i32 0 , align 4 , !dbg !7
@BoolGlob = common global i32 0 , align 4 , !dbg !10
@Char1Glob = common global i8 0 , align 1 , !dbg !13
@Char2Glob = common global i8 0 , align 1 , !dbg !15
@Array1Glob = common global [ 51 x i32 ] zeroinitializer , align 16 , !dbg !17
@Array2Glob = common global [ 51 x [ 51 x i32 ] ] zeroinitializer , align 16 , !dbg !23
@PtrGlb = common global %struct.Record * null , align 8 , !dbg !28
@PtrGlbNext = common global %struct.Record * null , align 8 , !dbg !54
2013-02-13 09:14:49 +08:00
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind optsize
define void @Proc8 ( i32 * nocapture %Array1Par , [ 51 x i32 ] * nocapture %Array2Par , i32 %IntParI1 , i32 %IntParI2 ) #0 !dbg !61 {
2013-02-13 09:14:49 +08:00
entry:
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 * %Array1Par , metadata !67 , metadata !73 ) , !dbg !74
tail call void @llvm.dbg.value ( metadata [ 51 x i32 ] * %Array2Par , metadata !68 , metadata !73 ) , !dbg !75
tail call void @llvm.dbg.value ( metadata i32 %IntParI1 , metadata !69 , metadata !73 ) , !dbg !76
tail call void @llvm.dbg.value ( metadata i32 %IntParI2 , metadata !70 , metadata !73 ) , !dbg !77
2016-12-22 08:45:21 +08:00
%add = add i32 %IntParI1 , 5 , !dbg !78
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 %add , metadata !71 , metadata !73 ) , !dbg !78
2016-12-22 08:45:21 +08:00
%idxprom = sext i32 %add to i64 , !dbg !79
%arrayidx = getelementptr inbounds i32 , i32 * %Array1Par , i64 %idxprom , !dbg !79
store i32 %IntParI2 , i32 * %arrayidx , align 4 , !dbg !79
%add3 = add nsw i32 %IntParI1 , 6 , !dbg !80
%idxprom4 = sext i32 %add3 to i64 , !dbg !80
%arrayidx5 = getelementptr inbounds i32 , i32 * %Array1Par , i64 %idxprom4 , !dbg !80
store i32 %IntParI2 , i32 * %arrayidx5 , align 4 , !dbg !80
%add6 = add nsw i32 %IntParI1 , 35 , !dbg !81
%idxprom7 = sext i32 %add6 to i64 , !dbg !81
%arrayidx8 = getelementptr inbounds i32 , i32 * %Array1Par , i64 %idxprom7 , !dbg !81
store i32 %add , i32 * %arrayidx8 , align 4 , !dbg !81
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 %add , metadata !72 , metadata !73 ) , !dbg !82
2016-12-22 08:45:21 +08:00
br label %for.body , !dbg !82
2013-02-13 09:14:49 +08:00
2016-12-22 08:45:21 +08:00
for.body: ; preds = %for.body, %entry
2013-02-13 09:14:49 +08:00
%indvars.iv = phi i64 [ %idxprom , %entry ] , [ %indvars.iv.next , %for.body ]
%IntIndex.046 = phi i32 [ %add , %entry ] , [ %inc , %for.body ]
2016-12-22 08:45:21 +08:00
%arrayidx13 = getelementptr inbounds [ 51 x i32 ] , [ 51 x i32 ] * %Array2Par , i64 %idxprom , i64 %indvars.iv , !dbg !84
store i32 %add , i32 * %arrayidx13 , align 4 , !dbg !84
%inc = add nsw i32 %IntIndex.046 , 1 , !dbg !82
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 %inc , metadata !72 , metadata !73 ) , !dbg !82
2016-12-22 08:45:21 +08:00
%cmp = icmp sgt i32 %inc , %add3 , !dbg !82
%indvars.iv.next = add i64 %indvars.iv , 1 , !dbg !82
br i1 %cmp , label %for.end , label %for.body , !dbg !82
2013-02-13 09:14:49 +08:00
for.end: ; preds = %for.body
2016-12-22 08:45:21 +08:00
%sub = add nsw i32 %IntParI1 , 4 , !dbg !85
%idxprom14 = sext i32 %sub to i64 , !dbg !85
%arrayidx17 = getelementptr inbounds [ 51 x i32 ] , [ 51 x i32 ] * %Array2Par , i64 %idxprom , i64 %idxprom14 , !dbg !85
%0 = load i32 , i32 * %arrayidx17 , align 4 , !dbg !85
%inc18 = add nsw i32 %0 , 1 , !dbg !85
store i32 %inc18 , i32 * %arrayidx17 , align 4 , !dbg !85
%1 = load i32 , i32 * %arrayidx , align 4 , !dbg !86
%add22 = add nsw i32 %IntParI1 , 25 , !dbg !86
%idxprom23 = sext i32 %add22 to i64 , !dbg !86
%arrayidx25 = getelementptr inbounds [ 51 x i32 ] , [ 51 x i32 ] * %Array2Par , i64 %idxprom23 , i64 %idxprom , !dbg !86
store i32 %1 , i32 * %arrayidx25 , align 4 , !dbg !86
store i32 5 , i32 * @IntGlob , align 4 , !dbg !87
ret void , !dbg !88
2013-02-13 09:14:49 +08:00
}
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind readnone
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata ) #1
2013-02-13 09:14:49 +08:00
2016-12-22 08:45:21 +08:00
attributes #0 = { nounwind optsize }
2013-02-13 09:14:49 +08:00
attributes #1 = { nounwind readnone }
2016-12-22 08:45:21 +08:00
!llvm.dbg.cu = ! { !56 }
!llvm.module.flags = ! { !60 }
2017-08-31 02:06:51 +08:00
!0 = !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!1 = !DIGlobalVariable ( name: "Version" , scope: null , file: !2 , line: 111 , type: !3 , isLocal: false , isDefinition: true )
!2 = !DIFile ( filename: "dry.c" , directory: "/Users/manmanren/test-Nov/rdar_13183203/test2" )
!3 = !DICompositeType ( tag: D W _ T A G _ a r r a y _ type , baseType: !4 , size: 32 , align: 8 , elements: !5 )
!4 = !DIBasicType ( name: "char" , size: 8 , align: 8 , encoding: D W _ A T E _ s i g n e d _ c h a r )
!5 = ! { !6 }
!6 = !DISubrange ( count: 4 ) ; [ DW_TAG_enumerator ] [Ident1 :: 0]
2017-08-31 02:06:51 +08:00
!7 = !DIGlobalVariableExpression ( var: !8 , expr: !DIExpression ( ) ) ; [ DW_TAG_enumerator ] [Ident2 :: 10000]
2016-12-22 08:45:21 +08:00
!8 = !DIGlobalVariable ( name: "IntGlob" , scope: null , file: !2 , line: 171 , type: !9 , isLocal: false , isDefinition: true ) ; [ DW_TAG_enumerator ] [Ident3 :: 10001]
!9 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d ) ; [ DW_TAG_enumerator ] [Ident4 :: 10002]
2017-08-31 02:06:51 +08:00
!10 = !DIGlobalVariableExpression ( var: !11 , expr: !DIExpression ( ) ) ; [ DW_TAG_enumerator ] [Ident5 :: 10003]
2016-12-22 08:45:21 +08:00
!11 = !DIGlobalVariable ( name: "BoolGlob" , scope: null , file: !2 , line: 172 , type: !12 , isLocal: false , isDefinition: true )
!12 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "boolean" , file: !2 , line: 149 , baseType: !9 )
2017-08-31 02:06:51 +08:00
!13 = !DIGlobalVariableExpression ( var: !14 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!14 = !DIGlobalVariable ( name: "Char1Glob" , scope: null , file: !2 , line: 173 , type: !4 , isLocal: false , isDefinition: true )
2017-08-31 02:06:51 +08:00
!15 = !DIGlobalVariableExpression ( var: !16 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!16 = !DIGlobalVariable ( name: "Char2Glob" , scope: null , file: !2 , line: 174 , type: !4 , isLocal: false , isDefinition: true )
2017-08-31 02:06:51 +08:00
!17 = !DIGlobalVariableExpression ( var: !18 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!18 = !DIGlobalVariable ( name: "Array1Glob" , scope: null , file: !2 , line: 175 , type: !19 , isLocal: false , isDefinition: true )
!19 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "Array1Dim" , file: !2 , line: 135 , baseType: !20 )
!20 = !DICompositeType ( tag: D W _ T A G _ a r r a y _ type , baseType: !9 , size: 1632 , align: 32 , elements: !21 )
!21 = ! { !22 }
!22 = !DISubrange ( count: 51 )
2017-08-31 02:06:51 +08:00
!23 = !DIGlobalVariableExpression ( var: !24 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!24 = !DIGlobalVariable ( name: "Array2Glob" , scope: null , file: !2 , line: 176 , type: !25 , isLocal: false , isDefinition: true )
!25 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "Array2Dim" , file: !2 , line: 136 , baseType: !26 )
!26 = !DICompositeType ( tag: D W _ T A G _ a r r a y _ type , baseType: !9 , size: 83232 , align: 32 , elements: !27 )
!27 = ! { !22 , !22 }
2017-08-31 02:06:51 +08:00
!28 = !DIGlobalVariableExpression ( var: !29 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!29 = !DIGlobalVariable ( name: "PtrGlb" , scope: null , file: !2 , line: 177 , type: !30 , isLocal: false , isDefinition: true )
!30 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "RecordPtr" , file: !2 , line: 148 , baseType: !31 )
!31 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !32 , size: 64 , align: 64 )
!32 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "RecordType" , file: !2 , line: 147 , baseType: !33 )
!33 = !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "Record" , file: !2 , line: 138 , size: 448 , align: 64 , elements: !34 )
!34 = ! { !35 , !37 , !46 , !47 , !49 }
!35 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "PtrComp" , scope: !33 , file: !2 , line: 140 , baseType: !36 , size: 64 , align: 64 )
!36 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !33 , size: 64 , align: 64 )
!37 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "Discr" , scope: !33 , file: !2 , line: 141 , baseType: !38 , size: 32 , align: 32 , offset: 64 )
!38 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "Enumeration" , file: !2 , line: 128 , baseType: !39 )
!39 = !DICompositeType ( tag: D W _ T A G _ e n u m e r a t i o n _ type , file: !2 , line: 128 , size: 32 , align: 32 , elements: !40 )
!40 = ! { !41 , !42 , !43 , !44 , !45 }
!41 = !DIEnumerator ( name: "Ident1" , value: 0 )
!42 = !DIEnumerator ( name: "Ident2" , value: 10000 )
!43 = !DIEnumerator ( name: "Ident3" , value: 10001 )
!44 = !DIEnumerator ( name: "Ident4" , value: 10002 )
!45 = !DIEnumerator ( name: "Ident5" , value: 10003 )
!46 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "EnumComp" , scope: !33 , file: !2 , line: 142 , baseType: !38 , size: 32 , align: 32 , offset: 96 )
!47 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "IntComp" , scope: !33 , file: !2 , line: 143 , baseType: !48 , size: 32 , align: 32 , offset: 128 )
!48 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "OneToFifty" , file: !2 , line: 132 , baseType: !9 )
!49 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "StringComp" , scope: !33 , file: !2 , line: 144 , baseType: !50 , size: 248 , align: 8 , offset: 160 )
!50 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "String30" , file: !2 , line: 134 , baseType: !51 )
!51 = !DICompositeType ( tag: D W _ T A G _ a r r a y _ type , baseType: !4 , size: 248 , align: 8 , elements: !52 )
!52 = ! { !53 }
!53 = !DISubrange ( count: 31 )
2017-08-31 02:06:51 +08:00
!54 = !DIGlobalVariableExpression ( var: !55 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!55 = !DIGlobalVariable ( name: "PtrGlbNext" , scope: null , file: !2 , line: 178 , type: !30 , isLocal: false , isDefinition: true )
!56 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !2 , producer: "clang version 3.3 (trunk 175015)" , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !57 , retainedTypes: !58 , globals: !59 , imports: !58 )
!57 = ! { !39 }
!58 = ! { }
!59 = ! { !0 , !7 , !10 , !13 , !15 , !17 , !23 , !28 , !54 }
!60 = ! { i32 1 , !"Debug Info Version" , i32 3 }
[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
!61 = distinct !DISubprogram ( name: "Proc8" , scope: !2 , file: !2 , line: 180 , type: !62 , isLocal: false , isDefinition: true , scopeLine: 185 , virtualIndex: 6 , isOptimized: true , unit: !56 , retainedNodes: !66 )
2016-12-22 08:45:21 +08:00
!62 = !DISubroutineType ( types: !63 )
!63 = ! { null , !64 , !65 , !48 , !48 }
!64 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !9 , size: 64 , align: 64 )
!65 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !20 , size: 64 , align: 64 )
!66 = ! { !67 , !68 , !69 , !70 , !71 , !72 }
!67 = !DILocalVariable ( name: "Array1Par" , arg: 1 , scope: !61 , file: !2 , line: 181 , type: !64 )
!68 = !DILocalVariable ( name: "Array2Par" , arg: 2 , scope: !61 , file: !2 , line: 182 , type: !65 )
!69 = !DILocalVariable ( name: "IntParI1" , arg: 3 , scope: !61 , file: !2 , line: 183 , type: !48 )
!70 = !DILocalVariable ( name: "IntParI2" , arg: 4 , scope: !61 , file: !2 , line: 184 , type: !48 )
!71 = !DILocalVariable ( name: "IntLoc" , scope: !61 , file: !2 , line: 186 , type: !48 )
!72 = !DILocalVariable ( name: "IntIndex" , scope: !61 , file: !2 , line: 187 , type: !48 )
!73 = !DIExpression ( )
!74 = !DILocation ( line: 181 , scope: !61 )
!75 = !DILocation ( line: 182 , scope: !61 )
!76 = !DILocation ( line: 183 , scope: !61 )
!77 = !DILocation ( line: 184 , scope: !61 )
!78 = !DILocation ( line: 189 , scope: !61 )
!79 = !DILocation ( line: 190 , scope: !61 )
!80 = !DILocation ( line: 191 , scope: !61 )
!81 = !DILocation ( line: 192 , scope: !61 )
!82 = !DILocation ( line: 193 , scope: !83 )
!83 = distinct !DILexicalBlock ( scope: !61 , file: !2 , line: 193 )
!84 = !DILocation ( line: 194 , scope: !83 )
!85 = !DILocation ( line: 195 , scope: !61 )
!86 = !DILocation ( line: 196 , scope: !61 )
!87 = !DILocation ( line: 197 , scope: !61 )
!88 = !DILocation ( line: 198 , scope: !61 )
2013-02-13 09:14:49 +08:00