Skip to content

Commit 9b8259b

Browse files
authored
[Custom Descriptors] Preserve traps in AbstractTypeRefining (#7752)
When AbstractTypeRefining optimized out descriptor casts targeting uninstantiated types, it previously did not preserve traps on null descriptors. Preserve the traps by inserting a ref.as_non_null on nullable descriptor operands.
1 parent a03f002 commit 9b8259b

File tree

2 files changed

+212
-52
lines changed

2 files changed

+212
-52
lines changed

src/passes/AbstractTypeRefining.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ struct AbstractTypeRefining : public Pass {
334334
if (!curr->desc || !curr->type.isNull()) {
335335
return;
336336
}
337+
// Preserve the trap on a null descriptor.
338+
if (curr->desc->type.isNullable()) {
339+
curr->desc =
340+
Builder(*getModule()).makeRefAs(RefAsNonNull, curr->desc);
341+
}
337342
Block* replacement =
338343
ChildLocalizer(curr, getFunction(), *getModule(), getPassOptions())
339344
.getChildrenReplacement();
@@ -352,6 +357,11 @@ struct AbstractTypeRefining : public Pass {
352357
return;
353358
}
354359
bool isFail = curr->op == BrOnCastDescFail;
360+
// Preserve the trap on a null descriptor.
361+
if (curr->desc->type.isNullable()) {
362+
curr->desc =
363+
Builder(*getModule()).makeRefAs(RefAsNonNull, curr->desc);
364+
}
355365
Block* replacement =
356366
ChildLocalizer(curr, getFunction(), *getModule(), getPassOptions())
357367
.getChildrenReplacement();

0 commit comments

Comments
 (0)