void PropagateJuliaAddrspaces::visitMemTransferInst(MemTransferInst &MTI) { unsigned DestAS = MTI.getDestAddressSpace(); unsigned SrcAS = MTI.getSourceAddressSpace(); if (!isSpecialAS(DestAS) && !isSpecialAS(SrcAS)) return; Value *Dest = MTI.getRawDest(); if (isSpecialAS(DestAS)) { Value *Replacement = LiftPointer(Dest, cast<PointerType>(Dest->getType())->getElementType(), &MTI); if (Replacement) Dest = Replacement; } Value *Src = MTI.getRawSource(); if (isSpecialAS(SrcAS)) { Value *Replacement = LiftPointer(Src, cast<PointerType>(Src->getType())->getElementType(), &MTI); if (Replacement) Src = Replacement; } if (Dest == MTI.getRawDest() && Src == MTI.getRawSource()) return; Value *TheFn = Intrinsic::getDeclaration(MTI.getModule(), MTI.getIntrinsicID(), {Dest->getType(), Src->getType(), MTI.getOperand(2)->getType()}); MTI.setCalledFunction(TheFn); MTI.setArgOperand(0, Dest); MTI.setArgOperand(1, Src); }