[RyuJIT/ARM32] Lack of GTF_IND_UNALIGNED support
It is reported that there is no support for GTF_IND_UNALIGNED yet in ryujit/arm32 at https://github.com/dotnet/coreclr/pull/11224#issuecomment-297797614.
category:correctness theme:alignment skill-level:intermediate cost:medium
Any news? @BruceForstall if not, could you assign this issue to me?
@BredPet Are you looking at this?
@BruceForstall @Buyduck is currently working on this.
@Buyduck Any progress?
@BruceForstall sorry, for delay, I was busy with other tasks, but now I am on :S Could you help me a little bit? At first, I can't get '.unaligned' prefix in IL, when I compiling C# code. Even if decompiled UseUnalignedDouble.il from tests and compiled it to IL again - I got no '.unaligned' prefix. At second, as far as I could understand legacy JIT takes into account GTF_IND_UNALIGNED flag only for floats and doubles and RYUJIT already has support of GTF_IND_UNALIGNED for floats and doubles. Why don't we take into account GTF_IND_UNALIGNED for other types or I understand something wrong?
At first, I can't get '.unaligned' prefix in IL, when I compiling C# code.
The C# compiler doesn't generate this prefix, there's no C# construct that needs it. You can use Unsafe.ReadUnaligned/WriteUnaligned methods if you don't want to write IL tests.
Does anyone know what problem this causes? ARM hardware should already handle 2- and 4-byte misaligned integer loads and stores. There are some odd cases with weird types of memory (normally not user-mode) and specialized instructions like LDM/STM, but the common cases "just work." Unless someone has a real-world repro case where this is going to cause a problem, I'm inclined to push this out of 2.1.
There are a few uses of Read/WriteUnaligned in the framework but all seem to use integers so if I understand correctly they should already work fine. For example: https://github.com/dotnet/coreclr/blob/master/src/mscorlib/shared/System/Marvin.cs
There are also a few uses that involve Vector<T> but they're under if (Vector.IsHardwareAccelerated) so they won't run on ARM32 currently.
RyuJIT doesn't use LDM/STM or LDRD/STRD at all or at least in situations where they could fault due to misalignment, so I'm pushing this out. I'm keeping it open because I think it may deserve a deeper analysis of whether there are any interesting cases to handle here--either for performance or correctness.
There is no activity on this from past almost 4 years. Please reopen it with adequate data if we want to address it.