[SystemZ] Add -mbackchain option.

This option, like the corresponding gcc option, is SystemZ-specific and
enables storing frame backchain links, as specified in the ABI.

Differential Revision: http://reviews.llvm.org/D19891

llvm-svn: 268575
This commit is contained in:
Marcin Koscielnicki 2016-05-04 23:37:40 +00:00
parent 68695b643d
commit b31ee6db11
8 changed files with 40 additions and 0 deletions

View File

@ -1524,6 +1524,10 @@ def fno_zvector : Flag<["-"], "fno-zvector">, Group<f_Group>,
def mzvector : Flag<["-"], "mzvector">, Alias<fzvector>;
def mno_zvector : Flag<["-"], "mno-zvector">, Alias<fno_zvector>;
def mbackchain : Flag<["-"], "mbackchain">, Group<m_Group>, Flags<[DriverOption,CC1Option]>,
HelpText<"Link stack frames through backchain on System Z">;
def mno_backchain : Flag<["-"], "mno-backchain">, Group<m_Group>, Flags<[DriverOption,CC1Option]>;
def mno_warn_nonportable_cfstrings : Flag<["-"], "mno-warn-nonportable-cfstrings">, Group<m_Group>;
def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, Group<m_Group>;
def momit_leaf_frame_pointer : Flag<["-"], "momit-leaf-frame-pointer">, Group<m_Group>,

View File

@ -34,6 +34,7 @@ CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm.
CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) operator new
CODEGENOPT(Autolink , 1, 1) ///< -fno-autolink
CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be EH-safe.
CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
CODEGENOPT(CoverageExtraChecksum, 1, 0) ///< Whether we need a second checksum for functions in GCNO files.
CODEGENOPT(CoverageNoFunctionNamesInData, 1, 0) ///< Do not include function names in GCDA files.
CODEGENOPT(CoverageExitBlockBeforeBody, 1, 0) ///< Whether to emit the exit block before the body blocks in GCNO files.

View File

@ -1714,6 +1714,8 @@ void CodeGenModule::ConstructAttributeList(
if (CodeGenOpts.StackRealignment)
FuncAttrs.addAttribute("stackrealign");
if (CodeGenOpts.Backchain)
FuncAttrs.addAttribute("backchain");
// Add target-cpu and target-features attributes to functions. If
// we have a decl for the function and it has a target attribute then

View File

@ -1655,6 +1655,12 @@ void Clang::AddSparcTargetArgs(const ArgList &Args,
}
}
void Clang::AddSystemZTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
if (Args.hasFlag(options::OPT_mbackchain, options::OPT_mno_backchain, false))
CmdArgs.push_back("-mbackchain");
}
static const char *getSystemZTargetCPU(const ArgList &Args) {
if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
return A->getValue();
@ -4241,6 +4247,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
AddSparcTargetArgs(Args, CmdArgs);
break;
case llvm::Triple::systemz:
AddSystemZTargetArgs(Args, CmdArgs);
break;
case llvm::Triple::x86:
case llvm::Triple::x86_64:
AddX86TargetArgs(Args, CmdArgs);

View File

@ -782,6 +782,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.CudaGpuBinaryFileNames =
Args.getAllArgValues(OPT_fcuda_include_gpubinary);
Opts.Backchain = Args.hasArg(OPT_mbackchain);
return Success;
}

View File

@ -0,0 +1,7 @@
// RUN: %clang -mbackchain --target=s390x-linux -S -emit-llvm -o - %s | FileCheck %s
// CHECK: define void @foo() [[NUW:#[0-9]+]]
void foo(void) {
}
// CHECK: attributes [[NUW]] = { {{.*}} "backchain" {{.*}} }

View File

@ -0,0 +1,7 @@
// RUN: %clang -mno-backchain --target=s390x-linux -S -emit-llvm -o - %s | FileCheck %s
// CHECK: define void @foo() [[NUW:#[0-9]+]]
void foo(void) {
}
// CHECK-NOT: "backchain"

View File

@ -0,0 +1,7 @@
// RUN: %clang_cc1 -mbackchain -triple s390x-linux -emit-llvm -o - %s | FileCheck %s
// CHECK: define void @foo() [[NUW:#[0-9]+]]
void foo(void) {
}
// CHECK: attributes [[NUW]] = { {{.*}} "backchain" {{.*}} }