Skip to content

Commit 4413a16

Browse files
committed
SIL: fix: SILCloner doesn't create SILUndefs correctly and add verification for that
cloned SILUndefs ended up with the wrong parent function
1 parent ad86461 commit 4413a16

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

include/swift/SIL/SILCloner.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,7 @@ SILCloner<ImplClass>::getMappedValue(SILValue Value) {
592592
// If we have undef, just remap the type.
593593
if (auto *U = dyn_cast<SILUndef>(Value)) {
594594
auto type = getOpType(U->getType());
595-
ValueBase *undef =
596-
(type == U->getType() ? U : SILUndef::get(Builder.getFunction(), type));
597-
return SILValue(undef);
595+
return SILUndef::get(Builder.getFunction(), type);
598596
}
599597

600598
llvm_unreachable("Unmapped value while cloning?");

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,10 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
12631263
"instruction isn't dominated by its bb argument operand");
12641264
}
12651265

1266+
if (auto *undef = dyn_cast<SILUndef>(operand.get())) {
1267+
require(undef->getParent() == BB->getParent(), "SILUndef in wrong function");
1268+
}
1269+
12661270
require(operand.getUser() == I,
12671271
"instruction's operand's owner isn't the instruction");
12681272
require(isOperandInValueUses(&operand), "operand value isn't used by operand");

0 commit comments

Comments
 (0)