[cfe-commits] r88980 - in /cfe/trunk/tools/clang-cc: Options.cpp Options.h clang-cc.cpp

Daniel Dunbar daniel at zuster.org
Mon Nov 16 14:38:15 PST 2009


Author: ddunbar
Date: Mon Nov 16 16:38:14 2009
New Revision: 88980

URL: http://llvm.org/viewvc/llvm-project?rev=88980&view=rev
Log:
clang-cc: Eliminate cyclic dependency in initializing CodeGenOptions.

Modified:
    cfe/trunk/tools/clang-cc/Options.cpp
    cfe/trunk/tools/clang-cc/Options.h
    cfe/trunk/tools/clang-cc/clang-cc.cpp

Modified: cfe/trunk/tools/clang-cc/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Options.cpp?rev=88980&r1=88979&r2=88980&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/Options.cpp (original)
+++ cfe/trunk/tools/clang-cc/Options.cpp Mon Nov 16 16:38:14 2009
@@ -807,7 +807,9 @@
 // Option Object Construction
 //===----------------------------------------------------------------------===//
 
-void clang::InitializeCodeGenOptions(CodeGenOptions &Opts) {
+void clang::InitializeCodeGenOptions(CodeGenOptions &Opts,
+                                     const LangOptions &Lang,
+                                     bool TimePasses) {
   using namespace codegenoptions;
 
   // -Os implies -O2
@@ -827,6 +829,13 @@
   Opts.SimplifyLibCalls = 1;
   Opts.UnrollLoops = (Opts.OptimizationLevel > 1 && !OptSize);
 
+  // FIXME: Eliminate this dependency?
+  if (Lang.NoBuiltin)
+    Opts.SimplifyLibCalls = 0;
+  if (Lang.CPlusPlus)
+    Opts.NoCommon = 1;
+  Opts.TimePasses = TimePasses;
+
 #ifdef NDEBUG
   Opts.VerifyModule = 0;
 #endif
@@ -1068,8 +1077,7 @@
 
 void clang::InitializeLangOptions(LangOptions &Options,
                                   FrontendOptions::InputKind IK,
-                                  TargetInfo &Target,
-                                  const CodeGenOptions &CodeGenOpts) {
+                                  TargetInfo &Target) {
   using namespace langoptions;
 
   bool NoPreprocess = false;
@@ -1289,18 +1297,19 @@
 
   // The __OPTIMIZE_SIZE__ define is tied to -Oz, which we don't support.
   Options.OptimizeSize = 0;
-  Options.Optimize = !!CodeGenOpts.OptimizationLevel;
+  Options.Optimize = codegenoptions::OptSize || codegenoptions::OptLevel;
 
   assert(PICLevel <= 2 && "Invalid value for -pic-level");
   Options.PICLevel = PICLevel;
 
   Options.GNUInline = !Options.C99;
-  // FIXME: This is affected by other options (-fno-inline).
 
   // This is the __NO_INLINE__ define, which just depends on things like the
   // optimization level and -fno-inline, not actually whether the backend has
   // inlining enabled.
-  Options.NoInline = !CodeGenOpts.OptimizationLevel;
+  //
+  // FIXME: This is affected by other options (-fno-inline).
+  Options.NoInline = !codegenoptions::OptLevel;
 
   Options.Static = StaticDefine;
 

Modified: cfe/trunk/tools/clang-cc/Options.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Options.h?rev=88980&r1=88979&r2=88980&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/Options.h (original)
+++ cfe/trunk/tools/clang-cc/Options.h Mon Nov 16 16:38:14 2009
@@ -29,22 +29,23 @@
 
 void InitializeAnalyzerOptions(AnalyzerOptions &Opts);
 
+void InitializeCodeGenOptions(CodeGenOptions &Opts,
+                              const LangOptions &Lang,
+                              bool TimePasses);
+
 void InitializeDependencyOutputOptions(DependencyOutputOptions &Opts);
 
 void InitializeDiagnosticOptions(DiagnosticOptions &Opts);
 
 void InitializeFrontendOptions(FrontendOptions &Opts);
 
-void InitializeCodeGenOptions(CodeGenOptions &Opts);
-
 void InitializeHeaderSearchOptions(HeaderSearchOptions &Opts,
                                    llvm::StringRef BuiltinIncludePath,
                                    const LangOptions &Lang);
 
 void InitializeLangOptions(LangOptions &Options,
                            FrontendOptions::InputKind LK,
-                           TargetInfo &Target,
-                           const CodeGenOptions &CodeGenOpts);
+                           TargetInfo &Target);
 
 void InitializePreprocessorOptions(PreprocessorOptions &Opts);
 

Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=88980&r1=88979&r2=88980&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Mon Nov 16 16:38:14 2009
@@ -165,10 +165,6 @@
   if (!Target)
     return 0;
 
-  // Initialize backend options, which may also be used to key some language
-  // options.
-  InitializeCodeGenOptions(Opts.getCodeGenOpts());
-
   // Initialize frontend options.
   InitializeFrontendOptions(Opts.getFrontendOpts());
 
@@ -188,8 +184,7 @@
   // code path to make this obvious.
   IsAST = (IK == FrontendOptions::IK_AST);
   if (!IsAST)
-    InitializeLangOptions(Opts.getLangOpts(), IK, *Target,
-                          Opts.getCodeGenOpts());
+    InitializeLangOptions(Opts.getLangOpts(), IK, *Target);
 
   // Initialize the static analyzer options.
   InitializeAnalyzerOptions(Opts.getAnalyzerOpts());
@@ -208,12 +203,10 @@
   // Initialize the preprocessed output options.
   InitializePreprocessorOutputOptions(Opts.getPreprocessorOutputOpts());
 
-  // Finalize some code generation options which are derived from other places.
-  if (Opts.getLangOpts().NoBuiltin)
-    Opts.getCodeGenOpts().SimplifyLibCalls = 0;
-  if (Opts.getLangOpts().CPlusPlus)
-    Opts.getCodeGenOpts().NoCommon = 1;
-  Opts.getCodeGenOpts().TimePasses = Opts.getFrontendOpts().ShowTimers;
+  // Initialize backend options, which may also be used to key some language
+  // options.
+  InitializeCodeGenOptions(Opts.getCodeGenOpts(), Opts.getLangOpts(),
+                           Opts.getFrontendOpts().ShowTimers);
 
   return Target.take();
 }





More information about the cfe-commits mailing list