Skip to content

Commit 43c35e8

Browse files
[mlir] Simplify calls to *Map::{insert,try_emplace} (NFC) (#143729)
This patch simplifies code by removing the values from insert/try_emplace. Note that default values inserted by try_emplace are immediately overrideen in all these cases.
1 parent 8da1ac9 commit 43c35e8

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

mlir/lib/IR/AsmPrinter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,8 +1146,7 @@ template <typename T, typename... PrintArgs>
11461146
std::pair<size_t, size_t> AliasInitializer::visitImpl(
11471147
T value, llvm::MapVector<const void *, InProgressAliasInfo> &aliases,
11481148
bool canBeDeferred, PrintArgs &&...printArgs) {
1149-
auto [it, inserted] =
1150-
aliases.insert({value.getAsOpaquePointer(), InProgressAliasInfo()});
1149+
auto [it, inserted] = aliases.try_emplace(value.getAsOpaquePointer());
11511150
size_t aliasIndex = std::distance(aliases.begin(), it);
11521151
if (!inserted) {
11531152
// Make sure that the alias isn't deferred if we don't permit it.

mlir/lib/IR/SymbolTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ void SymbolUserMap::replaceAllUsesWith(Operation *symbol,
11001100
if (newSymbol != symbol) {
11011101
// Transfer over the users to the new symbol. The reference to the old one
11021102
// is fetched again as the iterator is invalidated during the insertion.
1103-
auto newIt = symbolToUsers.try_emplace(newSymbol, SetVector<Operation *>{});
1103+
auto newIt = symbolToUsers.try_emplace(newSymbol);
11041104
auto oldIt = symbolToUsers.find(symbol);
11051105
assert(oldIt != symbolToUsers.end() && "missing old users list");
11061106
if (newIt.second)

mlir/lib/Transforms/Utils/CFGToSCF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ transformToReduceLoop(Block *loopHeader, Block *exitBlock,
709709
llvm::SmallDenseMap<Block *, bool> dominanceCache;
710710
// Returns true if `loopBlock` dominates `block`.
711711
auto loopBlockDominates = [&](Block *block) {
712-
auto [iter, inserted] = dominanceCache.insert({block, false});
712+
auto [iter, inserted] = dominanceCache.try_emplace(block);
713713
if (!inserted)
714714
return iter->second;
715715
iter->second = dominanceInfo.dominates(loopBlock, block);

0 commit comments

Comments
 (0)