The exact IR passes run is customizable via `-ir-passes`.
Reviewed By: regehr
Differential Revision: https://reviews.llvm.org/D123749
--- /dev/null
+; RUN: llvm-reduce --delta-passes=ir-passes --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
+; RUN: FileCheck --check-prefixes=CHECK-FINAL --input-file=%t %s
+
+; CHECK-INTERESTINGNESS-LABEL: @f1
+; CHECK-INTERESTINGNESS: add
+; CHECK-INTERESTINGNESS-LABEL: @f2
+; CHECK-INTERESTINGNESS: add
+; CHECK-INTERESTINGNESS: add
+
+; CHECK-FINAL-LABEL: @f1
+; CHECK-FINAL: add i32 %a, 10
+; CHECK-FINAL-LABEL: @f2
+; CHECK-FINAL: add i32 %a, 5
+; CHECK-FINAL: add i32 %b, 5
+
+define i32 @f1(i32 %a) {
+ %b = add i32 %a, 5
+ %c = add i32 %b, 5
+ ret i32 %c
+}
+
+define i32 @f2(i32 %a) {
+ %b = add i32 %a, 5
+ %c = add i32 %b, 5
+ ret i32 %c
+}
+
+declare void @f3()
\ No newline at end of file
IRReader
MC
MIRParser
+ Passes
Support
Target
TransformUtils
deltas/ReduceRegisterMasks.cpp
deltas/ReduceRegisterDefs.cpp
deltas/ReduceRegisterUses.cpp
+ deltas/RunIRPasses.cpp
deltas/SimplifyInstructions.cpp
llvm-reduce.cpp
#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"
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) \
--- /dev/null
+//===- 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";
+}
--- /dev/null
+//===- 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
"//llvm/lib/CodeGen/MIRParser",
"//llvm/lib/IR",
"//llvm/lib/IRReader",
+ "//llvm/lib/Passes",
"//llvm/lib/Support",
"//llvm/lib/Target",
"//llvm/lib/Target:TargetsToBuild",
"deltas/ReduceRegisterUses.cpp",
"deltas/ReduceSpecialGlobals.cpp",
"deltas/ReduceVirtualRegisters.cpp",
+ "deltas/RunIRPasses.cpp",
"deltas/SimplifyInstructions.cpp",
"deltas/Utils.cpp",
"llvm-reduce.cpp",