[llvm] 5b30fc2 - [opt] Add -p alias for -passes

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 2 10:46:51 PDT 2022


Author: Arthur Eubanks
Date: 2022-11-02T10:46:34-07:00
New Revision: 5b30fc23696eb9c01c1182a438709120853cf06d

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

LOG: [opt] Add -p alias for -passes

See [1] for background.

Some people have complained that `opt -passes=instcombine` is a lot more typing than `opt -instcombine`.
As a compromise that nobody has objected to in [1], allow `opt -p instcombine`.

[1] https://discourse.llvm.org/t/rfc-legacy-opt-pass-syntax-with-new-pass-manager/65863

Reviewed By: bjope, asbirlea

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

Added: 
    

Modified: 
    llvm/docs/NewPassManager.rst
    llvm/test/Other/new-pass-manager.ll
    llvm/tools/opt/opt.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/docs/NewPassManager.rst b/llvm/docs/NewPassManager.rst
index 9390afa300ca5..68a1ac1e0baa5 100644
--- a/llvm/docs/NewPassManager.rst
+++ b/llvm/docs/NewPassManager.rst
@@ -430,6 +430,8 @@ To use the new PM:
 .. code-block:: shell
 
   $ opt -passes='pass1,pass2' /tmp/a.ll -S
+  # -p is an alias for -passes
+  $ opt -p pass1,pass2 /tmp/a.ll -S
 
 The new PM typically requires explicit pass nesting. For example, to run a
 function pass, then a module pass, we need to wrap the function pass in a module

diff  --git a/llvm/test/Other/new-pass-manager.ll b/llvm/test/Other/new-pass-manager.ll
index f9cea34e22226..5be67a34a9174 100644
--- a/llvm/test/Other/new-pass-manager.ll
+++ b/llvm/test/Other/new-pass-manager.ll
@@ -8,6 +8,9 @@
 ; RUN: opt -disable-output -disable-verify -verify-cfg-preserved=1 -debug-pass-manager \
 ; RUN:     -passes=no-op-module %s 2>&1 \
 ; RUN:     | FileCheck %s --check-prefix=CHECK-MODULE-PASS
+; RUN: opt -disable-output -disable-verify -verify-cfg-preserved=1 -debug-pass-manager \
+; RUN:     -p no-op-module %s 2>&1 \
+; RUN:     | FileCheck %s --check-prefix=CHECK-MODULE-PASS
 ; CHECK-MODULE-PASS: Running pass: NoOpModulePass
 
 ; RUN: opt -disable-output -disable-verify -verify-cfg-preserved=1 -debug-pass-manager \

diff  --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 62bdd6e095014..8dac02a356b18 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -85,6 +85,8 @@ static cl::opt<std::string> PassPipeline(
     cl::desc(
         "A textual description of the pass pipeline. To have analysis passes "
         "available before a certain pass, add 'require<foo-analysis>'."));
+static cl::alias PassPipeline2("p", cl::aliasopt(PassPipeline),
+                                   cl::desc("Alias for -passes"));
 
 static cl::opt<bool> PrintPasses("print-passes",
                                  cl::desc("Print available passes that can be "


        


More information about the llvm-commits mailing list