• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# We do not support call site parameters when the machine instructions loading a value
2# into the forwarding register has a memory operand and multiple defs.
3# The generated code was modified a bit in order to have the scenario.
4#
5# RUN: llc -emit-call-site-info -debug-entry-values -start-after=machineverifier -filetype=obj %s -o - \
6# RUN:  | llvm-dwarfdump - | FileCheck %s --implicit-check-not=DW_TAG_GNU_call_site_parameter
7#
8# Command: clang -g -O2 -Xclang -femit-debug-entry-values test.c
9#          -mllvm -stop-before=machineverifier -o test.mir -c
10# extern void callee(int);
11# extern int y;
12#
13# #define FORCE_SPILL()                                                          \
14#   asm volatile(""                                                              \
15#                :                                                               \
16#                :                                                               \
17#                : "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rbp", "r8", "r9",  \
18#                  "r10", "r11", "r12", "r13", "r14", "r15")
19#
20# __attribute__((disable_tail_calls)) void caller(int x) {
21#   FORCE_SPILL();
22#   x = x % y;
23#   callee(x);
24# }
25#
26--- |
27  ; ModuleID = 'test.c'
28  source_filename = "test.c"
29  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
30  target triple = "x86_64-unknown-linux-gnu"
31
32  @y = external dso_local local_unnamed_addr global i32, align 4
33
34  ; Function Attrs: nounwind uwtable
35  define dso_local void @caller(i32 %x) local_unnamed_addr !dbg !12 {
36  entry:
37    call void @llvm.dbg.value(metadata i32 %x, metadata !14, metadata !DIExpression()), !dbg !15
38    call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"(), !dbg !16, !srcloc !17
39    %0 = load i32, i32* @y, align 4, !dbg !18
40    %rem = srem i32 %x, %0, !dbg !18
41    call void @llvm.dbg.value(metadata i32 %rem, metadata !14, metadata !DIExpression()), !dbg !15
42    call void @callee(i32 %rem), !dbg !18
43    ret void, !dbg !18
44  }
45
46  declare !dbg !4 dso_local void @callee(i32) local_unnamed_addr
47
48  ; Function Attrs: nounwind readnone speculatable willreturn
49  declare void @llvm.dbg.value(metadata, metadata, metadata)
50
51  !llvm.dbg.cu = !{!0}
52  !llvm.module.flags = !{!8, !9, !10}
53  !llvm.ident = !{!11}
54
55  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None)
56  !1 = !DIFile(filename: "test.c", directory: "/")
57  !2 = !{}
58  !3 = !{!4}
59  !4 = !DISubprogram(name: "callee", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
60  !5 = !DISubroutineType(types: !6)
61  !6 = !{null, !7}
62  !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
63  !8 = !{i32 7, !"Dwarf Version", i32 4}
64  !9 = !{i32 2, !"Debug Info Version", i32 3}
65  !10 = !{i32 1, !"wchar_size", i32 4}
66  !11 = !{!"clang version 11.0.0"}
67  !12 = distinct !DISubprogram(name: "caller", scope: !1, file: !1, line: 11, type: !5, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
68  !13 = !{!14}
69  !14 = !DILocalVariable(name: "x", arg: 1, scope: !12, file: !1, line: 11, type: !7)
70  !15 = !DILocation(line: 0, scope: !12)
71  !16 = !DILocation(line: 12, column: 4, scope: !12)
72  !17 = !{i32 -2147471651}
73  !18 = !DILocation(line: 13, column: 12, scope: !12)
74
75...
76---
77name:            caller
78alignment:       16
79stack:
80  - { id: 0, name: '', type: spill-slot, offset: -60, size: 4, alignment: 4,
81      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
82      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
83callSites:
84  - { bb: 0, offset: 30, fwdArgRegs:
85      - { arg: 0, reg: '$edi' } }
86body:             |
87  bb.0.entry:
88    liveins: $edi, $rbp, $r15, $r14, $r13, $r12, $rbx
89
90    DBG_VALUE $edi, $noreg, !14, !DIExpression(), debug-location !15
91    frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
92    CFI_INSTRUCTION def_cfa_offset 16
93    frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
94    CFI_INSTRUCTION def_cfa_offset 24
95    frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
96    CFI_INSTRUCTION def_cfa_offset 32
97    frame-setup PUSH64r killed $r13, implicit-def $rsp, implicit $rsp
98    CFI_INSTRUCTION def_cfa_offset 40
99    frame-setup PUSH64r killed $r12, implicit-def $rsp, implicit $rsp
100    CFI_INSTRUCTION def_cfa_offset 48
101    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
102    CFI_INSTRUCTION def_cfa_offset 56
103    frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
104    CFI_INSTRUCTION def_cfa_offset 64
105    CFI_INSTRUCTION offset $rbx, -56
106    CFI_INSTRUCTION offset $r12, -48
107    CFI_INSTRUCTION offset $r13, -40
108    CFI_INSTRUCTION offset $r14, -32
109    CFI_INSTRUCTION offset $r15, -24
110    CFI_INSTRUCTION offset $rbp, -16
111    MOV32mr $rsp, 1, $noreg, 4, $noreg, $edi :: (store 4 into %stack.0)
112    DBG_VALUE $rsp, 0, !14, !DIExpression(DW_OP_plus_uconst, 4), debug-location !15
113    INLINEASM &"", 1, 12, implicit-def dead early-clobber $rax, 12, implicit-def dead early-clobber $rbx, 12, implicit-def dead early-clobber $rcx, 12, implicit-def dead early-clobber $rdx, 12, implicit-def dead early-clobber $rsi, 12, implicit-def dead early-clobber $rdi, 12, implicit-def dead early-clobber $rbp, 12, implicit-def dead early-clobber $r8, 12, implicit-def dead early-clobber $r9, 12, implicit-def dead early-clobber $r10, 12, implicit-def dead early-clobber $r11, 12, implicit-def dead early-clobber $r12, 12, implicit-def dead early-clobber $r13, 12, implicit-def dead early-clobber $r14, 12, implicit-def dead early-clobber $r15, 12, implicit-def dead early-clobber $df, 12, implicit-def early-clobber $fpsw, 12, implicit-def dead early-clobber $eflags, !17, debug-location !16
114    $eax = MOV32rm $rsp, 1, $noreg, 4, $noreg :: (load 4 from %stack.0)
115    DBG_VALUE $eax, $noreg, !14, !DIExpression(), debug-location !15
116    CDQ implicit-def $eax, implicit-def $edx, implicit $eax, debug-location !18
117    DIV64m $rsp, 1, $noreg, 24, $noreg, implicit-def dead $rax, implicit-def $rdx, implicit-def dead $eflags, implicit $rax, implicit $rdx, debug-location !18 :: (load 8 from %stack.0)
118    $edi = MOV32rr $edx, debug-location !18
119    DBG_VALUE $edi, $noreg, !14, !DIExpression(), debug-location !15
120    CALL64pcrel32 @callee, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, debug-location !18
121    $rsp = frame-destroy ADD64ri8 $rsp, 8, implicit-def dead $eflags, debug-location !18
122    CFI_INSTRUCTION def_cfa_offset 56, debug-location !18
123    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !18
124    CFI_INSTRUCTION def_cfa_offset 48, debug-location !18
125    $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !18
126    CFI_INSTRUCTION def_cfa_offset 40, debug-location !18
127    $r13 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !18
128    CFI_INSTRUCTION def_cfa_offset 32, debug-location !18
129    $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !18
130    CFI_INSTRUCTION def_cfa_offset 24, debug-location !18
131    $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !18
132    CFI_INSTRUCTION def_cfa_offset 16, debug-location !18
133    $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !18
134    CFI_INSTRUCTION def_cfa_offset 8, debug-location !18
135    RETQ debug-location !18
136
137...
138