[llvm] 0ef404a - [llvm-stress] Remove dependency to legacy pass manager

Bjorn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 28 23:25:12 PDT 2022


Author: Bjorn Pettersson
Date: 2022-09-29T08:23:49+02:00
New Revision: 0ef404a9f993047adbbd11a6c98114eec08c75bd

URL: https://github.com/llvm/llvm-project/commit/0ef404a9f993047adbbd11a6c98114eec08c75bd
DIFF: https://github.com/llvm/llvm-project/commit/0ef404a9f993047adbbd11a6c98114eec08c75bd.diff

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

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 use Module::print() to output the IR. No need to setup passes and
populating a pass manager since we aren't doing anything more fancy
than that.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D134802

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-stress/llvm-stress.cpp b/llvm/tools/llvm-stress/llvm-stress.cpp
index e15d1d6048c7..d45acf00c418 100644
--- a/llvm/tools/llvm-stress/llvm-stress.cpp
+++ b/llvm/tools/llvm-stress/llvm-stress.cpp
@@ -24,17 +24,14 @@
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalValue.h"
-#include "llvm/IR/IRPrintingPasses.h"
 #include "llvm/IR/InstrTypes.h"
 #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 +758,13 @@ int main(int argc, char **argv) {
     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!");
+
+  // Output textual IR.
+  M->print(Out->os(), nullptr);
+
   Out->keep();
 
   return 0;


        


More information about the llvm-commits mailing list