[llvm] [memprof] Use ListSeparator (NFC) (PR #120047)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 15 23:26:38 PST 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/120047
ListSeparator from StringExtras.h is essentially the same as
FieldSeparator being removed in this patch. ListSeparator returns the
empty string on the first use via "operator StringRef()". It returns
", " on subsequent uses.
>From 49e8c8616d6c9506019ccfa4e9aaa619e6e0171c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 15 Dec 2024 23:14:22 -0800
Subject: [PATCH] [memprof] Use ListSeparator (NFC)
ListSeparator from StringExtras.h is essentially the same as
FieldSeparator being removed in this patch. ListSeparator returns the
empty string on the first use via "operator StringRef()". It returns
", " on subsequent uses.
---
.../IPO/MemProfContextDisambiguation.cpp | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index ea92c6e2f59e59..a6be24601047f7 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -896,21 +896,6 @@ struct DenseMapInfo<IndexCall>
namespace {
-struct FieldSeparator {
- bool Skip = true;
- const char *Sep;
-
- FieldSeparator(const char *Sep = ", ") : Sep(Sep) {}
-};
-
-raw_ostream &operator<<(raw_ostream &OS, FieldSeparator &FS) {
- if (FS.Skip) {
- FS.Skip = false;
- return OS;
- }
- return OS << FS.Sep;
-}
-
// Map the uint8_t alloc types (which may contain NotCold|Cold) to the alloc
// type we should actually use on the corresponding allocation.
// If we can't clone a node that has NotCold+Cold alloc type, we will fall
@@ -2784,9 +2769,9 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::ContextNode::print(
OS << "\t\t" << *Edge << "\n";
if (!Clones.empty()) {
OS << "\tClones: ";
- FieldSeparator FS;
+ ListSeparator LS;
for (auto *Clone : Clones)
- OS << FS << Clone;
+ OS << LS << Clone;
OS << "\n";
} else if (CloneOf) {
OS << "\tClone of " << CloneOf << "\n";
More information about the llvm-commits
mailing list