Skip to content

Commit 49c8b58

Browse files
committed
basic verifier coverage for explicit_copy_* instructions
These are just basic restrictions for now to help avoid mistakes. The restrictions are inferred based on how the move checker uses these instructions.
1 parent d4992be commit 49c8b58

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,6 +2822,18 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
28222822
"'MoveOnly' types can only be copied in Raw SIL?!");
28232823
}
28242824

2825+
void checkExplicitCopyAddrInst(ExplicitCopyAddrInst *ecai) {
2826+
require(F.hasOwnership(), "explicit_copy_* is only valid in OSSA.");
2827+
require(ecai->getSrc()->getType().isAddress(),
2828+
"Src value should be lvalue");
2829+
require(ecai->getDest()->getType().isAddress(),
2830+
"Dest address should be lvalue");
2831+
requireSameType(ecai->getDest()->getType(), ecai->getSrc()->getType(),
2832+
"Store operand type and dest type mismatch");
2833+
require(F.isTypeABIAccessible(ecai->getDest()->getType()),
2834+
"cannot directly copy type with inaccessible ABI");
2835+
}
2836+
28252837
void checkMarkUnresolvedMoveAddrInst(MarkUnresolvedMoveAddrInst *SI) {
28262838
require(F.hasOwnership(), "Only valid in OSSA.");
28272839
require(F.getModule().getStage() == SILStage::Raw, "Only valid in Raw SIL");
@@ -2861,6 +2873,14 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
28612873
"'MoveOnly' types can only be copied in Raw SIL?!");
28622874
}
28632875

2876+
void checkExplicitCopyValueInst(ExplicitCopyValueInst *I) {
2877+
require(F.hasOwnership(), "explicit_copy_* is only valid in OSSA.");
2878+
require(I->getOperand()->getType().isObject(),
2879+
"Source value should be an object value");
2880+
require(!I->getOperand()->getType().isTrivial(*I->getFunction()),
2881+
"Source value should be non-trivial");
2882+
}
2883+
28642884
void checkDestroyValueInst(DestroyValueInst *I) {
28652885
require(I->getOperand()->getType().isObject(),
28662886
"Source value should be an object value");

0 commit comments

Comments
 (0)