[llvm-bugs] [Bug 49099] New: GVNHoist should drop debug location according to the debug info guide
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Feb 8 15:58:00 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49099
Bug ID: 49099
Summary: GVNHoist should drop debug location according to the
debug info guide
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: yuanboli233 at gmail.com
CC: llvm-bugs at lists.llvm.org
Created attachment 24497
--> https://bugs.llvm.org/attachment.cgi?id=24497&action=edit
abc_debug.ll
Overview, the GVNHoist pass preserves the debug location, however, according to
the LLVM debug info update guide, the debug location should be dropped.
Steps to reproduce:
$ clang++ --version
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
0b5d8d668c210f263a93821fd51c564313c96099)
Target: x86_64-unknown-linux-gnu
Thread model: posix
The complete IR file abc_debug.ll is attached.
$ cat abc_debug.ll
...... (irrelevant content omitted)
entry:
call void @llvm.dbg.value(metadata i32 0, metadata !9, metadata
!DIExpression()), !dbg !11
switch i32 %c1, label %exit1 [
i32 0, label %sw0
i32 1, label %sw1
], !dbg !11
sw0: ; preds = %entry
store i32 1, i32* @G, align 4, !dbg !12
br label %exit, !dbg !13
sw1: ; preds = %entry
store i32 1, i32* @G, align 4, !dbg !14
br label %exit, !dbg !15
exit1: ; preds = %entry
store i32 1, i32* @G, align 4, !dbg !16
ret void, !dbg !17
......
The gvn hoist will hoist the identical store instructions to the predecessor
basic block.
$ opt -gvn-hoist abc_debug.ll > result.bc
$ llvm-dis result.bc
$ cat result.ll
......(omit irrelevant content)
entry:
call void @llvm.dbg.value(metadata i32 0, metadata !9, metadata
!DIExpression()), !dbg !11
store i32 1, i32* @G, align 4, !dbg !12
switch i32 %c1, label %exit1 [
i32 0, label %sw0
i32 1, label %sw1
], !dbg !11
sw0: ; preds = %entry
br label %exit, !dbg !13
sw1: ; preds = %entry
br label %exit, !dbg !14
exit1: ; preds = %entry
ret void, !dbg !15
......
However, according to the LLVM debug info update guide:
https://llvm.org/docs/HowToUpdateDebugInfo.html, "Hoisting identical
instructions which appear in several successor blocks into a predecessor block.
In this case there is no single merged instruction. The rule for dropping
locations applies". It seems that the debug location should be dropped instead
of preserving the "!dbg !12"
--
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/20210208/99ad6ebf/attachment.html>
More information about the llvm-bugs
mailing list