[llvm] [SandboxIR] Fix pass pipeline parsing after aux arguments (PR #207237)
Anshil Gandhi via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 2 10:22:56 PDT 2026
https://github.com/gandhi56 created https://github.com/llvm/llvm-project/pull/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)
>From 178b3f6520c4a5d0a82314c272c65146b18cf0ba Mon Sep 17 00:00:00 2001
From: Anshil Gandhi <Anshil.Gandhi at amd.com>
Date: Thu, 2 Jul 2026 13:22:06 -0400
Subject: [PATCH] [SandboxIR] Fix pass pipeline parsing after aux arguments
After parsing a pass aux argument, resume scanning pass names instead of
args when the next token is a delimiter. This allows flat pipelines like
foo(aux),bar to be parsed correctly.
Co-authored-by: Cursor <cursoragent at cursor.com>
---
llvm/include/llvm/SandboxIR/PassManager.h | 6 +++++-
llvm/unittests/SandboxIR/PassTest.cpp | 16 ++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/SandboxIR/PassManager.h b/llvm/include/llvm/SandboxIR/PassManager.h
index 5b9b4d0562e6d..dc56aba5adfdc 100644
--- a/llvm/include/llvm/SandboxIR/PassManager.h
+++ b/llvm/include/llvm/SandboxIR/PassManager.h
@@ -237,7 +237,11 @@ class PassManager : public ParentPass {
case State::AuxArgsEnded:
if (C == EndToken || C == PassDelimToken) {
AddPass(PassName, StringRef(), AuxArg);
- CurrentState = State::ScanArgs;
+ if (C == PassDelimToken) {
+ 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