summaryrefslogtreecommitdiff
path: root/tools/bugpoint/ExtractFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-02 16:28:32 +0000
committerChris Lattner <sabre@nondot.org>2004-04-02 16:28:32 +0000
commitfb4b96e77e2930bf3d0c148f1c3685b6a4434666 (patch)
treef03147eaa77ebe2368d098fd4b8940cd287b8853 /tools/bugpoint/ExtractFunction.cpp
parent1a66731da85061012767a561c2426e82954a7d96 (diff)
downloadllvm-fb4b96e77e2930bf3d0c148f1c3685b6a4434666.tar.gz
llvm-fb4b96e77e2930bf3d0c148f1c3685b6a4434666.tar.bz2
llvm-fb4b96e77e2930bf3d0c148f1c3685b6a4434666.tar.xz
Minor speedup
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12612 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint/ExtractFunction.cpp')
-rw-r--r--tools/bugpoint/ExtractFunction.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index eea7bd8e25..9f8dca8abd 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -26,6 +26,7 @@
#include "Support/CommandLine.h"
#include "Support/Debug.h"
#include "Support/FileUtilities.h"
+#include <set>
using namespace llvm;
namespace llvm {
@@ -183,7 +184,9 @@ Module *llvm::SplitFunctionsOutOfModule(Module *M,
I->setInitializer(0); // Delete the initializer to make it external
// Remove the Test functions from the Safe module
+ std::set<std::pair<std::string, const PointerType*> > TestFunctions;
for (unsigned i = 0, e = F.size(); i != e; ++i) {
+ TestFunctions.insert(std::make_pair(F[i]->getName(), F[i]->getType()));
Function *TNOF = M->getFunction(F[i]->getName(), F[i]->getFunctionType());
DEBUG(std::cerr << "Removing function " << F[i]->getName() << "\n");
assert(TNOF && "Function doesn't exist in module!");
@@ -191,16 +194,8 @@ Module *llvm::SplitFunctionsOutOfModule(Module *M,
}
// Remove the Safe functions from the Test module
- for (Module::iterator I = New->begin(), E = New->end(); I != E; ++I) {
- bool funcFound = false;
- for (std::vector<Function*>::const_iterator FI = F.begin(), Fe = F.end();
- FI != Fe; ++FI)
- if (I->getName() == (*FI)->getName() &&
- I->getType() == (*FI)->getType())
- funcFound = true;
-
- if (!funcFound)
+ for (Module::iterator I = New->begin(), E = New->end(); I != E; ++I)
+ if (!TestFunctions.count(std::make_pair(I->getName(), I->getType())))
DeleteFunctionBody(I);
- }
return New;
}