[llvm] d781605 - [opt] Print deprecation warning for use of legacy syntax with new pass manager

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 15 14:30:48 PST 2022


Author: Arthur Eubanks
Date: 2022-11-15T14:30:40-08:00
New Revision: d7816057d7165d2872a03d635b66ccef8ac99c46

URL: https://github.com/llvm/llvm-project/commit/d7816057d7165d2872a03d635b66ccef8ac99c46
DIFF: https://github.com/llvm/llvm-project/commit/d7816057d7165d2872a03d635b66ccef8ac99c46.diff

LOG: [opt] Print deprecation warning for use of legacy syntax with new pass manager

And a possible opt invocation plus a link to more extensive documentation.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D136617

Added: 
    llvm/test/Other/opt-legacy-syntax-deprecation.ll

Modified: 
    llvm/tools/opt/opt.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/Other/opt-legacy-syntax-deprecation.ll b/llvm/test/Other/opt-legacy-syntax-deprecation.ll
new file mode 100644
index 0000000000000..dd90c67609a25
--- /dev/null
+++ b/llvm/test/Other/opt-legacy-syntax-deprecation.ll
@@ -0,0 +1,12 @@
+; REQUIRES: x86-registered-target
+
+; RUN: opt /dev/null -disable-output 2>&1 | FileCheck %s --check-prefix=OK --allow-empty
+; RUN: opt /dev/null -disable-output -passes=instcombine 2>&1 | FileCheck %s --check-prefix=OK --allow-empty
+; RUN: opt /dev/null -disable-output -instcombine 2>&1 | FileCheck %s --check-prefix=WARN
+; RUN: opt /dev/null -disable-output -instcombine -globaldce 2>&1 | FileCheck %s --check-prefix=WARN
+; RUN: opt /dev/null -disable-output -instcombine -enable-new-pm=0 2>&1 | FileCheck %s --check-prefix=OK --allow-empty
+; RUN: opt /dev/null -disable-output -codegenprepare -mtriple=x86_64-unknown-linux-gnu 2>&1 | FileCheck %s --check-prefix=OK --allow-empty
+
+; OK-NOT: deprecated
+
+; WARN: The `opt -passname` syntax for the new pass manager is deprecated, please use `opt -passes=<pipeline>` (or the `-p` alias for a more concise version).

diff  --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 702eee3535cd0..a52dd98a6fe15 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -713,6 +713,13 @@ int main(int argc, char **argv) {
                 "-passes='default<O#>,other-pass'\n";
       return 1;
     }
+    if (!PassList.empty()) {
+      errs() << "The `opt -passname` syntax for the new pass manager is "
+                "deprecated, please use `opt -passes=<pipeline>` (or the `-p` "
+                "alias for a more concise version).\n";
+      errs() << "See https://llvm.org/docs/NewPassManager.html#invoking-opt "
+                "for more details on the pass pipeline syntax.\n\n";
+    }
     std::string Pipeline = PassPipeline;
 
     SmallVector<StringRef, 4> Passes;


        


More information about the llvm-commits mailing list