forked from OSchip/llvm-project
[Clang FE, SystemZ] Recognize -mpacked-stack CL option
Recognize -mpacked-stack from the command line and add a function attribute "mpacked-stack" when passed. This is needed for building the Linux kernel. If this option is passed for any other target than SystemZ, an error is generated. Review: Ulrich Weigand https://reviews.llvm.org/D71441
This commit is contained in:
parent
79b4c897b8
commit
599d1cc07a
|
@ -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(PackedStack , 1, 0) ///< Set when -mpacked-stack is enabled.
|
||||
CODEGENOPT(LessPreciseFPMAD , 1, 0) ///< Enable less precise MAD instructions to
|
||||
///< be generated.
|
||||
CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the
|
||||
|
|
|
@ -2474,6 +2474,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 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>;
|
||||
def mno_mips16 : Flag<["-"], "mno-mips16">, Group<m_mips_Features_Group>;
|
||||
def mmicromips : Flag<["-"], "mmicromips">, Group<m_mips_Features_Group>;
|
||||
|
|
|
@ -971,6 +971,14 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
|
|||
}
|
||||
}
|
||||
|
||||
if (CGM.getCodeGenOpts().PackedStack) {
|
||||
if (getContext().getTargetInfo().getTriple().getArch() !=
|
||||
llvm::Triple::systemz)
|
||||
CGM.getDiags().Report(diag::err_opt_not_valid_on_target)
|
||||
<< "-mpacked-stack";
|
||||
Fn->addFnAttr("packed-stack");
|
||||
}
|
||||
|
||||
if (RetTy->isVoidType()) {
|
||||
// Void type; nothing to return.
|
||||
ReturnValue = Address::invalid();
|
||||
|
|
|
@ -5014,6 +5014,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
if (TC.SupportsProfiling())
|
||||
Args.AddLastArg(CmdArgs, options::OPT_mnop_mcount);
|
||||
|
||||
Args.AddLastArg(CmdArgs, options::OPT_mpacked_stack);
|
||||
|
||||
if (Args.getLastArg(options::OPT_fapple_kext) ||
|
||||
(Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
|
||||
CmdArgs.push_back("-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.PackedStack = Args.hasArg(OPT_mpacked_stack);
|
||||
Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
|
||||
|
||||
if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// RUN: %clang_cc1 -mpacked-stack -triple s390x-ibm-linux -emit-llvm \
|
||||
// RUN: -o - %s 2>&1 | FileCheck %s
|
||||
// RUN: not %clang_cc1 -mpacked-stack -triple x86_64-linux-gnu \
|
||||
// RUN: -emit-llvm -o - %s 2>&1 | FileCheck -check-prefix=X86 %s
|
||||
|
||||
int foo(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//CHECK: attributes #0 = { {{.*}}"packed-stack" {{.*}} }
|
||||
//X86: error: option '-mpacked-stack' cannot be specified on this target
|
Loading…
Reference in New Issue