Skip to content

Drive profile validator from opt #147418

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

Draft
wants to merge 1 commit into
base: users/mtrofin/06-30-_pgo_profile_validation
Choose a base branch
from
Draft
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
8 changes: 6 additions & 2 deletions llvm/tools/opt/NewPMDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
#include "llvm/Transforms/Scalar/LoopPassManager.h"
#include "llvm/Transforms/Utils/Debugify.h"
#include "llvm/Transforms/Utils/ProfileValidation.h"

using namespace llvm;
using namespace opt_tool;
Expand Down Expand Up @@ -356,7 +357,7 @@ bool llvm::runPassPipeline(
OutputKind OK, VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
bool UnifiedLTO) {
bool EnableProfcheck, bool UnifiedLTO) {
auto FS = vfs::getRealFileSystem();
std::optional<PGOOptions> P;
switch (PGOKindFlag) {
Expand Down Expand Up @@ -487,7 +488,8 @@ bool llvm::runPassPipeline(
if (VerifyDIPreserve)
MPM.addPass(NewPMDebugifyPass(DebugifyMode::OriginalDebugInfo, "",
&DebugInfoBeforePass));

if (EnableProfcheck)
MPM.addPass(createModuleToFunctionPassAdaptor(ProfileInjectorPass()));
// Add passes according to the -passes options.
if (!PassPipeline.empty()) {
if (auto Err = PB.parsePassPipeline(MPM, PassPipeline)) {
Expand All @@ -504,6 +506,8 @@ bool llvm::runPassPipeline(
MPM.addPass(NewPMCheckDebugifyPass(
false, "", nullptr, DebugifyMode::OriginalDebugInfo,
&DebugInfoBeforePass, VerifyDIPreserveExport));
if (EnableProfcheck)
MPM.addPass(createModuleToFunctionPassAdaptor(ProfileVerifierPass()));

// Add any relevant output pass at the end of the pipeline.
switch (OK) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/opt/NewPMDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ bool runPassPipeline(
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
bool UnifiedLTO = false);
bool EnableProfcheck, bool UnifiedLTO = false);
} // namespace llvm

#endif
7 changes: 6 additions & 1 deletion llvm/tools/opt/optdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ static cl::opt<bool> VerifyDebugInfoPreserve(
cl::desc("Start the pipeline with collecting and end it with checking of "
"debug info preservation."));

static cl::opt<bool> EnableProfileVerification(
"enable-profcheck", cl::init(false),
cl::desc("Start the pipeline with prof-inject and end it with prof-check"));

static cl::opt<std::string> ClDataLayout("data-layout",
cl::desc("data layout string to use"),
cl::value_desc("layout-string"),
Expand Down Expand Up @@ -731,7 +735,8 @@ extern "C" int optMain(
RemarksFile.get(), Pipeline, PluginList, PassBuilderCallbacks,
OK, VK, PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash,
EnableDebugify, VerifyDebugInfoPreserve, UnifiedLTO)
EnableDebugify, VerifyDebugInfoPreserve,
EnableProfileVerification, UnifiedLTO)
? 0
: 1;
}
Expand Down
Loading