diff options
author | Chris Lattner <sabre@nondot.org> | 2003-06-19 21:15:11 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-06-19 21:15:11 +0000 |
commit | bd92b73be7cc90a3671310a44c1195e7a7087820 (patch) | |
tree | 2d0b0ddd2ca2ca2f2d201df584c69d85ece2b39e /lib/Analysis/DataStructure/Local.cpp | |
parent | 160cf4867183ed780aa94d8875b0ec115d468809 (diff) |
* Changes to make NodeType be private to DSNode.
* Add new MultiObject flag to DSNode which keeps track of whether or not
multiple objects have been merged into the node, allowing must-alias info
to be tracked.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6794 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/Local.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/Local.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index 369b76d611..a7751f23f7 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -86,9 +86,9 @@ namespace { private: // Visitor functions, used to handle each instruction type we encounter... friend class InstVisitor<GraphBuilder>; - void visitMallocInst(MallocInst &MI) { handleAlloc(MI, DSNode::HeapNode); } - void visitAllocaInst(AllocaInst &AI) { handleAlloc(AI, DSNode::AllocaNode);} - void handleAlloc(AllocationInst &AI, DSNode::NodeTy NT); + void visitMallocInst(MallocInst &MI) { handleAlloc(MI, true); } + void visitAllocaInst(AllocaInst &AI) { handleAlloc(AI, false); } + void handleAlloc(AllocationInst &AI, bool isHeap); void visitPHINode(PHINode &PN); @@ -108,8 +108,8 @@ namespace { /// createNode - Create a new DSNode, ensuring that it is properly added to /// the graph. /// - DSNode *createNode(DSNode::NodeTy NodeType, const Type *Ty = 0) { - DSNode *N = new DSNode(NodeType, Ty, &G); // Create the node + DSNode *createNode(const Type *Ty = 0) { + DSNode *N = new DSNode(Ty, &G); // Create the node if (DisableFieldSensitivity) { N->foldNodeCompletely(); if (DSNode *FN = N->getForwardNode()) @@ -194,7 +194,7 @@ DSNodeHandle GraphBuilder::getValueDest(Value &Val) { NH = I->second; } else { // This returns a conservative unknown node for any unhandled ConstExpr - return NH = createNode(DSNode::UnknownNode); + return NH = createNode()->setUnknownNodeMarker(); } if (NH.getNode() == 0) { // (getelementptr null, X) returns null ScalarMap.erase(V); @@ -204,7 +204,7 @@ DSNodeHandle GraphBuilder::getValueDest(Value &Val) { } else if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(C)) { // Random constants are unknown mem - return NH = createNode(DSNode::UnknownNode); + return NH = createNode()->setUnknownNodeMarker(); } else { assert(0 && "Unknown constant type!"); } @@ -213,11 +213,11 @@ DSNodeHandle GraphBuilder::getValueDest(Value &Val) { DSNode *N; if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) { // Create a new global node for this global variable... - N = createNode(DSNode::GlobalNode, GV->getType()->getElementType()); + N = createNode(GV->getType()->getElementType()); N->addGlobal(GV); } else { // Otherwise just create a shadow node - N = createNode(DSNode::ShadowNode); + N = createNode(); } NH.setNode(N); // Remember that we are pointing to it... @@ -237,7 +237,7 @@ DSNodeHandle &GraphBuilder::getLink(const DSNodeHandle &node, unsigned LinkNo) { DSNodeHandle &Link = Node.getLink(LinkNo); if (!Link.getNode()) { // If the link hasn't been created yet, make and return a new shadow node - Link = createNode(DSNode::ShadowNode); + Link = createNode(); } return Link; } @@ -263,8 +263,13 @@ void GraphBuilder::setDestTo(Value &V, const DSNodeHandle &NH) { /// Alloca & Malloc instruction implementation - Simply create a new memory /// object, pointing the scalar to it. /// -void GraphBuilder::handleAlloc(AllocationInst &AI, DSNode::NodeTy NodeType) { - setDestTo(AI, createNode(NodeType)); +void GraphBuilder::handleAlloc(AllocationInst &AI, bool isHeap) { + DSNode *N = createNode(); + if (isHeap) + N->setHeapNodeMarker(); + else + N->setAllocaNodeMarker(); + setDestTo(AI, N); } // PHINode - Make the scalar for the PHI node point to all of the things the @@ -368,7 +373,7 @@ void GraphBuilder::visitLoadInst(LoadInst &LI) { if (Ptr.getNode() == 0) return; // Make that the node is read from... - Ptr.getNode()->NodeType |= DSNode::Read; + Ptr.getNode()->setReadMarker(); // Ensure a typerecord exists... Ptr.getNode()->mergeTypeInfo(LI.getType(), Ptr.getOffset(), false); @@ -383,7 +388,7 @@ void GraphBuilder::visitStoreInst(StoreInst &SI) { if (Dest.getNode() == 0) return; // Mark that the node is written to... - Dest.getNode()->NodeType |= DSNode::Modified; + Dest.getNode()->setModifiedMarker(); // Ensure a typerecord exists... Dest.getNode()->mergeTypeInfo(StoredTy, Dest.getOffset()); @@ -426,8 +431,9 @@ void GraphBuilder::visitCallInst(CallInst &CI) { void GraphBuilder::visitFreeInst(FreeInst &FI) { // Mark that the node is written to... - getValueDest(*FI.getOperand(0)).getNode()->NodeType - |= DSNode::Modified | DSNode::HeapNode; + DSNode *N = getValueDest(*FI.getOperand(0)).getNode(); + N->setModifiedMarker(); + N->setHeapNodeMarker(); } /// Handle casts... @@ -441,7 +447,7 @@ void GraphBuilder::visitCastInst(CastInst &CI) { // to track the fact that the node points to SOMETHING, just something we // don't know about. Make an "Unknown" node. // - setDestTo(CI, createNode(DSNode::UnknownNode)); + setDestTo(CI, createNode()->setUnknownNodeMarker()); } } @@ -458,7 +464,7 @@ void GraphBuilder::visitInstruction(Instruction &Inst) { CurNode.mergeWith(getValueDest(**I)); if (CurNode.getNode()) - CurNode.getNode()->NodeType |= DSNode::UnknownNode; + CurNode.getNode()->setUnknownNodeMarker(); } |