[clang] [Clang][CMake] Support perf, LBR, and Instrument CLANG_BOLT options (PR #69133)

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 6 00:54:22 PST 2023


================
@@ -67,6 +67,67 @@ def merge_fdata(args):
     return 0
 
 
+def perf(args):
+    parser = argparse.ArgumentParser(
+        prog="perf-helper perf", description="perf wrapper for BOLT profile collection"
+    )
+    parser.add_argument(
+        "--lbr", action="store_true", help="Use perf with branch stacks"
+    )
+    parser.add_argument("cmd", nargs="*", help="")
+
+    # Use python's arg parser to handle all leading option arguments, but pass
+    # everything else through to perf
+    first_cmd = next(arg for arg in args if not arg.startswith("--"))
----------------
petrhosek wrote:

You can use `parser.add_argument('cmd', nargs=argparse.REMAINDER)` to let `argparse` handle this for you.

https://github.com/llvm/llvm-project/pull/69133


More information about the cfe-commits mailing list