[PATCH] D134802: [llvm-stress] Remove dependency to legacy pass manager

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 28 04:02:23 PDT 2022


bjope created this revision.
bjope added a reviewer: aeubanks.
Herald added a project: All.
bjope requested review of this revision.
Herald added a project: LLVM.

This patch removes the dependency to the legacy pass manager when
building llvm-stress.

Instead of setting up a pass manager at all we just run verifyModule
to check that the generated IR satisfies the verifier, and then
we run the PrintModulePass (new pass manager version) to print the
IR. This way we do not need to introduce a dependency to the
LLVMPasses component (which otherwise would have pulled in lots of
things making both the resulting binary larger and adding even more
build dependencies).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134802

Files:
  llvm/tools/llvm-stress/llvm-stress.cpp


Index: llvm/tools/llvm-stress/llvm-stress.cpp
===================================================================
--- llvm/tools/llvm-stress/llvm-stress.cpp
+++ llvm/tools/llvm-stress/llvm-stress.cpp
@@ -29,12 +29,10 @@
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/LLVMContext.h"
-#include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/Value.h"
 #include "llvm/IR/Verifier.h"
-#include "llvm/Pass.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -761,10 +759,13 @@
     return 1;
   }
 
-  legacy::PassManager Passes;
-  Passes.add(createVerifierPass());
-  Passes.add(createPrintModulePass(Out->os()));
-  Passes.run(*M.get());
+  // Check that the generated module is accepted by the verifier.
+  if (verifyModule(*M.get(), &Out->os()))
+    report_fatal_error("Broken module found, compilation aborted!");
+
+  ModuleAnalysisManager MAM;
+  PrintModulePass(Out->os()).run(*M.get(), MAM);
+
   Out->keep();
 
   return 0;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134802.463497.patch
Type: text/x-patch
Size: 1098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220928/fe74ac94/attachment.bin>


More information about the llvm-commits mailing list