aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-reduce/CMakeLists.txt2
-rw-r--r--llvm/tools/llvm-reduce/DeltaManager.cpp2
-rw-r--r--llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp53
-rw-r--r--llvm/tools/llvm-reduce/deltas/RunIRPasses.h18
4 files changed, 75 insertions, 0 deletions
diff --git a/llvm/tools/llvm-reduce/CMakeLists.txt b/llvm/tools/llvm-reduce/CMakeLists.txt
index fe6619d..969da36 100644
--- a/llvm/tools/llvm-reduce/CMakeLists.txt
+++ b/llvm/tools/llvm-reduce/CMakeLists.txt
@@ -11,6 +11,7 @@ set(LLVM_LINK_COMPONENTS
IRReader
MC
MIRParser
+ Passes
Support
Target
TransformUtils
@@ -48,6 +49,7 @@ add_llvm_tool(llvm-reduce
deltas/ReduceRegisterMasks.cpp
deltas/ReduceRegisterDefs.cpp
deltas/ReduceRegisterUses.cpp
+ deltas/RunIRPasses.cpp
deltas/SimplifyInstructions.cpp
llvm-reduce.cpp
diff --git a/llvm/tools/llvm-reduce/DeltaManager.cpp b/llvm/tools/llvm-reduce/DeltaManager.cpp
index 5601ee9..5fa0376 100644
--- a/llvm/tools/llvm-reduce/DeltaManager.cpp
+++ b/llvm/tools/llvm-reduce/DeltaManager.cpp
@@ -40,6 +40,7 @@
#include "deltas/ReduceRegisterUses.h"
#include "deltas/ReduceSpecialGlobals.h"
#include "deltas/ReduceVirtualRegisters.h"
+#include "deltas/RunIRPasses.h"
#include "deltas/SimplifyInstructions.h"
#include "llvm/Support/CommandLine.h"
@@ -67,6 +68,7 @@ static cl::opt<std::string>
DELTA_PASS("arguments", reduceArgumentsDeltaPass) \
DELTA_PASS("instructions", reduceInstructionsDeltaPass) \
DELTA_PASS("simplify-instructions", simplifyInstructionsDeltaPass) \
+ DELTA_PASS("ir-passes", runIRPassesDeltaPass) \
DELTA_PASS("operands-zero", reduceOperandsZeroDeltaPass) \
DELTA_PASS("operands-one", reduceOperandsOneDeltaPass) \
DELTA_PASS("operands-nan", reduceOperandsNaNDeltaPass) \
diff --git a/llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp b/llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp
new file mode 100644
index 0000000..ba93ba7
--- /dev/null
+++ b/llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp
@@ -0,0 +1,53 @@
+//===- RunIRPasses.cpp ----------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "RunIRPasses.h"
+#include "Delta.h"
+#include "llvm/Passes/PassBuilder.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
+
+using namespace llvm;
+
+static cl::opt<std::string> PassPipeline(
+ "ir-passes",
+ cl::desc("A textual description of the pass pipeline, same as "
+ "what's passed to `opt -passes`."),
+ cl::init(
+ "function(sroa,instcombine,gvn,simplifycfg,infer-address-spaces)"));
+
+static void runPasses(Oracle &O, Module &Program) {
+ LoopAnalysisManager LAM;
+ FunctionAnalysisManager FAM;
+ CGSCCAnalysisManager CGAM;
+ ModuleAnalysisManager MAM;
+
+ PassInstrumentationCallbacks PIC;
+ PIC.registerShouldRunOptionalPassCallback(
+ [&](StringRef, Any) { return !O.shouldKeep(); });
+ PassBuilder PB(nullptr, PipelineTuningOptions(), None, &PIC);
+
+ PB.registerModuleAnalyses(MAM);
+ PB.registerCGSCCAnalyses(CGAM);
+ PB.registerFunctionAnalyses(FAM);
+ PB.registerLoopAnalyses(LAM);
+ PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
+
+ ModulePassManager MPM;
+ if (auto Err = PB.parsePassPipeline(MPM, PassPipeline)) {
+ errs() << toString(std::move(Err)) << "\n";
+ report_fatal_error("Error constructing pass pipeline");
+ }
+ MPM.run(Program, MAM);
+}
+
+void llvm::runIRPassesDeltaPass(TestRunner &Test) {
+ errs() << "*** Running passes ...\n";
+ runDeltaPass(Test, runPasses);
+ errs() << "----------------------------\n";
+}
diff --git a/llvm/tools/llvm-reduce/deltas/RunIRPasses.h b/llvm/tools/llvm-reduce/deltas/RunIRPasses.h
new file mode 100644
index 0000000..603363b
--- /dev/null
+++ b/llvm/tools/llvm-reduce/deltas/RunIRPasses.h
@@ -0,0 +1,18 @@
+//===- RunIRPasses.h ------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVM_REDUCE_DELTAS_RUNPASSES_H
+#define LLVM_TOOLS_LLVM_REDUCE_DELTAS_RUNPASSES_H
+
+#include "Delta.h"
+
+namespace llvm {
+void runIRPassesDeltaPass(TestRunner &Test);
+} // namespace llvm
+
+#endif