[PATCH] D99382: Add -disable-verify flag to llvm-link.
Nick Lewycky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 25 14:53:59 PDT 2021
nickwasmer created this revision.
nickwasmer added reviewers: tejohnson, tra, jdoerfert.
nickwasmer added a project: LLVM.
nickwasmer requested review of this revision.
Herald added a subscriber: llvm-commits.
This flag allows the developer to see the result of linking even if it fails the verifier, as a step in debugging cases where the linked module fails the verifier. Same as opt -disable-verify.
No test is introduced. I don't want to write a test that relies on any manner of producing an invalid output that is a bug that should be fixed, as then the test would break if a bug is fixed.
There's an alternative that I considered but did not implement. Unlike opt, llvm-link has many intermediate outputs as it links more files and runs the verifier on each one. We could instead have a flag that outputs a module and stop after running the verifier and seeing a failure. This would allow us to find issues closer to the source, but it also requires that the verifier not crash on the invalid input in question.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D99382
Files:
llvm/tools/llvm-link/llvm-link.cpp
Index: llvm/tools/llvm-link/llvm-link.cpp
===================================================================
--- llvm/tools/llvm-link/llvm-link.cpp
+++ llvm/tools/llvm-link/llvm-link.cpp
@@ -110,6 +110,9 @@
cl::desc("Preserve use-list order when writing LLVM assembly."),
cl::init(false), cl::Hidden);
+static cl::opt<bool>
+NoVerify("disable-verify", cl::desc("Do not run the verifier"), cl::Hidden);
+
static ExitOnError ExitOnErr;
// Read the specified bitcode file in and return it. This routine searches the
@@ -311,7 +314,7 @@
// Load the specified source module.
auto &SrcModule = ModuleLoaderCache(argv0, FileName);
- if (verifyModule(SrcModule, &errs())) {
+ if (!NoVerify && verifyModule(SrcModule, &errs())) {
errs() << argv0 << ": " << FileName;
WithColor::error() << "input module is broken!\n";
return false;
@@ -372,7 +375,7 @@
// Note that when ODR merging types cannot verify input files in here When
// doing that debug metadata in the src module might already be pointing to
// the destination.
- if (DisableDITypeMap && verifyModule(*M, &errs())) {
+ if (DisableDITypeMap && !NoVerify && verifyModule(*M, &errs())) {
errs() << argv0 << ": " << File << ": ";
WithColor::error() << "input module is broken!\n";
return false;
@@ -471,7 +474,7 @@
return 1;
}
- if (verifyModule(*Composite, &errs())) {
+ if (!NoVerify && verifyModule(*Composite, &errs())) {
errs() << argv[0] << ": ";
WithColor::error() << "linked module is broken!\n";
return 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99382.333431.patch
Type: text/x-patch
Size: 1588 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210325/c3302453/attachment.bin>
More information about the llvm-commits
mailing list