Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@imhameed
Copy link
Contributor

Should fix #18221.

@imhameed imhameed requested a review from vargaz as a code owner December 25, 2019 22:19
@lambdageek
Copy link
Member

@monojenkins backport to 2019-12
@monojenkins backport to 2019-10

@monojenkins
Copy link
Contributor

@lambdageek backporting to 2019-10 failed, the patch results in conflicts:

Applying: Use byte-aligned LLVM loads and stores for unaligned mini IR loads and stores.
Using index info to reconstruct a base tree...
M	mono/mini/mini-llvm.c
Falling back to patching base and 3-way merge...
Auto-merging mono/mini/mini-llvm.c
CONFLICT (content): Merge conflict in mono/mini/mini-llvm.c
error: Failed to merge in the changes.
Patch failed at 0001 Use byte-aligned LLVM loads and stores for unaligned mini IR loads and stores.

Please backport manually!

@lewurm
Copy link
Contributor

lewurm commented Jan 2, 2020

I've verified that this PR fixes the issue on 32bit release mode iOS (with mono-2019-12 in the Xamarin.iOS repository).

Generated code before:

(lldb) r
Process 206 launched: '/Users/lewurm/Projects/32bitllvmbitconverter/32bitllvmbitconverter/bin/iPhone/Release/_32bitllvmbitconverter.app/_32bitllvmbitconverter' (armv7)
_32bitllvmbitconverter was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 206 stopped
* thread #1, name = 'tid_403', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_ARM_DA_ALIGN, address=0xf02339)
    frame #0: 0x0017e4c8 _32bitllvmbitconverter`mscorlib_System_BitConverter_ToInt64_byte___int at BitConverter.cs:287:13 [opt]
   284              if (startIndex > value.Length - sizeof(long))
   285                  ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall, ExceptionArgument.value);
   286
-> 287              return Unsafe.ReadUnaligned<long>(ref value[startIndex]);
   288          }
   289
   290          // Converts a Span into a long
Target 0: (_32bitllvmbitconverter) stopped.
(lldb) x/20i $pc-0x20
    0x17e4a8: 0xe3550000   cmp    r5, #0
    0x17e4ac: 0x0a00000e   beq    0x17e4ec                  ; <+108> at BitConverter.cs:281:17
    0x17e4b0: 0xe595000c   ldr    r0, [r5, #0xc]
    0x17e4b4: 0xe1500004   cmp    r0, r4
    0x17e4b8: 0x9a00000d   bls    0x17e4f4                  ; <+116> at BitConverter.cs:283:17
    0x17e4bc: 0xe2400008   sub    r0, r0, #8
    0x17e4c0: 0xe1500004   cmp    r0, r4
    0x17e4c4: 0xa0840005   addge  r0, r4, r5
->  0x17e4c8: 0xa1c001d0   ldrdge r0, r1, [r0, #16]
    0x17e4cc: 0xa8bd80b0   popge  {r4, r5, r7, pc}
    0x17e4d0: 0xe3a00005   mov    r0, #5
(lldb) register read r0 r4 r5
      r0 = 0x00f02329
      r4 = 0x00000001
      r5 = 0x00f02328

after:

(lldb) x/10i $pc-0x8
    0xac4c4: 0xa0841005   addge  r1, r4, r5
->  0xac4c8: 0xa5910010   ldrge  r0, [r1, #0x10]
    0xac4cc: 0xa5911014   ldrge  r1, [r1, #0x14]
    0xac4d0: 0xa8bd80b0   popge  {r4, r5, r7, pc}
    0xac4d4: 0xe3a00005   mov    r0, #5
    0xac4d8: 0xe3a0100f   mov    r1, #15
(lldb) register read r1 r4 r5
      r1 = 0x00e02329
      r4 = 0x00000001
      r5 = 0x00e02328
(lldb) si
(lldb) si
(lldb) register read r0 r1 r4 r5
      r0 = 0x9999999a
      r1 = 0x3fb99999
      r4 = 0x00000001
      r5 = 0x00e02328

Generated bitcode also has the align attribute now:

NOEX_BB16:                                        ; preds = %NOEX_BB13
  %18 = ptrtoint i32* %arg_0 to i32, !dbg !7434
  %t45 = add i32 %18, %arg_1, !dbg !7434
  %t50 = add i32 %t45, 16, !dbg !7434
  %19 = inttoptr i32 %t50 to i64*, !dbg !7434
  %t51 = load i64, i64* %19, align 1, !dbg !7434
  br label %BB1, !dbg !7434

monojenkins added a commit that referenced this pull request Jan 2, 2020
…d stores. (#18301)

[2019-12] Use byte-aligned LLVM loads and stores for unaligned mini IR loads and stores.

Should fix #18221.

Backport of #18296.

/cc @lambdageek @imhameed
imhameed added a commit to imhameed/mono that referenced this pull request Jan 7, 2020
imhameed added a commit that referenced this pull request Jan 7, 2020
ManickaP pushed a commit to ManickaP/runtime that referenced this pull request Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[arm32][llvm] crash running BitConverterTest unit tests

5 participants