[PATCH] D100371: [debug-info] SCCP should preserve the debug location for an one-to-one instruction replacement

Yuanbo Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 13 02:04:32 PDT 2021


yuanboli233 created this revision.
yuanboli233 added reviewers: vsk, jmorse, dblaikie, djtodoro, aprantl.
yuanboli233 added a project: debug-info.
Herald added a subscriber: hiraditya.
yuanboli233 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This revision focuses on fixing the bug proposed here: https://bugs.llvm.org/show_bug.cgi?id=48722

In the original ll file:

  %tmp9 = trunc i64 %tmp8 to i32, !dbg !29
  call void @llvm.dbg.value(metadata i32 %tmp9, metadata !18, metadata !DIExpression()), !dbg !29
  %tmp10 = sext i32 %tmp9 to i64, !dbg !30
  call void @llvm.dbg.value(metadata i64 %tmp10, metadata !19, metadata !DIExpression()), !dbg !30

is optimized to

  %tmp9 = trunc i64 %tmp8 to i32, !dbg !29
  call void @llvm.dbg.value(metadata i32 %tmp9, metadata !18, metadata !DIExpression()), !dbg !29
  %0 = zext i32 %tmp9 to i64
  call void @llvm.dbg.value(metadata i64 %0, metadata !19, metadata !DIExpression()), !dbg !30

There exists a one-to-one relationship between `%tmp10 = sext i32 %tmp9 to i64, !dbg !30` and `%0 = zext i32 %tmp9 to i64`, however, the debug location is unnecessarily dropped.

This revision proposes to preserve the debug location `!30` of the original instruction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100371

Files:
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/test/Transforms/SCCP/sccp_preserve_debugloc.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100371.337070.patch
Type: text/x-patch
Size: 5218 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210413/ad634b14/attachment.bin>


More information about the llvm-commits mailing list