Skip to content

Commit 03b555b

Browse files
committed
Drive profile validator from opt
1 parent 9c22f8c commit 03b555b

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

llvm/tools/opt/NewPMDriver.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
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

4445
using namespace llvm;
4546
using 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) {

llvm/tools/opt/NewPMDriver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ bool runPassPipeline(
7575
bool ShouldPreserveAssemblyUseListOrder,
7676
bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
7777
bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
78-
bool UnifiedLTO = false);
78+
bool EnableProfcheck, bool UnifiedLTO = false);
7979
} // namespace llvm
8080

8181
#endif

llvm/tools/opt/optdriver.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ static cl::opt<bool> VerifyDebugInfoPreserve(
213213
cl::desc("Start the pipeline with collecting and end it with checking of "
214214
"debug info preservation."));
215215

216+
static cl::opt<bool> EnableProfileVerification(
217+
"enable-profcheck", cl::init(true),
218+
cl::desc("Start the pipeline with prof-inject and end it with prof-check"));
219+
216220
static cl::opt<std::string> ClDataLayout("data-layout",
217221
cl::desc("data layout string to use"),
218222
cl::value_desc("layout-string"),
@@ -731,7 +735,8 @@ extern "C" int optMain(
731735
RemarksFile.get(), Pipeline, PluginList, PassBuilderCallbacks,
732736
OK, VK, PreserveAssemblyUseListOrder,
733737
PreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash,
734-
EnableDebugify, VerifyDebugInfoPreserve, UnifiedLTO)
738+
EnableDebugify, VerifyDebugInfoPreserve,
739+
EnableProfileVerification, UnifiedLTO)
735740
? 0
736741
: 1;
737742
}

0 commit comments

Comments
 (0)