[PATCH] D140904: [DebugInfo] Prefer to use setKillLocation rather than replacing operands with undef
Orlando Cazalet-Hyams via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 3 09:09:17 PST 2023
Orlando created this revision.
Orlando added reviewers: StephenTozer, jmorse, djtodoro, jryans, scott.linder.
Orlando added a project: debug-info.
Herald added subscribers: mattd, gchakrabarti, asavonic, hiraditya.
Herald added a project: All.
Orlando requested review of this revision.
Herald added subscribers: llvm-commits, jholewinski.
Herald added a project: LLVM.
NFC-ish. There is a functional change but the outputs are semantically identical. Where we might've before replaced one operand with undef (which means "this is a kill location marker") the use of `setKillLocation` will replace all location operands with `undef` (which also means "this is a kill location marker").
Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value
https://reviews.llvm.org/D140904
Files:
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/DebugInfo/NVPTX/debug-info.ll
Index: llvm/test/DebugInfo/NVPTX/debug-info.ll
===================================================================
--- llvm/test/DebugInfo/NVPTX/debug-info.ll
+++ llvm/test/DebugInfo/NVPTX/debug-info.ll
@@ -106,7 +106,7 @@
; CHECK-DAG: .file [[DEBUG_INFO_CU]] "{{.*}}debug-info.cu"
; CHECK-DAG: .file [[BUILTUIN_VARS_H]] "{{.*}}clang/include{{/|\\\\}}__clang_cuda_builtin_vars.h"
-; CHECK: .section .debug_abbrev
+; CHECK: .section .debug_abbrev
; CHECK-NEXT: {
; CHECK-NEXT:.b8 1 // Abbreviation Code
; CHECK-NEXT:.b8 17 // DW_TAG_compile_unit
@@ -703,12 +703,12 @@
; CHECK-NEXT: }
; CHECK-NEXT: .section .debug_info
; CHECK-NEXT: {
-; CHECK-NEXT:.b32 10029 // Length of Unit
+; CHECK-NEXT:.b32 10034 // Length of Unit
; CHECK-NEXT:.b8 2 // DWARF version number
; CHECK-NEXT:.b8 0
; CHECK-NEXT:.b32 .debug_abbrev // Offset Into Abbrev. Section
; CHECK-NEXT:.b8 8 // Address Size (in bytes)
-; CHECK-NEXT:.b8 1 // Abbrev [1] 0xb:0x2726 DW_TAG_compile_unit
+; CHECK-NEXT:.b8 1 // Abbrev [1] 0xb:0x272b DW_TAG_compile_unit
; CHECK-NEXT:.b8 0 // DW_AT_producer
; CHECK-NEXT:.b8 4 // DW_AT_language
; CHECK-NEXT:.b8 0
@@ -8307,7 +8307,7 @@
; CHECK-NEXT:.b8 3 // DW_AT_decl_line
; CHECK-NEXT:.b32 3345 // DW_AT_type
; CHECK-NEXT:.b8 0 // End Of Children Mark
-; CHECK-NEXT:.b8 40 // Abbrev [40] 0x2671:0xbf DW_TAG_subprogram
+; CHECK-NEXT:.b8 40 // Abbrev [40] 0x2671:0xc4 DW_TAG_subprogram
; CHECK-NEXT:.b64 $L__func_begin0 // DW_AT_low_pc
; CHECK-NEXT:.b64 $L__func_end0 // DW_AT_high_pc
; CHECK-NEXT:.b8 1 // DW_AT_frame_base
@@ -8387,7 +8387,7 @@
; CHECK-NEXT:.b8 12 // DW_AT_call_file
; CHECK-NEXT:.b8 6 // DW_AT_call_line
; CHECK-NEXT:.b8 37 // DW_AT_call_column
-; CHECK-NEXT:.b8 43 // Abbrev [43] 0x2711:0x1e DW_TAG_inlined_subroutine
+; CHECK-NEXT:.b8 43 // Abbrev [43] 0x2711:0x23 DW_TAG_inlined_subroutine
; CHECK-NEXT:.b32 9791 // DW_AT_abstract_origin
; CHECK-NEXT:.b64 $L__tmp9 // DW_AT_low_pc
; CHECK-NEXT:.b64 $L__tmp10 // DW_AT_high_pc
@@ -8396,6 +8396,8 @@
; CHECK-NEXT:.b8 5 // DW_AT_call_column
; CHECK-NEXT:.b8 44 // Abbrev [44] 0x2729:0x5 DW_TAG_formal_parameter
; CHECK-NEXT:.b32 9820 // DW_AT_abstract_origin
+; CHECK-NEXT:.b8 44 // Abbrev [44] 0x272e:0x5 DW_TAG_formal_parameter
+; CHECK-NEXT:.b32 9829 // DW_AT_abstract_origin
; CHECK-NEXT:.b8 0 // End Of Children Mark
; CHECK-NEXT:.b8 0 // End Of Children Mark
; CHECK-NEXT:.b8 0 // End Of Children Mark
Index: llvm/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -598,10 +598,8 @@
bool llvm::replaceDbgUsesWithUndef(Instruction *I) {
SmallVector<DbgVariableIntrinsic *, 1> DbgUsers;
findDbgUsers(DbgUsers, I);
- for (auto *DII : DbgUsers) {
- Value *Undef = UndefValue::get(I->getType());
- DII->replaceVariableLocationOp(I, Undef);
- }
+ for (auto *DII : DbgUsers)
+ DII->setKillLocation();
return !DbgUsers.empty();
}
@@ -1893,8 +1891,7 @@
// using DIArgList for dbg.assign yet. FIXME: support this.
// Also do not salvage if the resulting DIArgList would contain an
// unreasonably large number of values.
- Value *Undef = UndefValue::get(I.getOperand(0)->getType());
- DII->replaceVariableLocationOp(I.getOperand(0), Undef);
+ DII->setKillLocation();
}
LLVM_DEBUG(dbgs() << "SALVAGE: " << *DII << '\n');
Salvaged = true;
@@ -1903,10 +1900,8 @@
if (Salvaged)
return;
- for (auto *DII : DbgUsers) {
- Value *Undef = UndefValue::get(I.getType());
- DII->replaceVariableLocationOp(&I, Undef);
- }
+ for (auto *DII : DbgUsers)
+ DII->setKillLocation();
}
Value *getSalvageOpsForGEP(GetElementPtrInst *GEP, const DataLayout &DL,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140904.486006.patch
Type: text/x-patch
Size: 4871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230103/e71f8359/attachment.bin>
More information about the llvm-commits
mailing list