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