[clang] 8290440 - Map -O to -O1 instead of -O2
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Mon May 18 15:53:53 PDT 2020
Author: Fangrui Song
Date: 2020-05-18T15:53:41-07:00
New Revision: 82904401e3278c3f3a54481d6cd06cc43b801e3b
URL: https://github.com/llvm/llvm-project/commit/82904401e3278c3f3a54481d6cd06cc43b801e3b
DIFF: https://github.com/llvm/llvm-project/commit/82904401e3278c3f3a54481d6cd06cc43b801e3b.diff
LOG: Map -O to -O1 instead of -O2
rL82131 changed -O from -O1 to -O2, because -O1 was not different from
-O2 at that time.
GCC treats -O as -O1 and there is now work to make -O1 meaningful.
We can change -O back to -O1 again.
Reviewed By: echristo, dexonsmith, arphaman
Differential Revision: https://reviews.llvm.org/D79916
Added:
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/builtins-systemz-zvector-constrained.c
clang/test/CodeGen/builtins-systemz-zvector.c
clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
clang/test/CodeGen/builtins-systemz-zvector2.c
clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
clang/test/CodeGen/builtins-systemz-zvector3.c
clang/test/CodeGen/fma-builtins-constrained.c
clang/test/Driver/O.c
clang/test/Driver/clang_f_opts.c
clang/test/Driver/lto.c
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 158c2ad29bf7..7213af1731c1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -400,7 +400,7 @@ def ObjCXX : Flag<["-"], "ObjC++">, Flags<[DriverOption]>,
def ObjC : Flag<["-"], "ObjC">, Flags<[DriverOption]>,
HelpText<"Treat source input files as Objective-C inputs">;
def O : Joined<["-"], "O">, Group<O_Group>, Flags<[CC1Option]>;
-def O_flag : Flag<["-"], "O">, Flags<[CC1Option]>, Alias<O>, AliasArgs<["2"]>;
+def O_flag : Flag<["-"], "O">, Flags<[CC1Option]>, Alias<O>, AliasArgs<["1"]>;
def Ofast : Joined<["-"], "Ofast">, Group<O_Group>, Flags<[CC1Option]>;
def P : Flag<["-"], "P">, Flags<[CC1Option]>, Group<Preprocessor_Group>,
HelpText<"Disable linemarker output in -E mode">;
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 2ce71a96c35f..a30cb2add048 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -137,7 +137,7 @@ static unsigned getOptimizationLevel(ArgList &Args, InputKind IK,
assert(A->getOption().matches(options::OPT_O));
StringRef S(A->getValue());
- if (S == "s" || S == "z" || S.empty())
+ if (S == "s" || S == "z")
return llvm::CodeGenOpt::Default;
if (S == "g")
diff --git a/clang/test/CodeGen/builtins-systemz-zvector-constrained.c b/clang/test/CodeGen/builtins-systemz-zvector-constrained.c
index 42c70ce49f65..30d8a09d5bc9 100644
--- a/clang/test/CodeGen/builtins-systemz-zvector-constrained.c
+++ b/clang/test/CodeGen/builtins-systemz-zvector-constrained.c
@@ -1,10 +1,10 @@
// REQUIRES: systemz-registered-target
// RUN: %clang_cc1 -target-cpu z13 -triple s390x-linux-gnu \
-// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -O2 -fzvector -flax-vector-conversions=none \
// RUN: -ffp-exception-behavior=strict \
// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -target-cpu z13 -triple s390x-linux-gnu \
-// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -O2 -fzvector -flax-vector-conversions=none \
// RUN: -ffp-exception-behavior=strict \
// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
diff --git a/clang/test/CodeGen/builtins-systemz-zvector.c b/clang/test/CodeGen/builtins-systemz-zvector.c
index da0e720c9fae..9fe373b43a8c 100644
--- a/clang/test/CodeGen/builtins-systemz-zvector.c
+++ b/clang/test/CodeGen/builtins-systemz-zvector.c
@@ -1,9 +1,9 @@
// REQUIRES: systemz-registered-target
// RUN: %clang_cc1 -target-cpu z13 -triple s390x-linux-gnu \
-// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -O2 -fzvector -flax-vector-conversions=none \
// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -target-cpu z13 -triple s390x-linux-gnu \
-// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -O2 -fzvector -flax-vector-conversions=none \
// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
#include <vecintrin.h>
diff --git a/clang/test/CodeGen/builtins-systemz-zvector2-constrained.c b/clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
index 8f94fb7b9e2e..7b1b4c504782 100644
--- a/clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
+++ b/clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
@@ -1,10 +1,10 @@
// REQUIRES: systemz-registered-target
// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
-// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -O2 -fzvector -flax-vector-conversions=none \
// RUN: -ffp-exception-behavior=strict \
// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
-// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -O2 -fzvector -flax-vector-conversions=none \
// RUN: -ffp-exception-behavior=strict \
// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
diff --git a/clang/test/CodeGen/builtins-systemz-zvector2.c b/clang/test/CodeGen/builtins-systemz-zvector2.c
index a4f791e6019b..74e46b30a4b0 100644
--- a/clang/test/CodeGen/builtins-systemz-zvector2.c
+++ b/clang/test/CodeGen/builtins-systemz-zvector2.c
@@ -1,9 +1,9 @@
// REQUIRES: systemz-registered-target
// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
-// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -O2 -fzvector -flax-vector-conversions=none \
// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
-// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -O2 -fzvector -flax-vector-conversions=none \
// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
#include <vecintrin.h>
diff --git a/clang/test/CodeGen/builtins-systemz-zvector3-constrained.c b/clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
index b599470c19a2..17af7b8a7fcc 100644
--- a/clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
+++ b/clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
@@ -1,10 +1,10 @@
// REQUIRES: systemz-registered-target
// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
-// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -O2 -fzvector -flax-vector-conversions=none \
// RUN: -ffp-exception-behavior=strict \
// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
-// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -O2 -fzvector -flax-vector-conversions=none \
// RUN: -ffp-exception-behavior=strict \
// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
diff --git a/clang/test/CodeGen/builtins-systemz-zvector3.c b/clang/test/CodeGen/builtins-systemz-zvector3.c
index a987c6113e36..1b0520d471f9 100644
--- a/clang/test/CodeGen/builtins-systemz-zvector3.c
+++ b/clang/test/CodeGen/builtins-systemz-zvector3.c
@@ -1,9 +1,9 @@
// REQUIRES: systemz-registered-target
// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
-// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -O2 -fzvector -flax-vector-conversions=none \
// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
-// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -O2 -fzvector -flax-vector-conversions=none \
// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
#include <vecintrin.h>
diff --git a/clang/test/CodeGen/fma-builtins-constrained.c b/clang/test/CodeGen/fma-builtins-constrained.c
index 685b55cc4eb0..e5c22ec8b80d 100644
--- a/clang/test/CodeGen/fma-builtins-constrained.c
+++ b/clang/test/CodeGen/fma-builtins-constrained.c
@@ -1,8 +1,8 @@
// REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O -emit-llvm -o - | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -ffp-exception-behavior=strict -O -emit-llvm -o - | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O -S -o - | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM --check-prefix=CHECK-ASM-UNCONSTRAINED %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O -ffp-exception-behavior=strict -S -o - | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM --check-prefix=CHECK-ASM-CONSTRAINED %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -emit-llvm -o - | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -ffp-exception-behavior=strict -O2 -emit-llvm -o - | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -S -o - | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM --check-prefix=CHECK-ASM-UNCONSTRAINED %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -ffp-exception-behavior=strict -S -o - | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM --check-prefix=CHECK-ASM-CONSTRAINED %s
#include <immintrin.h>
diff --git a/clang/test/Driver/O.c b/clang/test/Driver/O.c
index a7dedc860cfc..0b68ee030d8f 100644
--- a/clang/test/Driver/O.c
+++ b/clang/test/Driver/O.c
@@ -1,7 +1,7 @@
// Test that we parse and translate the -O option correctly.
// RUN: %clang -O -### %s 2>&1 | FileCheck -check-prefix=CHECK-O %s
-// CHECK-O: -O2
+// CHECK-O: -O1
// RUN: %clang -O0 -### %s 2>&1 | FileCheck -check-prefix=CHECK-O0 %s
// CHECK-O0: -O0
diff --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c
index f1355cee650f..cb522959202e 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -135,7 +135,7 @@
// RUN: %clang -### -S -fno-tree-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
// RUN: %clang -### -S -fno-tree-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
// RUN: %clang -### -S -ftree-vectorize -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
-// RUN: %clang -### -S -O %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
+// RUN: %clang -### -S -O %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
// RUN: %clang -### -S -O2 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
// RUN: %clang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
// RUN: %clang -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
@@ -157,7 +157,7 @@
// RUN: %clang -### -S -fno-tree-slp-vectorize -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
// RUN: %clang -### -S -fno-tree-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
// RUN: %clang -### -S -ftree-slp-vectorize -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
-// RUN: %clang -### -S -O %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
+// RUN: %clang -### -S -O %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
// RUN: %clang -### -S -O2 %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
// RUN: %clang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
// RUN: %clang -### -S -Oz %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
diff --git a/clang/test/Driver/lto.c b/clang/test/Driver/lto.c
index 2308372af9f5..f6734c764917 100644
--- a/clang/test/Driver/lto.c
+++ b/clang/test/Driver/lto.c
@@ -49,7 +49,7 @@
// NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
-// RUN: -fuse-ld=lld -flto -O -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: -fuse-ld=lld -flto -O -### 2>&1 | FileCheck --check-prefix=O1 %s
// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
// RUN: -fuse-ld=lld -flto -O1 -### 2>&1 | FileCheck --check-prefix=O1 %s
// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
More information about the cfe-commits
mailing list