Page MenuHomePhabricator

[DebugInfo] Support for DW_OP_implicit_pointer (salvagDebugInfo improvement).
Needs ReviewPublic

Authored by alok on Thu, Nov 14, 11:10 AM.

Details

Summary

This patch (6/N) stems from D69787 as suggested by reviewers.

Summary:

  Whenever alloca is getting deleted, lets handle this to preserve debug info
 - Collect a variable description from corresponding llvm.dbg.declare intrinsic and pass that information to llvm.dbg.value intrinsic to create

 Before transformation
     %a = alloca [2 x i32], align 4
     call void @llvm.dbg.declare(metadata [2 x i32]* %arr, metadata !16, metadata !DIExpression()), !dbg !22
     call void @llvm.dbg.value(metadata [2 x i32]* %arr, metadata !20, metadata !DIExpression()), !dbg !24
     !16 = !DILocalVariable(name: "arr", scope: !12, file: !3, line: 5, type: !17)
     !20 = !DILocalVariable(name: "ptr", scope: !12, file: !3, line: 6, type: !21)

 After Transformation
     %a = alloca [2 x i32], align 4
     call void @llvm.dbg.declare(metadata [2 x i32]* %arr, metadata !16, metadata !DIExpression()), !dbg !22
     call void @llvm.dbg.derefval(metadata !16, metadata !20, metadata !DIExpression(DW_OP_LLVM_implicit_pointer, DW_OP_LLVM_arg0, 0)), !dbg !24
     call void @llvm.dbg.derefval(metadata !16, metadata !20, metadata !DIExpression(DW_OP_LLVM_implicit_pointer, DW_OP_LLVM_arg0, 4)), !dbg !24

     - In case llvm.dbg.declare is getting deleted before alloca instruction, preserve variable description map to use later.
 
Testing:
   - check-llvm
   - check-debuginfo (the debug info integration tests)

Diff Detail

Event Timeline

alok created this revision.Thu, Nov 14, 11:10 AM
alok edited the summary of this revision. (Show Details)Thu, Nov 14, 11:13 AM
alok updated this revision to Diff 229788.Mon, Nov 18, 3:21 AM

-Updated to use "git show" in place of "git diff" used earlier

alok updated this revision to Diff 230809.Sun, Nov 24, 10:24 AM
alok edited the summary of this revision. (Show Details)

Updated to re-base due to changes in trunk and parent patches.

Hi @alok. I haven't been following the DW_OP_implicit_pointer discussion too closely, so just some inline nitpick comments/questions from me.

Thanks,
Orlando

llvm/include/llvm/IR/Module.h
197

Are you using a std::map for a specific reason? Could you not use a std::unordered_map, or better yet, a DenseMap [0] or similar llvm container here instead?

[0] http://llvm.org/docs/ProgrammersManual.html#llvm-adt-densemap-h

llvm/lib/IR/DebugInfoMetadata.cpp
1000–1003

Why not unsigned numElements = getNumElements(); ?

llvm/lib/Transforms/Utils/Local.cpp
1642–1643

Please can you capitalise these variable names?

alok marked 5 inline comments as done.Sun, Nov 24, 10:06 PM

Hi @alok. I haven't been following the DW_OP_implicit_pointer discussion too closely, so just some inline nitpick comments/questions from me.

Thanks,
Orlando

Thanks for your comments. Next version would have all your comments incorporated. Please let me know if you have any more comments.

llvm/include/llvm/IR/Module.h
197

Thanks for the suggestion, It will be updated in next version to use DenseMap.

llvm/lib/IR/DebugInfoMetadata.cpp
1000–1003

Thanks for your comment. It will be updated in next version.

llvm/lib/Transforms/Utils/Local.cpp
1642–1643

Thanks for your comment. It will be updated in next version.

alok updated this revision to Diff 230833.Sun, Nov 24, 10:09 PM
alok marked 2 inline comments as done.

Updated to incorporate comments from @Orlando .

alok marked an inline comment as done.Sun, Nov 24, 10:10 PM