[llvm] c35cba4 - [SandboxIR] Fix pass pipeline parsing after aux arguments (#207237)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 6 09:55:52 PDT 2026
Author: Anshil Gandhi
Date: 2026-07-06T12:55:47-04:00
New Revision: c35cba42e67284a1b6b8609f20782f6d8c692a6c
URL: https://github.com/llvm/llvm-project/commit/c35cba42e67284a1b6b8609f20782f6d8c692a6c
DIFF: https://github.com/llvm/llvm-project/commit/c35cba42e67284a1b6b8609f20782f6d8c692a6c.diff
LOG: [SandboxIR] Fix pass pipeline parsing after aux arguments (#207237)
## Summary
- Fix `sandboxir::PassManager::setPassPipeline` to resume scanning pass
names after a pass aux argument when the next token is a delimiter.
- Add a unit test covering flat pipelines like `foo(aux1),bar`.
This fixes parsing of region pass pipelines such as
`bottom-up-vec(top-down),tr-accept` that will be used by the
SandboxVectorizer.
## Test plan
- [x] `ninja SandboxIRTests`
- [x] `./unittests/SandboxIR/SandboxIRTests
--gtest_filter=PassTest.SetPassPipeline`
Made with [Cursor](https://cursor.com)
Co-authored-by: Cursor <cursoragent at cursor.com>
Added:
Modified:
llvm/include/llvm/SandboxIR/PassManager.h
llvm/unittests/SandboxIR/PassTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/SandboxIR/PassManager.h b/llvm/include/llvm/SandboxIR/PassManager.h
index 5b9b4d0562e6d..057f61096e4ce 100644
--- a/llvm/include/llvm/SandboxIR/PassManager.h
+++ b/llvm/include/llvm/SandboxIR/PassManager.h
@@ -235,9 +235,14 @@ class PassManager : public ParentPass {
}
break;
case State::AuxArgsEnded:
- if (C == EndToken || C == PassDelimToken) {
+ if (C == EndToken) {
AddPass(PassName, StringRef(), AuxArg);
- CurrentState = State::ScanArgs;
+ CurrentState = State::ScanName;
+ } else if (C == PassDelimToken) {
+ AddPass(PassName, StringRef(), AuxArg);
+ PassBeginIdx = Idx + 1;
+ AuxArg = StringRef();
+ CurrentState = State::ScanName;
} else if (C == BeginArgsToken) {
++NestedArgs;
ArgsBeginIdx = Idx + 1;
diff --git a/llvm/unittests/SandboxIR/PassTest.cpp b/llvm/unittests/SandboxIR/PassTest.cpp
index 4707137645430..f0931ad66468e 100644
--- a/llvm/unittests/SandboxIR/PassTest.cpp
+++ b/llvm/unittests/SandboxIR/PassTest.cpp
@@ -323,6 +323,22 @@ define void @f() {
EXPECT_EQ(Str,
"foo(aux1)<abc>bar<nested1(aux2)<nested2<nested3()>>>foo(aux3)<>");
+ // A pass with an aux argument followed by another pass in a flat pipeline.
+ std::string AuxArgStr;
+ auto CreatePassWithAuxArg =
+ [&AuxArgStr](llvm::StringRef Name, llvm::StringRef Args,
+ llvm::StringRef AuxArg) -> std::unique_ptr<FunctionPass> {
+ if (Name == "foo")
+ return std::make_unique<FooPass>(AuxArgStr, Args, AuxArg);
+ if (Name == "bar")
+ return std::make_unique<BarPass>(AuxArgStr, Args, AuxArg);
+ return nullptr;
+ };
+ FunctionPassManager FPMWithAuxArg("test-fpm");
+ FPMWithAuxArg.setPassPipeline("foo(aux1),bar", CreatePassWithAuxArg);
+ FPMWithAuxArg.runOnFunction(*F, Analyses::emptyForTesting());
+ EXPECT_EQ(AuxArgStr, "foo(aux1)<>bar<>");
+
// A second call to setPassPipeline will trigger an assertion in debug mode.
#ifndef NDEBUG
EXPECT_DEATH(FPM.setPassPipeline("bar,bar,foo", CreatePass),
More information about the llvm-commits
mailing list