summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorAnders Leino <aleino@nvidia.com>2024-11-11 19:26:55 +0200
committerGitHub <noreply@github.com>2024-11-11 09:26:55 -0800
commit9aa7adb417cabfcb441035b415e80691332bcd1b (patch)
tree9da3e643338e3870dbd1dab5d7f0dfd5c8a2c037 /source
parentc0d0611b7331bb19e8b0b39143e3be107db5925b (diff)
Transfer offset decorations when legalizing laid-out structs (#5525)
* Transfer offset decorations when legalizing laid-out structs Struct legalization removing fields not representable in memory should transfer all decorations in case the struct has already had offsets calculated. Closes #5264. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-legalize-types.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/source/slang/slang-legalize-types.cpp b/source/slang/slang-legalize-types.cpp
index 9c79e3167..6d827a412 100644
--- a/source/slang/slang-legalize-types.cpp
+++ b/source/slang/slang-legalize-types.cpp
@@ -487,8 +487,13 @@ struct TupleTypeBuilder
fieldType = context->getBuilder()->getVoidType();
// TODO: shallow clone of modifiers, etc.
-
- builder->createStructField(ordinaryStructType, ee.fieldKey, fieldType);
+ IRStructField* originalField = findStructField(originalStructType, ee.fieldKey);
+ IRStructField* newField =
+ builder->createStructField(ordinaryStructType, ee.fieldKey, fieldType);
+ // In case the original struct had offset decorations attached, transfer those as
+ // well. The original offsets should still be valid, since we only skip fields of
+ // types that aren't representable in memory.
+ originalField->transferDecorationsTo(newField);
}
ordinaryType = LegalType::simple((IRType*)ordinaryStructType);