[llvm-bugs] [Bug 25432] New: Optimization removes debug info when processing comparison to constant
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Nov 6 09:58:45 PST 2015
https://llvm.org/bugs/show_bug.cgi?id=25432
Bug ID: 25432
Summary: Optimization removes debug info when processing
comparison to constant
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: DebugInfo
Assignee: unassignedbugs at nondot.org
Reporter: danielcdh at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Created attachment 15234
--> https://llvm.org/bugs/attachment.cgi?id=15234&action=edit
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151106/e78c2403/attachment.html>
More information about the llvm-bugs
mailing list