[PATCH] D74030: [DebugInfo] Avoid generating duplicate llvm.dbg.value

Alok Kumar Sharma via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 5 02:12:08 PST 2020


alok created this revision.
alok added reviewers: aprantl, probinson, dblaikie, jmorse, jini.susan.george, SouraVX, awpandey.
alok added projects: debug-info, LLVM.
Herald added subscribers: llvm-commits, ormris, kosarev, hiraditya.

This is to avoid generating duplicate llvm.dbg.value instrinsic if it already exists after the Instruction.

  Summary:
  
   Before inserting llvm.dbg.value instruction, LLVM checks if the same instruction is already present before the instruction to avoid duplicates.

Currently it misses to check if it already exists after the instruction.
 flang generates IR like this.

 -----

  %10 = load i32, i32* %i1_311, align 4, !tbaa !55, !dbg !48
  call void @llvm.dbg.value (metadata i32 %10, i64 0, metadata !46, metadata !23), !dbg !42

 -----

  When this IR is processed in llvm, it ends up inserting duplicates.

 -----

  call void @llvm.dbg.value(metadata i32 5, metadata !27, metadata !DIExpression()), !dbg !24
  call void @llvm.dbg.value(metadata i32 5, metadata !27, metadata !DIExpression()), !dbg !24

-----

  We have now updated LdStHasDebugValue to include the cases when instruction is already

followed by same dbg.value instruction we intend to insert.

  Testing:

- Added unit test for validation
- check-llvm
- check-debuginfo (the debug info integration tests)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74030

Files:
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/test/DebugInfo/duplicate_dbgvalue.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74030.242535.patch
Type: text/x-patch
Size: 12255 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200205/02057dec/attachment.bin>


More information about the llvm-commits mailing list