[llvm] [ThinLTO] Use StringRef instead of std::string (PR #97963)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 7 10:43:27 PDT 2024
https://github.com/luxufan created https://github.com/llvm/llvm-project/pull/97963
Use StringRef instead of std::string as the key of TypeIdCompatibleVtableMap.
>From 3cb74500ea082f929bc2cc6126bc9f0aca1dc270 Mon Sep 17 00:00:00 2001
From: luxufan <luxufan981014 at gmail.com>
Date: Sat, 6 Jul 2024 23:48:26 +0800
Subject: [PATCH] [ThinLTO] Use StringRef instead of std::string
Use StringRef instead of std::string as the key of
TypeIdCompatibleVtableMap.
---
llvm/include/llvm/IR/ModuleSummaryIndex.h | 4 ++--
llvm/lib/AsmParser/LLParser.cpp | 2 +-
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index ecafb0e68fa7a..4cceb6b40ef73 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -1326,7 +1326,7 @@ class ModuleSummaryIndex {
/// with that type identifier's metadata. Produced by per module summary
/// analysis and consumed by thin link. For more information, see description
/// above where TypeIdCompatibleVtableInfo is defined.
- std::map<std::string, TypeIdCompatibleVtableInfo, std::less<>>
+ std::map<StringRef, TypeIdCompatibleVtableInfo, std::less<>>
TypeIdCompatibleVtableMap;
/// Mapping from original ID to GUID. If original ID can map to multiple
@@ -1826,7 +1826,7 @@ class ModuleSummaryIndex {
/// the ThinLTO backends.
TypeIdCompatibleVtableInfo &
getOrInsertTypeIdCompatibleVtableSummary(StringRef TypeId) {
- return TypeIdCompatibleVtableMap[std::string(TypeId)];
+ return TypeIdCompatibleVtableMap[TypeId];
}
/// For the given \p TypeId, this returns the TypeIdCompatibleVtableMap
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 87cd8aac8d035..49880f3518449 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -8818,7 +8818,7 @@ bool LLParser::parseTypeIdCompatibleVtableEntry(unsigned ID) {
return true;
TypeIdCompatibleVtableInfo &TI =
- Index->getOrInsertTypeIdCompatibleVtableSummary(Name);
+ Index->getOrInsertTypeIdCompatibleVtableSummary(Index->saveString(Name));
if (parseToken(lltok::comma, "expected ',' here") ||
parseToken(lltok::kw_summary, "expected 'summary' here") ||
parseToken(lltok::colon, "expected ':' here") ||
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 7a228fb6c08b9..59ae46bafce46 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4133,7 +4133,7 @@ static void writeTypeIdSummaryRecord(SmallVector<uint64_t, 64> &NameVals,
static void writeTypeIdCompatibleVtableSummaryRecord(
SmallVector<uint64_t, 64> &NameVals, StringTableBuilder &StrtabBuilder,
- const std::string &Id, const TypeIdCompatibleVtableInfo &Summary,
+ const StringRef Id, const TypeIdCompatibleVtableInfo &Summary,
ValueEnumerator &VE) {
NameVals.push_back(StrtabBuilder.add(Id));
NameVals.push_back(Id.size());
More information about the llvm-commits
mailing list