<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - The generation of non-aligned instructions ldm cannot be avoided."
href="https://bugs.llvm.org/show_bug.cgi?id=48350">48350</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>The generation of non-aligned instructions ldm cannot be avoided.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>2077213809@qq.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>My armv8 hardware environment supports non-aligned access, except for ldrd and
ldm class instructions.But whatever option I add, I can't prevent the compiler
from generating ldm/stm, which can cause my program to be misaligned.
The code is as follows:
```
extern void* getaddr();
typedef struct {
unsigned int x[4];
unsigned char y;
}A;
typedef struct {
unsigned long long x;
}B;
typedef struct {
A a;
B b;
}Obj;
typedef struct {
int x;
A a;
B b;
}Src;
int test(Obj *a)
{
Src *b = getaddr();
a->a = b->a;
}
```
clang --target=arm-none-eabi -S -O2 a.c -o -
I've tried -mllvm arm-assume-misaligned-load-store=true, -mno-unaligned-access,
even O0, and I can't stop this kind of instruction.
```
.save {r4, r5, r6, r10, r11, lr}
push {r4, r5, r6, r10, r11, lr}
.setfp r11, sp, #16
add r11, sp, #16
mov r6, r0
bl getaddr
add r0, r0, #4
ldm r0, {r1, r2, r3, r4, r5} // This directive may cause exceptions
but cannot disable generation.
stm r6, {r1, r2, r3, r4, r5}
pop {r4, r5, r6, r10, r11, lr}
bx lr
```</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>