4040#include " llvm/Transforms/Instrumentation/AddressSanitizer.h"
4141#include " llvm/Transforms/Scalar/LoopPassManager.h"
4242#include " llvm/Transforms/Utils/Debugify.h"
43+ #include " llvm/Transforms/Utils/ProfileValidation.h"
4344
4445using namespace llvm ;
4546using namespace opt_tool ;
@@ -356,7 +357,7 @@ bool llvm::runPassPipeline(
356357 OutputKind OK, VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder,
357358 bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
358359 bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
359- bool UnifiedLTO) {
360+ bool EnableProfcheck, bool UnifiedLTO) {
360361 auto FS = vfs::getRealFileSystem ();
361362 std::optional<PGOOptions> P;
362363 switch (PGOKindFlag) {
@@ -487,7 +488,8 @@ bool llvm::runPassPipeline(
487488 if (VerifyDIPreserve)
488489 MPM.addPass (NewPMDebugifyPass (DebugifyMode::OriginalDebugInfo, " " ,
489490 &DebugInfoBeforePass));
490-
491+ if (EnableProfcheck)
492+ MPM.addPass (createModuleToFunctionPassAdaptor (ProfileInjectorPass ()));
491493 // Add passes according to the -passes options.
492494 if (!PassPipeline.empty ()) {
493495 if (auto Err = PB.parsePassPipeline (MPM, PassPipeline)) {
@@ -504,6 +506,8 @@ bool llvm::runPassPipeline(
504506 MPM.addPass (NewPMCheckDebugifyPass (
505507 false , " " , nullptr , DebugifyMode::OriginalDebugInfo,
506508 &DebugInfoBeforePass, VerifyDIPreserveExport));
509+ if (EnableProfcheck)
510+ MPM.addPass (createModuleToFunctionPassAdaptor (ProfileVerifierPass ()));
507511
508512 // Add any relevant output pass at the end of the pipeline.
509513 switch (OK) {
0 commit comments