r268575 - [SystemZ] Add -mbackchain option.

Marcin Koscielnicki via cfe-commits cfe-commits at lists.llvm.org
Wed May 4 16:37:40 PDT 2016


Author: koriakin
Date: Wed May  4 18:37:40 2016
New Revision: 268575

URL: http://llvm.org/viewvc/llvm-project?rev=268575&view=rev
Log:
[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

Added:
    cfe/trunk/test/CodeGen/mbackchain-2.c
    cfe/trunk/test/CodeGen/mbackchain-3.c
    cfe/trunk/test/CodeGen/mbackchain.c
Modified:
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/include/clang/Frontend/CodeGenOptions.def
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=268575&r1=268574&r2=268575&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed May  4 18:37:40 2016
@@ -1524,6 +1524,10 @@ def fno_zvector : Flag<["-"], "fno-zvect
 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>,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=268575&r1=268574&r2=268575&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed May  4 18:37:40 2016
@@ -34,6 +34,7 @@ CODEGENOPT(AsmVerbose        , 1, 0) ///
 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.

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=268575&r1=268574&r2=268575&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed May  4 18:37:40 2016
@@ -1714,6 +1714,8 @@ void CodeGenModule::ConstructAttributeLi
 
     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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=268575&r1=268574&r2=268575&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed May  4 18:37:40 2016
@@ -1655,6 +1655,12 @@ void Clang::AddSparcTargetArgs(const Arg
   }
 }
 
+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,
     AddSparcTargetArgs(Args, CmdArgs);
     break;
 
+  case llvm::Triple::systemz:
+    AddSystemZTargetArgs(Args, CmdArgs);
+    break;
+
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
     AddX86TargetArgs(Args, CmdArgs);

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=268575&r1=268574&r2=268575&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed May  4 18:37:40 2016
@@ -782,6 +782,8 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.CudaGpuBinaryFileNames =
       Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.Backchain = Args.hasArg(OPT_mbackchain);
+
   return Success;
 }
 

Added: cfe/trunk/test/CodeGen/mbackchain-2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mbackchain-2.c?rev=268575&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/mbackchain-2.c (added)
+++ cfe/trunk/test/CodeGen/mbackchain-2.c Wed May  4 18:37:40 2016
@@ -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" {{.*}} }

Added: cfe/trunk/test/CodeGen/mbackchain-3.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mbackchain-3.c?rev=268575&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/mbackchain-3.c (added)
+++ cfe/trunk/test/CodeGen/mbackchain-3.c Wed May  4 18:37:40 2016
@@ -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"

Added: cfe/trunk/test/CodeGen/mbackchain.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mbackchain.c?rev=268575&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/mbackchain.c (added)
+++ cfe/trunk/test/CodeGen/mbackchain.c Wed May  4 18:37:40 2016
@@ -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" {{.*}} }




More information about the cfe-commits mailing list