Skip to content

Commit fb83f3b

Browse files
committed
[LowerMemIntrinsics] Assert when expanding memcpy/memmove for CHERI
This is not safe since we haven't updated the hooks to use capability types when possible.
1 parent b4f17d8 commit fb83f3b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ void llvm::createMemCpyLoopKnownSize(
2525
ConstantInt *CopyLen, Align SrcAlign, Align DstAlign, bool SrcIsVolatile,
2626
bool DstIsVolatile, bool CanOverlap, const TargetTransformInfo &TTI,
2727
std::optional<uint32_t> AtomicElementSize) {
28+
assert(!InsertBefore->getModule()->getDataLayout().hasCheriCapabilities() &&
29+
"Should not expand memcpy in IR for CHERI until hooks are updated");
2830
// No need to expand zero length copies.
2931
if (CopyLen->isZero())
3032
return;
@@ -180,6 +182,8 @@ void llvm::createMemCpyLoopUnknownSize(
180182
Align SrcAlign, Align DstAlign, bool SrcIsVolatile, bool DstIsVolatile,
181183
bool CanOverlap, const TargetTransformInfo &TTI,
182184
std::optional<uint32_t> AtomicElementSize) {
185+
assert(!InsertBefore->getModule()->getDataLayout().hasCheriCapabilities() &&
186+
"Should not expand memcpy in IR for CHERI until hooks are updated");
183187
BasicBlock *PreLoopBB = InsertBefore->getParent();
184188
BasicBlock *PostLoopBB =
185189
PreLoopBB->splitBasicBlock(InsertBefore, "post-loop-memcpy-expansion");
@@ -381,6 +385,8 @@ static void createMemMoveLoop(Instruction *InsertBefore, Value *SrcAddr,
381385
Align DstAlign, bool SrcIsVolatile,
382386
bool DstIsVolatile,
383387
const TargetTransformInfo &TTI) {
388+
assert(!InsertBefore->getModule()->getDataLayout().hasCheriCapabilities() &&
389+
"Should not expand memcpy in IR for CHERI until hooks are updated");
384390
Type *TypeOfCopyLen = CopyLen->getType();
385391
BasicBlock *OrigBB = InsertBefore->getParent();
386392
Function *F = OrigBB->getParent();

0 commit comments

Comments
 (0)