• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llc %s -o - -run-pass=livedebugvalues -mtriple=x86_64-unknown-unknown | FileCheck %s
2#
3# This is a regression test for register/stack variable locations being
4# interpreted as each other. We place a variable location on the stack, based
5# on $rsp. We later make a memory load from $rsp. On faulty versions of LLVM
6# this gets interpreted as a stack restore of the spilt value (it's not).
7#
8# Test that LiveDebugValues does not create any new variable locations.
9#
10# CHECK-LABEL: name: baaar
11# CHECK-LABEL: bb.0.entry:
12# CHECK:       DBG_VALUE $r9d, $noreg, !{{[0-9]*}}, !DIExpression()
13# CHECK:       DBG_VALUE $rsp, 0, !{{[0-9]*}}, !DIExpression(DW_OP_plus_uconst, 16)
14# CHECK-NOT:   DBG_VALUE
15--- |
16  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
17  target triple = "x86_64-unknown-linux-gnu"
18
19  define void @baaar() !dbg !4 {
20  entry:
21    ret void
22  }
23
24  !llvm.module.flags = !{!0, !1}
25  !llvm.dbg.cu = !{!2}
26
27  !0 = !{i32 2, !"Debug Info Version", i32 3}
28  !1 = !{i32 2, !"Dwarf Version", i32 4}
29  !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
30  !3 = !DIFile(filename: "sheep.cpp", directory: ".")
31  !4 = distinct !DISubprogram(name: "baaar", scope: !3, file: !3, line: 1, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8)
32  !5 = !DISubroutineType(types: !6)
33  !6 = !{!7}
34  !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
35  !8 = !{!9}
36  !9 = !DILocalVariable(name: "moo", scope: !4, file: !3, line: 1, type: !7)
37  !10 = !DILocation(line: 1, scope: !4)
38
39...
40---
41name:            baaar
42alignment:       16
43tracksRegLiveness: true
44liveins:
45  - { reg: '$rdi', virtual-reg: '' }
46  - { reg: '$rsi', virtual-reg: '' }
47  - { reg: '$rdx', virtual-reg: '' }
48  - { reg: '$rcx', virtual-reg: '' }
49  - { reg: '$r8', virtual-reg: '' }
50  - { reg: '$r9d', virtual-reg: '' }
51frameInfo:
52  stackSize:       24
53  offsetAdjustment: -24
54  maxAlignment:    8
55  adjustsStack:    true
56  hasCalls:        true
57fixedStack:
58stack:
59  - { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
60      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
61      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
62  - { id: 1, name: '', type: spill-slot, offset: -32, size: 8, alignment: 8,
63      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
64      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
65body:             |
66  bb.0.entry:
67    liveins: $rcx, $rdi, $rdx, $rsi, $r8, $r9d, $rbp, $r15, $r14, $r13, $r12, $rbx
68
69    ; Setup
70    DBG_VALUE $r9d, $noreg, !9, !DIExpression(), debug-location !10
71    $rsp = frame-setup SUB64ri8 $rsp, 24, implicit-def dead $eflags
72
73    ; Spill
74    MOV32mr $rsp, 1, $noreg, 16, $noreg, $r9d :: (store 4 into %stack.0)
75    DBG_VALUE $rsp, 0, !9, !DIExpression(DW_OP_plus_uconst, 16), debug-location !10
76
77    ; This load from the stack can be misinterpreted as a stack restore of
78    ; any DBG_VALUe pointing at $rsp.
79    $rsi = MOV64rm $rsp, 1, $noreg, 0, $noreg :: (load 8 from %stack.1)
80
81    ; Return faff
82    $eax = MOV32ri 0
83    $rsp = frame-destroy ADD64ri8 $rsp, 24, implicit-def dead $eflags
84    RETQ debug-location !10
85...
86