[LLVMdev] CloneFunctionInto() overwrites alignment attribute

Ralf Karrenberg Chareos at gmx.de
Tue May 15 09:18:43 PDT 2012


Hi everybody,

I am trying to clone a function body into an existing declaration.
That declaration has the same number of parameters but they differ in 
type and alignment.
Fortunately, it does not care about the type.
Unfortunately, CloneFunctionInto() copies the attributes from the old 
function to the new one unconditionally, overwriting the alignment 
attribute.
Also, the Attribute interface does not allow me to change the alignment 
of a parameter afterwards ("Attempt to change alignment!" assertion). 
Removing the attribute and setting it again is also not allowed.

Note that I don't want to exclude the arguments from cloning (not adding 
them to the ValueMap) since the main point of using CloneFunctionInto() 
is that I don't have to manually rewire them.

I think it is generally not a good idea to just blindly copy and 
overwrite all attributes (including function attributes) since it might 
more often be the case that CloneFunctionInto() is used exactly to copy 
some code into a different signature.

Any ideas?
I am willing to submit a trivial patch that allows to control this 
behavior via a parameter to CloneFunctionInto() with a default value 
that does not change the current behavior.

Cheers,
Ralf



More information about the llvm-dev mailing list