Skip to content

[Docs] Update MergeBB usage to New Pass Manager syntax#133

Merged
banach-space merged 1 commit intobanach-space:mainfrom
E00N777:docs/fix-mergebb-readme
Dec 27, 2025
Merged

[Docs] Update MergeBB usage to New Pass Manager syntax#133
banach-space merged 1 commit intobanach-space:mainfrom
E00N777:docs/fix-mergebb-readme

Conversation

@E00N777
Copy link
Copy Markdown
Contributor

@E00N777 E00N777 commented Dec 27, 2025

@banach-space

Summary

The README currently lists the Legacy Pass Manager command (-load, -legacy-merge-bb) for running the MergeBB pass. However, the codebase uses the New Pass Manager registration.

//-----------------------------------------------------------------------------
// New PM Registration
//-----------------------------------------------------------------------------
llvm::PassPluginLibraryInfo getMergeBBPluginInfo() {
  return {LLVM_PLUGIN_API_VERSION, "MergeBB", LLVM_VERSION_STRING,
          [](PassBuilder &PB) {
            PB.registerPipelineParsingCallback(
                [](StringRef Name, FunctionPassManager &FPM,
                   ArrayRef<PassBuilder::PipelineElement>) {
                  if (Name == "merge-bb") {
                    FPM.addPass(MergeBB());
                    return true;
                  }
                  return false;
                });
          }};
}

extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo
llvmGetPassPluginInfo() {
  return getMergeBBPluginInfo();
}

This PR updates the command to use the New PM syntax:

  • Changed -load to -load-pass-plugin
  • Changed -legacy-merge-bb to -passes="merge-bb"

Validation

Verified locally that the new command works with LLVM-21 in ubuntu 22.04

Others

I also noticed something: the readme doesn't seem to mention where foo.ll comes from.
I Verified by duplicate.ll which generated by libduplicateBB.so. in the previous section(duplicateBB) like:

$ opt-21 -load-pass-plugin /home/ubuntu/llvm-tutor-debug/build/lib/libMergeBB.so -passes="merge-bb"  -S ./duplicate_bb.ll  -o duplicate_bb_merge.ll

It worked.
I didn't fixed it in this PR.Perhaps you have some suggestions?

@banach-space banach-space merged commit e1585f5 into banach-space:main Dec 27, 2025
5 of 6 checks passed
@banach-space
Copy link
Copy Markdown
Owner

Thank you!

I didn't fixed it in this PR.Perhaps you have some suggestions?

Feel free to send a PR which updates README with a step to generate an input file.

Thanks for pointing it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants