@@ -704,8 +704,12 @@ struct InfoCollector
704
704
void visitRefCast (RefCast* curr) { receiveChildValue (curr->ref , curr); }
705
705
void visitRefTest (RefTest* curr) { addRoot (curr); }
706
706
void visitRefGetDesc (RefGetDesc* curr) {
707
- // TODO: Do something more similar to struct.get here
708
- addRoot (curr);
707
+ // Parallel to StructGet.
708
+ if (!isRelevant (curr->ref )) {
709
+ addRoot (curr);
710
+ return ;
711
+ }
712
+ addChildParentLink (curr->ref , curr);
709
713
}
710
714
void visitBrOn (BrOn* curr) {
711
715
// TODO: optimize when possible
@@ -939,6 +943,10 @@ struct InfoCollector
939
943
return DataLocation{type, i};
940
944
});
941
945
}
946
+ if (curr->desc ) {
947
+ info.links .push_back ({ExpressionLocation{curr->desc , 0 },
948
+ DataLocation{type, DataLocation::DescriptorIndex}});
949
+ }
942
950
addRoot (curr, PossibleContents::exactType (curr->type ));
943
951
}
944
952
void visitArrayNew (ArrayNew* curr) {
@@ -2679,6 +2687,11 @@ void Flower::flowAfterUpdate(LocationIndex locationIndex) {
2679
2687
} else if (auto * set = parent->dynCast <ArraySet>()) {
2680
2688
assert (set->ref == child || set->value == child);
2681
2689
writeToData (set->ref , set->value , 0 );
2690
+ } else if (auto * get = parent->dynCast <RefGetDesc>()) {
2691
+ // Similar to struct.get.
2692
+ assert (get->ref == child);
2693
+ readFromData (
2694
+ get->ref ->type , DataLocation::DescriptorIndex, contents, get);
2682
2695
} else {
2683
2696
// TODO: ref.test and all other casts can be optimized (see the cast
2684
2697
// helper code used in OptimizeInstructions and RemoveUnusedBrs)
@@ -2839,6 +2852,10 @@ void Flower::filterGlobalContents(PossibleContents& contents,
2839
2852
2840
2853
void Flower::filterDataContents (PossibleContents& contents,
2841
2854
const DataLocation& dataLoc) {
2855
+ if (dataLoc.index == DataLocation::DescriptorIndex) {
2856
+ // Nothing to filter (packing is not relevant for a descriptor).
2857
+ return ;
2858
+ }
2842
2859
auto field = GCTypeUtils::getField (dataLoc.type , dataLoc.index );
2843
2860
if (!field) {
2844
2861
// This is a bottom type; nothing will be written here.
0 commit comments