llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-backend-hexagon Author: None (llvmbot) <details> <summary>Changes</summary> Backport 02771a3eaff153002ec544c3dc4427d56ccd4456 Requested by: @<!-- -->androm3da --- Full diff: https://github.com/llvm/llvm-project/pull/178679.diff 2 Files Affected: - (modified) llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp (+30-3) - (added) llvm/test/CodeGen/Hexagon/livedebugvalues-bundle-terminator.mir (+38) ``````````diff diff --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp index 1c4b2f9136857..293dfa53c3c84 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp @@ -125,6 +125,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineInstrBundle.h" #include "llvm/CodeGen/MachineMemOperand.h" #include "llvm/CodeGen/MachineOperand.h" #include "llvm/CodeGen/PseudoSourceValue.h" @@ -2347,9 +2348,35 @@ bool VarLocBasedLDV::ExtendRanges(MachineFunction &MF, OpenRanges.insertFromLocSet(getVarLocsInMBB(MBB, InLocs), VarLocIDs); LastNonDbgMI = nullptr; RegSetInstrs.clear(); - for (auto &MI : *MBB) - process(MI, OpenRanges, VarLocIDs, Transfers, EntryValTransfers, - RegSetInstrs); + // Iterate through instructions within each packet to handle VLIW + // bundles correctly; this keeps DBG_VALUE placement valid on + // packet-based targets. + for (auto I = MBB->instr_begin(), E = MBB->instr_end(); I != E;) { + auto BStart = llvm::getBundleStart(I); + auto BEnd = llvm::getBundleEnd(I); + bool PacketHasTerminator = false; + for (auto BI = BStart; BI != BEnd; ++BI) { + if (BI->isTerminator()) { + PacketHasTerminator = true; + break; + } + } + if (PacketHasTerminator) { + // FIXME: This drops debug info for spills in terminator bundles; + // DBG_VALUE instructions can't be inserted after the bundle. + // It may be possible to insert the DBG_VALUE elsewhere. + I = BEnd; + continue; + } + auto FirstOp = (BStart->isBundle()) ? std::next(BStart) : BStart; + for (auto BI = FirstOp; BI != BEnd; ++BI) { + if (BI->isTerminator()) + continue; + process(*BI, OpenRanges, VarLocIDs, Transfers, EntryValTransfers, + RegSetInstrs); + } + I = BEnd; + } OLChanged |= transferTerminator(MBB, OpenRanges, OutLocs, VarLocIDs); LLVM_DEBUG(printVarLocInMBB(MF, OutLocs, VarLocIDs, diff --git a/llvm/test/CodeGen/Hexagon/livedebugvalues-bundle-terminator.mir b/llvm/test/CodeGen/Hexagon/livedebugvalues-bundle-terminator.mir new file mode 100644 index 0000000000000..4bc3541d949dc --- /dev/null +++ b/llvm/test/CodeGen/Hexagon/livedebugvalues-bundle-terminator.mir @@ -0,0 +1,38 @@ +# RUN: llc -march=hexagon -run-pass=livedebugvalues -verify-machineinstrs %s -o - | FileCheck %s +# CHECK: BUNDLE +--- | + + define void @foo() !dbg !5 { + ret void + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4} + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) + !1 = !DIFile(filename: "t.c", directory: "/") + !3 = !{i32 2, !"Debug Info Version", i32 3} + !4 = !{i32 1, !"PIC Level", i32 2} + !5 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !6, isDefinition: true, unit: !0) + !6 = !DISubroutineType(types: !7) + !7 = !{null} + !8 = !DILocalVariable(name: "x", scope: !5, file: !1, line: 1, type: !9) + !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !10 = !DILocation(line: 1, column: 1, scope: !5) + +... +--- +name: foo +tracksRegLiveness: true +stack: + - { id: 0, type: spill-slot, size: 4, alignment: 4 } +body: | + bb.0: + liveins: $r29, $r31 + + DBG_VALUE $r29, $noreg, !8, !DIExpression(), debug-location !10 + + BUNDLE implicit-def $pc, implicit killed $r29, implicit $r31, debug-location !10 :: (store (s32) into %stack.0) { + S2_storeri_io %stack.0, 0, killed $r29 :: (store (s32) into %stack.0) + PS_jmpret $r31, implicit-def $pc + } +... `````````` </details> https://github.com/llvm/llvm-project/pull/178679 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
