]> granicus.if.org Git - clang/commitdiff
Fix -ftrap-function fallout from llvm r145714. <rdar://problem/10799325>
authorBob Wilson <bob.wilson@apple.com>
Fri, 3 Feb 2012 06:27:22 +0000 (06:27 +0000)
committerBob Wilson <bob.wilson@apple.com>
Fri, 3 Feb 2012 06:27:22 +0000 (06:27 +0000)
That llvm change removed the -trap-func backend option, so that using
-ftrap-function with clang would cause the backend to complain.  Fix it
by adding the trap function name to the CodeGenOptions and passing it through
to the TargetOptions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149679 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/CC1Options.td
include/clang/Frontend/CodeGenOptions.h
lib/CodeGen/BackendUtil.cpp
lib/Driver/Tools.cpp
lib/Frontend/CompilerInvocation.cpp

index 3d36340e86d9eb0c7ee98878b59d625cf37de868..fd3e32cd35d104d73f6f4d063018178bb342a1b6 100644 (file)
@@ -154,6 +154,8 @@ def ffunction_sections : Flag<"-ffunction-sections">,
   HelpText<"Place each function in its own section (ELF Only)">;
 def fdata_sections : Flag<"-fdata-sections">,
   HelpText<"Place each data in its own section (ELF Only)">;
+def ftrap_function_EQ : Joined<"-ftrap-function=">,
+  HelpText<"Issue call to specified function rather than a trap instruction">;
 def funroll_loops : Flag<"-funroll-loops">,
   HelpText<"Turn on loop unroller">;
 def femit_coverage_notes : Flag<"-femit-coverage-notes">,
index a0d260fb34f33000af205a1fe4738736da89b368..42b471986b159923498fd38196ca7774bdf3ec33 100644 (file)
@@ -148,6 +148,10 @@ public:
   /// The name of the relocation model to use.
   std::string RelocationModel;
 
+  /// If not an empty string, trap intrinsics are lowered to calls to this
+  /// function instead of to trap instructions.
+  std::string TrapFuncName;
+
   /// A list of command-line options to forward to the LLVM backend.
   std::vector<std::string> BackendOptions;
 
index c1636952da1fd3abecb3e8718decba8176f2f108..1cbc69b03b6a022330c659350827604993df6d02 100644 (file)
@@ -327,6 +327,7 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action,
   Options.StackAlignmentOverride = CodeGenOpts.StackAlignment;
   Options.RealignStack = CodeGenOpts.StackRealignment;
   Options.DisableTailCalls = CodeGenOpts.DisableTailCalls;
+  Options.TrapFuncName = CodeGenOpts.TrapFuncName;
 
   TargetMachine *TM = TheTarget->createTargetMachine(Triple, TargetOpts.CPU,
                                                      FeaturesStr, Options,
index 97c3c69709cca3b16ff95b37f1c9a6745ef0f84d..93dcd0d461bdfa0443b994137514925eefee6265 100644 (file)
@@ -1947,12 +1947,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back(A->getValue(Args));
   }
 
-  // Forward -ftrap_function= options to the backend.
-  if (Arg *A = Args.getLastArg(options::OPT_ftrap_function_EQ)) {
-    StringRef FuncName = A->getValue(Args);
-    CmdArgs.push_back("-backend-option");
-    CmdArgs.push_back(Args.MakeArgString("-trap-func=" + FuncName));
-  }
+  Args.AddLastArg(CmdArgs, options::OPT_ftrap_function_EQ);
 
   // -fno-strict-overflow implies -fwrapv if it isn't disabled, but
   // -fstrict-overflow won't turn off an explicitly enabled -fwrapv.
index 2cb5c604ca204a24dc10c0f0bf2fd3de9de2abd3..23fe830a03584184140e263ab295433d3e288020 100644 (file)
@@ -1143,6 +1143,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
                       Args.hasArg(OPT_cl_fast_relaxed_math);
   Opts.UnwindTables = Args.hasArg(OPT_munwind_tables);
   Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
+  Opts.TrapFuncName = Args.getLastArgValue(OPT_ftrap_function_EQ);
 
   Opts.FunctionSections = Args.hasArg(OPT_ffunction_sections);
   Opts.DataSections = Args.hasArg(OPT_fdata_sections);