From 15fefcb9eb3a2b9080b44e3784608597666000ec Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Mon, 18 Oct 2021 15:43:08 -0700 Subject: [PATCH] [opt] Directly translate -O# to -passes='default' Right now when we see -O# we add the corresponding 'default' into the list of passes to run when translating legacy -pass-name. This has the side effect of not using the default AA pipeline. Instead, treat -O# as -passes='default', but don't allow any other -passes or -pass-name. I think we can keep `opt -O#` as shorthand for `opt -passes='default` but disallow anything more than just -O#. Tests need to be updated to not use `opt -O# -pass-name`. Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D112036 --- .../test/CodeGen/AMDGPU/extra-sroa-after-unroll.ll | 6 ++--- .../CodeGen/AMDGPU/r600.amdgpu-alias-analysis.ll | 2 +- llvm/test/CodeGen/NVPTX/nvvm-reflect-arch.ll | 4 ++-- llvm/test/CodeGen/NVPTX/nvvm-reflect.ll | 4 ++-- .../MemorySanitizer/msan_llvm_launder_invariant.ll | 4 ++-- .../MemorySanitizer/msan_llvm_strip_invariant.ll | 4 ++-- llvm/test/Other/opt-On.ll | 19 +++++++++++++++ .../GlobalOpt/long-compilation-global-sra.ll | 2 +- llvm/test/Transforms/Inline/devirtualize-3.ll | 1 - .../Transforms/LoopVectorize/PowerPC/reg-usage.ll | 4 ++-- .../LoopVectorize/PowerPC/widened-massv-call.ll | 2 +- .../LoopVectorize/X86/float-induction-x86.ll | 2 +- .../LoopVectorize/X86/metadata-enable.ll | 19 ++++++++------- .../LoopVectorize/X86/x86_fp80-vector-store.ll | 2 +- llvm/test/Transforms/LoopVectorize/global_alias.ll | 2 +- .../LoopVersioningLICM/loopversioningLICM3.ll | 2 +- .../test/Transforms/LoopVersioningLICM/metadata.ll | 1 - .../MergeFunc/mergefunc-preserve-debug-info.ll | 4 ++-- llvm/tools/opt/opt.cpp | 27 ++++++++++++++++------ 19 files changed, 70 insertions(+), 41 deletions(-) create mode 100644 llvm/test/Other/opt-On.ll diff --git a/llvm/test/CodeGen/AMDGPU/extra-sroa-after-unroll.ll b/llvm/test/CodeGen/AMDGPU/extra-sroa-after-unroll.ll index db704a8..6f50abc 100644 --- a/llvm/test/CodeGen/AMDGPU/extra-sroa-after-unroll.ll +++ b/llvm/test/CodeGen/AMDGPU/extra-sroa-after-unroll.ll @@ -1,6 +1,6 @@ -; RUN: opt -instnamer -O1 -mtriple=amdgcn-- -S -o - %s | FileCheck -check-prefixes=GCN,O1 %s -; RUN: opt -instnamer -O2 -mtriple=amdgcn-- -S -o - %s | FileCheck -check-prefixes=GCN,O2 %s -; RUN: opt -instnamer -O3 -mtriple=amdgcn-- -S -o - %s | FileCheck -check-prefixes=GCN,O3 %s +; RUN: opt -passes='default,instnamer' -mtriple=amdgcn-- -S -o - %s | FileCheck -check-prefixes=GCN,O1 %s +; RUN: opt -passes='default,instnamer' -mtriple=amdgcn-- -S -o - %s | FileCheck -check-prefixes=GCN,O2 %s +; RUN: opt -passes='default,instnamer' -mtriple=amdgcn-- -S -o - %s | FileCheck -check-prefixes=GCN,O3 %s target datalayout = "A5" ; GCN-LABEL: t0 diff --git a/llvm/test/CodeGen/AMDGPU/r600.amdgpu-alias-analysis.ll b/llvm/test/CodeGen/AMDGPU/r600.amdgpu-alias-analysis.ll index 9199e9b..32dd8e5f 100644 --- a/llvm/test/CodeGen/AMDGPU/r600.amdgpu-alias-analysis.ll +++ b/llvm/test/CodeGen/AMDGPU/r600.amdgpu-alias-analysis.ll @@ -1,4 +1,4 @@ -; RUN: opt -mtriple=r600-- -O3 -aa-eval -print-all-alias-modref-info -disable-output < %s 2>&1 | FileCheck %s +; RUN: opt -mtriple=r600-- -passes='default,aa-eval' -print-all-alias-modref-info -disable-output < %s 2>&1 | FileCheck %s ; CHECK: MayAlias: i8 addrspace(5)* %p, i8 addrspace(999)* %p1 define amdgpu_kernel void @test(i8 addrspace(5)* %p, i8 addrspace(999)* %p1) { diff --git a/llvm/test/CodeGen/NVPTX/nvvm-reflect-arch.ll b/llvm/test/CodeGen/NVPTX/nvvm-reflect-arch.ll index 8e8d866..7e7cde8 100644 --- a/llvm/test/CodeGen/NVPTX/nvvm-reflect-arch.ll +++ b/llvm/test/CodeGen/NVPTX/nvvm-reflect-arch.ll @@ -1,9 +1,9 @@ ; Libdevice in recent CUDA versions relies on __CUDA_ARCH reflecting GPU type. ; Verify that __nvvm_reflect() is replaced with an appropriate value. ; -; RUN: opt %s -S -nvvm-reflect -O2 -mtriple=nvptx64 \ +; RUN: opt %s -S -passes='default' -mtriple=nvptx64 \ ; RUN: | FileCheck %s --check-prefixes=COMMON,SM20 -; RUN: opt %s -S -nvvm-reflect -O2 -mtriple=nvptx64 -mcpu=sm_35 \ +; RUN: opt %s -S -passes='default' -mtriple=nvptx64 -mcpu=sm_35 \ ; RUN: | FileCheck %s --check-prefixes=COMMON,SM35 @"$str" = private addrspace(1) constant [12 x i8] c"__CUDA_ARCH\00" diff --git a/llvm/test/CodeGen/NVPTX/nvvm-reflect.ll b/llvm/test/CodeGen/NVPTX/nvvm-reflect.ll index f7403df..ec0c787 100644 --- a/llvm/test/CodeGen/NVPTX/nvvm-reflect.ll +++ b/llvm/test/CodeGen/NVPTX/nvvm-reflect.ll @@ -3,12 +3,12 @@ ; RUN: cat %s > %t.noftz ; RUN: echo '!0 = !{i32 4, !"nvvm-reflect-ftz", i32 0}' >> %t.noftz -; RUN: opt %t.noftz -S -mtriple=nvptx-nvidia-cuda -nvvm-reflect -O2 \ +; RUN: opt %t.noftz -S -mtriple=nvptx-nvidia-cuda -passes='default' \ ; RUN: | FileCheck %s --check-prefix=USE_FTZ_0 --check-prefix=CHECK ; RUN: cat %s > %t.ftz ; RUN: echo '!0 = !{i32 4, !"nvvm-reflect-ftz", i32 1}' >> %t.ftz -; RUN: opt %t.ftz -S -mtriple=nvptx-nvidia-cuda -nvvm-reflect -O2 \ +; RUN: opt %t.ftz -S -mtriple=nvptx-nvidia-cuda -passes='default' \ ; RUN: | FileCheck %s --check-prefix=USE_FTZ_1 --check-prefix=CHECK @str = private unnamed_addr addrspace(4) constant [11 x i8] c"__CUDA_FTZ\00" diff --git a/llvm/test/Instrumentation/MemorySanitizer/msan_llvm_launder_invariant.ll b/llvm/test/Instrumentation/MemorySanitizer/msan_llvm_launder_invariant.ll index d3d57fd..6dd2c44 100644 --- a/llvm/test/Instrumentation/MemorySanitizer/msan_llvm_launder_invariant.ll +++ b/llvm/test/Instrumentation/MemorySanitizer/msan_llvm_launder_invariant.ll @@ -1,7 +1,7 @@ ; Make sure MSan handles llvm.launder.invariant.group correctly. -; RUN: opt < %s -msan -msan-kernel=1 -O1 -S | FileCheck -check-prefixes=CHECK %s -; RUN: opt < %s -msan -O1 -S | FileCheck -check-prefixes=CHECK %s +; RUN: opt < %s -passes='function(msan),default' -msan-kernel=1 -S | FileCheck -check-prefixes=CHECK %s +; RUN: opt < %s -passes='function(msan),default' -S | FileCheck -check-prefixes=CHECK %s target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/llvm/test/Instrumentation/MemorySanitizer/msan_llvm_strip_invariant.ll b/llvm/test/Instrumentation/MemorySanitizer/msan_llvm_strip_invariant.ll index aa7745f..063ca6e 100644 --- a/llvm/test/Instrumentation/MemorySanitizer/msan_llvm_strip_invariant.ll +++ b/llvm/test/Instrumentation/MemorySanitizer/msan_llvm_strip_invariant.ll @@ -1,7 +1,7 @@ ; Make sure MSan handles llvm.launder.invariant.group correctly. -; RUN: opt < %s -msan -msan-kernel=1 -O1 -S | FileCheck -check-prefixes=CHECK %s -; RUN: opt < %s -msan -O1 -S | FileCheck -check-prefixes=CHECK %s +; RUN: opt < %s -passes='function(msan),default' -msan-kernel=1 -S | FileCheck -check-prefixes=CHECK %s +; RUN: opt < %s -passes='function(msan),default' -S | FileCheck -check-prefixes=CHECK %s target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/llvm/test/Other/opt-On.ll b/llvm/test/Other/opt-On.ll new file mode 100644 index 0000000..4bbbd0f --- /dev/null +++ b/llvm/test/Other/opt-On.ll @@ -0,0 +1,19 @@ +; RUN: not opt -O1 -O2 < %s 2>&1 | FileCheck %s --check-prefix=MULTIPLE +; RUN: not opt -O1 -passes='no-op-module' < %s 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt -O0 < %s -S 2>&1 | FileCheck %s --check-prefix=OPT +; RUN: opt -O1 < %s -S 2>&1 | FileCheck %s --check-prefix=OPT +; RUN: opt -O2 < %s -S 2>&1 | FileCheck %s --check-prefix=OPT +; RUN: opt -O3 < %s -S 2>&1 | FileCheck %s --check-prefix=OPT +; RUN: opt -Os < %s -S 2>&1 | FileCheck %s --check-prefix=OPT +; RUN: opt -Oz < %s -S 2>&1 | FileCheck %s --check-prefix=OPT +; RUN: opt -O2 -debug-pass-manager -disable-output < %s 2>&1 | FileCheck %s --check-prefix=AA + +; MULTIPLE: Cannot specify multiple -O# +; BOTH: Cannot specify -O# and --passes= +; OPT: define void @f +; Make sure we run the default AA pipeline with `opt -O#` +; AA: Running analysis: ScopedNoAliasAA + +define void @f() { + unreachable +} diff --git a/llvm/test/Transforms/GlobalOpt/long-compilation-global-sra.ll b/llvm/test/Transforms/GlobalOpt/long-compilation-global-sra.ll index 69a358e..c71ac32 100644 --- a/llvm/test/Transforms/GlobalOpt/long-compilation-global-sra.ll +++ b/llvm/test/Transforms/GlobalOpt/long-compilation-global-sra.ll @@ -1,4 +1,4 @@ -; RUN: opt %s --O0 -globalopt -S -o - +; RUN: opt %s -passes='default,globalopt' -S -o - ; This is a regression test against very slow execution... ; In bad case it should fail by timeout. diff --git a/llvm/test/Transforms/Inline/devirtualize-3.ll b/llvm/test/Transforms/Inline/devirtualize-3.ll index 987463a..ea6d39a 100644 --- a/llvm/test/Transforms/Inline/devirtualize-3.ll +++ b/llvm/test/Transforms/Inline/devirtualize-3.ll @@ -1,4 +1,3 @@ -; RUN: opt -basic-aa -S -O2 < %s | FileCheck %s ; RUN: opt -aa-pipeline=basic-aa -S -passes='default' < %s | FileCheck %s ; PR5009 diff --git a/llvm/test/Transforms/LoopVectorize/PowerPC/reg-usage.ll b/llvm/test/Transforms/LoopVectorize/PowerPC/reg-usage.ll index f63effd..39b91e2 100644 --- a/llvm/test/Transforms/LoopVectorize/PowerPC/reg-usage.ll +++ b/llvm/test/Transforms/LoopVectorize/PowerPC/reg-usage.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -debug-only=loop-vectorize -loop-vectorize -vectorizer-maximize-bandwidth -O2 -mtriple=powerpc64-unknown-linux -S -mcpu=pwr8 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-PWR8 -; RUN: opt < %s -debug-only=loop-vectorize -loop-vectorize -vectorizer-maximize-bandwidth -O2 -mtriple=powerpc64le-unknown-linux -S -mcpu=pwr9 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-PWR9 +; RUN: opt < %s -debug-only=loop-vectorize -passes='function(loop-vectorize),default' -vectorizer-maximize-bandwidth -mtriple=powerpc64-unknown-linux -S -mcpu=pwr8 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-PWR8 +; RUN: opt < %s -debug-only=loop-vectorize -passes='function(loop-vectorize),default' -vectorizer-maximize-bandwidth -mtriple=powerpc64le-unknown-linux -S -mcpu=pwr9 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-PWR9 ; REQUIRES: asserts @a = global [1024 x i8] zeroinitializer, align 16 diff --git a/llvm/test/Transforms/LoopVectorize/PowerPC/widened-massv-call.ll b/llvm/test/Transforms/LoopVectorize/PowerPC/widened-massv-call.ll index f498679..c6b06dc 100644 --- a/llvm/test/Transforms/LoopVectorize/PowerPC/widened-massv-call.ll +++ b/llvm/test/Transforms/LoopVectorize/PowerPC/widened-massv-call.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -vector-library=MASSV -force-vector-interleave=1 \ -; RUN: -vectorizer-maximize-bandwidth -O2 -inject-tli-mappings -loop-vectorize \ +; RUN: -vectorizer-maximize-bandwidth -passes='default,inject-tli-mappings,loop-vectorize' \ ; RUN: -mtriple=powerpc64le-unknown-linux -S -mcpu=pwr9 2>&1 | FileCheck %s define dso_local double @test(float* %Arr) { diff --git a/llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll b/llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll index 2296fb1..254a4c3 100644 --- a/llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll +++ b/llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -O3 -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -keep-loops=false -mcpu=core-avx2 -mtriple=x86_64-unknown-linux-gnu -S | FileCheck --check-prefix AUTO_VEC %s +; RUN: opt < %s -passes='default,simplifycfg' -simplifycfg-require-and-preserve-domtree=1 -keep-loops=false -mcpu=core-avx2 -mtriple=x86_64-unknown-linux-gnu -S | FileCheck --check-prefix AUTO_VEC %s target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" diff --git a/llvm/test/Transforms/LoopVectorize/X86/metadata-enable.ll b/llvm/test/Transforms/LoopVectorize/X86/metadata-enable.ll index 84aaf33..e24ec51f 100644 --- a/llvm/test/Transforms/LoopVectorize/X86/metadata-enable.ll +++ b/llvm/test/Transforms/LoopVectorize/X86/metadata-enable.ll @@ -1,14 +1,13 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -mcpu=corei7 -O1 -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O1 -; RUN: opt < %s -mcpu=corei7 -O2 -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O2 -; RUN: opt < %s -mcpu=corei7 -O3 -S -unroll-threshold=150 -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3 -; RUN: opt < %s -mcpu=corei7 -O3 -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3DEFAULT -; RUN: opt < %s -mcpu=corei7 -Os -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=Os -; RUN: opt < %s -mcpu=corei7 -Oz -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=Oz -; RUN: opt < %s -mcpu=corei7 -O1 -loop-vectorize -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O1VEC2 -; RUN: opt < %s -mcpu=corei7 -Oz -loop-vectorize -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=OzVEC2 -; RUN: opt < %s -mcpu=corei7 -O3 -unroll-threshold=150 -vectorize-loops=false -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3DIS -; RUN: opt < %s -mcpu=corei7 -O1 -loop-vectorize -S -unroll-allow-partial=0 -enable-new-pm=1 | FileCheck %s --check-prefix=O1VEC2 +; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O1 +; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O2 +; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-threshold=150 -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3 +; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3DEFAULT +; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=Os +; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=Oz +; RUN: opt < %s -mcpu=corei7 -passes='default,loop-vectorize' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O1VEC2 +; RUN: opt < %s -mcpu=corei7 -passes='default,loop-vectorize' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=OzVEC2 +; RUN: opt < %s -mcpu=corei7 -passes='default' -unroll-threshold=150 -vectorize-loops=false -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3DIS ; This file tests the llvm.loop.vectorize.enable metadata forcing ; vectorization even when optimization levels are too low, or when diff --git a/llvm/test/Transforms/LoopVectorize/X86/x86_fp80-vector-store.ll b/llvm/test/Transforms/LoopVectorize/X86/x86_fp80-vector-store.ll index 5c9077f..37df46f 100644 --- a/llvm/test/Transforms/LoopVectorize/X86/x86_fp80-vector-store.ll +++ b/llvm/test/Transforms/LoopVectorize/X86/x86_fp80-vector-store.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -O3 -loop-vectorize -force-vector-interleave=1 -force-vector-width=2 -S < %s | FileCheck %s +; RUN: opt -passes='default,loop-vectorize' -force-vector-interleave=1 -force-vector-width=2 -S < %s | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.7.0" diff --git a/llvm/test/Transforms/LoopVectorize/global_alias.ll b/llvm/test/Transforms/LoopVectorize/global_alias.ll index 7333af3..abf2942 100644 --- a/llvm/test/Transforms/LoopVectorize/global_alias.ll +++ b/llvm/test/Transforms/LoopVectorize/global_alias.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -O1 -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -S | FileCheck %s +; RUN: opt < %s -passes='default,loop-vectorize,dce,instcombine' -force-vector-interleave=1 -force-vector-width=4 -S | FileCheck %s target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S64" diff --git a/llvm/test/Transforms/LoopVersioningLICM/loopversioningLICM3.ll b/llvm/test/Transforms/LoopVersioningLICM/loopversioningLICM3.ll index f5da40b..0db07ed 100644 --- a/llvm/test/Transforms/LoopVersioningLICM/loopversioningLICM3.ll +++ b/llvm/test/Transforms/LoopVersioningLICM/loopversioningLICM3.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -O1 -S -loop-versioning-licm -debug-only=loop-versioning-licm 2>&1 | FileCheck %s +; RUN: opt < %s -S -passes='default,loop-versioning-licm' -debug-only=loop-versioning-licm 2>&1 | FileCheck %s ; RUN: opt < %s -S -passes='loop-versioning-licm' -debug-only=loop-versioning-licm 2>&1 | FileCheck %s ; REQUIRES: asserts ; diff --git a/llvm/test/Transforms/LoopVersioningLICM/metadata.ll b/llvm/test/Transforms/LoopVersioningLICM/metadata.ll index 445b09c..3656218 100644 --- a/llvm/test/Transforms/LoopVersioningLICM/metadata.ll +++ b/llvm/test/Transforms/LoopVersioningLICM/metadata.ll @@ -1,4 +1,3 @@ -; RUN: opt < %s -O1 -S -loop-versioning-licm -licm 2>&1 | FileCheck %s ; RUN: opt < %s -S -passes='function(loop-versioning-licm,loop-mssa(licm))' 2>&1 | FileCheck %s ; CHECK-LABEL: @without_metadata( diff --git a/llvm/test/Transforms/MergeFunc/mergefunc-preserve-debug-info.ll b/llvm/test/Transforms/MergeFunc/mergefunc-preserve-debug-info.ll index bb63358..65169a2 100644 --- a/llvm/test/Transforms/MergeFunc/mergefunc-preserve-debug-info.ll +++ b/llvm/test/Transforms/MergeFunc/mergefunc-preserve-debug-info.ll @@ -1,5 +1,5 @@ -; RUN: opt -O0 -S -mergefunc -mergefunc-preserve-debug-info < %s | FileCheck %s --check-prefix=OPTIMIZATION_LEVEL_0 -; RUN: opt -O2 -S -mergefunc -mergefunc-preserve-debug-info < %s | FileCheck %s --check-prefix=OPTIMIZATION_LEVEL_2 +; RUN: opt -passes='default,mergefunc' -S -mergefunc-preserve-debug-info < %s | FileCheck %s --check-prefix=OPTIMIZATION_LEVEL_0 +; RUN: opt -passes='default,mergefunc' -S -mergefunc-preserve-debug-info < %s | FileCheck %s --check-prefix=OPTIMIZATION_LEVEL_2 ; Preserve debug info in thunks under -mergefunc -mergefunc-preserve-debug-info ; diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index b299fa2..7793a54 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -772,19 +772,32 @@ int main(int argc, char **argv) { << "Cannot specify passes via both -foo-pass and --passes=foo-pass\n"; return 1; } + auto NumOLevel = OptLevelO0 + OptLevelO1 + OptLevelO2 + OptLevelO3 + + OptLevelOs + OptLevelOz; + if (NumOLevel > 1) { + errs() << "Cannot specify multiple -O#\n"; + return 1; + } + if (NumOLevel > 0 && PassPipeline.getNumOccurrences() > 0) { + errs() << "Cannot specify -O# and --passes=, use " + "-passes='default,other-pass'\n"; + return 1; + } + std::string Pipeline = PassPipeline; + SmallVector Passes; if (OptLevelO0) - Passes.push_back("default"); + Pipeline = "default"; if (OptLevelO1) - Passes.push_back("default"); + Pipeline = "default"; if (OptLevelO2) - Passes.push_back("default"); + Pipeline = "default"; if (OptLevelO3) - Passes.push_back("default"); + Pipeline = "default"; if (OptLevelOs) - Passes.push_back("default"); + Pipeline = "default"; if (OptLevelOz) - Passes.push_back("default"); + Pipeline = "default"; for (const auto &P : PassList) Passes.push_back(P->getPassArgument()); OutputKind OK = OK_NoOutput; @@ -803,7 +816,7 @@ int main(int argc, char **argv) { // string. Hand off the rest of the functionality to the new code for that // layer. return runPassPipeline(argv[0], *M, TM.get(), &TLII, Out.get(), - ThinLinkOut.get(), RemarksFile.get(), PassPipeline, + ThinLinkOut.get(), RemarksFile.get(), Pipeline, Passes, OK, VK, PreserveAssemblyUseListOrder, PreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash, EnableDebugify) -- 2.7.4