<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55849>55849</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Save and restore of extra register in the call frame.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          hiraditya
      </td>
    </tr>
</table>

<pre>
    test case:
```cpp
// Type your code here, or load an example.
/* Nonzero if either X or Y is not aligned on a "long" boundary.  */
#define UNALIGNED(X, Y) \
  (((unsigned long)X & (sizeof (unsigned long) - 1)) | ((unsigned long)Y & (sizeof (unsigned long) - 1)))

  #define UNALIGNED1(a) \
    ((unsigned long)(a) & (sizeof(unsigned long)-1))

/* How many bytes are copied each iteration of the 4X unrolled loop.  */
#define BIGBLOCKSIZE    (sizeof (unsigned long) * 4)

/* How many bytes are copied each iteration of the word copy loop.  */
#define LITTLEBLOCKSIZE (sizeof (unsigned long))

/* Threshhold for punting to the byte copier.  */
#define TOO_SMALL(LEN)  ((LEN) < BIGBLOCKSIZE)

void * memcpy (void *__restrict dst0,
        const void *__restrict src0,
        unsigned long len0)
{
  unsigned char *dst = dst0;
  const unsigned char *src = src0;
  

  /* If the size is small, or either SRC or DST is unaligned,
     then punt into the byte copy loop.  This should be rare.  */
  if (len0 >= LITTLEBLOCKSIZE && !UNALIGNED (src, dst))
    {
    unsigned long *aligned_dst;
    const unsigned long *aligned_src;
      aligned_dst = (unsigned long*)dst;
      aligned_src = (const unsigned long*)src;

      /* Copy one long word at a time if possible.  */


      /* Copy one long word at a time if possible.  */
      do
        {
          *aligned_dst++ = *aligned_src++;
          len0 -= LITTLEBLOCKSIZE;
        } while (len0 >= LITTLEBLOCKSIZE);

       /* Pick up any residual with a byte copier.  */
      dst = (unsigned char*)aligned_dst;
      src = (const unsigned char*)aligned_src;
    }

  for (; len0; len0--)
    *dst++ = *src++;

  return dst0;
}
```

```
# command
$ armv7a-clang-11.0.1 -O3  -mabi=aapcs --target=arm-none-eabi -ftree-vectorize -mcpu=arm7tdmi -mtune=arm7tdmi -march=armv4t  -mthumb test.c -S -o -

memcpy:
        push    {r4, r6, r7, lr} ; <----------------- (save) r6 is never used
        add     r7, sp, #8
        cmp     r2, #4
        blo     .LBB0_3
        movs    r3, r1
        orrs    r3, r0
        lsls    r3, r3, #30
        beq     .LBB0_4
        movs    r3, r0
        b       .LBB0_6
.LBB0_3:
        movs    r3, r0
        b       .LBB0_7
.LBB0_4:
        movs    r3, r0
.LBB0_5:
        ldm     r1!, {r4}
        stm     r3!, {r4}
        subs    r2, r2, #4
        cmp     r2, #3
        bhi     .LBB0_5
        b       .LBB0_7
.LBB0_6:
        ldrb    r4, [r1]
        strb    r4, [r3]
        subs    r2, r2, #1
        adds    r3, r3, #1
        adds    r1, r1, #1
.LBB0_7:
        cmp     r2, #0
        bne     .LBB0_6
        pop     {r4, r6, r7} <----------------- (restore) r6 is never used
        pop     {r1}
        bx      r1
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytV1tz4jYU_jXwcsaMjY2BBx5Ckm4zpUlnQ2eSvmRkW2C1tuVKMln21_dIssEXSLMzy3gQlj6dy3cuEhFPjitFpYKYSDryb0bu3ci9GYWufeKyrGemv-AD22NJ4cgrATFPKKRU0NH0FriAjJMESAH0G8nLjE5a227gkRffqeDAdkCZwl3wove8ApNQcAUkY_uCJsALIDCaTjNe7HGAiFdFQsRxAjhrhNVS_YTuWEHhz8ebzcOXx_u70XTxoi15HU2XMJrdWqDetrBPVUirw8pevuBSqJcl-075Di5AwAEPByNxfguX5bz-iBz9WA9O5g08QeiC9LyAK8pP0LYJF3CON1Reh-ZX_g45KY4QHTEPgAiKoS0Z7qUkToEpKohiGBj0DSMHwQtUheBZZqTz8mpo1g9f1pun29-eH_66rz34gCJtSvBzLHznItGI48f2bR6228392cQP7bts2TYVVKYpzxLYY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