diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp --- a/llvm/tools/opt/NewPMDriver.cpp +++ b/llvm/tools/opt/NewPMDriver.cpp @@ -354,11 +354,15 @@ } if (CSPGOKindFlag != NoCSPGO) { if (P && (P->Action == PGOOptions::IRInstr || - P->Action == PGOOptions::SampleUse)) + P->Action == PGOOptions::SampleUse)) { errs() << "CSPGOKind cannot be used with IRInstr or SampleUse"; + return false; + } if (CSPGOKindFlag == CSInstrGen) { - if (CSProfileGenFile.empty()) + if (CSProfileGenFile.empty()) { errs() << "CSInstrGen needs to specify CSProfileGenFile"; + return false; + } if (P) { P->CSAction = PGOOptions::CSIRInstr; P->CSProfileGenFile = CSProfileGenFile; @@ -366,8 +370,10 @@ P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile, PGOOptions::NoAction, PGOOptions::CSIRInstr); } else /* CSPGOKindFlag == CSInstrUse */ { - if (!P) + if (!P) { errs() << "CSInstrUse needs to be together with InstrUse"; + return false; + } P->CSAction = PGOOptions::CSIRUse; } }