[llvm] [BOLT][Utils] Add nfc-check-setup --cmp-bin flag (PR #72065)

Amir Ayupov via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 12 11:33:08 PST 2023


https://github.com/aaupov created https://github.com/llvm/llvm-project/pull/72065

None

>From 6e1d6685d0cc268e586c37867a9384ec5dfc42b8 Mon Sep 17 00:00:00 2001
From: Amir Aupov <amir.aupov at gmail.com>
Date: Sun, 12 Nov 2023 11:20:56 -0800
Subject: [PATCH] [BOLT][Utils] Add nfc-check-setup --cmp-bin flag

---
 bolt/utils/nfc-check-setup.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/bolt/utils/nfc-check-setup.py b/bolt/utils/nfc-check-setup.py
index 710b18350585374..7783ac071b16aa4 100755
--- a/bolt/utils/nfc-check-setup.py
+++ b/bolt/utils/nfc-check-setup.py
@@ -34,7 +34,7 @@ def main():
         "build_dir",
         nargs="?",
         default=os.getcwd(),
-        help="Path to BOLT build directory, default is current " "directory",
+        help="Path to BOLT build directory, default is current directory",
     )
     parser.add_argument(
         "--switch-back",
@@ -47,6 +47,12 @@ def main():
         default="HEAD^",
         help="Revision to checkout to compare vs HEAD",
     )
+    parser.add_argument(
+        "--cmp-bin",
+        default=True,
+        action="store_true",
+        help="Check old and new llvm-bolt binaries and exit with zero code if binaries are different",
+    )
     args, wrapper_args = parser.parse_known_args()
     bolt_path = f"{args.build_dir}/bin/llvm-bolt"
 
@@ -116,6 +122,10 @@ def main():
         "\tbin/llvm-lit -sv tools/bolt/test\nor\n"
         "\tbin/llvm-lit -sv tools/bolttests"
     )
+    if args.cmp_bin:
+        return not subprocess.call(
+            shlex.split(f"cmp -s {bolt_path}.old {bolt_path}.new")
+        )
 
 
 if __name__ == "__main__":



More information about the llvm-commits mailing list