mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-16 23:38:40 +00:00
Fix steensgaard to work on a lot more cases...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5488 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
714752fa8e
commit
e6c0b5dba4
@ -21,6 +21,7 @@ namespace {
|
|||||||
namespace {
|
namespace {
|
||||||
class Steens : public Pass, public AliasAnalysis {
|
class Steens : public Pass, public AliasAnalysis {
|
||||||
DSGraph *ResultGraph;
|
DSGraph *ResultGraph;
|
||||||
|
DSGraph *GlobalsGraph; // FIXME: Eliminate globals graph stuff from DNE
|
||||||
public:
|
public:
|
||||||
Steens() : ResultGraph(0) {}
|
Steens() : ResultGraph(0) {}
|
||||||
~Steens() { assert(ResultGraph == 0 && "releaseMemory not called?"); }
|
~Steens() { assert(ResultGraph == 0 && "releaseMemory not called?"); }
|
||||||
@ -85,8 +86,7 @@ namespace {
|
|||||||
/// with the specified call site descriptor. This function links the arguments
|
/// with the specified call site descriptor. This function links the arguments
|
||||||
/// and the return value for the call site context-insensitively.
|
/// and the return value for the call site context-insensitively.
|
||||||
///
|
///
|
||||||
void Steens::ResolveFunctionCall(Function *F,
|
void Steens::ResolveFunctionCall(Function *F, const DSCallSite &Call,
|
||||||
const DSCallSite &Call,
|
|
||||||
DSNodeHandle &RetVal) {
|
DSNodeHandle &RetVal) {
|
||||||
assert(ResultGraph != 0 && "Result graph not allocated!");
|
assert(ResultGraph != 0 && "Result graph not allocated!");
|
||||||
hash_map<Value*, DSNodeHandle> &ValMap = ResultGraph->getScalarMap();
|
hash_map<Value*, DSNodeHandle> &ValMap = ResultGraph->getScalarMap();
|
||||||
@ -100,7 +100,7 @@ void Steens::ResolveFunctionCall(Function *F,
|
|||||||
for (Function::aiterator AI = F->abegin(), AE = F->aend(); AI != AE; ++AI) {
|
for (Function::aiterator AI = F->abegin(), AE = F->aend(); AI != AE; ++AI) {
|
||||||
hash_map<Value*, DSNodeHandle>::iterator I = ValMap.find(AI);
|
hash_map<Value*, DSNodeHandle>::iterator I = ValMap.find(AI);
|
||||||
if (I != ValMap.end()) // If its a pointer argument...
|
if (I != ValMap.end()) // If its a pointer argument...
|
||||||
I->second.addEdgeTo(Call.getPtrArg(PtrArgIdx++));
|
I->second.mergeWith(Call.getPtrArg(PtrArgIdx++));
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(PtrArgIdx == Call.getNumPtrArgs() && "Argument resolution mismatch!");
|
assert(PtrArgIdx == Call.getNumPtrArgs() && "Argument resolution mismatch!");
|
||||||
@ -116,7 +116,8 @@ bool Steens::run(Module &M) {
|
|||||||
|
|
||||||
// Create a new, empty, graph...
|
// Create a new, empty, graph...
|
||||||
ResultGraph = new DSGraph();
|
ResultGraph = new DSGraph();
|
||||||
|
GlobalsGraph = new DSGraph();
|
||||||
|
ResultGraph->setGlobalsGraph(GlobalsGraph);
|
||||||
// RetValMap - Keep track of the return values for all functions that return
|
// RetValMap - Keep track of the return values for all functions that return
|
||||||
// valid pointers.
|
// valid pointers.
|
||||||
//
|
//
|
||||||
@ -143,16 +144,9 @@ bool Steens::run(Module &M) {
|
|||||||
// Incorporate the inlined Function's ScalarMap into the global
|
// Incorporate the inlined Function's ScalarMap into the global
|
||||||
// ScalarMap...
|
// ScalarMap...
|
||||||
hash_map<Value*, DSNodeHandle> &GVM = ResultGraph->getScalarMap();
|
hash_map<Value*, DSNodeHandle> &GVM = ResultGraph->getScalarMap();
|
||||||
|
for (hash_map<Value*, DSNodeHandle>::iterator I = ValMap.begin(),
|
||||||
while (!ValMap.empty()) { // Loop over value map, moving entries over...
|
E = ValMap.end(); I != E; ++I)
|
||||||
const std::pair<Value*, DSNodeHandle> &DSN = *ValMap.begin();
|
GVM[I->first].mergeWith(I->second);
|
||||||
hash_map<Value*, DSNodeHandle>::iterator I = GVM.find(DSN.first);
|
|
||||||
if (I == GVM.end())
|
|
||||||
GVM[DSN.first] = DSN.second;
|
|
||||||
else
|
|
||||||
I->second.mergeWith(DSN.second);
|
|
||||||
ValMap.erase(ValMap.begin());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Must recalculate and use the Incomplete markers!!
|
// FIXME: Must recalculate and use the Incomplete markers!!
|
||||||
@ -199,6 +193,7 @@ bool Steens::run(Module &M) {
|
|||||||
ResultGraph->markIncompleteNodes(DSGraph::IgnoreFormalArgs);
|
ResultGraph->markIncompleteNodes(DSGraph::IgnoreFormalArgs);
|
||||||
|
|
||||||
// Remove any nodes that are dead after all of the merging we have done...
|
// Remove any nodes that are dead after all of the merging we have done...
|
||||||
|
// FIXME: We should be able to disable the globals graph for steens!
|
||||||
ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
|
ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
|
||||||
|
|
||||||
DEBUG(print(std::cerr, &M));
|
DEBUG(print(std::cerr, &M));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user