aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-reduce
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-reduce')
-rw-r--r--llvm/tools/llvm-reduce/CMakeLists.txt1
-rw-r--r--llvm/tools/llvm-reduce/DeltaManager.cpp2
-rw-r--r--llvm/tools/llvm-reduce/deltas/ReduceUsingSimplifyCFG.cpp34
-rw-r--r--llvm/tools/llvm-reduce/deltas/ReduceUsingSimplifyCFG.h23
4 files changed, 60 insertions, 0 deletions
diff --git a/llvm/tools/llvm-reduce/CMakeLists.txt b/llvm/tools/llvm-reduce/CMakeLists.txt
index 969da36..a782d39 100644
--- a/llvm/tools/llvm-reduce/CMakeLists.txt
+++ b/llvm/tools/llvm-reduce/CMakeLists.txt
@@ -49,6 +49,7 @@ add_llvm_tool(llvm-reduce
deltas/ReduceRegisterMasks.cpp
deltas/ReduceRegisterDefs.cpp
deltas/ReduceRegisterUses.cpp
+ deltas/ReduceUsingSimplifyCFG.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 5fa0376..89fd33b 100644
--- a/llvm/tools/llvm-reduce/DeltaManager.cpp
+++ b/llvm/tools/llvm-reduce/DeltaManager.cpp
@@ -39,6 +39,7 @@
#include "deltas/ReduceRegisterMasks.h"
#include "deltas/ReduceRegisterUses.h"
#include "deltas/ReduceSpecialGlobals.h"
+#include "deltas/ReduceUsingSimplifyCFG.h"
#include "deltas/ReduceVirtualRegisters.h"
#include "deltas/RunIRPasses.h"
#include "deltas/SimplifyInstructions.h"
@@ -75,6 +76,7 @@ static cl::opt<std::string>
DELTA_PASS("operands-to-args", reduceOperandsToArgsDeltaPass) \
DELTA_PASS("operands-skip", reduceOperandsSkipDeltaPass) \
DELTA_PASS("operand-bundles", reduceOperandBundesDeltaPass) \
+ DELTA_PASS("simplify-cfg", reduceUsingSimplifyCFGDeltaPass) \
DELTA_PASS("attributes", reduceAttributesDeltaPass) \
DELTA_PASS("module-data", reduceModuleDataDeltaPass) \
} while (false)
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceUsingSimplifyCFG.cpp b/llvm/tools/llvm-reduce/deltas/ReduceUsingSimplifyCFG.cpp
new file mode 100644
index 0000000..504f4c2
--- /dev/null
+++ b/llvm/tools/llvm-reduce/deltas/ReduceUsingSimplifyCFG.cpp
@@ -0,0 +1,34 @@
+//===- ReduceUsingSimplifyCFG.h - Specialized Delta Pass ------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements a function which calls the Generic Delta pass in order
+// to call SimplifyCFG on individual basic blocks.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ReduceUsingSimplifyCFG.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/Transforms/Utils/Local.h"
+
+using namespace llvm;
+
+static void reduceUsingSimplifyCFG(Oracle &O, Module &Program) {
+ SmallVector<BasicBlock *, 16> ToSimplify;
+ for (auto &F : Program)
+ for (auto &BB : F)
+ if (!O.shouldKeep())
+ ToSimplify.push_back(&BB);
+ TargetTransformInfo TTI(Program.getDataLayout());
+ for (auto *BB : ToSimplify)
+ simplifyCFG(BB, TTI);
+}
+
+void llvm::reduceUsingSimplifyCFGDeltaPass(TestRunner &Test) {
+ outs() << "*** Reducing using SimplifyCFG...\n";
+ runDeltaPass(Test, reduceUsingSimplifyCFG);
+}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceUsingSimplifyCFG.h b/llvm/tools/llvm-reduce/deltas/ReduceUsingSimplifyCFG.h
new file mode 100644
index 0000000..0105ad2
--- /dev/null
+++ b/llvm/tools/llvm-reduce/deltas/ReduceUsingSimplifyCFG.h
@@ -0,0 +1,23 @@
+//===- ReduceUsingSimplifyCFG.h - Specialized Delta Pass ------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements a function which calls the Generic Delta pass in order
+// to call SimplifyCFG on individual basic blocks.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVM_REDUCE_DELTAS_SIMPLIFYCFG_H
+#define LLVM_TOOLS_LLVM_REDUCE_DELTAS_SIMPLIFYCFG_H
+
+#include "Delta.h"
+
+namespace llvm {
+void reduceUsingSimplifyCFGDeltaPass(TestRunner &Test);
+} // namespace llvm
+
+#endif