[lld] r251136 - Parse and store the value of the -O option.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 23 12:02:20 PDT 2015


Author: rafael
Date: Fri Oct 23 14:02:19 2015
New Revision: 251136

URL: http://llvm.org/viewvc/llvm-project?rev=251136&view=rev
Log:
Parse and store the value of the -O option.

Modified:
    lld/trunk/ELF/Config.h
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/Options.td

Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=251136&r1=251135&r2=251136&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Fri Oct 23 14:02:19 2015
@@ -66,6 +66,7 @@ struct Configuration {
   ELFKind EKind = ELFNoneKind;
   uint16_t EMachine = llvm::ELF::EM_NONE;
   uint64_t EntryAddr = -1;
+  unsigned Optimize = 0;
 };
 
 extern Configuration *Config;

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=251136&r1=251135&r2=251136&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Oct 23 14:02:19 2015
@@ -156,6 +156,12 @@ void LinkerDriver::createFiles(opt::Inpu
   Config->SoName = getString(Args, OPT_soname);
   Config->Sysroot = getString(Args, OPT_sysroot);
 
+  if (auto *Arg = Args.getLastArg(OPT_O)) {
+    StringRef Val = Arg->getValue();
+    if (Val.getAsInteger(10, Config->Optimize))
+      error("Invalid optimization level");
+  }
+
   if (auto *Arg = Args.getLastArg(OPT_hash_style)) {
     StringRef S = Arg->getValue();
     if (S == "gnu") {

Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=251136&r1=251135&r2=251136&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Fri Oct 23 14:02:19 2015
@@ -12,6 +12,8 @@ def Bstatic: Flag<["-"], "Bstatic">,
 def L : Joined<["-"], "L">, MetaVarName<"<dir>">,
   HelpText<"Directory to search for libraries">;
 
+def O : Joined<["-"], "O">, HelpText<"Optimize">;
+
 def allow_multiple_definition: Flag<["--"], "allow-multiple-definition">,
   HelpText<"Allow multiple definitions">;
 
@@ -125,7 +127,6 @@ def alias_script_T : Separate<["-"], "T"
 def alias_undefined_u : Separate<["-"], "u">, Alias<undefined>;
 
 // Options listed below are silently ignored now.
-def O3 : Flag<["-"], "O3">;
 def build_id : Flag<["--"], "build-id">;
 def eh_frame_hdr : Flag<["--"], "eh-frame-hdr">;
 def end_group : Flag<["--"], "end-group">;




More information about the llvm-commits mailing list