using namespace DS;
+/// isForwarding - Return true if this NodeHandle is forwarding to another
+/// one.
+bool DSNodeHandle::isForwarding() const {
+ return N && N->isForwarding();
+}
+
DSNode *DSNodeHandle::HandleForwarding() const {
assert(N->isForwarding() && "Can only be invoked if forwarding!");
CurNodeH.getNode()->foldNodeCompletely();
assert(CurNodeH.getNode() && CurNodeH.getOffset() == 0 &&
"folding did not make offset 0?");
- NOffset = NH.getOffset();
NSize = NH.getNode()->getSize();
+ NOffset = NH.getOffset();
assert(NOffset == 0 && NSize == 1);
}
const DSNode *SN = SrcNH.getNode();
DSNodeHandle &NH = NodeMap[SN];
- if (!NH.isNull()) // Node already mapped?
- return DSNodeHandle(NH.getNode(), NH.getOffset()+SrcNH.getOffset());
+ if (!NH.isNull()) { // Node already mapped?
+ DSNode *NHN = NH.getNode();
+ return DSNodeHandle(NHN, NH.getOffset()+SrcNH.getOffset());
+ }
// If SrcNH has globals and the destination graph has one of the same globals,
// merge this node with the destination node, which is much more efficient.
// We found one, use merge instead!
merge(GI->second, Src.getNodeForValue(GV));
assert(!NH.isNull() && "Didn't merge node!");
- return DSNodeHandle(NH.getNode(), NH.getOffset()+SrcNH.getOffset());
+ DSNode *NHN = NH.getNode();
+ return DSNodeHandle(NHN, NH.getOffset()+SrcNH.getOffset());
}
}
}
const DSNode *SN = SrcNH.getNode();
DSNodeHandle &SCNH = NodeMap[SN]; // SourceClonedNodeHandle
if (!SCNH.isNull()) { // Node already cloned?
- NH.mergeWith(DSNodeHandle(SCNH.getNode(),
+ DSNode *SCNHN = SCNH.getNode();
+ NH.mergeWith(DSNodeHandle(SCNHN,
SCNH.getOffset()+SrcNH.getOffset()));
-
return; // Nothing to do!
}
-
+
// Okay, so the source node has not already been cloned. Instead of creating
// a new DSNode, only to merge it into the one we already have, try to perform
// the merge in-place. The only case we cannot handle here is when the offset
for (unsigned i = 0, e = Links.size(); i != e; ++i)
if (DSNode *N = Links[i].getNode()) {
DSGraph::NodeMapTy::const_iterator ONMI = OldNodeMap.find(N);
- if (ONMI != OldNodeMap.end())
- Links[i].setTo(ONMI->second.getNode(),
- Links[i].getOffset()+ONMI->second.getOffset());
+ if (ONMI != OldNodeMap.end()) {
+ DSNode *ONMIN = ONMI->second.getNode();
+ Links[i].setTo(ONMIN, Links[i].getOffset()+ONMI->second.getOffset());
+ }
}
}
E = G.ScalarMap.end(); I != E; ++I) {
DSNodeHandle &MappedNode = OldNodeMap[I->second.getNode()];
DSNodeHandle &H = OldValMap[I->first];
- H.mergeWith(DSNodeHandle(MappedNode.getNode(),
+ DSNode *MappedNodeN = MappedNode.getNode();
+ H.mergeWith(DSNodeHandle(MappedNodeN,
I->second.getOffset()+MappedNode.getOffset()));
// If this is a global, add the global to this fn or merge if already exists
E = G.getReturnNodes().end(); I != E; ++I) {
const DSNodeHandle &Ret = I->second;
DSNodeHandle &MappedRet = OldNodeMap[Ret.getNode()];
+ DSNode *MappedRetN = MappedRet.getNode();
OldReturnNodes.insert(std::make_pair(I->first,
- DSNodeHandle(MappedRet.getNode(),
+ DSNodeHandle(MappedRetN,
MappedRet.getOffset()+Ret.getOffset())));
}
}
// Add the link from the argument scalar to the provided value
DSNodeHandle &NH = getNodeForValue(AI);
- assert(NH.getNode() && "Pointer argument without scalarmap entry?");
+ assert(!NH.isNull() && "Pointer argument without scalarmap entry?");
NH.mergeWith(CS.getPtrArg(i));
}
}
{ TIME_REGION(Y, "removeDeadNodes:scalarscan");
for (DSScalarMap::iterator I = ScalarMap.begin(), E = ScalarMap.end(); I !=E;)
if (isa<GlobalValue>(I->first)) { // Keep track of global nodes
- assert(I->second.getNode() && "Null global node?");
+ assert(!I->second.isNull() && "Null global node?");
assert(I->second.getNode()->isGlobalNode() && "Should be a global node!");
GlobalNodes.push_back(std::make_pair(I->first, I->second.getNode()));
for (ScalarMapTy::const_iterator I = ScalarMap.begin(),
E = ScalarMap.end(); I != E; ++I) {
- assert(I->second.getNode() && "Null node in scalarmap!");
+ assert(!I->second.isNull() && "Null node in scalarmap!");
AssertNodeInGraph(I->second.getNode());
if (GlobalValue *GV = dyn_cast<GlobalValue>(I->first)) {
assert(I->second.getNode()->isGlobalNode() &&
if (N1 == 0 || N2 == 0) return;
DSNodeHandle &Entry = NodeMap[N1];
- if (Entry.getNode()) {
+ if (!Entry.isNull()) {
// Termination of recursion!
if (StrictChecking) {
assert(Entry.getNode() == N2 && "Inconsistent mapping detected!");