forked from OSchip/llvm-project
parent
03b18721be
commit
9e5b6904e5
|
@ -12,7 +12,7 @@
|
||||||
#include "llvm/iOther.h"
|
#include "llvm/iOther.h"
|
||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
using std::cerr;
|
||||||
|
|
||||||
// Make all of the pointers that point to Val also point to N.
|
// Make all of the pointers that point to Val also point to N.
|
||||||
//
|
//
|
||||||
|
@ -111,8 +111,8 @@ void FunctionDSGraph::computeClosure(const DataStructure &DS) {
|
||||||
Function *F = cast<Function>(FGDN->getGlobal());
|
Function *F = cast<Function>(FGDN->getGlobal());
|
||||||
|
|
||||||
if ((int)NumInlines++ == InlineLimit) { // CUTE hack huh?
|
if ((int)NumInlines++ == InlineLimit) { // CUTE hack huh?
|
||||||
std::cerr << "Infinite (?) recursion halted\n";
|
cerr << "Infinite (?) recursion halted\n";
|
||||||
std::cerr << "Not inlining: " << F->getName() << "\n";
|
cerr << "Not inlining: " << F->getName() << "\n";
|
||||||
CN->dump();
|
CN->dump();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -126,10 +126,10 @@ void FunctionDSGraph::computeClosure(const DataStructure &DS) {
|
||||||
//
|
//
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
std::cerr << "\nSearching for: " << (void*)CN->getCall() << ": ";
|
cerr << "\nSearching for: " << (void*)CN->getCall() << ": ";
|
||||||
for (unsigned X = 0; X != CN->getArgs().size(); ++X) {
|
for (unsigned X = 0; X != CN->getArgs().size(); ++X) {
|
||||||
std::cerr << " " << X << " is\n";
|
cerr << " " << X << " is\n";
|
||||||
CN->getArgs().first[X].print(std::cerr);
|
CN->getArgs().first[X].print(cerr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -137,9 +137,9 @@ void FunctionDSGraph::computeClosure(const DataStructure &DS) {
|
||||||
PointerValSet *CMI = 0;
|
PointerValSet *CMI = 0;
|
||||||
for (unsigned i = 0, e = CallMap.size(); i != e; ++i) {
|
for (unsigned i = 0, e = CallMap.size(); i != e; ++i) {
|
||||||
#if 0
|
#if 0
|
||||||
std::cerr << "Found: " << (void*)CallMap[i].first.second << ": ";
|
cerr << "Found: " << (void*)CallMap[i].first.second << ": ";
|
||||||
for (unsigned X = 0; X != CallMap[i].first.first.size(); ++X) {
|
for (unsigned X = 0; X != CallMap[i].first.first.size(); ++X) {
|
||||||
std::cerr << " " << X << " is\n"; CallMap[i].first.first[X].print(std::cerr);
|
cerr << " " << X << " is\n"; CallMap[i].first.first[X].print(cerr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// DataStructure Class Implementation
|
// DataStructure Class Implementation
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "llvm/Value.h"
|
#include "llvm/Value.h"
|
||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
using std::vector;
|
||||||
|
|
||||||
//#define DEBUG_NODE_ELIMINATE 1
|
//#define DEBUG_NODE_ELIMINATE 1
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ static void DestroyFirstNodeOfPair(DSNode *N1, DSNode *N2) {
|
||||||
// Now make sure that all of the nodes that point to N1 also point to the node
|
// Now make sure that all of the nodes that point to N1 also point to the node
|
||||||
// that we are merging it with...
|
// that we are merging it with...
|
||||||
//
|
//
|
||||||
const std::vector<PointerValSet*> &Refs = N1->getReferrers();
|
const vector<PointerValSet*> &Refs = N1->getReferrers();
|
||||||
for (unsigned i = 0, e = Refs.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Refs.size(); i != e; ++i) {
|
||||||
PointerValSet &PVS = *Refs[i];
|
PointerValSet &PVS = *Refs[i];
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ static bool isIndistinguishableNode(DSNode *DN) {
|
||||||
//
|
//
|
||||||
|
|
||||||
DSNode *IndFrom = 0;
|
DSNode *IndFrom = 0;
|
||||||
const std::vector<PointerValSet*> &Refs = DN->getReferrers();
|
const vector<PointerValSet*> &Refs = DN->getReferrers();
|
||||||
for (unsigned R = 0, RE = Refs.size(); R != RE; ++R) {
|
for (unsigned R = 0, RE = Refs.size(); R != RE; ++R) {
|
||||||
const PointerValSet &Ptr = *Refs[R];
|
const PointerValSet &Ptr = *Refs[R];
|
||||||
|
|
||||||
|
@ -126,9 +126,9 @@ static bool isIndistinguishableNode(DSNode *DN) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename NodeTy>
|
template<typename NodeTy>
|
||||||
static bool removeIndistinguishableNodes(std::vector<NodeTy*> &Nodes) {
|
static bool removeIndistinguishableNodes(vector<NodeTy*> &Nodes) {
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
std::vector<NodeTy*>::iterator I = Nodes.begin();
|
vector<NodeTy*>::iterator I = Nodes.begin();
|
||||||
while (I != Nodes.end()) {
|
while (I != Nodes.end()) {
|
||||||
if (isIndistinguishableNode(*I)) {
|
if (isIndistinguishableNode(*I)) {
|
||||||
I = Nodes.erase(I);
|
I = Nodes.erase(I);
|
||||||
|
@ -141,12 +141,12 @@ static bool removeIndistinguishableNodes(std::vector<NodeTy*> &Nodes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename NodeTy>
|
template<typename NodeTy>
|
||||||
static bool removeIndistinguishableNodePairs(std::vector<NodeTy*> &Nodes) {
|
static bool removeIndistinguishableNodePairs(vector<NodeTy*> &Nodes) {
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
std::vector<NodeTy*>::iterator I = Nodes.begin();
|
vector<NodeTy*>::iterator I = Nodes.begin();
|
||||||
while (I != Nodes.end()) {
|
while (I != Nodes.end()) {
|
||||||
NodeTy *N1 = *I++;
|
NodeTy *N1 = *I++;
|
||||||
for (std::vector<NodeTy*>::iterator I2 = I, I2E = Nodes.end();
|
for (vector<NodeTy*>::iterator I2 = I, I2E = Nodes.end();
|
||||||
I2 != I2E; ++I2) {
|
I2 != I2E; ++I2) {
|
||||||
NodeTy *N2 = *I2;
|
NodeTy *N2 = *I2;
|
||||||
if (N1->isEquivalentTo(N2)) {
|
if (N1->isEquivalentTo(N2)) {
|
||||||
|
@ -178,16 +178,16 @@ bool FunctionDSGraph::UnlinkUndistinguishableNodes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MarkReferredNodesReachable(DSNode *N,
|
static void MarkReferredNodesReachable(DSNode *N,
|
||||||
std::vector<ShadowDSNode*> &ShadowNodes,
|
vector<ShadowDSNode*> &ShadowNodes,
|
||||||
std::vector<bool> &ReachableShadowNodes,
|
vector<bool> &ReachableShadowNodes,
|
||||||
std::vector<AllocDSNode*> &AllocNodes,
|
vector<AllocDSNode*> &AllocNodes,
|
||||||
std::vector<bool> &ReachableAllocNodes);
|
vector<bool> &ReachableAllocNodes);
|
||||||
|
|
||||||
static inline void MarkReferredNodeSetReachable(const PointerValSet &PVS,
|
static inline void MarkReferredNodeSetReachable(const PointerValSet &PVS,
|
||||||
std::vector<ShadowDSNode*> &ShadowNodes,
|
vector<ShadowDSNode*> &ShadowNodes,
|
||||||
std::vector<bool> &ReachableShadowNodes,
|
vector<bool> &ReachableShadowNodes,
|
||||||
std::vector<AllocDSNode*> &AllocNodes,
|
vector<AllocDSNode*> &AllocNodes,
|
||||||
std::vector<bool> &ReachableAllocNodes) {
|
vector<bool> &ReachableAllocNodes) {
|
||||||
for (unsigned i = 0, e = PVS.size(); i != e; ++i)
|
for (unsigned i = 0, e = PVS.size(); i != e; ++i)
|
||||||
if (isa<ShadowDSNode>(PVS[i].Node) || isa<AllocDSNode>(PVS[i].Node))
|
if (isa<ShadowDSNode>(PVS[i].Node) || isa<AllocDSNode>(PVS[i].Node))
|
||||||
MarkReferredNodesReachable(PVS[i].Node, ShadowNodes, ReachableShadowNodes,
|
MarkReferredNodesReachable(PVS[i].Node, ShadowNodes, ReachableShadowNodes,
|
||||||
|
@ -195,21 +195,21 @@ static inline void MarkReferredNodeSetReachable(const PointerValSet &PVS,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MarkReferredNodesReachable(DSNode *N,
|
static void MarkReferredNodesReachable(DSNode *N,
|
||||||
std::vector<ShadowDSNode*> &ShadowNodes,
|
vector<ShadowDSNode*> &ShadowNodes,
|
||||||
std::vector<bool> &ReachableShadowNodes,
|
vector<bool> &ReachableShadowNodes,
|
||||||
std::vector<AllocDSNode*> &AllocNodes,
|
vector<AllocDSNode*> &AllocNodes,
|
||||||
std::vector<bool> &ReachableAllocNodes) {
|
vector<bool> &ReachableAllocNodes) {
|
||||||
assert(ShadowNodes.size() == ReachableShadowNodes.size());
|
assert(ShadowNodes.size() == ReachableShadowNodes.size());
|
||||||
assert(AllocNodes.size() == ReachableAllocNodes.size());
|
assert(AllocNodes.size() == ReachableAllocNodes.size());
|
||||||
|
|
||||||
if (ShadowDSNode *Shad = dyn_cast<ShadowDSNode>(N)) {
|
if (ShadowDSNode *Shad = dyn_cast<ShadowDSNode>(N)) {
|
||||||
std::vector<ShadowDSNode*>::iterator I =
|
vector<ShadowDSNode*>::iterator I =
|
||||||
std::find(ShadowNodes.begin(), ShadowNodes.end(), Shad);
|
std::find(ShadowNodes.begin(), ShadowNodes.end(), Shad);
|
||||||
unsigned i = I-ShadowNodes.begin();
|
unsigned i = I-ShadowNodes.begin();
|
||||||
if (ReachableShadowNodes[i]) return; // Recursion detected, abort...
|
if (ReachableShadowNodes[i]) return; // Recursion detected, abort...
|
||||||
ReachableShadowNodes[i] = true;
|
ReachableShadowNodes[i] = true;
|
||||||
} else if (AllocDSNode *Alloc = dyn_cast<AllocDSNode>(N)) {
|
} else if (AllocDSNode *Alloc = dyn_cast<AllocDSNode>(N)) {
|
||||||
std::vector<AllocDSNode*>::iterator I =
|
vector<AllocDSNode*>::iterator I =
|
||||||
std::find(AllocNodes.begin(), AllocNodes.end(), Alloc);
|
std::find(AllocNodes.begin(), AllocNodes.end(), Alloc);
|
||||||
unsigned i = I-AllocNodes.begin();
|
unsigned i = I-AllocNodes.begin();
|
||||||
if (ReachableAllocNodes[i]) return; // Recursion detected, abort...
|
if (ReachableAllocNodes[i]) return; // Recursion detected, abort...
|
||||||
|
@ -221,7 +221,7 @@ static void MarkReferredNodesReachable(DSNode *N,
|
||||||
ShadowNodes, ReachableShadowNodes,
|
ShadowNodes, ReachableShadowNodes,
|
||||||
AllocNodes, ReachableAllocNodes);
|
AllocNodes, ReachableAllocNodes);
|
||||||
|
|
||||||
const std::vector<PointerValSet> *Links = N->getAuxLinks();
|
const vector<PointerValSet> *Links = N->getAuxLinks();
|
||||||
if (Links)
|
if (Links)
|
||||||
for (unsigned i = 0, e = Links->size(); i != e; ++i)
|
for (unsigned i = 0, e = Links->size(); i != e; ++i)
|
||||||
MarkReferredNodeSetReachable((*Links)[i],
|
MarkReferredNodeSetReachable((*Links)[i],
|
||||||
|
@ -230,8 +230,8 @@ static void MarkReferredNodesReachable(DSNode *N,
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionDSGraph::MarkEscapeableNodesReachable(
|
void FunctionDSGraph::MarkEscapeableNodesReachable(
|
||||||
std::vector<bool> &ReachableShadowNodes,
|
vector<bool> &ReachableShadowNodes,
|
||||||
std::vector<bool> &ReachableAllocNodes) {
|
vector<bool> &ReachableAllocNodes) {
|
||||||
// Mark all shadow nodes that have edges from other nodes as reachable.
|
// Mark all shadow nodes that have edges from other nodes as reachable.
|
||||||
// Recursively mark any shadow nodes pointed to by the newly live shadow
|
// Recursively mark any shadow nodes pointed to by the newly live shadow
|
||||||
// nodes as also alive.
|
// nodes as also alive.
|
||||||
|
@ -261,8 +261,8 @@ bool FunctionDSGraph::RemoveUnreachableNodes() {
|
||||||
// Reachable*Nodes - Contains true if there is an edge from a reachable
|
// Reachable*Nodes - Contains true if there is an edge from a reachable
|
||||||
// node to the numbered node...
|
// node to the numbered node...
|
||||||
//
|
//
|
||||||
std::vector<bool> ReachableShadowNodes(ShadowNodes.size());
|
vector<bool> ReachableShadowNodes(ShadowNodes.size());
|
||||||
std::vector<bool> ReachableAllocNodes (AllocNodes.size());
|
vector<bool> ReachableAllocNodes (AllocNodes.size());
|
||||||
|
|
||||||
MarkEscapeableNodesReachable(ReachableShadowNodes, ReachableAllocNodes);
|
MarkEscapeableNodesReachable(ReachableShadowNodes, ReachableAllocNodes);
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ bool FunctionDSGraph::RemoveUnreachableNodes() {
|
||||||
// Loop over the global nodes, removing nodes that have no edges into them or
|
// Loop over the global nodes, removing nodes that have no edges into them or
|
||||||
// out of them.
|
// out of them.
|
||||||
//
|
//
|
||||||
for (std::vector<GlobalDSNode*>::iterator I = GlobalNodes.begin();
|
for (vector<GlobalDSNode*>::iterator I = GlobalNodes.begin();
|
||||||
I != GlobalNodes.end(); )
|
I != GlobalNodes.end(); )
|
||||||
if ((*I)->getReferrers().empty()) {
|
if ((*I)->getReferrers().empty()) {
|
||||||
GlobalDSNode *GDN = *I;
|
GlobalDSNode *GDN = *I;
|
||||||
|
@ -347,9 +347,9 @@ bool FunctionDSGraph::RemoveUnreachableNodes() {
|
||||||
// getEscapingAllocations - Add all allocations that escape the current
|
// getEscapingAllocations - Add all allocations that escape the current
|
||||||
// function to the specified vector.
|
// function to the specified vector.
|
||||||
//
|
//
|
||||||
void FunctionDSGraph::getEscapingAllocations(std::vector<AllocDSNode*> &Allocs) {
|
void FunctionDSGraph::getEscapingAllocations(vector<AllocDSNode*> &Allocs) {
|
||||||
std::vector<bool> ReachableShadowNodes(ShadowNodes.size());
|
vector<bool> ReachableShadowNodes(ShadowNodes.size());
|
||||||
std::vector<bool> ReachableAllocNodes (AllocNodes.size());
|
vector<bool> ReachableAllocNodes (AllocNodes.size());
|
||||||
|
|
||||||
MarkEscapeableNodesReachable(ReachableShadowNodes, ReachableAllocNodes);
|
MarkEscapeableNodesReachable(ReachableShadowNodes, ReachableAllocNodes);
|
||||||
|
|
||||||
|
@ -361,9 +361,9 @@ void FunctionDSGraph::getEscapingAllocations(std::vector<AllocDSNode*> &Allocs)
|
||||||
// getNonEscapingAllocations - Add all allocations that do not escape the
|
// getNonEscapingAllocations - Add all allocations that do not escape the
|
||||||
// current function to the specified vector.
|
// current function to the specified vector.
|
||||||
//
|
//
|
||||||
void FunctionDSGraph::getNonEscapingAllocations(std::vector<AllocDSNode*> &Allocs) {
|
void FunctionDSGraph::getNonEscapingAllocations(vector<AllocDSNode*> &Allocs) {
|
||||||
std::vector<bool> ReachableShadowNodes(ShadowNodes.size());
|
vector<bool> ReachableShadowNodes(ShadowNodes.size());
|
||||||
std::vector<bool> ReachableAllocNodes (AllocNodes.size());
|
vector<bool> ReachableAllocNodes (AllocNodes.size());
|
||||||
|
|
||||||
MarkEscapeableNodesReachable(ReachableShadowNodes, ReachableAllocNodes);
|
MarkEscapeableNodesReachable(ReachableShadowNodes, ReachableAllocNodes);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
// synthesizeNode - Create a new shadow node that is to be linked into this
|
// synthesizeNode - Create a new shadow node that is to be linked into this
|
||||||
// chain..
|
// chain..
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include "llvm/Analysis/DataStructure.h"
|
#include "llvm/Analysis/DataStructure.h"
|
||||||
#include "llvm/Support/InstVisitor.h"
|
#include "llvm/Support/InstVisitor.h"
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
// DEBUG_DATA_STRUCTURE_CONSTRUCTION - Define this to 1 if you want debug output
|
// DEBUG_DATA_STRUCTURE_CONSTRUCTION - Define this to 1 if you want debug output
|
||||||
//#define DEBUG_DATA_STRUCTURE_CONSTRUCTION 1
|
//#define DEBUG_DATA_STRUCTURE_CONSTRUCTION 1
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
@ -128,7 +127,7 @@ DSNode::DSNode(enum NodeTy NT, const Type *T) : Ty(T), NodeType(NT) {
|
||||||
|
|
||||||
void DSNode::removeReferrer(PointerValSet *PVS) {
|
void DSNode::removeReferrer(PointerValSet *PVS) {
|
||||||
std::vector<PointerValSet*>::iterator I = std::find(Referrers.begin(),
|
std::vector<PointerValSet*>::iterator I = std::find(Referrers.begin(),
|
||||||
Referrers.end(), PVS);
|
Referrers.end(), PVS);
|
||||||
assert(I != Referrers.end() && "PVS not pointing to node!");
|
assert(I != Referrers.end() && "PVS not pointing to node!");
|
||||||
Referrers.erase(I);
|
Referrers.erase(I);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue