[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Dec 8 08:22:41 PST 2004



Changes in directory llvm/lib/Analysis/DataStructure:

Local.cpp updated: 1.118 -> 1.119
---
Log message:

Work correctly with ICC, Patch contributed by Bjørn Wennberg


---
Diffs of the changes:  (+16 -8)

Index: llvm/lib/Analysis/DataStructure/Local.cpp
diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.118 llvm/lib/Analysis/DataStructure/Local.cpp:1.119
--- llvm/lib/Analysis/DataStructure/Local.cpp:1.118	Mon Nov  8 15:08:28 2004
+++ llvm/lib/Analysis/DataStructure/Local.cpp	Wed Dec  8 10:22:26 2004
@@ -629,9 +629,12 @@
 
           // If this is freopen, merge the file descriptor passed in with the
           // result.
-          if (F->getName() == "freopen")
-            Result.mergeWith(getValueDest(**--CS.arg_end()));
-
+          if (F->getName() == "freopen") {
+            // ICC doesn't handle getting the iterator, decrementing and
+            // dereferencing it in one operation without error. Do it in 2 steps
+            CallSite::arg_iterator compit = CS.arg_end();
+            Result.mergeWith(getValueDest(**--compit));
+          }
           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
@@ -665,7 +668,8 @@
                    (F->getName() == "fwrite" || F->getName() == "fread")) {
           // fread writes the first operand, fwrite reads it.  They both
           // read/write the FILE descriptor, and merges the FILE type.
-          DSNodeHandle H = getValueDest(**--CS.arg_end());
+          CallSite::arg_iterator compit = CS.arg_end();
+          DSNodeHandle H = getValueDest(**--compit);
           if (DSNode *N = H.getNode()) {
             N->setReadMarker()->setModifiedMarker();
             const Type *ArgTy = F->getFunctionType()->getParamType(3);
@@ -706,10 +710,12 @@
                    F->getName() == "_IO_putc") {
           // These functions read and write the memory for the file descriptor,
           // which is passes as the last argument.
-          DSNodeHandle H = getValueDest(**--CS.arg_end());
+          CallSite::arg_iterator compit = CS.arg_end();
+          DSNodeHandle H = getValueDest(**--compit);
           if (DSNode *N = H.getNode()) {
             N->setReadMarker()->setModifiedMarker();
-            const Type *ArgTy = *--F->getFunctionType()->param_end();
+            FunctionType::param_iterator compit2 = F->getFunctionType()->param_end();
+            const Type *ArgTy = *--compit2;
             if (const PointerType *PTy = dyn_cast<PointerType>(ArgTy))
               N->mergeTypeInfo(PTy->getElementType(), H.getOffset());
           }
@@ -727,7 +733,8 @@
           // and read/write all other arguments.
           DSNodeHandle H = getValueDest(**CS.arg_begin());
           if (DSNode *N = H.getNode()) {
-            const Type *ArgTy = *--F->getFunctionType()->param_end();
+            FunctionType::param_iterator compit2 = F->getFunctionType()->param_end();
+            const Type *ArgTy = *--compit2;
             if (const PointerType *PTy = dyn_cast<PointerType>(ArgTy))
               N->mergeTypeInfo(PTy->getElementType(), H.getOffset());
           }
@@ -897,7 +904,8 @@
           return;
         } else if (F->getName() == "modf" && CS.arg_end()-CS.arg_begin() == 2) {
           // This writes its second argument, and forces it to double.
-          DSNodeHandle H = getValueDest(**--CS.arg_end());
+          CallSite::arg_iterator compit = CS.arg_end();
+          DSNodeHandle H = getValueDest(**--compit);
           if (DSNode *N = H.getNode()) {
             N->setModifiedMarker();
             N->mergeTypeInfo(Type::DoubleTy, H.getOffset());






More information about the llvm-commits mailing list