mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
Only spit out warning for functions that take pointers, not for sin and the like
Add more special case handling for stdio functions. I feel dirty, how about you? git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11506 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -484,6 +484,12 @@ void GraphBuilder::visitCallSite(CallSite CS) {
|
|||||||
if (DSNode *N = RetNH.getNode())
|
if (DSNode *N = RetNH.getNode())
|
||||||
N->setHeapNodeMarker()->setModifiedMarker()->setReadMarker();
|
N->setHeapNodeMarker()->setModifiedMarker()->setReadMarker();
|
||||||
return;
|
return;
|
||||||
|
} else if (F->getName() == "atoi") {
|
||||||
|
// atoi reads its argument.
|
||||||
|
if (DSNode *N = getValueDest(**CS.arg_begin()).getNode())
|
||||||
|
N->setReadMarker();
|
||||||
|
return;
|
||||||
|
|
||||||
} else if (F->getName() == "fopen" && CS.arg_end()-CS.arg_begin() == 2){
|
} else if (F->getName() == "fopen" && CS.arg_end()-CS.arg_begin() == 2){
|
||||||
// fopen reads the mode argument strings.
|
// fopen reads the mode argument strings.
|
||||||
CallSite::arg_iterator AI = CS.arg_begin();
|
CallSite::arg_iterator AI = CS.arg_begin();
|
||||||
@ -511,8 +517,11 @@ void GraphBuilder::visitCallSite(CallSite CS) {
|
|||||||
if (const PointerType *PTy = dyn_cast<PointerType>(ArgTy))
|
if (const PointerType *PTy = dyn_cast<PointerType>(ArgTy))
|
||||||
H.getNode()->mergeTypeInfo(PTy->getElementType(), H.getOffset());
|
H.getNode()->mergeTypeInfo(PTy->getElementType(), H.getOffset());
|
||||||
return;
|
return;
|
||||||
} else if (F->getName() == "fflush" && CS.arg_end()-CS.arg_begin() ==1){
|
} else if (CS.arg_end()-CS.arg_begin() == 1 &&
|
||||||
// fclose reads and writes the memory for the file descriptor. It
|
(F->getName() == "fflush" || F->getName() == "feof" ||
|
||||||
|
F->getName() == "fileno" || F->getName() == "clearerr" ||
|
||||||
|
F->getName() == "rewind" || F->getName() == "ftell")) {
|
||||||
|
// fflush reads and writes the memory for the file descriptor. It
|
||||||
// merges the FILE type into the descriptor.
|
// merges the FILE type into the descriptor.
|
||||||
DSNodeHandle H = getValueDest(**CS.arg_begin());
|
DSNodeHandle H = getValueDest(**CS.arg_begin());
|
||||||
H.getNode()->setReadMarker()->setModifiedMarker();
|
H.getNode()->setReadMarker()->setModifiedMarker();
|
||||||
@ -522,7 +531,7 @@ void GraphBuilder::visitCallSite(CallSite CS) {
|
|||||||
H.getNode()->mergeTypeInfo(PTy->getElementType(), H.getOffset());
|
H.getNode()->mergeTypeInfo(PTy->getElementType(), H.getOffset());
|
||||||
return;
|
return;
|
||||||
} else if (F->getName() == "fgets" && CS.arg_end()-CS.arg_begin() == 3){
|
} else if (F->getName() == "fgets" && CS.arg_end()-CS.arg_begin() == 3){
|
||||||
// fclose reads and writes the memory for the file descriptor. It
|
// fgets reads and writes the memory for the file descriptor. It
|
||||||
// merges the FILE type into the descriptor, and writes to the
|
// merges the FILE type into the descriptor, and writes to the
|
||||||
// argument. It returns the argument as well.
|
// argument. It returns the argument as well.
|
||||||
CallSite::arg_iterator AI = CS.arg_begin();
|
CallSite::arg_iterator AI = CS.arg_begin();
|
||||||
@ -565,8 +574,19 @@ void GraphBuilder::visitCallSite(CallSite CS) {
|
|||||||
} else if (F->getName() == "exit") {
|
} else if (F->getName() == "exit") {
|
||||||
// Nothing to do!
|
// Nothing to do!
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "WARNING: Call to unknown external function '"
|
// Unknown function, warn if it returns a pointer type or takes a
|
||||||
<< F->getName() << "' will cause pessimistic results!\n";
|
// pointer argument.
|
||||||
|
bool Warn = isPointerType(CS.getInstruction()->getType());
|
||||||
|
if (!Warn)
|
||||||
|
for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end();
|
||||||
|
I != E; ++I)
|
||||||
|
if (isPointerType((*I)->getType())) {
|
||||||
|
Warn = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (Warn)
|
||||||
|
std::cerr << "WARNING: Call to unknown external function '"
|
||||||
|
<< F->getName() << "' will cause pessimistic results!\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user