[PATCH] D118597: [DebugInfo][InstrRef][NFC] Don't build mappings of values to locations for un-needed values
Jeremy Morse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 1 10:58:26 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG91fb66cf91ae: [DebugInfo][InstrRef][NFC] Don't build a map of un-needed values (authored by jmorse).
Changed prior to commit:
https://reviews.llvm.org/D118597?vs=404481&id=405011#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118597/new/
https://reviews.llvm.org/D118597
Files:
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
Index: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
===================================================================
--- llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -274,6 +274,13 @@
// Map of the preferred location for each value.
DenseMap<ValueIDNum, LocIdx> ValueToLoc;
+
+ // Initialized the preferred-location map with illegal locations, to be
+ // filled in later.
+ for (auto &VLoc : VLocs)
+ if (VLoc.second.Kind == DbgValue::Def)
+ ValueToLoc.insert({VLoc.second.ID, LocIdx::MakeIllegalLoc()});
+
ActiveMLocs.reserve(VLocs.size());
ActiveVLocs.reserve(VLocs.size());
@@ -285,21 +292,20 @@
ValueIDNum &VNum = MLocs[Idx.asU64()];
VarLocs.push_back(VNum);
- // Short-circuit unnecessary preferred location update.
- if (VLocs.empty())
+ // Is there a variable that wants a location for this value? If not, skip.
+ auto VIt = ValueToLoc.find(VNum);
+ if (VIt == ValueToLoc.end())
continue;
- auto it = ValueToLoc.find(VNum);
+ LocIdx CurLoc = VIt->second;
// In order of preference, pick:
// * Callee saved registers,
// * Other registers,
// * Spill slots.
- if (it == ValueToLoc.end() || MTracker->isSpill(it->second) ||
- (!isCalleeSaved(it->second) && isCalleeSaved(Idx.asU64()))) {
+ if (CurLoc.isIllegal() || MTracker->isSpill(CurLoc) ||
+ (!isCalleeSaved(CurLoc) && isCalleeSaved(Idx.asU64()))) {
// Insert, or overwrite if insertion failed.
- auto PrefLocRes = ValueToLoc.insert(std::make_pair(VNum, Idx));
- if (!PrefLocRes.second)
- PrefLocRes.first->second = Idx;
+ VIt->second = Idx;
}
}
@@ -314,7 +320,7 @@
// If the value has no location, we can't make a variable location.
const ValueIDNum &Num = Var.second.ID;
auto ValuesPreferredLoc = ValueToLoc.find(Num);
- if (ValuesPreferredLoc == ValueToLoc.end()) {
+ if (ValuesPreferredLoc->second.isIllegal()) {
// If it's a def that occurs in this block, register it as a
// use-before-def to be resolved as we step through the block.
if (Num.getBlock() == (unsigned)MBB.getNumber() && !Num.isPHI())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118597.405011.patch
Type: text/x-patch
Size: 2328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220201/ffcfbc09/attachment.bin>
More information about the llvm-commits
mailing list