aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
diff options
context:
space:
mode:
authorYeting Kuo <yeting.kuo@sifive.com>2023-05-07 16:33:36 +0800
committerYeting Kuo <yeting.kuo@sifive.com>2023-05-07 19:30:16 +0800
commit42601e116b662a2329f9bf6db9e16b561a9d7337 (patch)
treeff3ff54453d103e5c080134542ceabd605ea7121 /llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
parentfbc6a2a3f6df46b4864fb45bc0c555a87c03dc06 (diff)
downloadllvm-42601e116b662a2329f9bf6db9e16b561a9d7337.zip
llvm-42601e116b662a2329f9bf6db9e16b561a9d7337.tar.gz
llvm-42601e116b662a2329f9bf6db9e16b561a9d7337.tar.bz2
[ASAN] Support memory checks on vp.load/store.
The patch adds new member MaybeEVL into InterestingMemoryOperand to represent the effective vector length for vp intrinsics. It may be extended for some target intrinsics in the future. Reviewed By: kito-cheng Differential Revision: https://reviews.llvm.org/D146208
Diffstat (limited to 'llvm/lib/Transforms/Utils/BasicBlockUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/BasicBlockUtils.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index 5a66100..9d86afa 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -1651,6 +1651,27 @@ void llvm::SplitBlockAndInsertForEachLane(ElementCount EC,
}
}
+void llvm::SplitBlockAndInsertForEachLane(
+ Value *EVL, Instruction *InsertBefore,
+ std::function<void(IRBuilderBase &, Value *)> Func) {
+
+ IRBuilder<> IRB(InsertBefore);
+ Type *Ty = EVL->getType();
+
+ if (!isa<ConstantInt>(EVL)) {
+ auto [BodyIP, Index] = SplitBlockAndInsertSimpleForLoop(EVL, InsertBefore);
+ IRB.SetInsertPoint(BodyIP);
+ Func(IRB, Index);
+ return;
+ }
+
+ unsigned Num = cast<ConstantInt>(EVL)->getZExtValue();
+ for (unsigned Idx = 0; Idx < Num; ++Idx) {
+ IRB.SetInsertPoint(InsertBefore);
+ Func(IRB, ConstantInt::get(Ty, Idx));
+ }
+}
+
BranchInst *llvm::GetIfCondition(BasicBlock *BB, BasicBlock *&IfTrue,
BasicBlock *&IfFalse) {
PHINode *SomePHI = dyn_cast<PHINode>(BB->begin());