[llvm-commits] [poolalloc] r108216 - /poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
Will Dietz
wdietz2 at illinois.edu
Mon Jul 12 17:04:39 PDT 2010
Author: wdietz2
Date: Mon Jul 12 19:04:39 2010
New Revision: 108216
URL: http://llvm.org/viewvc/llvm-project?rev=108216&view=rev
Log:
Improve/fix attribute copying from old function to the new clone.
Not listing the attributes also makes it more robust to changes
in the types of attributes moving forward.
Fixes PR#7631.
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=108216&r1=108215&r2=108216&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Mon Jul 12 19:04:39 2010
@@ -645,10 +645,6 @@
NI->setName(I->getName());
}
- // Perform the cloning.
- SmallVector<ReturnInst*,100> Returns;
- CloneFunctionInto(New, &F, ValueMap, Returns);
-
//
// Invert the ValueMap into the NewToOldValueMap.
//
@@ -657,6 +653,10 @@
E = ValueMap.end(); I != E; ++I)
NewToOldValueMap.insert(std::make_pair(I->second, I->first));
+ // Perform the cloning.
+ SmallVector<ReturnInst*,100> Returns;
+ CloneFunctionInto(New, &F, ValueMap, Returns);
+
//
// FIXME: File a bug report for CloneFunctionInto; it should take care of
// this mess for us. Also check whether it does it correctly.
@@ -673,8 +673,8 @@
Function::ArgumentListType & ArgList = New->getArgumentList ();
Function::ArgumentListType::iterator arg = ArgList.begin();
for (; arg != ArgList.end(); ++arg) {
- arg->removeAttr (Attribute::ParameterOnly);
- arg->removeAttr (Attribute::NoAlias);
+ // Whatever attributes New has for this argument, remove them.
+ arg->removeAttr(New->getAttributes().getParamAttributes(arg->getArgNo()+1));
}
//
@@ -686,11 +686,7 @@
Argument * newArg = dyn_cast<Argument>(ValueMap[arg]);
assert (newArg && "Value Map for arguments incorrect!\n");
- if (arg->hasByValAttr ()) newArg->addAttr (Attribute::ByVal);
- if (arg->hasNestAttr ()) newArg->addAttr (Attribute::Nest);
- if (arg->hasNoAliasAttr ()) newArg->addAttr (Attribute::NoAlias);
- if (arg->hasNoCaptureAttr ()) newArg->addAttr (Attribute::NoCapture);
- if (arg->hasStructRetAttr ()) newArg->addAttr (Attribute::StructRet);
+ newArg->addAttr(F.getAttributes().getParamAttributes(arg->getArgNo()+1));
}
return FI.Clone = New;
More information about the llvm-commits
mailing list