File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 30
30
#include " ir/find_all.h"
31
31
#include " ir/lubs.h"
32
32
#include " ir/module-utils.h"
33
+ #include " ir/subtypes.h"
33
34
#include " ir/type-updating.h"
34
35
#include " ir/utils.h"
35
36
#include " pass.h"
@@ -139,6 +140,16 @@ struct SignatureRefining : public Pass {
139
140
allInfo[exportedFunc->type ].canModify = false ;
140
141
}
141
142
143
+ // For now, do not optimize types that have subtypes. When we modify such a
144
+ // type we need to modify subtypes as well, similar to the analysis in
145
+ // TypeRefining, and perhaps we can unify this pass with that. TODO
146
+ SubTypes subTypes (*module );
147
+ for (auto & [type, info] : allInfo) {
148
+ if (!subTypes.getStrictSubTypes (type).empty ()) {
149
+ info.canModify = false ;
150
+ }
151
+ }
152
+
142
153
bool refinedResults = false ;
143
154
144
155
// Compute optimal LUBs.
Original file line number Diff line number Diff line change 758
758
)
759
759
)
760
760
)
761
+
762
+ ;; If we refine a type, that may require changes to its subtypes. For now, we
763
+ ;; skip such optimizations. TODO
764
+ (module
765
+ (rec
766
+ ;; CHECK: (type $A (func (param (ref null $B)) (result (ref null $A))))
767
+ (type $A (func (param (ref null $B )) (result (ref null $A ))))
768
+ ;; CHECK: (type $B (func_subtype (param (ref null $A)) (result (ref null $B)) $A))
769
+ (type $B (func_subtype (param (ref null $A )) (result (ref null $B )) $A ))
770
+ )
771
+
772
+ ;; CHECK: (elem declare func $func)
773
+
774
+ ;; CHECK: (func $func (type $A) (param $0 (ref null $B)) (result (ref null $A))
775
+ ;; CHECK-NEXT: (ref.func $func)
776
+ ;; CHECK-NEXT: )
777
+ (func $func (type $A ) (param $0 (ref null $B )) (result (ref null $A ))
778
+ ;; This result is non-nullable, and we could refine type $A accordingly. But
779
+ ;; if we did that, we'd need to refine $B as well.
780
+ (ref.func $func )
781
+ )
782
+ )
You can’t perform that action at this time.
0 commit comments