File tree Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -375,10 +375,8 @@ struct GUFAOptimizer
375
375
376
376
auto oracleType = parent.getContents (curr).getType ();
377
377
// Exact casts are only allowed when custom descriptors is enabled.
378
- if (oracleType.isExact () &&
379
- !getModule ()->features .hasCustomDescriptors ()) {
380
- oracleType = oracleType.with (Inexact);
381
- }
378
+ oracleType =
379
+ oracleType.withInexactIfNoCustomDescs (getModule ()->features );
382
380
if (oracleType.isRef () && oracleType != curr->type &&
383
381
Type::isSubType (oracleType, curr->type )) {
384
382
replaceCurrent (Builder (*getModule ()).makeRefCast (curr, oracleType));
Original file line number Diff line number Diff line change @@ -906,11 +906,10 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
906
906
// further optimizations after this, and those optimizations might even
907
907
// benefit from this improvement.
908
908
auto glb = Type::getGreatestLowerBound (curr->castType , refType);
909
- if (!getModule ()->features .hasCustomDescriptors () && glb.isExact () &&
910
- !curr->castType .isExact ()) {
909
+ if (!curr->castType .isExact ()) {
911
910
// When custom descriptors is not enabled, nontrivial exact casts are
912
911
// not allowed.
913
- glb = glb.with (Inexact );
912
+ glb = glb.withInexactIfNoCustomDescs ( getModule ()-> features );
914
913
}
915
914
if (curr->op == BrOnCastFail) {
916
915
// BrOnCastFail sends the input type, with adjusted nullability. The
Original file line number Diff line number Diff line change @@ -418,16 +418,21 @@ class Type {
418
418
}
419
419
420
420
// Return a new reference type with some part updated to the specified value.
421
- Type with (HeapType heapType) {
421
+ Type with (HeapType heapType) const {
422
422
return Type (heapType, getNullability (), getExactness ());
423
423
}
424
- Type with (Nullability nullability) {
424
+ Type with (Nullability nullability) const {
425
425
return Type (getHeapType (), nullability, getExactness ());
426
426
}
427
- Type with (Exactness exactness) {
427
+ Type with (Exactness exactness) const {
428
428
return Type (getHeapType (), getNullability (), exactness);
429
429
}
430
430
431
+ // Make the type inexact if custom descriptors is not enabled.
432
+ Type withInexactIfNoCustomDescs (FeatureSet feats) const {
433
+ return !isExact () || feats.hasCustomDescriptors () ? *this : with (Inexact);
434
+ }
435
+
431
436
private:
432
437
template <bool (Type::*pred)() const > bool hasPredicate () {
433
438
for (const auto & type : *this ) {
You can’t perform that action at this time.
0 commit comments