<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 --- - Optimization removes debug info when processing comparison to constant"
href="https://llvm.org/bugs/show_bug.cgi?id=25432">25432</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Optimization removes debug info when processing comparison to constant
</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>Linux
</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>DebugInfo
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>danielcdh@gmail.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>Created <span class=""><a href="attachment.cgi?id=15234" name="attach_15234" title="original source file">attachment 15234</a> <a href="attachment.cgi?id=15234&action=edit" title="original source file">[details]</a></span>
original source file
#clang -S -O2 -g a.cc
In the produced binary:
# BB#0:
#DEBUG_VALUE: foo:i <- EDI
.loc 1 5 15 prologue_end # a.cc:5:15
cmpl $128, %edi
je .LBB0_2
# BB#1:
#DEBUG_VALUE: foo:i <- EDI
cmpl $80, %edi
jne .LBB0_3
Apparent, the cmpl in BB#1 should be attributed to ".loc 1 6 9". However its
debug info is removed by cfg-simplify.
Original IR:
define void @_Z3fooi(i32 %i) #0 {
%1 = alloca i32, align 4
store i32 %i, i32* %1, align 4, !tbaa !13
call void @llvm.dbg.declare(metadata i32* %1, metadata !9, metadata !17),
!dbg !18
%2 = load i32, i32* %1, align 4, !dbg !19, !tbaa !13
%3 = icmp eq i32 %2, 80, !dbg !21
br i1 %3, label %7, label %4, !dbg !22
; <label>:4 ; preds = %0
%5 = load i32, i32* %1, align 4, !dbg !23, !tbaa !13
%6 = icmp eq i32 %5, 128, !dbg !24
br i1 %6, label %7, label %8, !dbg !25
; <label>:7 ; preds = %4, %0
call void @_Z3barv(), !dbg !26
br label %9, !dbg !26
; <label>:8 ; preds = %4
call void @_Z3bazv(), !dbg !27
br label %9
; <label>:9 ; preds = %8, %7
ret void, !dbg !28
}
After some transformation (debug info still correct):
define void @_Z3fooi(i32 %i) #0 {
call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !9, metadata !13),
!dbg !14
%1 = icmp eq i32 %i, 80, !dbg !15
%2 = icmp eq i32 %i, 128, !dbg !17
%or.cond = or i1 %1, %2, !dbg !18
br i1 %or.cond, label %3, label %4, !dbg !18
; <label>:3 ; preds = %0
call void @_Z3barv(), !dbg !19
br label %5, !dbg !19
; <label>:4 ; preds = %0
call void @_Z3bazv(), !dbg !20
br label %5
; <label>:5 ; preds = %4, %3
ret void, !dbg !21
}
After cfg-simply:
define void @_Z3fooi(i32 %i) #0 {
call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !9, metadata !13),
!dbg !14
switch i32 %i, label %2 [
i32 128, label %1
i32 80, label %1
], !dbg !15
; <label>:1 ; preds = %0, %0
call void @_Z3barv(), !dbg !17
br label %3, !dbg !17
; <label>:2 ; preds = %0
call void @_Z3bazv(), !dbg !18
br label %3
; <label>:3 ; preds = %2, %1
ret void, !dbg !19
}
The debug info is all lost here when converting compare to switch. Later when
converting to machine code, the switch is expanded to compare again, but
without correct debug info.</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>