Skip to content

Commit a5bbfcf

Browse files
[GlobalISel] Avoid repeated hash lookups (NFC) (#129653)
1 parent 2127af8 commit a5bbfcf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ ArrayRef<Register> IRTranslator::getOrCreateVRegs(const Value &Val) {
252252
}
253253

254254
int IRTranslator::getOrCreateFrameIndex(const AllocaInst &AI) {
255-
auto MapEntry = FrameIndices.find(&AI);
256-
if (MapEntry != FrameIndices.end())
255+
auto [MapEntry, Inserted] = FrameIndices.try_emplace(&AI);
256+
if (!Inserted)
257257
return MapEntry->second;
258258

259259
uint64_t ElementSize = DL->getTypeAllocSize(AI.getAllocatedType());
@@ -263,7 +263,7 @@ int IRTranslator::getOrCreateFrameIndex(const AllocaInst &AI) {
263263
// Always allocate at least one byte.
264264
Size = std::max<uint64_t>(Size, 1u);
265265

266-
int &FI = FrameIndices[&AI];
266+
int &FI = MapEntry->second;
267267
FI = MF->getFrameInfo().CreateStackObject(Size, AI.getAlign(), false, &AI);
268268
return FI;
269269
}

0 commit comments

Comments
 (0)