diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2018-08-23 05:39:02 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2018-08-23 05:39:02 +0000 |
commit | 8505dcf7459ef6fafe1326ecc1fe6b67d4d95739 (patch) | |
tree | 8425dd63d63f26d86b6f5224849c6d58467a7d4e | |
parent | 8715e034776d8da9d9d9ab844f57f53813b15d2f (diff) | |
download | bcm5719-llvm-8505dcf7459ef6fafe1326ecc1fe6b67d4d95739.tar.gz bcm5719-llvm-8505dcf7459ef6fafe1326ecc1fe6b67d4d95739.zip |
Revert r340508: [DebugInfo] Fix bug in LiveDebugVariables.
This patch's test case relies on debug prints which isn't generally an
OK way to test stuff in LLVM and fails whenever asserts aren't enabled.
I've send a heads-up to the commit and detailed comments on the review.
llvm-svn: 340513
-rw-r--r-- | llvm/include/llvm/CodeGen/SlotIndexes.h | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugVariables.cpp | 15 | ||||
-rw-r--r-- | llvm/test/DebugInfo/Generic/debug-var-slot.ll | 59 |
3 files changed, 5 insertions, 71 deletions
diff --git a/llvm/include/llvm/CodeGen/SlotIndexes.h b/llvm/include/llvm/CodeGen/SlotIndexes.h index bb9c5cb4cfb..334267d9828 100644 --- a/llvm/include/llvm/CodeGen/SlotIndexes.h +++ b/llvm/include/llvm/CodeGen/SlotIndexes.h @@ -414,8 +414,6 @@ class raw_ostream; SlotIndex getInstructionIndex(const MachineInstr &MI) const { // Instructions inside a bundle have the same number as the bundle itself. const MachineInstr &BundleStart = *getBundleStart(MI.getIterator()); - assert(!BundleStart.isDebugInstr() && - "Could not use a debug instruction to query mi2iMap."); Mi2IndexMap::const_iterator itr = mi2iMap.find(&BundleStart); assert(itr != mi2iMap.end() && "Instruction not found in maps."); return itr->second; diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp index 3d934bff25d..3ff03ec4a7e 100644 --- a/llvm/lib/CodeGen/LiveDebugVariables.cpp +++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp @@ -578,28 +578,23 @@ bool LDVImpl::collectDebugValues(MachineFunction &mf) { MachineBasicBlock *MBB = &*MFI; for (MachineBasicBlock::iterator MBBI = MBB->begin(), MBBE = MBB->end(); MBBI != MBBE;) { - // Use the first debug instruction in the sequence to get a SlotIndex - // for following consecutive debug instructions. - if (!MBBI->isDebugInstr()) { + if (!MBBI->isDebugValue()) { ++MBBI; continue; } - // Debug instructions has no slot index. Use the previous - // non-debug instruction's SlotIndex as its SlotIndex. + // DBG_VALUE has no slot index, use the previous instruction instead. SlotIndex Idx = MBBI == MBB->begin() ? LIS->getMBBStartIdx(MBB) : LIS->getInstructionIndex(*std::prev(MBBI)).getRegSlot(); - // Handle consecutive debug instructions with the same slot index. + // Handle consecutive DBG_VALUE instructions with the same slot index. do { - // Only handle DBG_VALUE in handleDebugValue(). Skip all other - // kinds of debug instructions. - if (MBBI->isDebugValue() && handleDebugValue(*MBBI, Idx)) { + if (handleDebugValue(*MBBI, Idx)) { MBBI = MBB->erase(MBBI); Changed = true; } else ++MBBI; - } while (MBBI != MBBE && MBBI->isDebugInstr()); + } while (MBBI != MBBE && MBBI->isDebugValue()); } } return Changed; diff --git a/llvm/test/DebugInfo/Generic/debug-var-slot.ll b/llvm/test/DebugInfo/Generic/debug-var-slot.ll deleted file mode 100644 index bed1d90f6e5..00000000000 --- a/llvm/test/DebugInfo/Generic/debug-var-slot.ll +++ /dev/null @@ -1,59 +0,0 @@ -; After adding new debug instruction for labels, it is possible to have -; debug instructions before DBG_VALUE. When querying DBG_VALUE's slot -; index using previous instruction and the previous instruction is debug -; instruction, it will trigger an assertion as using debug instruction -; to get slot index. This test is to emulate the case when DBG_VALUE's -; previous instruction is DBG_LABEL in LiveDebugVariables pass. -; -; RUN: llc < %s -stop-after=livedebugvars -debug 2>&1 | FileCheck %s -; -; CHECK: COMPUTING LIVE DEBUG VARIABLES: foo -; CHECK: DEBUG VARIABLES -; CHECK-NEXT: "local_var,7" - -source_filename = "debug-var-slot.c" - -define dso_local i32 @foo(i32 %a, i32 %b) !dbg !6 { -entry: - %a.addr = alloca i32, align 4 - %b.addr = alloca i32, align 4 - %sum = alloca i32, align 4 - store i32 %a, i32* %a.addr, align 4 - store i32 %b, i32* %b.addr, align 4 - br label %top - -top: - call void @llvm.dbg.label(metadata !10), !dbg !13 - call void @llvm.dbg.value(metadata i32 %0, metadata !12, metadata !DIExpression()), !dbg !14 - %0 = load i32, i32* %a.addr, align 4 - %1 = load i32, i32* %a.addr, align 4 - %2 = load i32, i32* %b.addr, align 4 - %add = add nsw i32 %1, %2 - store i32 %add, i32* %sum, align 4 - br label %done - -done: - %3 = load i32, i32* %sum, align 4 - ret i32 %3, !dbg !15 -} - -declare void @llvm.dbg.label(metadata) -declare void @llvm.dbg.value(metadata, metadata, metadata) - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!4} - -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: true, emissionKind: FullDebug, enums: !2) -!1 = !DIFile(filename: "debug-var-slot.c", directory: "./") -!2 = !{} -!4 = !{i32 2, !"Debug Info Version", i32 3} -!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: !0, retainedNodes: !2) -!7 = !DISubroutineType(types: !8) -!8 = !{!9, !9, !9} -!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!10 = !DILabel(scope: !6, name: "top", file: !1, line: 4) -!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!12 = !DILocalVariable(name: "local_var", scope: !6, file: !1, line: 7, type: !11) -!13 = !DILocation(line: 4, column: 1, scope: !6) -!14 = !DILocation(line: 7, column: 1, scope: !6) -!15 = !DILocation(line: 8, column: 3, scope: !6) |