[llvm] 431b23d - [opt] Error on `opt -O# --foo-pass`
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon May 9 09:53:36 PDT 2022
Author: Arthur Eubanks
Date: 2022-05-09T09:53:24-07:00
New Revision: 431b23d20d5c2889d38c9ce20ac8e66357d5d9c4
URL: https://github.com/llvm/llvm-project/commit/431b23d20d5c2889d38c9ce20ac8e66357d5d9c4
DIFF: https://github.com/llvm/llvm-project/commit/431b23d20d5c2889d38c9ce20ac8e66357d5d9c4.diff
LOG: [opt] Error on `opt -O# --foo-pass`
Matches the error message we emit with `-opt -O# --passes=foo`.
Otherwise we crash later on.
Makes #55320 much less confusing.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D125196
Added:
Modified:
llvm/test/Other/opt-On.ll
llvm/tools/opt/opt.cpp
Removed:
################################################################################
diff --git a/llvm/test/Other/opt-On.ll b/llvm/test/Other/opt-On.ll
index 4bbbd0ff68227..c0e61695e008d 100644
--- a/llvm/test/Other/opt-On.ll
+++ b/llvm/test/Other/opt-On.ll
@@ -1,5 +1,6 @@
; 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: not opt -O1 --gvn < %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
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 2b3b392171846..bd4738ded693b 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -780,8 +780,9 @@ int main(int argc, char **argv) {
errs() << "Cannot specify multiple -O#\n";
return 1;
}
- if (NumOLevel > 0 && PassPipeline.getNumOccurrences() > 0) {
- errs() << "Cannot specify -O# and --passes=, use "
+ if (NumOLevel > 0 &&
+ (PassPipeline.getNumOccurrences() > 0 || PassList.size() > 0)) {
+ errs() << "Cannot specify -O# and --passes=/--foo-pass, use "
"-passes='default<O#>,other-pass'\n";
return 1;
}
More information about the llvm-commits
mailing list