Skip to content

[BOLT][NFC] Return Error from BinaryFunctionPass::runOnFunctions #81521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/ADRRelaxationPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ADRRelaxationPass : public BinaryFunctionPass {
const char *getName() const override { return "adr-relaxation"; }

/// Pass entry point
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
void runOnFunction(BinaryFunction &BF);
};

Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/Aligner.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AlignerPass : public BinaryFunctionPass {
const char *getName() const override { return "aligner"; }

/// Pass entry point
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/AllocCombiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AllocCombinerPass : public BinaryFunctionPass {
}

/// Pass entry point
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/AsmDump.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AsmDumpPass : public BinaryFunctionPass {
bool shouldPrint(const BinaryFunction &BF) const override { return false; }

/// Pass entry point
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
45 changes: 23 additions & 22 deletions bolt/include/bolt/Passes/BinaryPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class BinaryFunctionPass {
virtual bool shouldPrint(const BinaryFunction &BF) const;

/// Execute this pass on the given functions.
virtual void runOnFunctions(BinaryContext &BC) = 0;
virtual Error runOnFunctions(BinaryContext &BC) = 0;
};

/// A pass to print program-wide dynostats.
Expand All @@ -70,7 +70,7 @@ class DynoStatsPrintPass : public BinaryFunctionPass {

bool shouldPrint(const BinaryFunction &BF) const override { return false; }

void runOnFunctions(BinaryContext &BC) override {
Error runOnFunctions(BinaryContext &BC) override {
const DynoStats NewDynoStats =
getDynoStats(BC.getBinaryFunctions(), BC.isAArch64());
const bool Changed = (NewDynoStats != PrevDynoStats);
Expand All @@ -82,6 +82,7 @@ class DynoStatsPrintPass : public BinaryFunctionPass {
NewDynoStats.print(outs(), &PrevDynoStats, BC.InstPrinter.get());
}
outs() << '\n';
return Error::success();
}
};

Expand All @@ -100,7 +101,7 @@ class NormalizeCFG : public BinaryFunctionPass {

const char *getName() const override { return "normalize CFG"; }

void runOnFunctions(BinaryContext &) override;
Error runOnFunctions(BinaryContext &) override;
};

/// Detect and eliminate unreachable basic blocks. We could have those
Expand All @@ -119,7 +120,7 @@ class EliminateUnreachableBlocks : public BinaryFunctionPass {
bool shouldPrint(const BinaryFunction &BF) const override {
return BinaryFunctionPass::shouldPrint(BF) && Modified.count(&BF) > 0;
}
void runOnFunctions(BinaryContext &) override;
Error runOnFunctions(BinaryContext &) override;
};

// Reorder the basic blocks for each function based on hotness.
Expand Down Expand Up @@ -165,7 +166,7 @@ class ReorderBasicBlocks : public BinaryFunctionPass {

const char *getName() const override { return "reorder-blocks"; }
bool shouldPrint(const BinaryFunction &BF) const override;
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Sync local branches with CFG.
Expand All @@ -175,7 +176,7 @@ class FixupBranches : public BinaryFunctionPass {
: BinaryFunctionPass(PrintPass) {}

const char *getName() const override { return "fix-branches"; }
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Fix the CFI state and exception handling information after all other
Expand All @@ -186,7 +187,7 @@ class FinalizeFunctions : public BinaryFunctionPass {
: BinaryFunctionPass(PrintPass) {}

const char *getName() const override { return "finalize-functions"; }
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Perform any necessary adjustments for functions that do not fit into their
Expand All @@ -198,7 +199,7 @@ class CheckLargeFunctions : public BinaryFunctionPass {

const char *getName() const override { return "check-large-functions"; }

void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;

bool shouldOptimize(const BinaryFunction &BF) const override;
};
Expand All @@ -210,7 +211,7 @@ class LowerAnnotations : public BinaryFunctionPass {
: BinaryFunctionPass(PrintPass) {}

const char *getName() const override { return "lower-annotations"; }
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Clean the state of the MC representation before sending it to emission
Expand All @@ -220,7 +221,7 @@ class CleanMCState : public BinaryFunctionPass {
: BinaryFunctionPass(PrintPass) {}

const char *getName() const override { return "clean-mc-state"; }
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// An optimization to simplify conditional tail calls by removing
Expand Down Expand Up @@ -292,7 +293,7 @@ class SimplifyConditionalTailCalls : public BinaryFunctionPass {
bool shouldPrint(const BinaryFunction &BF) const override {
return BinaryFunctionPass::shouldPrint(BF) && Modified.count(&BF) > 0;
}
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Convert instructions to the form with the minimum operand width.
Expand All @@ -305,7 +306,7 @@ class ShortenInstructions : public BinaryFunctionPass {

const char *getName() const override { return "shorten-instructions"; }

void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Perform simple peephole optimizations.
Expand Down Expand Up @@ -339,7 +340,7 @@ class Peepholes : public BinaryFunctionPass {
: BinaryFunctionPass(PrintPass) {}

const char *getName() const override { return "peepholes"; }
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// An optimization to simplify loads from read-only sections.The pass converts
Expand Down Expand Up @@ -370,7 +371,7 @@ class SimplifyRODataLoads : public BinaryFunctionPass {
bool shouldPrint(const BinaryFunction &BF) const override {
return BinaryFunctionPass::shouldPrint(BF) && Modified.count(&BF) > 0;
}
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Assign output sections to all functions.
Expand All @@ -379,7 +380,7 @@ class AssignSections : public BinaryFunctionPass {
explicit AssignSections() : BinaryFunctionPass(false) {}

const char *getName() const override { return "assign-sections"; }
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Compute and report to the user the imbalance in flow equations for all
Expand All @@ -394,7 +395,7 @@ class PrintProfileStats : public BinaryFunctionPass {

const char *getName() const override { return "profile-stats"; }
bool shouldPrint(const BinaryFunction &) const override { return false; }
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Prints a list of the top 100 functions sorted by a set of
Expand All @@ -406,7 +407,7 @@ class PrintProgramStats : public BinaryFunctionPass {

const char *getName() const override { return "print-stats"; }
bool shouldPrint(const BinaryFunction &) const override { return false; }
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Pass for lowering any instructions that we have raised and that have
Expand All @@ -418,7 +419,7 @@ class InstructionLowering : public BinaryFunctionPass {

const char *getName() const override { return "inst-lowering"; }

void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Pass for stripping 'repz' from 'repz retq' sequence of instructions.
Expand All @@ -429,7 +430,7 @@ class StripRepRet : public BinaryFunctionPass {

const char *getName() const override { return "strip-rep-ret"; }

void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Pass for inlining calls to memcpy using 'rep movsb' on X86.
Expand All @@ -440,7 +441,7 @@ class InlineMemcpy : public BinaryFunctionPass {

const char *getName() const override { return "inline-memcpy"; }

void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Pass for specializing memcpy for a size of 1 byte.
Expand All @@ -461,7 +462,7 @@ class SpecializeMemcpy1 : public BinaryFunctionPass {

const char *getName() const override { return "specialize-memcpy"; }

void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

/// Pass to remove nops in code
Expand All @@ -475,7 +476,7 @@ class RemoveNops : public BinaryFunctionPass {
const char *getName() const override { return "remove-nops"; }

/// Pass entry point
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

enum FrameOptimizationType : char {
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/CMOVConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CMOVConversion : public BinaryFunctionPass {

const char *getName() const override { return "CMOV conversion"; }

void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/FixRISCVCallsPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FixRISCVCallsPass : public BinaryFunctionPass {
const char *getName() const override { return "fix-riscv-calls"; }

/// Pass entry point
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/FixRelaxationPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FixRelaxations : public BinaryFunctionPass {
const char *getName() const override { return "fix-relaxations"; }

/// Pass entry point
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/FrameOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class FrameOptimizerPass : public BinaryFunctionPass {
const char *getName() const override { return "frame-optimizer"; }

/// Pass entry point
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;

bool shouldPrint(const BinaryFunction &BF) const override {
return BinaryFunctionPass::shouldPrint(BF) && FuncsChanged.count(&BF) > 0;
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/Hugify.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HugePage : public BinaryFunctionPass {
public:
HugePage(const cl::opt<bool> &PrintPass) : BinaryFunctionPass(PrintPass) {}

void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;

const char *getName() const override { return "HugePage"; }
};
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/IdenticalCodeFolding.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class IdenticalCodeFolding : public BinaryFunctionPass {
: BinaryFunctionPass(PrintPass) {}

const char *getName() const override { return "identical-code-folding"; }
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/IndirectCallPromotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class IndirectCallPromotion : public BinaryFunctionPass {
return BF.isSimple() && !BF.isIgnored() && BF.hasProfile() &&
!BF.hasUnknownControlFlow();
}
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/Inliner.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Inliner : public BinaryFunctionPass {
return BinaryFunctionPass::shouldPrint(BF) && Modified.count(&BF) > 0;
}

void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/Instrumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Instrumentation : public BinaryFunctionPass {
Summary(std::make_unique<InstrumentationSummary>()) {}

/// Modifies all functions by inserting instrumentation code (first step)
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;

const char *getName() const override { return "instrumentation"; }

Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/JTFootprintReduction.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class JTFootprintReduction : public BinaryFunctionPass {
bool shouldPrint(const BinaryFunction &BF) const override {
return BinaryFunctionPass::shouldPrint(BF) && Modified.count(&BF) > 0;
}
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/LongJmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class LongJmpPass : public BinaryFunctionPass {

const char *getName() const override { return "long-jmp"; }

void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};
} // namespace bolt
} // namespace llvm
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/LoopInversionPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LoopInversionPass : public BinaryFunctionPass {
const char *getName() const override { return "loop-inversion-opt"; }

/// Pass entry point
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
bool runOnFunction(BinaryFunction &Function);
};

Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/PLTCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PLTCall : public BinaryFunctionPass {
bool shouldPrint(const BinaryFunction &BF) const override {
return BinaryFunctionPass::shouldPrint(BF);
}
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/PatchEntries.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PatchEntries : public BinaryFunctionPass {
explicit PatchEntries() : BinaryFunctionPass(false) {}

const char *getName() const override { return "patch-entries"; }
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/RegReAssign.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class RegReAssign : public BinaryFunctionPass {
return BinaryFunctionPass::shouldPrint(BF) && FuncsChanged.count(&BF) > 0;
}

void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};
} // namespace bolt
} // namespace llvm
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/ReorderData.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ReorderData : public BinaryFunctionPass {

const char *getName() const override { return "reorder-data"; }

void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
};

} // namespace bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/ReorderFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ReorderFunctions : public BinaryFunctionPass {
: BinaryFunctionPass(PrintPass) {}

const char *getName() const override { return "reorder-functions"; }
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;

static std::vector<std::string> readFunctionOrderFile();
};
Expand Down
Loading