Skip to content

[mlir] Simplify calls to *Map::{insert,try_emplace} (NFC) #143729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions mlir/lib/IR/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,7 @@ template <typename T, typename... PrintArgs>
std::pair<size_t, size_t> AliasInitializer::visitImpl(
T value, llvm::MapVector<const void *, InProgressAliasInfo> &aliases,
bool canBeDeferred, PrintArgs &&...printArgs) {
auto [it, inserted] =
aliases.insert({value.getAsOpaquePointer(), InProgressAliasInfo()});
auto [it, inserted] = aliases.try_emplace(value.getAsOpaquePointer());
size_t aliasIndex = std::distance(aliases.begin(), it);
if (!inserted) {
// Make sure that the alias isn't deferred if we don't permit it.
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/IR/SymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ void SymbolUserMap::replaceAllUsesWith(Operation *symbol,
if (newSymbol != symbol) {
// Transfer over the users to the new symbol. The reference to the old one
// is fetched again as the iterator is invalidated during the insertion.
auto newIt = symbolToUsers.try_emplace(newSymbol, SetVector<Operation *>{});
auto newIt = symbolToUsers.try_emplace(newSymbol);
auto oldIt = symbolToUsers.find(symbol);
assert(oldIt != symbolToUsers.end() && "missing old users list");
if (newIt.second)
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Transforms/Utils/CFGToSCF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ transformToReduceLoop(Block *loopHeader, Block *exitBlock,
llvm::SmallDenseMap<Block *, bool> dominanceCache;
// Returns true if `loopBlock` dominates `block`.
auto loopBlockDominates = [&](Block *block) {
auto [iter, inserted] = dominanceCache.insert({block, false});
auto [iter, inserted] = dominanceCache.try_emplace(block);
if (!inserted)
return iter->second;
iter->second = dominanceInfo.dominates(loopBlock, block);
Expand Down
Loading