diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -150,7 +150,8 @@ ///< generates a 'patchable-function' attribute. CODEGENOPT(JMCInstrument, 1, 0) ///< Set when -fjmc is enabled. -CODEGENOPT(InstrumentForProfiling , 1, 0) ///< Set when -pg is enabled. +CODEGENOPT(InstrumentForProfiling , 1, 0) ///< Set when -p is enabled. +CODEGENOPT(InstrumentForProfilingGraph , 1, 0) ///< Set when -pg is enabled. CODEGENOPT(CallFEntry , 1, 0) ///< Set when -mfentry is enabled. CODEGENOPT(MNopMCount , 1, 0) ///< Set when -mnop-mcount is enabled. CODEGENOPT(RecordMCount , 1, 0) ///< Set when -mrecord-mcount is enabled. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4094,8 +4094,10 @@ MarshallingInfoFlag>; def pedantic : Flag<["-", "--"], "pedantic">, Group, Flags<[CC1Option,FlangOption,FC1Option]>, HelpText<"Warn on language extensions">, MarshallingInfoFlag>; -def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, Flags<[CC1Option]>, +def p : Flag<["-"], "p">, HelpText<"Enable mcount instrumentation">, Flags<[CC1Option]>, MarshallingInfoFlag>; +def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, Flags<[CC1Option]>, + MarshallingInfoFlag>; def pipe : Flag<["-", "--"], "pipe">, HelpText<"Use pipes between commands, when possible">; def prebind__all__twolevel__modules : Flag<["-"], "prebind_all_twolevel_modules">; @@ -4140,7 +4142,6 @@ LangOpts<"POSIXThreads">, DefaultFalse, PosFlag, NegFlag, BothFlags<[CC1Option]>>; -def p : Flag<["-"], "p">; def pie : Flag<["-"], "pie">, Group; def static_pie : Flag<["-"], "static-pie">, Group; def read__only__relocs : Separate<["-"], "read_only_relocs">; diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -923,7 +923,8 @@ if (CodeGenOpts.InstrumentFunctions || CodeGenOpts.InstrumentFunctionEntryBare || CodeGenOpts.InstrumentFunctionsAfterInlining || - CodeGenOpts.InstrumentForProfiling) { + CodeGenOpts.InstrumentForProfiling || + CodeGenOpts.InstrumentForProfilingGraph) { PB.registerPipelineStartEPCallback( [](ModulePassManager &MPM, OptimizationLevel Level) { MPM.addPass(createModuleToFunctionPassAdaptor( diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1043,7 +1043,8 @@ // inlining, we just add an attribute to insert a mcount call in backend. // The attribute "counting-function" is set to mcount function name which is // architecture dependent. - if (CGM.getCodeGenOpts().InstrumentForProfiling) { + if (CGM.getCodeGenOpts().InstrumentForProfiling || + CGM.getCodeGenOpts().InstrumentForProfilingGraph) { // Calls to fentry/mcount should not be generated if function has // the no_instrument_function attribute. if (!CurFuncDecl || !CurFuncDecl->hasAttr()) { diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -521,7 +521,8 @@ static bool useFramePointerForTargetByDefault(const ArgList &Args, const llvm::Triple &Triple) { - if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry)) + if (Args.hasArg(options::OPT_p, options::OPT_pg) && + !Args.hasArg(options::OPT_mfentry)) return true; switch (Triple.getArch()) { @@ -6268,6 +6269,7 @@ Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch); if (TC.SupportsProfiling()) { + Args.AddLastArg(CmdArgs, options::OPT_p); Args.AddLastArg(CmdArgs, options::OPT_pg); llvm::Triple::ArchType Arch = TC.getArch(); @@ -7388,7 +7390,7 @@ C.getJobs().getJobs().back()->PrintInputFilenames = true; } - if (Arg *A = Args.getLastArg(options::OPT_pg)) + if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg)) if (FPKeepKind == CodeGenOptions::FramePointerKind::None && !Args.hasArg(options::OPT_mfentry)) D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"