From 58a1aa065abc3a2af143dc1c44f92ec77d836d98 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 17 Apr 2025 21:55:49 -0700 Subject: [PATCH] [llvm] Use llvm::interleaved (NFC) --- llvm/lib/Analysis/ScalarEvolution.cpp | 9 ++++----- llvm/lib/Transforms/IPO/AttributorAttributes.cpp | 8 ++------ llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp | 7 ++----- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 471c71f75eb23..6055c3d791cb2 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -116,6 +116,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/InterleavedRange.h" #include "llvm/Support/KnownBits.h" #include "llvm/Support/SaveAndRestore.h" #include "llvm/Support/raw_ostream.h" @@ -349,11 +350,9 @@ void SCEV::print(raw_ostream &OS) const { default: llvm_unreachable("There are no other nary expression types."); } - OS << "("; - ListSeparator LS(OpStr); - for (const SCEV *Op : NAry->operands()) - OS << LS << *Op; - OS << ")"; + OS << "(" + << llvm::interleaved(llvm::make_pointee_range(NAry->operands()), OpStr) + << ")"; switch (NAry->getSCEVType()) { case scAddExpr: case scMulExpr: diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 1032dede7cb36..a72c1d329e199 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -63,6 +63,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/GraphWriter.h" +#include "llvm/Support/InterleavedRange.h" #include "llvm/Support/KnownFPClass.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/TypeSize.h" @@ -1012,12 +1013,7 @@ namespace { #ifndef NDEBUG static raw_ostream &operator<<(raw_ostream &OS, const AAPointerInfo::OffsetInfo &OI) { - ListSeparator LS; - OS << "["; - for (auto Offset : OI) { - OS << LS << Offset; - } - OS << "]"; + OS << llvm::interleaved_array(OI); return OS; } #endif // NDEBUG diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp index 207e86b22db1d..0d299b8402cdf 100644 --- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp +++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp @@ -39,6 +39,7 @@ #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/GraphWriter.h" +#include "llvm/Support/InterleavedRange.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Utils/CallPromotionUtils.h" @@ -2955,11 +2956,7 @@ void CallsiteContextGraph::ContextNode::print( for (auto &Edge : CallerEdges) OS << "\t\t" << *Edge << "\n"; if (!Clones.empty()) { - OS << "\tClones: "; - ListSeparator LS; - for (auto *Clone : Clones) - OS << LS << Clone; - OS << "\n"; + OS << "\tClones: " << llvm::interleaved(Clones) << "\n"; } else if (CloneOf) { OS << "\tClone of " << CloneOf << "\n"; }