[llvm] [IR] Use llvm::interleaved (NFC) (PR #137482)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 26 17:02:10 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/137482
None
>From d5b75b0c293f22bc2ee3e92de6cdf0269c1a3b41 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 26 Apr 2025 16:21:02 -0700
Subject: [PATCH] [IR] Use llvm::interleaved (NFC)
---
llvm/include/llvm/IR/ModuleSummaryIndex.h | 19 +++----------------
llvm/lib/IR/AsmWriter.cpp | 6 +-----
2 files changed, 4 insertions(+), 21 deletions(-)
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 3f20d40722ca2..7bc7d8550d6df 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -28,6 +28,7 @@
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/Allocator.h"
+#include "llvm/Support/InterleavedRange.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/ScaledNumber.h"
#include "llvm/Support/StringSaver.h"
@@ -342,22 +343,8 @@ struct CallsiteInfo {
inline raw_ostream &operator<<(raw_ostream &OS, const CallsiteInfo &SNI) {
OS << "Callee: " << SNI.Callee;
- bool First = true;
- OS << " Clones: ";
- for (auto V : SNI.Clones) {
- if (!First)
- OS << ", ";
- First = false;
- OS << V;
- }
- First = true;
- OS << " StackIds: ";
- for (auto Id : SNI.StackIdIndices) {
- if (!First)
- OS << ", ";
- First = false;
- OS << Id;
- }
+ OS << " Clones: " << llvm::interleaved(SNI.Clones);
+ OS << " StackIds: " << llvm::interleaved(SNI.StackIdIndices);
return OS;
}
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index ac8aa0d35ea30..8ef953472beb3 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -4996,13 +4996,9 @@ void AssemblyWriter::printUseListOrder(const Value *V,
Out << " ";
writeOperand(V, true);
}
- Out << ", { ";
assert(Shuffle.size() >= 2 && "Shuffle too small");
- Out << Shuffle[0];
- for (unsigned I = 1, E = Shuffle.size(); I != E; ++I)
- Out << ", " << Shuffle[I];
- Out << " }\n";
+ Out << ", { " << llvm::interleaved(Shuffle) << " }\n";
}
void AssemblyWriter::printUseLists(const Function *F) {
More information about the llvm-commits
mailing list