[PATCH] D46599: [DbgInfo] Attempt to fix bug 37149
Son Tuan Vu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 8 13:43:28 PDT 2018
tyb0807 created this revision.
tyb0807 added reviewers: aprantl, rob.lougher.
Herald added a subscriber: llvm-commits.
Hello,
This is only for demonstrating my idea. I don't know the LLVM structures really well (yet), so my implementation is quite hackish (make `SlotIndex::getIndex()` public for example). So please tell me:
1, Whether my *idea* and my understanding of the problem are correct,
2, What should be the right way to implement the solution.
Thank you all for your help
Repository:
rL LLVM
https://reviews.llvm.org/D46599
Files:
include/llvm/CodeGen/SlotIndexes.h
lib/CodeGen/LiveDebugVariables.cpp
Index: lib/CodeGen/LiveDebugVariables.cpp
===================================================================
--- lib/CodeGen/LiveDebugVariables.cpp
+++ lib/CodeGen/LiveDebugVariables.cpp
@@ -164,7 +164,7 @@
/// Set of interval start indexes that have been trimmed to the
/// lexical scope.
- SmallSet<SlotIndex, 2> trimmedDefs;
+ SmallDenseMap<unsigned, SlotIndex, 2> trimmedDefs;
/// insertDebugValue - Insert a DBG_VALUE into MBB at Idx for LocNo.
void insertDebugValue(MachineBasicBlock *MBB, SlotIndex StartIdx,
@@ -812,10 +812,10 @@
return;
if (I.start() < RStart) {
+ // Remember that this interval was trimmed.
+ trimmedDefs.insert({RStart.getIndex(), I.start()});
// Interval start overlaps range - trim to the scope range.
I.setStartUnchecked(RStart);
- // Remember that this interval was trimmed.
- trimmedDefs.insert(RStart);
}
// The end of a lexical scope range is the last instruction in the
@@ -1210,8 +1210,9 @@
// If the interval start was trimmed to the lexical scope insert the
// DBG_VALUE at the previous index (otherwise it appears after the
// first instruction in the range).
- if (trimmedDefs.count(Start))
- Start = Start.getPrevIndex();
+ auto trimmedDef = trimmedDefs.find(Start.getIndex());
+ if (trimmedDef != trimmedDefs.end())
+ Start = trimmedDef->second;
DEBUG(dbgs() << "\t[" << Start << ';' << Stop << "):" << Loc.locNo());
MachineFunction::iterator MBB = LIS.getMBBFromIndex(Start)->getIterator();
Index: include/llvm/CodeGen/SlotIndexes.h
===================================================================
--- include/llvm/CodeGen/SlotIndexes.h
+++ include/llvm/CodeGen/SlotIndexes.h
@@ -122,10 +122,6 @@
return lie.getPointer();
}
- unsigned getIndex() const {
- return listEntry()->getIndex() | getSlot();
- }
-
/// Returns the slot for this SlotIndex.
Slot getSlot() const {
return static_cast<Slot>(lie.getInt());
@@ -147,6 +143,10 @@
"Attempt to construct index with 0 pointer.");
}
+ unsigned getIndex() const {
+ return listEntry()->getIndex() | getSlot();
+ }
+
/// Returns true if this is a valid index. Invalid indices do
/// not point into an index table, and cannot be compared.
bool isValid() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46599.145769.patch
Type: text/x-patch
Size: 2367 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180508/f0b17928/attachment.bin>
More information about the llvm-commits
mailing list