<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - DBG_VALUE is accidentally promoted to location for the entire function"
href="https://llvm.org/bugs/show_bug.cgi?id=26585">26585</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>DBG_VALUE is accidentally promoted to location for the entire function
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>aprantl@apple.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>This condition in DwarfDebug::collectVariableInfo() is wrong:
// Check if the first DBG_VALUE is valid for the rest of the function.
if (Ranges.size() == 1 && Ranges.front().second == nullptr) {
RegVar->initializeDbgValue(MInsn);
continue;
}
If a variable is described by a single DBG_VALUE and that location isn't
clobbered until the end of the function this will cause the range to be
extended to cover the entire function (and thus before the first write to that
location).
Example
-------
Compile this with -O.
void h(int);
int g();
void f() {
h(0);
int a = g();
h(a);
}
output of -stop-after=ssa:
--- |
; ModuleID = 'test.ll'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx"
; Function Attrs: nounwind ssp uwtable
define void @f() #0 !dbg !4 {
entry:
tail call void @h(i32 0) #3, !dbg !14
%call = tail call i32 (...) @g() #3, !dbg !15
tail call void @llvm.dbg.value(metadata i32 %call, i64 0, metadata !8,
metadata !16), !dbg !17
tail call void @h(i32 %call) #3, !dbg !18
ret void, !dbg !19
}
declare void @h(i32) #1
declare i32 @g(...) #1
; Function Attrs: nounwind readnone
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
attributes #0 = { nounwind ssp uwtable }
attributes #1 = { }
attributes #2 = { nounwind readnone }
attributes #3 = { nounwind }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!10, !11, !12}
!llvm.ident = !{!13}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer:
"clang version 3.9.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: 1,
enums: !2, subprograms: !3)
!1 = !DIFile(filename: "test.c", directory: "/Volumes/Data/llvm")
!2 = !{}
!3 = !{!4}
!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type:
!5, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true,
variables: !7)
!5 = !DISubroutineType(types: !6)
!6 = !{null}
!7 = !{!8}
!8 = !DILocalVariable(name: "a", scope: !4, file: !1, line: 5, type: !9)
!9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
!10 = !{i32 2, !"Dwarf Version", i32 2}
!11 = !{i32 2, !"Debug Info Version", i32 3}
!12 = !{i32 1, !"PIC Level", i32 2}
!13 = !{!"clang version 3.9.0 "}
!14 = !DILocation(line: 4, column: 3, scope: !4)
!15 = !DILocation(line: 5, column: 11, scope: !4)
!16 = !DIExpression()
!17 = !DILocation(line: 5, column: 7, scope: !4)
!18 = !DILocation(line: 6, column: 3, scope: !4)
!19 = !DILocation(line: 7, column: 1, scope: !4)
...
---
name: f
alignment: 4
exposesReturnsTwice: false
hasInlineAsm: false
isSSA: false
tracksRegLiveness: true
tracksSubRegLiveness: false
calleeSavedRegisters: [ '%bh', '%bl', '%bp', '%bpl', '%bx', '%ebp', '%ebx',
'%rbp', '%rbx', '%r12', '%r13', '%r14', '%r15',
'%r12b', '%r13b', '%r14b', '%r15b', '%r12d', '%r13d',
'%r14d', '%r15d', '%r12w', '%r13w', '%r14w', '%r15w' ]
frameInfo:
isFrameAddressTaken: false
isReturnAddressTaken: false
hasStackMap: false
hasPatchPoint: false
stackSize: 8
offsetAdjustment: 0
maxAlignment: 0
adjustsStack: true
hasCalls: true
maxCallFrameSize: 0
hasOpaqueSPAdjustment: false
hasVAStart: false
hasMustTailInVarArgFunc: false
fixedStack:
- { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16 }
body: |
bb.0.entry:
liveins: %rbp
frame-setup PUSH64r killed %rbp, implicit-def %rsp, implicit %rsp
CFI_INSTRUCTION .cfi_def_cfa_offset 16
CFI_INSTRUCTION .cfi_offset %rbp, -16
%rbp = frame-setup MOV64rr %rsp
CFI_INSTRUCTION .cfi_def_cfa_register %rbp
%edi = XOR32rr undef %edi, undef %edi, implicit-def dead %eflags,
debug-location !14
CALL64pcrel32 @h, csr_64, implicit %rsp, implicit killed %edi, implicit-def
%rsp, debug-location !14
dead %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags,
implicit-def %al, debug-location !15
CALL64pcrel32 @g, csr_64, implicit %rsp, implicit %al, implicit-def %rsp,
implicit-def %eax, debug-location !15
DBG_VALUE debug-use %eax, debug-use _, !8, !16, debug-location !17
%edi = MOV32rr killed %eax, debug-location !18
%rbp = POP64r implicit-def %rsp, implicit %rsp, debug-location !18
TAILJMPd64 @h, csr_64, implicit %rsp, implicit %rsp, implicit killed %edi,
debug-location !18
...
Dwarfdump:
0x0000004a: TAG_variable [3]
AT_location( rax, piece 0x00000004 )
^^^^^ this should be a location list instead!
AT_name( "a" )
AT_decl_file( "/Volumes/Data/llvm/test.c" )
AT_decl_line( 5 )
AT_type( {0x0000005a} ( int ) )</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>