[llvm] [CodeGen] Support --print-changed for legacy codegen IR passes (PR #202252)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 9 13:53:08 PDT 2026
================
@@ -137,54 +119,18 @@ bool MachineFunctionPass::runOnFunction(Function &F) {
MFProps.set(SetProperties);
- // For --print-changed, print if the serialized MF has changed. Modes other
- // than quiet/verbose are unimplemented and treated the same as 'quiet'.
- if (ShouldPrintChanged || !IsInterestingPass) {
- if (ShouldPrintChanged) {
- raw_svector_ostream OS(AfterStr);
- MF.print(OS);
- }
- if (IsInterestingPass && BeforeStr != AfterStr) {
- errs() << ("*** IR Dump After " + getPassName() + " (" + PassID +
- ") on " + MF.getName() + " ***\n");
- switch (PrintChanged) {
- case ChangePrinter::None:
- llvm_unreachable("");
- case ChangePrinter::Quiet:
- case ChangePrinter::Verbose:
- case ChangePrinter::DotCfgQuiet: // unimplemented
- case ChangePrinter::DotCfgVerbose: // unimplemented
- errs() << AfterStr;
- break;
- case ChangePrinter::DiffQuiet:
- case ChangePrinter::DiffVerbose:
- case ChangePrinter::ColourDiffQuiet:
- case ChangePrinter::ColourDiffVerbose: {
- bool Color = llvm::is_contained(
- {ChangePrinter::ColourDiffQuiet, ChangePrinter::ColourDiffVerbose},
- PrintChanged.getValue());
- StringRef Removed = Color ? "\033[31m-%l\033[0m\n" : "-%l\n";
- StringRef Added = Color ? "\033[32m+%l\033[0m\n" : "+%l\n";
- StringRef NoChange = " %l\n";
- errs() << doSystemDiff(BeforeStr, AfterStr, Removed, Added, NoChange);
- break;
- }
- }
- } else if (llvm::is_contained({ChangePrinter::Verbose,
- ChangePrinter::DiffVerbose,
- ChangePrinter::ColourDiffVerbose},
- PrintChanged.getValue())) {
- const char *Reason =
- IsInterestingPass ? " omitted because no change" : " filtered out";
- errs() << "*** IR Dump After " << getPassName();
- if (!PassID.empty())
- errs() << " (" << PassID << ")";
- errs() << " on " << MF.getName() + Reason + " ***\n";
- }
- }
return RV;
}
+bool MachineFunctionPass::printIRUnit(raw_ostream &OS, Function &F) {
+ // available_externally functions are not codegen'd (see runOnFunction).
+ if (F.hasAvailableExternallyLinkage())
----------------
aeubanks wrote:
oh MachineFunctionPass inherits from FunctionPass and FPPassManager is the thing calling printIRUnit... that's annoying
https://github.com/llvm/llvm-project/pull/202252
More information about the llvm-commits
mailing list