MichalStrehovsky / iltrim

MIT License
9 stars 1 forks source link

Postpone marking of instance fields on ref types #107

Open mateoatr opened 2 years ago

mateoatr commented 2 years ago

This was a TODO in TypeDefinitionNode.cs

MichalStrehovsky commented 2 years ago

I just remembered there was a problem when I introduced this optimization in IL Linker. CoreLib does an Unsafe.As<SomeNeverAllocatedType>() cast and then accesses a field on the result of the cast but we stripped the unused fields from it, making things misaligned.

The fix was to also keep all the instance fields if any instance field on an Sequential/Explicit reference type is kept.

Maybe a good fix for that would be to: