summaryrefslogtreecommitdiff
path: root/src/ir/struct-utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir/struct-utils.h')
-rw-r--r--src/ir/struct-utils.h28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/ir/struct-utils.h b/src/ir/struct-utils.h
index f68692363..bc2eb5485 100644
--- a/src/ir/struct-utils.h
+++ b/src/ir/struct-utils.h
@@ -221,15 +221,21 @@ public:
SubTypes subTypes;
void propagateToSuperTypes(StructValuesMap<T>& infos) {
- propagate(infos, false);
+ propagate(infos, false, true);
+ }
+
+ void propagateToSubTypes(StructValuesMap<T>& infos) {
+ propagate(infos, true, false);
}
void propagateToSuperAndSubTypes(StructValuesMap<T>& infos) {
- propagate(infos, true);
+ propagate(infos, true, true);
}
private:
- void propagate(StructValuesMap<T>& combinedInfos, bool toSubTypes) {
+ void propagate(StructValuesMap<T>& combinedInfos,
+ bool toSubTypes,
+ bool toSuperTypes) {
UniqueDeferredQueue<HeapType> work;
for (auto& [type, _] : combinedInfos) {
work.push(type);
@@ -238,13 +244,15 @@ private:
auto type = work.pop();
auto& infos = combinedInfos[type];
- // Propagate shared fields to the supertype.
- if (auto superType = type.getSuperType()) {
- auto& superInfos = combinedInfos[*superType];
- auto& superFields = superType->getStruct().fields;
- for (Index i = 0; i < superFields.size(); i++) {
- if (superInfos[i].combine(infos[i])) {
- work.push(*superType);
+ if (toSuperTypes) {
+ // Propagate shared fields to the supertype.
+ if (auto superType = type.getSuperType()) {
+ auto& superInfos = combinedInfos[*superType];
+ auto& superFields = superType->getStruct().fields;
+ for (Index i = 0; i < superFields.size(); i++) {
+ if (superInfos[i].combine(infos[i])) {
+ work.push(*superType);
+ }
}
}
}