[llvm] [SandboxVectorizer] Use sbvec-passes flag to create a pipeline of Region passes after BottomUpVec. (PR #111223)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 8 17:14:47 PDT 2024
================
@@ -255,3 +255,58 @@ define i8 @foo(i8 %v0, i8 %v1) {
EXPECT_EQ(Buff, "test-rpm(test-pass1,test-pass2)");
#endif // NDEBUG
}
+
+TEST_F(PassTest, SetPassPipeline) {
+ auto *F = parseFunction(R"IR(
+define void @f() {
+ ret void
+}
+)IR",
+ "f");
+ class FooPass final : public FunctionPass {
+ std::string &Str;
+
+ public:
+ FooPass(std::string &Str) : FunctionPass("foo-pass"), Str(Str) {}
+ bool runOnFunction(Function &F) final {
+ Str += "foo";
+ return false;
+ }
+ };
+ class BarPass final : public FunctionPass {
+ std::string &Str;
+
+ public:
+ BarPass(std::string &Str) : FunctionPass("bar-pass"), Str(Str) {}
+ bool runOnFunction(Function &F) final {
+ Str += "bar";
+ return false;
+ }
+ };
+
+ std::string Str;
+ auto CreatePass =
+ [&Str](llvm::StringRef Name) -> std::unique_ptr<FunctionPass> {
+ if (Name == "foo")
+ return std::make_unique<FooPass>(Str);
+ if (Name == "bar")
+ return std::make_unique<BarPass>(Str);
+ return nullptr;
+ };
+
+ FunctionPassManager FPM("test-fpm");
+ FPM.setPassPipeline("foo,bar,foo", CreatePass);
+ FPM.runOnFunction(*F);
+ EXPECT_EQ(Str, "foobarfoo");
+
+ // Check that a second call to setPassPipeline clears the previous pipeline.
----------------
vporpo wrote:
Should we allow a second call to setPassPipeline() ? Shouldn't we crash if we try to do so instead?
https://github.com/llvm/llvm-project/pull/111223
More information about the llvm-commits
mailing list