277 lines · plain
1# RUN: llc -o - %s -start-after=patchable-function -filetype=obj -O0 -mtriple=i386-unknown-linux-gnu -dwarf-version=4 | llvm-dwarfdump -v - | FileCheck %s2 3# From the code:4#5# debug-loc-offset1.cc6# int bar (int b) {7# return b+4;8# }9#10# debug-loc-offset2.cc11# struct A {12# int var;13# virtual char foo();14# };15#16# void baz(struct A a) {17# int z = 2;18# if (a.var > 2)19# z++;20# if (a.foo() == 'a')21# z++;22# }23#24# Compiled separately for i386-pc-linux-gnu and linked together.25# This ensures that we have multiple compile units and multiple location lists26# so that we can verify that27# debug_loc entries are relative to the low_pc of the CU. The loc entry for28# the byval argument in foo.cpp is in the second CU and so should have29# an offset relative to that CU rather than from the beginning of the text30# section.31#32# Checking that we have two compile units with two sets of high/lo_pc.33# CHECK: .debug_info contents34# CHECK: DW_TAG_compile_unit35# CHECK: DW_AT_low_pc {{.*}} (0x00000020 ".text")36# CHECK: DW_AT_high_pc37#38# CHECK: DW_TAG_subprogram39# CHECK-NOT: DW_TAG40# CHECK: DW_AT_linkage_name [DW_FORM_strp]{{.*}}"_Z3baz1A"41# CHECK-NOT: {{DW_TAG|NULL}}42# CHECK: DW_TAG_formal_parameter43# CHECK-NOT: DW_TAG44# CHECK: DW_AT_location [DW_FORM_sec_offset] ({{.*}}45# CHECK-NEXT: [0x00000029, 0x00000037) ".text": DW_OP_breg0 EAX+0, DW_OP_deref46# CHECK-NEXT: [0x00000037, 0x00000063) ".text": DW_OP_breg5 EBP-8, DW_OP_deref, DW_OP_deref47# CHECK-NEXT: DW_AT_name [DW_FORM_strp]{{.*}}"a"48#49# CHECK: DW_TAG_variable50# CHECK: DW_AT_location [DW_FORM_exprloc]51# CHECK-NOT: DW_AT_location52#53# CHECK: DW_TAG_compile_unit54# CHECK: DW_AT_low_pc {{.*}} (0x00000000 ".text")55# CHECK: DW_AT_high_pc56#57# CHECK: DW_TAG_subprogram58# CHECK-NOT: DW_TAG59# CHECK: DW_AT_linkage_name [DW_FORM_strp]{{.*}}"_Z3bari"60# CHECK-NOT: {{DW_TAG|NULL}}61# CHECK: DW_TAG_formal_parameter62# CHECK-NOT: DW_TAG63# CHECK: DW_AT_location [DW_FORM_sec_offset] ({{.*}}64# CHECK-NEXT: [0x00000000, 0x0000000a) ".text": DW_OP_consts +0, DW_OP_stack_value65# CHECK-NEXT: [0x0000000a, 0x00000017) ".text": DW_OP_consts +1, DW_OP_stack_value)66# CHECK-NEXT: DW_AT_name [DW_FORM_strp]{{.*}}"b"67#68# CHECK: .debug_loc contents:69# CHECK: 0x00000000:70# CHECK-NEXT: (0x00000000, 0x0000000a): DW_OP_consts +0, DW_OP_stack_value71# CHECK-NEXT: (0x0000000a, 0x00000017): DW_OP_consts +1, DW_OP_stack_value72# CHECK: 0x00000022:73# CHECK-NEXT: (0x00000009, 0x00000017): DW_OP_breg0 EAX+0, DW_OP_deref74# CHECK-NEXT: (0x00000017, 0x00000043): DW_OP_breg5 EBP-8, DW_OP_deref, DW_OP_deref75--- |76 target triple = "i386-unknown-linux-gnu"77 78 %struct.A = type { ptr, i32 }79 80 ; Function Attrs: nounwind81 define i32 @_Z3bari(i32 %b) #0 !dbg !10 {82 entry:83 %b.addr = alloca i32, align 484 store i32 %b, ptr %b.addr, align 485 call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression()), !dbg !1586 %0 = load i32, ptr %b.addr, align 4, !dbg !1687 call void @llvm.dbg.value(metadata i32 1, metadata !14, metadata !DIExpression()), !dbg !1588 %add = add nsw i32 %0, 4, !dbg !1689 ret i32 %add, !dbg !1690 }91 92 ; Function Attrs: nounwind readnone speculatable93 declare void @llvm.dbg.declare(metadata, metadata, metadata) #194 95 ; Function Attrs: nounwind readnone speculatable96 declare void @llvm.dbg.value(metadata, metadata, metadata) #197 98 define void @_Z3baz1A(ptr %a) #2 !dbg !17 {99 entry:100 %z = alloca i32, align 4101 call void @llvm.dbg.declare(metadata ptr %a, metadata !20, metadata !DIExpression(DW_OP_deref)), !dbg !21102 call void @llvm.dbg.declare(metadata ptr %z, metadata !22, metadata !DIExpression()), !dbg !23103 store i32 2, ptr %z, align 4, !dbg !23104 %var = getelementptr inbounds %struct.A, ptr %a, i32 0, i32 1, !dbg !24105 %0 = load i32, ptr %var, align 4, !dbg !24106 %cmp = icmp sgt i32 %0, 2, !dbg !24107 br i1 %cmp, label %if.then, label %if.end, !dbg !24108 109 if.then: ; preds = %entry110 %1 = load i32, ptr %z, align 4, !dbg !26111 %inc = add nsw i32 %1, 1, !dbg !26112 store i32 %inc, ptr %z, align 4, !dbg !26113 br label %if.end, !dbg !26114 115 if.end: ; preds = %if.then, %entry116 %call = call signext i8 @_ZN1A3fooEv(ptr %a), !dbg !27117 %conv = sext i8 %call to i32, !dbg !27118 %cmp1 = icmp eq i32 %conv, 97, !dbg !27119 br i1 %cmp1, label %if.then2, label %if.end4, !dbg !27120 121 if.then2: ; preds = %if.end122 %2 = load i32, ptr %z, align 4, !dbg !29123 %inc3 = add nsw i32 %2, 1, !dbg !29124 store i32 %inc3, ptr %z, align 4, !dbg !29125 br label %if.end4, !dbg !29126 127 if.end4: ; preds = %if.then2, %if.end128 ret void, !dbg !30129 }130 131 declare signext i8 @_ZN1A3fooEv(ptr) #2132 133 ; Function Attrs: nounwind134 declare void @llvm.stackprotector(ptr, ptr) #3135 136 attributes #0 = { nounwind "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }137 attributes #1 = { nounwind readnone speculatable }138 attributes #2 = { "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }139 attributes #3 = { nounwind }140 141 !llvm.dbg.cu = !{!0, !3}142 !llvm.module.flags = !{!7, !8}143 !llvm.ident = !{!9, !9}144 145 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.5.0 (210479)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)146 !1 = !DIFile(filename: "debug-loc-offset1.cc", directory: "/llvm_cmake_gcc")147 !2 = !{}148 !3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "clang version 3.5.0 (210479)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !5, globals: !2, imports: !2)149 !4 = !DIFile(filename: "debug-loc-offset2.cc", directory: "/llvm_cmake_gcc")150 !5 = !{!6}151 !6 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !4, line: 1, flags: DIFlagFwdDecl, identifier: "_ZTS1A")152 !7 = !{i32 2, !"Dwarf Version", i32 4}153 !8 = !{i32 2, !"Debug Info Version", i32 3}154 !9 = !{!"clang version 3.5.0 (210479)"}155 !10 = distinct !DISubprogram(name: "bar", linkageName: "_Z3bari", scope: !1, file: !1, line: 1, type: !11, isLocal: false, isDefinition: true, scopeLine: 1, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)156 !11 = !DISubroutineType(types: !12)157 !12 = !{!13, !13}158 !13 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)159 !14 = !DILocalVariable(name: "b", arg: 1, scope: !10, file: !1, line: 1, type: !13)160 !15 = !DILocation(line: 1, scope: !10)161 !16 = !DILocation(line: 2, scope: !10)162 !17 = distinct !DISubprogram(name: "baz", linkageName: "_Z3baz1A", scope: !4, file: !4, line: 6, type: !18, isLocal: false, isDefinition: true, scopeLine: 6, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !3, retainedNodes: !2)163 !18 = !DISubroutineType(types: !19)164 !19 = !{null, !6}165 !20 = !DILocalVariable(name: "a", arg: 1, scope: !17, file: !4, line: 6, type: !6)166 !21 = !DILocation(line: 6, scope: !17)167 !22 = !DILocalVariable(name: "z", scope: !17, file: !4, line: 7, type: !13)168 !23 = !DILocation(line: 7, scope: !17)169 !24 = !DILocation(line: 8, scope: !25)170 !25 = distinct !DILexicalBlock(scope: !17, file: !4, line: 8)171 !26 = !DILocation(line: 9, scope: !25)172 !27 = !DILocation(line: 10, scope: !28)173 !28 = distinct !DILexicalBlock(scope: !17, file: !4, line: 10)174 !29 = !DILocation(line: 11, scope: !28)175 !30 = !DILocation(line: 12, scope: !17)176 177...178---179name: _Z3bari180alignment: 16181tracksRegLiveness: true182frameInfo: 183 stackSize: 8184 offsetAdjustment: -4185 maxAlignment: 4186 maxCallFrameSize: 0187fixedStack: 188 - { id: 0, type: spill-slot, offset: -8, size: 4, alignment: 8, stack-id: default }189 - { id: 1, size: 4, alignment: 16, stack-id: default }190stack: 191 - { id: 0, type: spill-slot, offset: -12, size: 4, alignment: 4, stack-id: default }192body: |193 bb.0.entry:194 frame-setup PUSH32r killed $ebp, implicit-def $esp, implicit $esp195 CFI_INSTRUCTION def_cfa_offset 8196 CFI_INSTRUCTION offset $ebp, -8197 $ebp = frame-setup MOV32rr $esp198 CFI_INSTRUCTION def_cfa_register $ebp199 frame-setup PUSH32r undef $eax, implicit-def $esp, implicit $esp200 renamable $eax = MOV32rm $ebp, 1, $noreg, 8, $noreg :: (load (s32) from %fixed-stack.1)201 DBG_VALUE 0, 0, !14, !DIExpression(), debug-location !15202 renamable $ecx = MOV32rm $ebp, 1, $noreg, 8, $noreg, debug-location !16 :: (load (s32) from %ir.b.addr)203 DBG_VALUE 1, 0, !14, !DIExpression(), debug-location !15204 renamable $ecx = ADD32ri8 renamable $ecx, 4, implicit-def $eflags, debug-location !16205 MOV32mr $ebp, 1, $noreg, -4, $noreg, killed $eax :: (store (s32) into %fixed-stack.1)206 $eax = MOV32rr killed $ecx, debug-location !16207 $esp = frame-destroy ADD32ri8 $esp, 4, implicit-def dead $eflags, debug-location !16208 $ebp = frame-destroy POP32r implicit-def $esp, implicit $esp, debug-location !16209 CFI_INSTRUCTION def_cfa $esp, 4, debug-location !16210 RET32 implicit killed $eax, debug-location !16211 212...213---214name: _Z3baz1A215alignment: 16216tracksRegLiveness: true217frameInfo: 218 stackSize: 28219 offsetAdjustment: -24220 maxAlignment: 4221 adjustsStack: true222 hasCalls: true223 maxCallFrameSize: 4224fixedStack: 225 - { id: 0, type: spill-slot, offset: -8, size: 4, alignment: 8, stack-id: default }226 - { id: 1, size: 4, alignment: 16, stack-id: default, isImmutable: true }227stack: 228 - { id: 0, name: z, offset: -12, size: 4, alignment: 4, stack-id: default,229 debug-info-variable: '!22', debug-info-expression: '!DIExpression()', 230 debug-info-location: '!23' }231 - { id: 1, type: spill-slot, offset: -16, size: 4, alignment: 4, stack-id: default }232body: |233 bb.0.entry:234 frame-setup PUSH32r killed $ebp, implicit-def $esp, implicit $esp235 CFI_INSTRUCTION def_cfa_offset 8236 CFI_INSTRUCTION offset $ebp, -8237 $ebp = frame-setup MOV32rr $esp238 CFI_INSTRUCTION def_cfa_register $ebp239 $esp = frame-setup SUB32ri8 $esp, 24, implicit-def dead $eflags240 renamable $eax = MOV32rm $ebp, 1, $noreg, 8, $noreg :: (load (s32) from %fixed-stack.1)241 DBG_VALUE renamable $eax, 0, !20, !DIExpression(DW_OP_deref), debug-location !21242 MOV32mi $ebp, 1, $noreg, -4, $noreg, 2, debug-location !23 :: (store (s32) into %ir.z)243 CMP32mi renamable $eax, 1, $noreg, 4, $noreg, 2, implicit-def $eflags, debug-location !24 :: (load (s32) from %ir.var)244 MOV32mr $ebp, 1, $noreg, -8, $noreg, killed $eax :: (store (s32) into %stack.1)245 DBG_VALUE $ebp, 0, !20, !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_deref), debug-location !21246 JCC_1 %bb.2, 14, implicit $eflags, debug-location !24247 248 bb.1.if.then:249 DBG_VALUE $ebp, 0, !20, !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_deref), debug-location !21250 renamable $eax = MOV32rm $ebp, 1, $noreg, -4, $noreg, debug-location !26 :: (load (s32) from %ir.z)251 renamable $eax = ADD32ri8 renamable $eax, 1, implicit-def $eflags, debug-location !26252 MOV32mr $ebp, 1, $noreg, -4, $noreg, killed renamable $eax, debug-location !26 :: (store (s32) into %ir.z)253 254 bb.2.if.end:255 DBG_VALUE $ebp, 0, !20, !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_deref), debug-location !21256 $eax = MOV32rm $ebp, 1, $noreg, -8, $noreg :: (load (s32) from %stack.1)257 MOV32mr $esp, 1, $noreg, 0, $noreg, killed renamable $eax, debug-location !27 :: (store (s32) into stack)258 CALLpcrel32 @_ZN1A3fooEv, csr_32, implicit $esp, implicit $ssp, implicit-def $al, debug-location !27259 renamable $ecx = MOVSX32rr8 killed renamable $al, debug-location !27260 CMP32ri8 killed renamable $ecx, 97, implicit-def $eflags, debug-location !27261 JCC_1 %bb.4, 5, implicit $eflags, debug-location !27262 263 bb.3.if.then2:264 DBG_VALUE $ebp, 0, !20, !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_deref), debug-location !21265 renamable $eax = MOV32rm $ebp, 1, $noreg, -4, $noreg, debug-location !29 :: (load (s32) from %ir.z)266 renamable $eax = ADD32ri8 renamable $eax, 1, implicit-def $eflags, debug-location !29267 MOV32mr $ebp, 1, $noreg, -4, $noreg, killed renamable $eax, debug-location !29 :: (store (s32) into %ir.z)268 269 bb.4.if.end4:270 DBG_VALUE $ebp, 0, !20, !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_deref), debug-location !21271 $esp = frame-destroy ADD32ri8 $esp, 24, implicit-def dead $eflags, debug-location !30272 $ebp = frame-destroy POP32r implicit-def $esp, implicit $esp, debug-location !30273 CFI_INSTRUCTION def_cfa $esp, 4, debug-location !30274 RET32 debug-location !30275 276...277