[llvm-commits] [poolalloc] r107020 - /poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp

John Criswell criswell at uiuc.edu
Mon Jun 28 10:16:46 PDT 2010


Author: criswell
Date: Mon Jun 28 12:16:45 2010
New Revision: 107020

URL: http://llvm.org/viewvc/llvm-project?rev=107020&view=rev
Log:
Fixed the code that repairs the function attributes of cloned functions to
work with LLVM 2.7.  This modifies the code to simply strip attributes off of
the new pool arguments.

Modified:
    poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp

Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=107020&r1=107019&r2=107020&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Mon Jun 28 12:16:45 2010
@@ -12,6 +12,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <iostream>
+
 #define DEBUG_TYPE "poolalloc"
 
 #include "dsa/DataStructure.h"
@@ -572,30 +574,19 @@
 
   //
   // The CloneFunctionInto() function will copy the parameter attributes
-  // verbatim.  This is incorrect; each attribute should be shifted one so
-  // that the pool descriptor has no attributes.
-  //
-  // FIXME: I believe the code below assumes that we've only added one pool
-  //        handle.  We actually add one pool handle per incoming argument
-  //        that needs a pool handle.
-  //
-  const AttrListPtr OldAttrs = New->getAttributes();
-  if (!OldAttrs.isEmpty()) {
-    AttrListPtr NewAttrsVector;
-    for (unsigned index = 0; index < OldAttrs.getNumSlots(); ++index) {
-      const AttributeWithIndex & PAWI = OldAttrs.getSlot(index);
-      unsigned argIndex = PAWI.Index;
-
-      // If it's not the return value, move the attribute to the next
-      // parameter.
-      if (argIndex) ++argIndex;
-
-      // Add the parameter to the new list.
-      NewAttrsVector.addAttr(argIndex, PAWI.Attrs);
+  // almost correctly.  However, it will set attributes incorrectly on the new
+  // pool descriptor arguments.  Go through and strip away the attributes on
+  // the pool descriptor arguments.
+  //
+  Function::ArgumentListType & ArgList = New->getArgumentList ();
+  Function::ArgumentListType::iterator arg = ArgList.begin();
+  for (; arg != ArgList.end(); ++arg) {
+    if (arg->getType() == PoolDescPtrTy) {
+      arg->removeAttr (Attribute::ByVal     |
+                       Attribute::Nest      |
+                       Attribute::StructRet |
+                       Attribute::NoCapture);
     }
-
-    // Assign the new attributes to the function clone
-    New->setAttributes (NewAttrsVector);
   }
 
   //





More information about the llvm-commits mailing list