summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/DataStructure/Local.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-13 20:05:32 +0000
committerChris Lattner <sabre@nondot.org>2004-02-13 20:05:32 +0000
commite00227248e8ead7b15fe8a7ac56e2a4e75742013 (patch)
tree52b620f426636eeaf56faaedd84f848111440ff4 /llvm/lib/Analysis/DataStructure/Local.cpp
parentde6a3816917aa0f16d5de0585a1629c0e586254b (diff)
downloadbcm5719-llvm-e00227248e8ead7b15fe8a7ac56e2a4e75742013.tar.gz
bcm5719-llvm-e00227248e8ead7b15fe8a7ac56e2a4e75742013.zip
Add support for fopen/fclose. Specifically with fopen, we were marking all of the
operands as incomplete, though fopen is known to only read them. This just adds fclose for symmetry, though it doesn't gain anything. This makes the dsgraphs for 181.mcf much more precise. llvm-svn: 11390
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/Local.cpp')
-rw-r--r--llvm/lib/Analysis/DataStructure/Local.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/DataStructure/Local.cpp b/llvm/lib/Analysis/DataStructure/Local.cpp
index 2a04d291283..16e3cbaed41 100644
--- a/llvm/lib/Analysis/DataStructure/Local.cpp
+++ b/llvm/lib/Analysis/DataStructure/Local.cpp
@@ -493,6 +493,33 @@ void GraphBuilder::visitCallSite(CallSite CS) {
if (DSNode *N = H.getNode())
N->setModifiedMarker();
return;
+ } else if (F->getName() == "fopen" && CS.arg_end()-CS.arg_begin() == 2){
+ // fopen reads the mode argument strings.
+ CallSite::arg_iterator AI = CS.arg_begin();
+ DSNodeHandle Path = getValueDest(**AI);
+ DSNodeHandle Mode = getValueDest(**++AI);
+ if (DSNode *N = Path.getNode()) N->setReadMarker();
+ if (DSNode *N = Mode.getNode()) N->setReadMarker();
+
+ // fopen allocates in an unknown way and writes to the file
+ // descriptor. Also, merge the allocated type into the node.
+ DSNodeHandle Result = getValueDest(*CS.getInstruction());
+ Result.getNode()->setModifiedMarker()->setUnknownNodeMarker();
+ const Type *RetTy = F->getFunctionType()->getReturnType();
+ if (const PointerType *PTy = dyn_cast<PointerType>(RetTy))
+ Result.getNode()->mergeTypeInfo(PTy->getElementType(),
+ Result.getOffset());
+ return;
+ } else if (F->getName() == "fclose" && CS.arg_end()-CS.arg_begin() ==1){
+ // fclose reads and deallocates the memory in an unknown way for the
+ // file descriptor. It merges the FILE type into the descriptor.
+ DSNodeHandle H = getValueDest(**CS.arg_begin());
+ H.getNode()->setReadMarker()->setUnknownNodeMarker();
+
+ const Type *ArgTy = *F->getFunctionType()->param_begin();
+ if (const PointerType *PTy = dyn_cast<PointerType>(ArgTy))
+ H.getNode()->mergeTypeInfo(PTy->getElementType(), H.getOffset());
+ return;
}
}
OpenPOWER on IntegriCloud