205 lines · plain
1# RUN: llc -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s2#3# CHECK: DW_TAG_GNU_call_site4# CHECK-NEXT: DW_AT_abstract_origin {{.*}} "foo"5# CHECK-NEXT: DW_AT_low_pc6# CHECK-EMPTY:7# CHECK-NEXT: DW_TAG_GNU_call_site_parameter8# CHECK-NEXT: DW_AT_location (DW_OP_reg2 RCX)9# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg14 R14+0)10# CHECK-EMPTY: 11# CHECK-NEXT: DW_TAG_GNU_call_site_parameter12# CHECK-NEXT: DW_AT_location (DW_OP_reg1 RDX)13# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8)14# CHECK-EMPTY: 15# CHECK-NEXT: DW_TAG_GNU_call_site_parameter16# CHECK-NEXT: DW_AT_location (DW_OP_reg4 RSI)17# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg4 RSI))18# CHECK-EMPTY: 19# CHECK-NEXT: DW_TAG_GNU_call_site_parameter20# CHECK-NEXT: DW_AT_location (DW_OP_reg5 RDI)21# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg4 RSI))22# CHECK-EMPTY:23# CHECK: DW_TAG_GNU_call_site24# CHECK-NEXT: DW_AT_abstract_origin {{.*}}"foo"25# CHECK-NEXT: DW_AT_low_pc26# CHECK-EMPTY:27# CHECK-NEXT: DW_TAG_GNU_call_site_parameter28# RCX loads memory location. We can't rely that memory location won't be changed.29# CHECK-NOT: DW_AT_location (DW_OP_reg2 RCX)30# CHECK-NEXT: DW_AT_location (DW_OP_reg4 RSI)31# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit4)32# CHECK-EMPTY:33# CHECK-NOT: DW_TAG_GNU_call_site_parameter34#35# Check that call site interpretation analysis can interpret instructions such36# as move immediate, register to register moves, stack loading and LEA37# instructions. Last negative check should verify that we are not producing38# interpretation for RDX register since its loaded value is call clobberable.39# Also check that we are generating proper call site debug entities.40--- |41 ; ModuleID = 'dbgcall-site-interpretation.c'42 source_filename = "dbgcall-site-interpretation.c"43 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"44 target triple = "x86_64-unknown-linux-gnu"45 46 ; Function Attrs: nounwind uwtable47 define dso_local i32 @baa(i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4) local_unnamed_addr !dbg !9 {48 entry:49 %arg3.addr = alloca i32, align 450 %local2 = alloca i32, align 451 call void @llvm.dbg.value(metadata i32 %arg1, metadata !14, metadata !DIExpression()), !dbg !2152 call void @llvm.dbg.value(metadata i32 %arg2, metadata !15, metadata !DIExpression()), !dbg !2153 call void @llvm.dbg.value(metadata i32 %arg3, metadata !16, metadata !DIExpression()), !dbg !2154 store i32 %arg3, ptr %arg3.addr, align 455 call void @llvm.dbg.value(metadata i32 %arg4, metadata !17, metadata !DIExpression()), !dbg !2156 %0 = bitcast ptr %local2 to ptr, !dbg !2157 call void @llvm.dbg.value(metadata ptr %arg3.addr, metadata !16, metadata !DIExpression(DW_OP_deref)), !dbg !2158 %call = call i32 @foo(i32 %arg1, i32 %arg2, ptr nonnull %arg3.addr, i32 %arg4), !dbg !2159 call void @llvm.dbg.value(metadata i32 %call, metadata !18, metadata !DIExpression()), !dbg !2160 %cmp = icmp sgt i32 %arg1, %arg2, !dbg !2161 %1 = load i32, ptr %arg3.addr, align 4, !dbg !2162 call void @llvm.dbg.value(metadata i32 %1, metadata !16, metadata !DIExpression()), !dbg !2163 %add = add nsw i32 %1, %arg1, !dbg !2164 %add1 = add nsw i32 %arg4, %arg2, !dbg !2165 %local1.0 = select i1 %cmp, i32 %add, i32 %add1, !dbg !2166 call void @llvm.dbg.value(metadata i32 %local1.0, metadata !18, metadata !DIExpression()), !dbg !2167 %rem = srem i32 %1, %arg1, !dbg !2168 %tobool = icmp eq i32 %rem, 0, !dbg !2169 %mul = mul nsw i32 %1, %arg1, !dbg !2170 %add3 = add nsw i32 %1, %arg4, !dbg !2171 %storemerge = select i1 %tobool, i32 %mul, i32 %add3, !dbg !2172 call void @llvm.dbg.value(metadata i32 %storemerge, metadata !19, metadata !DIExpression()), !dbg !2173 store i32 %storemerge, ptr %local2, align 4, !dbg !2174 %cmp6 = icmp slt i32 %storemerge, %arg4, !dbg !2175 %local3.0.v = select i1 %cmp6, i32 %local1.0, i32 %arg1, !dbg !2176 %local3.0 = mul nsw i32 %local3.0.v, %storemerge, !dbg !2177 call void @llvm.dbg.value(metadata i32 %local3.0, metadata !20, metadata !DIExpression()), !dbg !2178 call void @llvm.dbg.value(metadata ptr %local2, metadata !19, metadata !DIExpression(DW_OP_deref)), !dbg !2179 %call12 = call i32 @foo(i32 %local1.0, i32 4, ptr nonnull %local2, i32 %local3.0), !dbg !2180 call void @llvm.dbg.value(metadata i32 %call12, metadata !14, metadata !DIExpression()), !dbg !2181 %add13 = add nsw i32 %call12, 4, !dbg !2182 ret i32 %add13, !dbg !2183 }84 85 declare !dbg !4 dso_local i32 @foo(i32, i32, ptr, i32) local_unnamed_addr86 87 ; Function Attrs: nounwind readnone speculatable88 declare void @llvm.dbg.value(metadata, metadata, metadata)89 90 !llvm.dbg.cu = !{!0}91 !llvm.module.flags = !{!5, !6, !7}92 !llvm.ident = !{!8}93 94 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)95 !1 = !DIFile(filename: "dbgcall-site-interpretation.c", directory: "/dir")96 !2 = !{}97 !3 = !{!4}98 !4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 9, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)99 !5 = !{i32 2, !"Dwarf Version", i32 4}100 !6 = !{i32 2, !"Debug Info Version", i32 3}101 !7 = !{i32 1, !"wchar_size", i32 4}102 !8 = !{!"clang version 9.0.0"}103 !9 = distinct !DISubprogram(name: "baa", scope: !1, file: !1, line: 10, type: !10, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)104 !10 = !DISubroutineType(types: !11)105 !11 = !{!12, !12, !12, !12, !12}106 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)107 !13 = !{!14, !15, !16, !17, !18, !19, !20}108 !14 = !DILocalVariable(name: "arg1", arg: 1, scope: !9, file: !1, line: 10, type: !12)109 !15 = !DILocalVariable(name: "arg2", arg: 2, scope: !9, file: !1, line: 10, type: !12)110 !16 = !DILocalVariable(name: "arg3", arg: 3, scope: !9, file: !1, line: 10, type: !12)111 !17 = !DILocalVariable(name: "arg4", arg: 4, scope: !9, file: !1, line: 10, type: !12)112 !18 = !DILocalVariable(name: "local1", scope: !9, file: !1, line: 11, type: !12)113 !19 = !DILocalVariable(name: "local2", scope: !9, file: !1, line: 11, type: !12)114 !20 = !DILocalVariable(name: "local3", scope: !9, file: !1, line: 11, type: !12)115 !21 = !DILocation(line: 10, column: 13, scope: !9)116 117...118---119name: baa120liveins: 121 - { reg: '$edi', virtual-reg: '' }122 - { reg: '$esi', virtual-reg: '' }123 - { reg: '$edx', virtual-reg: '' }124 - { reg: '$ecx', virtual-reg: '' }125callSites: 126 - { bb: 0, offset: 23, fwdArgRegs: 127 - { arg: 0, reg: '$edi' }128 - { arg: 1, reg: '$esi' }129 - { arg: 2, reg: '$rdx' }130 - { arg: 3, reg: '$ecx' } }131 - { bb: 0, offset: 49, fwdArgRegs: 132 - { arg: 0, reg: '$edi' }133 - { arg: 1, reg: '$esi' }134 - { arg: 2, reg: '$rdx' }135 - { arg: 3, reg: '$ecx' } }136body: |137 bb.0.entry:138 liveins: $ecx, $edi, $edx, $esi, $r15, $r14, $rbx139 140 DBG_VALUE $edi, $noreg, !14, !DIExpression(), debug-location !21141 DBG_VALUE $esi, $noreg, !15, !DIExpression(), debug-location !21142 DBG_VALUE $edx, $noreg, !16, !DIExpression(), debug-location !21143 DBG_VALUE $ecx, $noreg, !17, !DIExpression(), debug-location !21144 frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp145 CFI_INSTRUCTION def_cfa_offset 16146 frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp147 CFI_INSTRUCTION def_cfa_offset 24148 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp149 CFI_INSTRUCTION def_cfa_offset 32150 $rsp = frame-setup SUB64ri8 $rsp, 16, implicit-def dead $eflags151 CFI_INSTRUCTION def_cfa_offset 48152 CFI_INSTRUCTION offset $rbx, -32153 CFI_INSTRUCTION offset $r14, -24154 CFI_INSTRUCTION offset $r15, -16155 $r14d = MOV32rr $ecx, implicit-def $r14156 DBG_VALUE $edx, $noreg, !16, !DIExpression(), debug-location !21157 $r15d = MOV32rr $esi, implicit-def $r15158 $ebx = MOV32rr $edi, implicit-def $rbx159 $edi = MOV32rr $esi160 MOV32mr $rsp, 1, $noreg, 8, $noreg, killed renamable $edx :: (store (s32) into %ir.arg3.addr)161 renamable $rdx = LEA64r $rsp, 1, $noreg, 8, $noreg162 renamable $ecx = MOV32rr $r14d,163 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit $rdx, implicit $ecx, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, implicit-def $rax, debug-location !21164 DBG_VALUE $noreg, $noreg, !18, !DIExpression(), debug-location !21165 $rdx = MOV64rr renamable $rax166 $ecx = KILL renamable $ecx, implicit-def $rcx 167 renamable $eax = LEA64_32r renamable $rcx, 1, renamable $rbx, 0, $noreg, debug-location !21168 renamable $edi = LEA64_32r renamable $r14, 1, renamable $r15, 0, $noreg, debug-location !21169 CMP32rr renamable $ebx, renamable $r15d, implicit-def $eflags, implicit killed $r15, debug-location !21170 renamable $edi = CMOV32rr killed renamable $edi, killed renamable $eax, 15, implicit killed $eflags, debug-location !21171 DBG_VALUE $edi, $noreg, !18, !DIExpression(), debug-location !21172 $eax = MOV32rr $ecx, debug-location !21173 CDQ implicit-def $eax, implicit-def $edx, implicit $eax, debug-location !21174 IDIV32r renamable $ebx, implicit-def dead $eax, implicit-def $edx, implicit-def dead $eflags, implicit $eax, implicit $edx, debug-location !21175 $eax = MOV32rr $ecx, debug-location !21176 renamable $eax = nsw IMUL32rr killed renamable $eax, renamable $ebx, implicit-def dead $eflags, debug-location !21177 renamable $ecx = nsw ADD32rr renamable $ecx, renamable $r14d, implicit-def dead $eflags, implicit killed $rcx, implicit-def $rcx, debug-location !21178 TEST32rr killed renamable $edx, renamable $edx, implicit-def $eflags, debug-location !21179 renamable $ecx = CMOV32rr renamable $ecx, killed renamable $eax, 4, implicit killed $eflags, implicit killed $rcx, implicit-def $rcx, debug-location !21180 DBG_VALUE $ecx, $noreg, !19, !DIExpression(), debug-location !21181 MOV32mr $rsp, 1, $noreg, 12, $noreg, renamable $ecx, debug-location !21 :: (store (s32) into %ir.local2)182 CMP32rr renamable $ecx, renamable $r14d, implicit-def $eflags, implicit killed $r14, debug-location !21183 renamable $ebx = CMOV32rr renamable $ebx, renamable $edi, 12, implicit killed $eflags, implicit killed $rbx, implicit-def $rbx, debug-location !21184 renamable $ecx = nsw IMUL32rr renamable $ecx, renamable $ebx, implicit-def dead $eflags, implicit killed $rbx, implicit killed $rcx, implicit-def $rcx, debug-location !21185 DBG_VALUE $rsp, $noreg, !19, !DIExpression(DW_OP_plus_uconst, 12, DW_OP_deref), debug-location !21186 DBG_VALUE $ecx, $noreg, !20, !DIExpression(), debug-location !21187 $esi = MOV32ri 4, debug-location !21188 renamable $ecx = MOV32rm $rsp, 1, $noreg, 8, $noreg, implicit-def $rcx, debug-location !21 :: (dereferenceable load (s32) from %ir.arg3.addr)189 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit $rdx, implicit $ecx, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, implicit-def $rax, debug-location !21190 DBG_VALUE $eax, $noreg, !14, !DIExpression(), debug-location !21191 renamable $eax = nsw ADD32ri8 killed renamable $eax, 4, implicit-def dead $eflags, debug-location !21192 $rsp = frame-destroy ADD64ri8 $rsp, 16, implicit-def dead $eflags, debug-location !21193 CFI_INSTRUCTION def_cfa_offset 32, debug-location !21194 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !21195 CFI_INSTRUCTION def_cfa_offset 24, debug-location !21196 $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !21197 DBG_VALUE $ecx, $noreg, !17, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !21198 CFI_INSTRUCTION def_cfa_offset 16, debug-location !21199 $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !21200 DBG_VALUE $esi, $noreg, !15, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !21201 CFI_INSTRUCTION def_cfa_offset 8, debug-location !21202 RET64 $eax, debug-location !21203 204...205