]> granicus.if.org Git - clang/commitdiff
Improve llvm-gcc compatibility, -Os implies -O2 (sortof).
authorDaniel Dunbar <daniel@zuster.org>
Wed, 29 Oct 2008 07:56:11 +0000 (07:56 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 29 Oct 2008 07:56:11 +0000 (07:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58374 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/clang.cpp

index 696e8842c9dbdc1139385420386e976199ce88d8..84eb341b61e0537830acf976de34f7c369bfbe34 100644 (file)
@@ -1140,8 +1140,14 @@ OptLevel("O", llvm::cl::Prefix,
          llvm::cl::init(0));
 
 static void InitializeCompileOptions(CompileOptions &Opts) {
-  Opts.OptimizationLevel = OptLevel;
   Opts.OptimizeSize = OptSize;
+  if (OptSize) {
+    // -Os implies -O2
+    // FIXME: Diagnose conflicting options.
+    Opts.OptimizationLevel = 2;
+  } else {
+    Opts.OptimizationLevel = OptLevel;
+  }
 
   // FIXME: There are llvm-gcc options to control these selectively.
   Opts.InlineFunctions = (Opts.OptimizationLevel > 1);