Can anyone please guide me how can I replace a load instruction with a prefetch. I was looking at the intrinsic creation methods of the IRBuilder, but I can only find functions corresponding to memset, memcpy and memmove intrinsics, not for prefetching.
Also, I target x86-64 architectures. Is it sufficient to insert a call to the intrinsic in the LLVM IR to have the corresponding prefetch instruction generated for this target?
Thank you for your help,
I'm not sure what you mean by "replace", but I have code that does this to insert prefetches:
Type *I8Ptr = Type::getInt8PtrTy((*I)->getContext(), PtrAddrSpace);
Value *PrefPtrValue = ...
Module *M = (*I)->getParent()->getParent();
Type *I32 = Type::getInt32Ty((*I)->getContext());
Value *PrefetchFunc = Intrinsic::getDeclaration(M, Intrinsic::prefetch);
ConstantInt::get(I32, MemI->mayReadFromMemory() ? 0 : 1),
ConstantInt::get(I32, 3), ConstantInt::get(I32, 1));
Thank you, this is what I was looking for.