diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGStmt.cpp | 4 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenPGO.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 25 |
7 files changed, 37 insertions, 16 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 457af0611b2..d8f96db55a7 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -429,7 +429,7 @@ void EmitAssemblyHelper::CreatePasses(FunctionInfoIndex *FunctionIndex) { MPM->add(createStripSymbolsPass(true)); } - if (CodeGenOpts.ProfileInstrGenerate) { + if (CodeGenOpts.hasProfileClangInstr()) { InstrProfOptions Options; Options.NoRedZone = CodeGenOpts.DisableRedZone; Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput; diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index cd49f5404ec..950781aa922 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -1159,7 +1159,7 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S) { // If the body of the case is just a 'break', try to not emit an empty block. // If we're profiling or we're not optimizing, leave the block in for better // debug and coverage analysis. - if (!CGM.getCodeGenOpts().ProfileInstrGenerate && + if (!CGM.getCodeGenOpts().hasProfileClangInstr() && CGM.getCodeGenOpts().OptimizationLevel > 0 && isa<BreakStmt>(S.getSubStmt())) { JumpDest Block = BreakContinueStack.back().BreakBlock; @@ -1206,7 +1206,7 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S) { if (SwitchWeights) SwitchWeights->push_back(getProfileCount(NextCase)); - if (CGM.getCodeGenOpts().ProfileInstrGenerate) { + if (CGM.getCodeGenOpts().hasProfileClangInstr()) { CaseDest = createBasicBlock("sw.bb"); EmitBlockWithFallThrough(CaseDest, &S); } diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index e079b5869d9..3d0b17b9246 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -883,7 +883,7 @@ void CodeGenFunction::EmitFunctionBody(FunctionArgList &Args, void CodeGenFunction::EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S) { llvm::BasicBlock *SkipCountBB = nullptr; - if (HaveInsertPoint() && CGM.getCodeGenOpts().ProfileInstrGenerate) { + if (HaveInsertPoint() && CGM.getCodeGenOpts().hasProfileClangInstr()) { // When instrumenting for profiling, the fallthrough to certain // statements needs to skip over the instrumentation code so that we // get an accurate count. diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 33fcf0dceb8..55bbf48473d 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -952,7 +952,7 @@ private: public: /// Increment the profiler's counter for the given statement. void incrementProfileCounter(const Stmt *S) { - if (CGM.getCodeGenOpts().ProfileInstrGenerate) + if (CGM.getCodeGenOpts().hasProfileClangInstr()) PGO.emitCounterIncrement(Builder, S); PGO.setCurrentStmt(S); } diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index df043537dd4..c59d2d1b27f 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -37,7 +37,7 @@ void CodeGenPGO::setFuncName(StringRef Name, PGOReader ? PGOReader->getVersion() : llvm::IndexedInstrProf::Version); // If we're generating a profile, create a variable for the name. - if (CGM.getCodeGenOpts().ProfileInstrGenerate) + if (CGM.getCodeGenOpts().hasProfileClangInstr()) FuncNameVar = llvm::createPGOFuncNameVar(CGM.getModule(), Linkage, FuncName); } @@ -610,7 +610,7 @@ uint64_t PGOHash::finalize() { void CodeGenPGO::assignRegionCounters(GlobalDecl GD, llvm::Function *Fn) { const Decl *D = GD.getDecl(); - bool InstrumentRegions = CGM.getCodeGenOpts().ProfileInstrGenerate; + bool InstrumentRegions = CGM.getCodeGenOpts().hasProfileClangInstr(); llvm::IndexedInstrProfReader *PGOReader = CGM.getPGOReader(); if (!InstrumentRegions && !PGOReader) return; @@ -729,7 +729,7 @@ CodeGenPGO::applyFunctionAttributes(llvm::IndexedInstrProfReader *PGOReader, } void CodeGenPGO::emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S) { - if (!CGM.getCodeGenOpts().ProfileInstrGenerate || !RegionCounterMap) + if (!CGM.getCodeGenOpts().hasProfileClangInstr() || !RegionCounterMap) return; if (!Builder.GetInsertBlock()) return; @@ -754,7 +754,7 @@ void CodeGenPGO::valueProfile(CGBuilderTy &Builder, uint32_t ValueKind, if (!ValuePtr || !ValueSite || !Builder.GetInsertBlock()) return; - bool InstrumentValueSites = CGM.getCodeGenOpts().ProfileInstrGenerate; + bool InstrumentValueSites = CGM.getCodeGenOpts().hasProfileClangInstr(); if (InstrumentValueSites && RegionCounterMap) { llvm::LLVMContext &Ctx = CGM.getLLVMContext(); auto *I8PtrTy = llvm::Type::getInt8PtrTy(Ctx); diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 29bdbfc088b..b16c6722505 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -3224,15 +3224,17 @@ static void addPGOAndCoverageFlags(Compilation &C, const Driver &D, if (ProfileGenerateArg) { if (ProfileGenerateArg->getOption().matches( options::OPT_fprofile_instr_generate_EQ)) - ProfileGenerateArg->render(Args, CmdArgs); + CmdArgs.push_back(Args.MakeArgString(Twine("-fprofile-instrument-path=") + + ProfileGenerateArg->getValue())); else if (ProfileGenerateArg->getOption().matches( options::OPT_fprofile_generate_EQ)) { SmallString<128> Path(ProfileGenerateArg->getValue()); llvm::sys::path::append(Path, "default.profraw"); CmdArgs.push_back( - Args.MakeArgString(Twine("-fprofile-instr-generate=") + Path)); - } else - Args.AddAllArgs(CmdArgs, options::OPT_fprofile_instr_generate); + Args.MakeArgString(Twine("-fprofile-instrument-path=") + Path)); + } + // The default is to use Clang Instrumentation. + CmdArgs.push_back("-fprofile-instrument=clang"); } if (ProfileUseArg) { diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 91d2ffbe1cb..f085af30865 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -477,9 +477,28 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as); Opts.Autolink = !Args.hasArg(OPT_fno_autolink); Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ); - Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate) || - Args.hasArg(OPT_fprofile_instr_generate_EQ); - Opts.InstrProfileOutput = Args.getLastArgValue(OPT_fprofile_instr_generate_EQ); + + enum PGOInstrumentor { Unknown, None, Clang }; + if (Arg *A = Args.getLastArg(OPT_fprofile_instrument_EQ)) { + StringRef Value = A->getValue(); + PGOInstrumentor Method = llvm::StringSwitch<PGOInstrumentor>(Value) + .Case("clang", Clang) + .Case("none", None) + .Default(Unknown); + switch (Method) { + case Clang: + Opts.setProfileInstr(CodeGenOptions::ProfileClangInstr); + break; + case None: + break; + case Unknown: + Diags.Report(diag::err_drv_invalid_pgo_instrumentor) + << A->getAsString(Args) << Value; + break; + } + } + + Opts.InstrProfileOutput = Args.getLastArgValue(OPT_fprofile_instrument_path_EQ); Opts.InstrProfileInput = Args.getLastArgValue(OPT_fprofile_instr_use_EQ); Opts.CoverageMapping = Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false); |