[llvm-commits] [llvm-gcc-4.0] r40664 - /llvm-gcc-4.0/trunk/gcc/llvm-types.cpp

Christopher Lamb christopher.lamb at gmail.com
Tue Jul 31 21:17:43 PDT 2007


Author: clamb
Date: Tue Jul 31 23:17:42 2007
New Revision: 40664

URL: http://llvm.org/viewvc/llvm-project?rev=40664&view=rev
Log:
Clean up restrict handling per feedback.

Modified:
    llvm-gcc-4.0/trunk/gcc/llvm-types.cpp

Modified: llvm-gcc-4.0/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-types.cpp?rev=40664&r1=40663&r2=40664&view=diff

==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-types.cpp Tue Jul 31 23:17:42 2007
@@ -784,8 +784,9 @@
     if (const Type *Ty = GET_TYPE_LLVM(type))
       return Ty;
     
+    // No declaration to pass through, passing NULL
     unsigned CallingConv;
-    return TypeDB.setType(type, ConvertFunctionType(type, orig_type, NULL, CallingConv));
+    return TypeDB.setType(type, ConvertFunctionType(type, NULL, NULL, CallingConv));
   }
   case ARRAY_TYPE: {
     if (const Type *Ty = GET_TYPE_LLVM(type))
@@ -978,9 +979,10 @@
   LLVM_TARGET_INIT_REGPARM(local_regparam, type);
 #endif // LLVM_TARGET_ENABLE_REGPARM
   
+  // Check if we have a corresponding decl to inspect
+  tree DeclArgs = (decl) ? DECL_ARGUMENTS(decl) : NULL;
   // Loop over all of the arguments, adding them as we go.
   tree Args = TYPE_ARG_TYPES(type);
-  tree DeclArgs = DECL_ARGUMENTS(decl);
   for (; Args && TREE_VALUE(Args) != void_type_node; Args = TREE_CHAIN(Args)){
     tree ArgTy = TREE_VALUE(Args);
     if (!isPassedByInvisibleReference(ArgTy) &&
@@ -1013,13 +1015,15 @@
         Attributes |= ParamAttr::SExt;
     }
 
-    // Compute noalias attributes.
-    tree RestrictArgTy = (DeclArgs) ? DeclArgs->type.common.type : ArgTy;
-    RestrictArgTy = (RestrictArgTy) ? RestrictArgTy : ArgTy;
+    // Compute noalias attributes. If we have a decl for the function
+    // inspect it for restrict qualifiers, otherwise try the argument
+    // types
+    tree RestrictArgTy = (DeclArgs) ? TREE_TYPE(DeclArgs) : ArgTy;
     if (TREE_CODE(RestrictArgTy) == POINTER_TYPE ||
-        TREE_CODE(RestrictArgTy) == REFERENCE_TYPE)
+        TREE_CODE(RestrictArgTy) == REFERENCE_TYPE) {
       if (TYPE_RESTRICT(RestrictArgTy))
         Attributes |= ParamAttr::NoAlias;
+    }
     
 #ifdef LLVM_TARGET_ENABLE_REGPARM
     // Allow the target to mark this as inreg.





More information about the llvm-commits mailing list