mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 02:33:33 +00:00
CloneModule stores the BasicBlock mapping in ValueMap. There's no need to
recompute it. This fixes a O(n^2) in number of blocks when reducing a crash. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68422 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5a30f4f84a
commit
e032590f58
@ -21,6 +21,7 @@
|
|||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/ValueSymbolTable.h"
|
#include "llvm/ValueSymbolTable.h"
|
||||||
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
#include "llvm/Analysis/Verifier.h"
|
#include "llvm/Analysis/Verifier.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
@ -267,21 +268,9 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
|
|||||||
Module *M = CloneModule(BD.getProgram(), ValueMap);
|
Module *M = CloneModule(BD.getProgram(), ValueMap);
|
||||||
|
|
||||||
// Convert list to set for fast lookup...
|
// Convert list to set for fast lookup...
|
||||||
std::set<BasicBlock*> Blocks;
|
SmallPtrSet<BasicBlock*, 8> Blocks;
|
||||||
for (unsigned i = 0, e = BBs.size(); i != e; ++i) {
|
for (unsigned i = 0, e = BBs.size(); i != e; ++i)
|
||||||
// Convert the basic block from the original module to the new module...
|
Blocks.insert(cast<BasicBlock>(ValueMap[BBs[i]]));
|
||||||
const Function *F = BBs[i]->getParent();
|
|
||||||
Function *CMF = cast<Function>(ValueMap[F]);
|
|
||||||
assert(CMF && "Function not in module?!");
|
|
||||||
assert(CMF->getFunctionType() == F->getFunctionType() && "wrong type?");
|
|
||||||
assert(CMF->getName() == F->getName() && "wrong name?");
|
|
||||||
|
|
||||||
// Get the mapped basic block...
|
|
||||||
Function::iterator CBI = CMF->begin();
|
|
||||||
std::advance(CBI, std::distance(F->begin(),
|
|
||||||
Function::const_iterator(BBs[i])));
|
|
||||||
Blocks.insert(CBI);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "Checking for crash with only these blocks:";
|
std::cout << "Checking for crash with only these blocks:";
|
||||||
unsigned NumPrint = Blocks.size();
|
unsigned NumPrint = Blocks.size();
|
||||||
@ -320,8 +309,8 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
|
|||||||
// have to take.
|
// have to take.
|
||||||
std::vector<std::pair<Function*, std::string> > BlockInfo;
|
std::vector<std::pair<Function*, std::string> > BlockInfo;
|
||||||
|
|
||||||
for (std::set<BasicBlock*>::iterator I = Blocks.begin(), E = Blocks.end();
|
for (SmallPtrSet<BasicBlock*, 8>::iterator I = Blocks.begin(),
|
||||||
I != E; ++I)
|
E = Blocks.end(); I != E; ++I)
|
||||||
BlockInfo.push_back(std::make_pair((*I)->getParent(), (*I)->getName()));
|
BlockInfo.push_back(std::make_pair((*I)->getParent(), (*I)->getName()));
|
||||||
|
|
||||||
// Now run the CFG simplify pass on the function...
|
// Now run the CFG simplify pass on the function...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user