Could you please describe the problem in more detail? AFAIR, if a function has readonly/readonone attr, all the writes we insert there are magically eliminated, right? So, why not (also?) remove these attributes while transforming the function itself? http://llvm-reviews.chandlerc.com/D173