[llvm] [Asan][RISCV] Enhance getTgtMemIntrinsic() to allow Asan instrument t… (PR #135198)
Kito Cheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 10 19:18:48 PDT 2025
================
@@ -43,6 +44,87 @@ static cl::opt<unsigned>
"vectorization while tail-folding."),
cl::init(5), cl::Hidden);
+bool RISCVTTIImpl::getTgtMemIntrinsic(
+ IntrinsicInst *Inst, MemIntrinsicInfo &Info,
+ SmallVectorImpl<InterestingMemoryOperand> *Interesting) const {
+ const DataLayout &DL = getDataLayout();
+ Intrinsic::ID IID = Inst->getIntrinsicID();
+ LLVMContext &C = Inst->getContext();
+ bool HasMask = false;
+ bool HasInteresting = (Interesting == nullptr) ? false : true;
+
+ switch (IID) {
+ case Intrinsic::riscv_vle_mask:
+ case Intrinsic::riscv_vse_mask:
+ HasMask = true;
+ [[fallthrough]];
+ case Intrinsic::riscv_vle:
+ case Intrinsic::riscv_vse: {
+ // Intrinsic interface:
+ // riscv_vle(merge, ptr, vl)
+ // riscv_vle_mask(merge, ptr, mask, vl, policy)
+ // riscv_vse(val, ptr, vl)
+ // riscv_vse_mask(val, ptr, mask, vl, policy)
+ bool IsWrite = Inst->getType()->isVoidTy();
+ Type *Ty = IsWrite ? Inst->getArgOperand(0)->getType() : Inst->getType();
+ const auto *RVVIInfo = RISCVVIntrinsicsTable::getRISCVVIntrinsicInfo(IID);
+ unsigned VLIndex = RVVIInfo->VLOperand;
+ unsigned PtrOperandNo = VLIndex - 1 - HasMask;
+ MaybeAlign Alignment =
+ Inst->getArgOperand(PtrOperandNo)->getPointerAlignment(DL);
+ Type *MaskType = Ty->getWithNewType(Type::getInt1Ty(C));
+ Value *Mask = ConstantInt::getTrue(MaskType);
+ if (HasMask)
+ Mask = Inst->getArgOperand(VLIndex - 1);
+ Value *EVL = Inst->getArgOperand(VLIndex);
+ if (HasInteresting)
+ Interesting->emplace_back(Inst, PtrOperandNo, IsWrite, Ty, Alignment,
+ Mask, EVL);
+ return true;
----------------
kito-cheng wrote:
Return true means we have fill up `MemIntrinsicInfo`, but seems like we didn't...
https://github.com/llvm/llvm-project/pull/135198
More information about the llvm-commits
mailing list