forked from OSchip/llvm-project
[Clang FE, SystemZ] Recognize -mrecord-mcount CL option.
Recognize -mrecord-mcount from the command line and add a function attribute "mrecord-mcount" when passed. Only valid on SystemZ (when used with -mfentry). Review: Ulrich Weigand https://reviews.llvm.org/D71627
This commit is contained in:
parent
a116f28a0d
commit
2520bef865
|
@ -113,6 +113,7 @@ VALUE_CODEGENOPT(XRayInstructionThreshold , 32, 200)
|
|||
CODEGENOPT(InstrumentForProfiling , 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.
|
||||
CODEGENOPT(PackedStack , 1, 0) ///< Set when -mpacked-stack is enabled.
|
||||
CODEGENOPT(LessPreciseFPMAD , 1, 0) ///< Enable less precise MAD instructions to
|
||||
///< be generated.
|
||||
|
|
|
@ -2477,6 +2477,8 @@ def mfentry : Flag<["-"], "mfentry">, HelpText<"Insert calls to fentry at functi
|
|||
Flags<[CC1Option]>, Group<m_Group>;
|
||||
def mnop_mcount : Flag<["-"], "mnop-mcount">, HelpText<"Generate mcount/__fentry__ calls as nops. To activate they need to be patched in.">,
|
||||
Flags<[CC1Option]>, Group<m_Group>;
|
||||
def mrecord_mcount : Flag<["-"], "mrecord-mcount">, HelpText<"Generate a __mcount_loc section entry for each __fentry__ call.">,
|
||||
Flags<[CC1Option]>, Group<m_Group>;
|
||||
def mpacked_stack : Flag<["-"], "mpacked-stack">, HelpText<"Use packed stack layout (SystemZ only).">,
|
||||
Flags<[CC1Option]>, Group<m_Group>;
|
||||
def mips16 : Flag<["-"], "mips16">, Group<m_mips_Features_Group>;
|
||||
|
|
|
@ -968,6 +968,17 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
|
|||
<< "-mnop-mcount" << "-mfentry";
|
||||
Fn->addFnAttr("mnop-mcount");
|
||||
}
|
||||
|
||||
if (CGM.getCodeGenOpts().RecordMCount) {
|
||||
if (getContext().getTargetInfo().getTriple().getArch() !=
|
||||
llvm::Triple::systemz)
|
||||
CGM.getDiags().Report(diag::err_opt_not_valid_on_target)
|
||||
<< "-mrecord-mcount";
|
||||
if (!CGM.getCodeGenOpts().CallFEntry)
|
||||
CGM.getDiags().Report(diag::err_opt_not_valid_without_opt)
|
||||
<< "-mrecord-mcount" << "-mfentry";
|
||||
Fn->addFnAttr("mrecord-mcount");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4990,6 +4990,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
if (TC.SupportsProfiling())
|
||||
Args.AddLastArg(CmdArgs, options::OPT_mnop_mcount);
|
||||
|
||||
if (TC.SupportsProfiling())
|
||||
Args.AddLastArg(CmdArgs, options::OPT_mrecord_mcount);
|
||||
|
||||
Args.AddLastArg(CmdArgs, options::OPT_mpacked_stack);
|
||||
|
||||
if (Args.getLastArg(options::OPT_fapple_kext) ||
|
||||
|
|
|
@ -1104,6 +1104,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
|||
Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
|
||||
Opts.CallFEntry = Args.hasArg(OPT_mfentry);
|
||||
Opts.MNopMCount = Args.hasArg(OPT_mnop_mcount);
|
||||
Opts.RecordMCount = Args.hasArg(OPT_mrecord_mcount);
|
||||
Opts.PackedStack = Args.hasArg(OPT_mpacked_stack);
|
||||
Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
// RUN: %clang_cc1 -pg -mfentry -mrecord-mcount -triple s390x-ibm-linux -emit-llvm \
|
||||
// RUN: -o - %s 2>&1 | FileCheck %s
|
||||
// RUN: not %clang_cc1 -pg -mrecord-mcount -triple s390x-ibm-linux -emit-llvm -o - \
|
||||
// RUN: %s 2>&1 | FileCheck -check-prefix=NOMFENTRY %s
|
||||
// RUN: %clang_cc1 -mfentry -mrecord-mcount -triple s390x-ibm-linux -emit-llvm -o - \
|
||||
// RUN: %s 2>&1 | FileCheck -check-prefix=NOPG %s
|
||||
// RUN: %clang_cc1 -mrecord-mcount -triple s390x-ibm-linux -emit-llvm -o - %s \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=NOPG %s
|
||||
// RUN: not %clang_cc1 -pg -mfentry -mrecord-mcount -triple x86_64-linux-gnu \
|
||||
// RUN: -emit-llvm -o - %s 2>&1 | FileCheck -check-prefix=X86 %s
|
||||
|
||||
int foo(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __attribute__((no_instrument_function)) no_instrument(void) {
|
||||
return foo();
|
||||
}
|
||||
|
||||
//CHECK: attributes #0 = { {{.*}}"mrecord-mcount"{{.*}} }
|
||||
//CHECK: attributes #1 = { {{.*}} }
|
||||
//CHECK-NOT: attributes #1 = { {{.*}}"mrecord-mcount"{{.*}} }
|
||||
//NOMFENTRY: error: option '-mrecord-mcount' cannot be specified without '-mfentry'
|
||||
//NOPG-NOT: attributes #0 = { {{.*}}"mrecord-mcount"{{.*}} }
|
||||
//NOPG-NOT: attributes #1 = { {{.*}}"mrecord-mcount"{{.*}} }
|
||||
//X86: error: option '-mrecord-mcount' cannot be specified on this target
|
Loading…
Reference in New Issue