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

John Criswell criswell at uiuc.edu
Mon Feb 18 15:06:24 PST 2008


Author: criswell
Date: Mon Feb 18 17:06:24 2008
New Revision: 47291

URL: http://llvm.org/viewvc/llvm-project?rev=47291&view=rev
Log:
Taught pool allocation how to deal with the new function attributes.

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=47291&r1=47290&r2=47291&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Mon Feb 18 17:06:24 2008
@@ -24,6 +24,7 @@
 #include "llvm/Instructions.h"
 #include "llvm/Module.h"
 #include "llvm/Constants.h"
+#include "llvm/ParameterAttributes.h"
 #include "llvm/Support/CFG.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
@@ -424,6 +425,29 @@
 {TIME_REGION(X, "CloneFunctionInto");
   CloneFunctionInto(New, &F, ValueMap, Returns);
 }
+
+  //
+  // 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.
+  //
+  const ParamAttrsList * OldAttrs = New->getParamAttrs();
+  ParamAttrsVector NewAttrsVector;
+  for (unsigned index = 0; index < OldAttrs->size(); ++index) {
+    // Find the argument index
+    unsigned argIndex = OldAttrs->getParamIndex (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.push_back(ParamAttrsWithIndex::get(argIndex,OldAttrs->getParamAttrsAtIndex(index)));
+  }
+
+  // Assign the new attributes to the function clone
+  New->setParamAttrs (ParamAttrsList::get (NewAttrsVector));
+
   // Invert the ValueMap into the NewToOldValueMap
   std::map<Value*, const Value*> &NewToOldValueMap = FI.NewToOldValueMap;
 





More information about the llvm-commits mailing list