I am having a problem with using CloneFunctionInto to clone a function that includes changing the type of a value using the VMap. Specifically, I am using the VMap to change the address space of values that have particular pointer types.
The problem seems to be that RemapInstruction successfully changes the operands using the VMap, but the VTy member indicating the type of the instruction does not change to reflect the new types. In my case, this manifests itself as a GetElementPtr instruction (among others) that is accessing a value with a pointer in address space 1, but getType() returns a pointer in address space 0 (the types match otherwise).
Unfortunately, I don't see any way to fix this without duplicating the logic for getting the VTy for each class of instruction. I am wondering if someone more familiar with this functionality might have a better idea of how to fix this?