Skip to content

Commit b9d85b1

Browse files
[CodeGen] Use DenseMap::operator[] (NFC) (#108489)
Once we modernize CopyInfo with default member initializations, Copies.insert({Unit, ...}) becomes equivalent to: Copies.try_emplace(Unit) which we can simplify further down to Copies[Unit].
1 parent 02e4186 commit b9d85b1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/CodeGen/MachineCopyPropagation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ static std::optional<DestSourcePair> isCopyInstr(const MachineInstr &MI,
108108

109109
class CopyTracker {
110110
struct CopyInfo {
111-
MachineInstr *MI, *LastSeenUseInCopy;
111+
MachineInstr *MI = nullptr;
112+
MachineInstr *LastSeenUseInCopy = nullptr;
112113
SmallVector<MCRegister, 4> DefRegs;
113-
bool Avail;
114+
bool Avail = false;
114115
};
115116

116117
DenseMap<MCRegUnit, CopyInfo> Copies;
@@ -240,8 +241,7 @@ class CopyTracker {
240241
// Remember source that's copied to Def. Once it's clobbered, then
241242
// it's no longer available for copy propagation.
242243
for (MCRegUnit Unit : TRI.regunits(Src)) {
243-
auto I = Copies.insert({Unit, {nullptr, nullptr, {}, false}});
244-
auto &Copy = I.first->second;
244+
auto &Copy = Copies[Unit];
245245
if (!is_contained(Copy.DefRegs, Def))
246246
Copy.DefRegs.push_back(Def);
247247
Copy.LastSeenUseInCopy = MI;

0 commit comments

Comments
 (0)