[llvm] [llvm] Use llvm::interleaved (NFC) (PR #137496)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 26 22:31:37 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/137496.diff
3 Files Affected:
- (modified) llvm/lib/Analysis/ScalarEvolution.cpp (+4-5)
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+2-6)
- (modified) llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp (+2-5)
``````````diff
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<DerivedCCG, FuncTy, CallTy>::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";
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/137496
More information about the llvm-commits
mailing list