Skip to content

Conversation

@ellishg
Copy link
Contributor

@ellishg ellishg commented Mar 19, 2025

The --disable_verify flag is implemented for ELF and is used to disable LLVM module verification.

def disable_verify: F<"disable-verify">;

This allows us to quickly suppress verification errors.

@llvmbot
Copy link
Member

llvmbot commented Mar 19, 2025

@llvm/pr-subscribers-lld-macho

@llvm/pr-subscribers-lld

Author: Ellis Hoag (ellishg)

Changes

The --disable_verify flag is implemented for ELF and is used to disable LLVM module verification.

def disable_verify: F<"disable-verify">;

This allows us to quickly suppress verification errors.


Full diff: https://github.com/llvm/llvm-project/pull/132105.diff

5 Files Affected:

  • (modified) lld/MachO/Config.h (+1)
  • (modified) lld/MachO/Driver.cpp (+1)
  • (modified) lld/MachO/LTO.cpp (+1)
  • (modified) lld/MachO/Options.td (+3)
  • (added) lld/test/MachO/verify.ll (+16)
diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h
index f8dcc84e4ee1b..1752f4ef3406e 100644
--- a/lld/MachO/Config.h
+++ b/lld/MachO/Config.h
@@ -219,6 +219,7 @@ struct Configuration {
   llvm::StringRef csProfilePath;
   bool pgoWarnMismatch;
   bool warnThinArchiveMissingMembers;
+  bool disableVerify;
 
   bool callGraphProfileSort = false;
   llvm::StringRef printSymbolOrder;
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 4f6c9b4ddc798..ee26fafb50b73 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -1832,6 +1832,7 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
       args.hasFlag(OPT_warn_thin_archive_missing_members,
                    OPT_no_warn_thin_archive_missing_members, true);
   config->generateUuid = !args.hasArg(OPT_no_uuid);
+  config->disableVerify = args.hasArg(OPT_disable_verify);
 
   auto IncompatWithCGSort = [&](StringRef firstArgStr) {
     // Throw an error only if --call-graph-profile-sort is explicitly specified
diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp
index 2eeca44ecbb3c..075faa8801a54 100644
--- a/lld/MachO/LTO.cpp
+++ b/lld/MachO/LTO.cpp
@@ -60,6 +60,7 @@ static lto::Config createConfig() {
   c.CSIRProfile = std::string(config->csProfilePath);
   c.RunCSIRInstr = config->csProfileGenerate;
   c.PGOWarnMismatch = config->pgoWarnMismatch;
+  c.DisableVerify = config->disableVerify;
   c.OptLevel = config->ltoo;
   c.CGOptLevel = config->ltoCgo;
   if (config->saveTemps)
diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index 9001e85582c12..0f78c3bbe2b06 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -197,6 +197,9 @@ def cs_profile_generate: Flag<["--"], "cs-profile-generate">,
     HelpText<"Perform context sensitive PGO instrumentation">, Group<grp_lld>;
 def cs_profile_path: Joined<["--"], "cs-profile-path=">,
     HelpText<"Context sensitive profile file path">, Group<grp_lld>;
+def disable_verify : Flag<["--"], "disable_verify">,
+                     HelpText<"Do not verify LLVM modules">,
+                     Group<grp_lld>;
 defm pgo_warn_mismatch: BB<"pgo-warn-mismatch",
   "turn on warnings about profile cfg mismatch (default)",
   "turn off warnings about profile cfg mismatch">, Group<grp_lld>;
diff --git a/lld/test/MachO/verify.ll b/lld/test/MachO/verify.ll
new file mode 100644
index 0000000000000..8731c99c2ca14
--- /dev/null
+++ b/lld/test/MachO/verify.ll
@@ -0,0 +1,16 @@
+; REQUIRES: x86
+
+; RUN: llvm-as %s -o %t.o
+; RUN: %lld -dylib %t.o -o %t2 --lto-debug-pass-manager 2>&1 | FileCheck %s --check-prefix=VERIFY
+; RUN: %lld -dylib %t.o -o %t2 --lto-debug-pass-manager --disable_verify 2>&1 | FileCheck %s --implicit-check-not=VerifierPass
+
+target triple = "x86_64-apple-darwin"
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @_start() {
+entry:
+  ret void
+}
+
+; VERIFY: Running pass: VerifierPass
+; VERIFY: Running pass: VerifierPass

def cs_profile_path: Joined<["--"], "cs-profile-path=">,
HelpText<"Context sensitive profile file path">, Group<grp_lld>;
def disable_verify : Flag<["--"], "disable_verify">,
HelpText<"Do not verify LLVM modules">,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit : would be good to move this flag around other LTO-specific flags. Ex: lto_CGO.
Also maybe help text could show this is LTO related. Ex "Do not verify LLVM modules during LTO"

@ellishg ellishg merged commit 86fc897 into llvm:main Mar 19, 2025
8 of 10 checks passed
@ellishg ellishg deleted the lld-macho-disable-verify branch March 19, 2025 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants