[all-commits] [llvm/llvm-project] 6f029d: [DebugInfo] Avoid generating duplicate llvm.dbg.value

Alok Kumar Sharma via All-commits all-commits at lists.llvm.org
Mon Mar 2 20:30:55 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 6f029dadf6900e6957f899a60486ec1e0740d555
      https://github.com/llvm/llvm-project/commit/6f029dadf6900e6957f899a60486ec1e0740d555
  Author: Alok Kumar Sharma <AlokKumar.Sharma at amd.com>
  Date:   2020-03-03 (Tue, 03 Mar 2020)

  Changed paths:
    M llvm/lib/Transforms/Utils/Local.cpp
    A llvm/test/DebugInfo/duplicate_dbgvalue.ll
    M llvm/test/Transforms/Util/dbg-call-bitcast.ll

  Log Message:
  -----------
  [DebugInfo] Avoid generating duplicate llvm.dbg.value

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

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.

%4 = load i32, i32* %i1_311, align 4, !dbg !42
call void @llvm.dbg.value(metadata i32 %4, metadata !35, metadata !DIExpression()), !dbg !33
When this IR is processed in llvm, it ends up inserting duplicates.
%4 = load i32, i32* %i1_311, align 4, !dbg !42
call void @llvm.dbg.value(metadata i32 %4, metadata !35, metadata !DIExpression()), !dbg !33
call void @llvm.dbg.value(metadata i32 %4, metadata !35, metadata !DIExpression()), !dbg !33
We have now updated LdStHasDebugValue to include the cases when instruction is already
followed by same dbg.value instruction we intend to insert.

Now,

Definition and usage of function LdStHasDebugValue are deleted.
RemoveRedundantDbgInstrs is called for the cleanup of duplicate dbg.value's

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

Reviewers: aprantl, probinson, dblaikie, jmorse, jini.susan.george
SouraVX, awpandey, dstenb, vsk

Reviewed By: aprantl, jmorse, dstenb, vsk

Differential Revision: https://reviews.llvm.org/D74030




More information about the All-commits mailing list