This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

armclang and memcpy: Weird behavior

Just for info:

armclang optimizes memcpy() in a weird way (seen for ARMv7e-M), not respecting the order of access.

So a memcpy(RBAR, mputable,...) failes :(

Parents
  • ARM clang 6.6.3 _and_ 6.16.1

     memcpy((void *)&(MPU->RBAR),&boot_pt[0],sizeof(uint32_t)*8);

    =>

    ______addr/line|code_____|label____|mnemonic________________|comment
                176|  memcpy((void *)&(MPU->RBAR),&boot_pt[0],sizeof(uint32_t)*8);
        ST:08001D22|F24A4048            movw    r0,#0xA448
        ST:08001D26|F64E55B0            movw    r5,#0xEDB0
        ST:08001D2A|F6C00000            movt    r0,#0x800
        ST:08001D2E|F2CE0500            movt    r5,#0xE000
        ST:08001D32|E9D0CE00            ldrd    r12,r14,[r0]
        ST:08001D36|E9D03102            ldrd    r3,r1,[r0,#0x8]
        ST:08001D3A|E9D02404            ldrd    r2,r4,[r0,#0x10]
        ST:08001D3E|602C                str     r4,[r5]
        ST:08001D40|F64E54AC            movw    r4,#0xEDAC
        ST:08001D44|F2CE0400            movt    r4,#0xE000
        ST:08001D48|6022                str     r2,[r4]
    

    What happens is, that first it store to RASR (EDB0) then to RABR (EDAC), which is wrong.

Reply
  • ARM clang 6.6.3 _and_ 6.16.1

     memcpy((void *)&(MPU->RBAR),&boot_pt[0],sizeof(uint32_t)*8);

    =>

    ______addr/line|code_____|label____|mnemonic________________|comment
                176|  memcpy((void *)&(MPU->RBAR),&boot_pt[0],sizeof(uint32_t)*8);
        ST:08001D22|F24A4048            movw    r0,#0xA448
        ST:08001D26|F64E55B0            movw    r5,#0xEDB0
        ST:08001D2A|F6C00000            movt    r0,#0x800
        ST:08001D2E|F2CE0500            movt    r5,#0xE000
        ST:08001D32|E9D0CE00            ldrd    r12,r14,[r0]
        ST:08001D36|E9D03102            ldrd    r3,r1,[r0,#0x8]
        ST:08001D3A|E9D02404            ldrd    r2,r4,[r0,#0x10]
        ST:08001D3E|602C                str     r4,[r5]
        ST:08001D40|F64E54AC            movw    r4,#0xEDAC
        ST:08001D44|F2CE0400            movt    r4,#0xE000
        ST:08001D48|6022                str     r2,[r4]
    

    What happens is, that first it store to RASR (EDB0) then to RABR (EDAC), which is wrong.

Children