[LLVMdev] Writing an address space re-numbering pass?

Dan Liew dan at su-root.co.uk
Sat May 17 00:37:26 PDT 2014


> I believe the correct way to do this would be to use ValueMapTypeRemapper to
> help you rewrite a function with the same instructions, but new types

Thanks. I wasn't aware of this class. Was there a particular function
you had in mind that I could use this class with?
I took a look at the utilities that can use this class and I don't
fully understand them

All these functions use a ValueToValueMapTy (VMap). It looks quite
important but I'm not sure how the map is supposed to be used. Is the
map supposed to be empty and filled in by the function so that the
clients know how Values were mapped by the function or is the client
supposed to fill in the map first?

void llvm::CloneFunctionInto(...)

Looking at the implementation it seems the VMap should already contain
a mapping for function arguments, but this doesn't look like it will
copy function arguments and consequently ValueMapTypeRemapper won't be
called on function arguments, it only does this on instructions but I
may need to modify the type of the function as well. I suppose I could
do that bit myself (taking inspiration from llvm::CloneModule()).

 Value * llvm::MapValue(...)

Looking at the implementation this won't call the ValueMapTypeRemapper
on Globals so this isn't any use.

Really what I want is the ability to clone an entire module but use
the ValueMapTypeRemapper but this doesn't seem to be an option.

Thanks,
Dan.

-- 
Dan Liew
PhD Student - Imperial College London



More information about the llvm-dev mailing list