xref: /llvm-project/llvm/test/DebugInfo/PowerPC/live-debug-vars-subreg-offset.ll (revision 45acc9610bc61fe3f76ff192cf70e1757440f383)
1; RUN: llc -O3 -stop-after virtregrewriter %s -o - | FileCheck %s
2
3target datalayout = "E-m:e-i64:64-n32:64"
4target triple = "ppc64"
5
6; Verify that live-debug-variables includes the stack slot offset
7; for the sub-register in the debug expression for `spilled'.
8
9; This reproducer was generated from the following C file:
10;
11;     extern int foo(void);
12;     extern void bar(int);
13;
14;     int main() {
15;       int spilled = foo();
16;
17;       // Clobber all GPRs.
18;       __asm volatile ("" : : : "0", "1", "2", "3", "4", "5", "6", "7",
19;                                "8", "9", "10", "11", "12", "13", "14", "15",
20;                                "16", "17", "18", "19", "20", "21", "22", "23",
21;                                "24", "25", "26", "27", "28", "29", "30", "31");
22;
23;       for(;;)
24;         bar(spilled);
25;
26;       return 0;
27;     }
28;
29; compiled using:
30;
31;     clang --target=ppc64 -O3 -g -S -emit-llvm
32
33; CHECK: ![[VAR:.*]] = !DILocalVariable(name: "spilled"
34
35; CHECK: STD $x3, 0, %stack.0
36; CHECK-NEXT: DBG_VALUE %stack.0, 0, ![[VAR]], !DIExpression(DW_OP_plus_uconst, 4)
37
38; Function Attrs: noreturn nounwind
39define signext i32 @main() local_unnamed_addr #0 !dbg !8 {
40entry:
41  %call = tail call signext i32 @foo() #2, !dbg !14
42  call void @llvm.dbg.value(metadata i32 %call, metadata !13, metadata !DIExpression()), !dbg !14
43  tail call void asm sideeffect "", "~{r0},~{r1},~{r2},~{r3},~{r4},~{r5},~{r6},~{r7},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{r16},~{r17},~{r18},~{r19},~{r20},~{r21},~{r22},~{r23},~{r24},~{r25},~{r26},~{r27},~{r28},~{r29},~{r30},~{r31}"() #2, !dbg !14, !srcloc !15
44  br label %for.cond, !dbg !14
45
46for.cond:                                         ; preds = %for.cond, %entry
47  tail call void @bar(i32 signext %call) #2, !dbg !14
48  br label %for.cond, !dbg !14
49}
50
51declare signext i32 @foo() local_unnamed_addr
52
53declare void @bar(i32 signext) local_unnamed_addr
54
55; Function Attrs: nounwind readnone speculatable
56declare void @llvm.dbg.value(metadata, metadata, metadata) #1
57
58attributes #0 = { noreturn nounwind }
59attributes #1 = { nounwind readnone speculatable }
60attributes #2 = { nounwind }
61
62!llvm.dbg.cu = !{!0}
63!llvm.module.flags = !{!3, !4, !5, !6}
64!llvm.ident = !{!7}
65
66!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
67!1 = !DIFile(filename: "live-debug-vars-subreg-offset.c", directory: "/")
68!2 = !{}
69!3 = !{i32 2, !"Dwarf Version", i32 4}
70!4 = !{i32 2, !"Debug Info Version", i32 3}
71!5 = !{i32 1, !"wchar_size", i32 4}
72!6 = !{i32 7, !"PIC Level", i32 2}
73!7 = !{!"clang version 8.0.0"}
74!8 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 4, type: !9, isLocal: false, isDefinition: true, scopeLine: 4, isOptimized: true, unit: !0, retainedNodes: !12)
75!9 = !DISubroutineType(types: !10)
76!10 = !{!11}
77!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
78!12 = !{!13}
79!13 = !DILocalVariable(name: "spilled", scope: !8, file: !1, line: 5, type: !11)
80!14 = !DILocation(line: 5, column: 17, scope: !8)
81!15 = !{i32 125}
82