[llvm] 3b703d4 - [Bitcode] Use DenseSet instead of std::set (NFC) (#105851)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 23 14:19:53 PDT 2024


Author: Kazu Hirata
Date: 2024-08-23T14:19:48-07:00
New Revision: 3b703d479ff37883242acc20fed317ed8a5466dc

URL: https://github.com/llvm/llvm-project/commit/3b703d479ff37883242acc20fed317ed8a5466dc
DIFF: https://github.com/llvm/llvm-project/commit/3b703d479ff37883242acc20fed317ed8a5466dc.diff

LOG: [Bitcode] Use DenseSet instead of std::set (NFC) (#105851)

DefOrUseGUIDs is used only for membership checking purposes.  We don't
need std::set's strengths like iterators staying valid or the ability
to traverse in a sorted order.

While I am at it, this patch replaces count with contains for slightly
increased readability.

Added: 
    

Modified: 
    llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 03d0537291dada..20737c0812cf86 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4628,7 +4628,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
     NameVals.clear();
   };
 
-  std::set<GlobalValue::GUID> DefOrUseGUIDs;
+  DenseSet<GlobalValue::GUID> DefOrUseGUIDs;
   forEachSummary([&](GVInfo I, bool IsAliasee) {
     GlobalValueSummary *S = I.second;
     assert(S);
@@ -4777,7 +4777,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
 
   if (!Index.cfiFunctionDefs().empty()) {
     for (auto &S : Index.cfiFunctionDefs()) {
-      if (DefOrUseGUIDs.count(
+      if (DefOrUseGUIDs.contains(
               GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(S)))) {
         NameVals.push_back(StrtabBuilder.add(S));
         NameVals.push_back(S.size());
@@ -4791,7 +4791,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
 
   if (!Index.cfiFunctionDecls().empty()) {
     for (auto &S : Index.cfiFunctionDecls()) {
-      if (DefOrUseGUIDs.count(
+      if (DefOrUseGUIDs.contains(
               GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(S)))) {
         NameVals.push_back(StrtabBuilder.add(S));
         NameVals.push_back(S.size());


        


More information about the llvm-commits mailing list