[llvm] [AsmParser] Simplify code with std::map::operator[] (NFC) (PR #111480)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 22:04:46 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111480
None
>From dfcb527eac43e0f2edf04c01104fed35ce675983 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 7 Oct 2024 21:53:32 -0700
Subject: [PATCH] [AsmParser] Simplify code with std::map::operator[] (NFC)
---
llvm/lib/AsmParser/LLParser.cpp | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 6450d8b109063a..9f2ef2e6a9311e 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -4000,11 +4000,7 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
if (!F) {
// Make a global variable as a placeholder for this reference.
GlobalValue *&FwdRef =
- ForwardRefBlockAddresses.insert(std::make_pair(
- std::move(Fn),
- std::map<ValID, GlobalValue *>()))
- .first->second.insert(std::make_pair(std::move(Label), nullptr))
- .first->second;
+ ForwardRefBlockAddresses[std::move(Fn)][std::move(Label)];
if (!FwdRef) {
unsigned FwdDeclAS;
if (ExpectedTy) {
@@ -4082,7 +4078,7 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
auto &FwdRefMap = (Fn.Kind == ValID::t_GlobalID)
? ForwardRefDSOLocalEquivalentIDs
: ForwardRefDSOLocalEquivalentNames;
- GlobalValue *&FwdRef = FwdRefMap.try_emplace(Fn, nullptr).first->second;
+ GlobalValue *&FwdRef = FwdRefMap[Fn];
if (!FwdRef) {
FwdRef = new GlobalVariable(*M, Type::getInt8Ty(Context), false,
GlobalValue::InternalLinkage, nullptr, "",
More information about the llvm-commits
mailing list