summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
diff options
context:
space:
mode:
authorDiego Trevino Ferrer <diegof30@gmail.com>2019-08-07 21:51:54 +0000
committerDiego Trevino Ferrer <diegof30@gmail.com>2019-08-07 21:51:54 +0000
commitd4d00ae6a254f6ee42a044cf5c7b804fd1ec60b2 (patch)
tree5b078c7b27885bc535d2da39889647310df86a90 /llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
parent127af283abee88774c45bccdaafc4a0b52d59d5d (diff)
downloadbcm5719-llvm-d4d00ae6a254f6ee42a044cf5c7b804fd1ec60b2.tar.gz
bcm5719-llvm-d4d00ae6a254f6ee42a044cf5c7b804fd1ec60b2.zip
Revert Added Delta IR Reduction Tool
This reverts r368071 (git commit a2584978f5bb41973d65a145b0d9459b81e3ac6d) llvm-svn: 368217
Diffstat (limited to 'llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp')
-rw-r--r--llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp80
1 files changed, 0 insertions, 80 deletions
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp b/llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
deleted file mode 100644
index bf0e07f34ab..00000000000
--- a/llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-//===- ReduceFunctions.cpp - 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 reduce functions (and any instruction that calls it) in the provided
-// Module.
-//
-//===----------------------------------------------------------------------===//
-
-#include "ReduceFunctions.h"
-
-/// Removes all the Defined Functions (as well as their calls)
-/// that aren't inside any of the desired Chunks.
-/// @returns the Module stripped of out-of-chunk functions
-static void extractFunctionsFromModule(const std::vector<Chunk> &ChunksToKeep,
- Module *Program) {
- // Get functions inside desired chunks
- std::set<Function *> FuncsToKeep;
- unsigned I = 0, FunctionCount = 0;
- for (auto &F : *Program) {
- if (!F.isDeclaration() && I < ChunksToKeep.size()) {
- if (ChunksToKeep[I].contains(++FunctionCount))
- FuncsToKeep.insert(&F);
- if (FunctionCount == ChunksToKeep[I].end)
- ++I;
- }
- }
-
- // Delete out-of-chunk functions, and replace their calls with undef
- std::vector<Function *> FuncsToRemove;
- for (auto &F : *Program) {
- if (!F.isDeclaration() && !FuncsToKeep.count(&F)) {
- F.replaceAllUsesWith(UndefValue::get(F.getType()));
- FuncsToRemove.push_back(&F);
- }
- }
- for (auto *F : FuncsToRemove)
- F->eraseFromParent();
-
- // Delete instructions with undef calls
- std::vector<Instruction *> InstToRemove;
- for (auto &F : *Program)
- for (auto &BB : F)
- for (auto &I : BB)
- if (auto *Call = dyn_cast<CallInst>(&I))
- if (!Call->getCalledFunction()) {
- // Instruction might be stored / used somewhere else
- I.replaceAllUsesWith(UndefValue::get(I.getType()));
- InstToRemove.push_back(&I);
- }
-
- for (auto *I : InstToRemove)
- I->eraseFromParent();
-}
-
-/// Counts the amount of non-declaration functions and prints their
-/// respective name & index
-static unsigned countDefinedFunctions(Module *Program) {
- // TODO: Silence index with --quiet flag
- outs() << "----------------------------\n";
- outs() << "Function Index Reference:\n";
- unsigned FunctionCount = 0;
- for (auto &F : *Program)
- if (!F.isDeclaration())
- outs() << "\t" << ++FunctionCount << ": " << F.getName() << "\n";
-
- outs() << "----------------------------\n";
- return FunctionCount;
-}
-
-void llvm::reduceFunctionsDeltaPass(TestRunner &Test) {
- outs() << "*** Reducing Functions...\n";
- unsigned Functions = countDefinedFunctions(Test.getProgram());
- runDeltaPass(Test, Functions, extractFunctionsFromModule);
-} \ No newline at end of file
OpenPOWER on IntegriCloud