[llvm-commits] [poolalloc] r131569 - /poolalloc/trunk/lib/AssistDS/LoadArgs.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Wed May 18 13:50:04 PDT 2011
Author: aggarwa4
Date: Wed May 18 15:50:04 2011
New Revision: 131569
URL: http://llvm.org/viewvc/llvm-project?rev=131569&view=rev
Log:
Correctly copy attributes when replacing call inst.
Modified:
poolalloc/trunk/lib/AssistDS/LoadArgs.cpp
Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/LoadArgs.cpp?rev=131569&r1=131568&r2=131569&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/LoadArgs.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Wed May 18 15:50:04 2011
@@ -129,7 +129,7 @@
&M);
Function::arg_iterator NI = NewF->arg_begin();
- NI->setName("Sarg");
+ NI->setName("LDarg");
++NI;
DenseMap<const Value*, Value*> ValueMap;
@@ -137,6 +137,7 @@
for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) {
ValueMap[II] = NI;
NI->setName(II->getName());
+ NI->addAttr(F->getAttributes().getParamAttributes(II->getArgNo() + 1));
}
// Perform the cloning.
SmallVector<ReturnInst*,100> Returns;
@@ -147,23 +148,44 @@
fargs.push_back(ai);
}
- NewF->setAlignment(F->getAlignment());
+ NewF->setAttributes(NewF->getAttributes().addAttr(
+ 0, F->getAttributes().getRetAttributes()));
+ NewF->setAttributes(NewF->getAttributes().addAttr(
+ ~0, F->getAttributes().getFnAttributes()));
//Get the point to insert the GEP instr.
- NI = NewF->arg_begin();
SmallVector<Value*, 8> Ops(CI->op_begin()+1, CI->op_end());
Instruction *InsertPoint;
for (BasicBlock::iterator insrt = NewF->front().begin(); isa<AllocaInst>(InsertPoint = insrt); ++insrt) {;}
+ NI = NewF->arg_begin();
LoadInst *LI_new = new LoadInst(cast<Value>(NI), "", InsertPoint);
fargs.at(argNum)->replaceAllUsesWith(LI_new);
+ SmallVector<AttributeWithIndex, 8> AttributesVec;
+
+ // Get the initial attributes of the call
+ AttrListPtr CallPAL = CI->getAttributes();
+ Attributes RAttrs = CallPAL.getRetAttributes();
+ Attributes FnAttrs = CallPAL.getFnAttributes();
SmallVector<Value*, 8> Args;
Args.push_back(LI->getOperand(0));
for(unsigned j =1;j<CI->getNumOperands();j++) {
Args.push_back(CI->getOperand(j));
+ // position in the AttributesVec
+ if (Attributes Attrs = CallPAL.getParamAttributes(j))
+ AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
}
+ // Create the new attributes vec.
+ if (FnAttrs != Attribute::None)
+ AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
+ if (RAttrs)
+ AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
+
+ AttrListPtr NewCallPAL = AttrListPtr::get(AttributesVec.begin(),
+ AttributesVec.end());
CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI);
CallI->setCallingConv(CI->getCallingConv());
+ CallI->setAttributes(NewCallPAL);
CI->replaceAllUsesWith(CallI);
CI->eraseFromParent();
changed = true;
More information about the llvm-commits
mailing list