Skip to content

Commit 214d47a

Browse files
committed
[SandboxVec][PassManager][NFC] Fix PM printing
It currently prints '(' instead of '<'. This patch fixes it.
1 parent 299cb5d commit 214d47a

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

llvm/include/llvm/SandboxIR/PassManager.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ class PassManager : public ParentPass {
5858
Passes.push_back(std::move(Pass));
5959
}
6060

61+
static constexpr const char EndToken = '\0';
62+
static constexpr const char BeginArgsToken = '<';
63+
static constexpr const char EndArgsToken = '>';
64+
static constexpr const char PassDelimToken = ',';
65+
6166
/// Parses \p Pipeline as a comma-separated sequence of pass names and sets
6267
/// the pass pipeline, using \p CreatePass to instantiate passes by name.
6368
///
@@ -74,11 +79,6 @@ class PassManager : public ParentPass {
7479
/// An empty args string is treated the same as no args, so "pass" and
7580
/// "pass<>" are equivalent.
7681
void setPassPipeline(StringRef Pipeline, CreatePassFunc CreatePass) {
77-
static constexpr const char EndToken = '\0';
78-
static constexpr const char BeginArgsToken = '<';
79-
static constexpr const char EndArgsToken = '>';
80-
static constexpr const char PassDelimToken = ',';
81-
8282
assert(Passes.empty() &&
8383
"setPassPipeline called on a non-empty sandboxir::PassManager");
8484

@@ -183,10 +183,10 @@ class PassManager : public ParentPass {
183183
#ifndef NDEBUG
184184
void print(raw_ostream &OS) const override {
185185
OS << this->getName();
186-
OS << "(";
187-
// TODO: This should call Pass->print(OS) because Pass may be a PM.
188-
interleave(Passes, OS, [&OS](auto &Pass) { OS << Pass->getName(); }, ",");
189-
OS << ")";
186+
OS << BeginArgsToken;
187+
std::string Delim(1, PassDelimToken);
188+
interleave(Passes, OS, [&OS](auto &Pass) { Pass->print(OS); }, Delim);
189+
OS << EndArgsToken;
190190
}
191191
LLVM_DUMP_METHOD void dump() const override {
192192
print(dbgs());

llvm/unittests/SandboxIR/PassTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ define void @foo() {
197197
std::string Buff;
198198
llvm::raw_string_ostream SS(Buff);
199199
FPM.print(SS);
200-
EXPECT_EQ(Buff, "test-fpm(test-pass1,test-pass2)");
200+
EXPECT_EQ(Buff, "test-fpm<test-pass1,test-pass2>");
201201
#endif // NDEBUG
202202
}
203203

@@ -256,7 +256,7 @@ define i8 @foo(i8 %v0, i8 %v1) {
256256
std::string Buff;
257257
llvm::raw_string_ostream SS(Buff);
258258
RPM.print(SS);
259-
EXPECT_EQ(Buff, "test-rpm(test-pass1,test-pass2)");
259+
EXPECT_EQ(Buff, "test-rpm<test-pass1,test-pass2>");
260260
#endif // NDEBUG
261261
}
262262

0 commit comments

Comments
 (0)