Skip to content

Commit 68b69f5

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 3cc01e9 commit 68b69f5

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
@@ -107,9 +107,10 @@ static std::optional<DestSourcePair> isCopyInstr(const MachineInstr &MI,
107107

108108
class CopyTracker {
109109
struct CopyInfo {
110-
MachineInstr *MI, *LastSeenUseInCopy;
110+
MachineInstr *MI = nullptr;
111+
MachineInstr *LastSeenUseInCopy = nullptr;
111112
SmallVector<MCRegister, 4> DefRegs;
112-
bool Avail;
113+
bool Avail = false;
113114
};
114115

115116
DenseMap<MCRegister, CopyInfo> Copies;
@@ -198,8 +199,7 @@ class CopyTracker {
198199
// Remember source that's copied to Def. Once it's clobbered, then
199200
// it's no longer available for copy propagation.
200201
for (MCRegUnit Unit : TRI.regunits(Src)) {
201-
auto I = Copies.insert({Unit, {nullptr, nullptr, {}, false}});
202-
auto &Copy = I.first->second;
202+
auto &Copy = Copies[Unit];
203203
if (!is_contained(Copy.DefRegs, Def))
204204
Copy.DefRegs.push_back(Def);
205205
Copy.LastSeenUseInCopy = MI;

0 commit comments

Comments
 (0)