[llvm-commits] [llvm-gcc-4.2] r56820 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-types.cpp

Devang Patel dpatel at apple.com
Mon Sep 29 17:22:26 PDT 2008


Author: dpatel
Date: Mon Sep 29 19:22:25 2008
New Revision: 56820

URL: http://llvm.org/viewvc/llvm-project?rev=56820&view=rev
Log:
Distinguish between function attributes and return value attributes.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=56820&r1=56819&r2=56820&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Sep 29 19:22:25 2008
@@ -2623,9 +2623,9 @@
   // Work out whether to use an invoke or an ordinary call.
   if (!tree_could_throw_p(exp))
     // This call does not throw - mark it 'nounwind'.
-    PAL = PAL.addAttr(0, Attribute::NoUnwind);
+    PAL = PAL.addAttr(~0, Attribute::NoUnwind);
 
-  if (!PAL.paramHasAttr(0, Attribute::NoUnwind)) {
+  if (!PAL.paramHasAttr(~0, Attribute::NoUnwind)) {
     // This call may throw.  Determine if we need to generate
     // an invoke rather than a simple call.
     int RegionNo = lookup_stmt_eh_region(exp);

Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=56820&r1=56819&r2=56820&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon Sep 29 19:22:25 2008
@@ -1129,17 +1129,17 @@
 
   // Compute attributes for return type (and function attributes).
   SmallVector<AttributeWithIndex, 8> Attrs;
-  Attributes RAttributes = Attribute::None;
+  Attributes FnAttributes = Attribute::None;
 
   int flags = flags_from_decl_or_type(decl ? decl : type);
 
   // Check for 'noreturn' function attribute.
   if (flags & ECF_NORETURN)
-    RAttributes |= Attribute::NoReturn;
+    FnAttributes |= Attribute::NoReturn;
 
   // Check for 'nounwind' function attribute.
   if (flags & ECF_NOTHROW)
-    RAttributes |= Attribute::NoUnwind;
+    FnAttributes |= Attribute::NoUnwind;
 
   // Check for 'readnone' function attribute.
   // Both PURE and CONST will be set if the user applied
@@ -1150,25 +1150,26 @@
   // accepts it).  But llvm IR does not allow both, so
   // set only ReadNone.
   if (flags & ECF_CONST)
-    RAttributes |= Attribute::ReadNone;
+    FnAttributes |= Attribute::ReadNone;
 
   // Check for 'readonly' function attribute.
   if (flags & ECF_PURE && !(flags & ECF_CONST))
-    RAttributes |= Attribute::ReadOnly;
+    FnAttributes |= Attribute::ReadOnly;
 
   // Since they write the return value through a pointer,
   // 'sret' functions cannot be 'readnone' or 'readonly'.
   if (ABIConverter.isShadowReturn())
-    RAttributes &= ~(Attribute::ReadNone|Attribute::ReadOnly);
+    FnAttributes &= ~(Attribute::ReadNone|Attribute::ReadOnly);
 
   // Demote 'readnone' nested functions to 'readonly' since
   // they may need to read through the static chain.
-  if (static_chain && (RAttributes & Attribute::ReadNone)) {
-    RAttributes &= ~Attribute::ReadNone;
-    RAttributes |= Attribute::ReadOnly;
+  if (static_chain && (FnAttributes & Attribute::ReadNone)) {
+    FnAttributes &= ~Attribute::ReadNone;
+    FnAttributes |= Attribute::ReadOnly;
   }
 
   // Compute whether the result needs to be zext or sext'd.
+  Attributes RAttributes = Attribute::None;
   RAttributes |= HandleArgumentExtension(TREE_TYPE(type));
 
   // Allow the target to change the attributes.
@@ -1278,6 +1279,9 @@
   isVarArg = (Args == 0);
   assert(RetTy && "Return type not specified!");
 
+  if (FnAttributes != Attribute::None)
+    Attrs.push_back(AttributeWithIndex::get(~0, FnAttributes));
+
   // Finally, make the function type and result attributes.
   PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
   return GetFunctionType(RetTy, ArgTypes, isVarArg);





More information about the llvm-commits mailing list