As reported in https://llvm.org/PR38828, Thumb2 ldrex instructions accessing local variables are not being handled correctly. In release builds this results in bad code, in debug builds an assertion.
The issue is that the t2LDREX and t2STREX instructions are marked with AddrModeNone, but rewriteT2FrameIndex relies on knowing the addressing-mode so that it can fold a stack offset into the instruction. This patch adds a new addressing-mode to handle the situation and applies it to the relevant instructions.
Neither the byte/half/dword forms, nor any ARM variant is affected because they do not allow an offset to the base register.
I'm not sure I understand why AddrModeT2_i12 needs special handling, but AddrModeT2_ldrex doesn't; I think they have a similar restriction that they only support positive offsets?