<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - [ARM] redundant CP entries"
href="https://llvm.org/bugs/show_bug.cgi?id=31233">31233</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[ARM] redundant CP entries
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>weimingz@codeaurora.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>for test.c:
int g;
void foo() {
++g;
}
void bar() {
--g;
}
clang -mcpu=cortex-m3 -target armv7m-linux-gnueabi -c -Os test.c -o test.llvm.o
it generates:
@ BB#0: @ %entry
movw r0, :lower16:g
movt r0, :upper16:g
ldr r1, [r0]
adds r1, #1
str r1, [r0]
bx lr
.Lfunc_end0:
.size foo, .Lfunc_end0-foo
.cantunwind
.fnend
.globl bar
.p2align 1
.type bar,%function
.code 16 @ @bar
.thumb_func
bar:
.fnstart
@ BB#0: @ %entry
movw r0, :lower16:g
movt r0, :upper16:g
ldr r1, [r0]
subs r1, #1
str r1, [r0]
bx lr
.Lfunc_end1:
.size bar, .Lfunc_end1-bar
.cantunwind
.fnend
First, it use movw/movt for each GV access.
By using "-mno-movt", it generates one "ldr" plus one CP entry.
However, for every function, it generates one CP entry for each gv it uses:
@ BB#0: @ %entry
ldr r0, .LCPI0_0
ldr r1, [r0]
adds r1, #1
str r1, [r0]
bx lr
.p2align 2
@ BB#1:
.LCPI0_0:
.long g
.Lfunc_end0:
.size foo, .Lfunc_end0-foo
.cantunwind
.fnend
.globl bar
.p2align 2
.type bar,%function
.code 16 @ @bar
.thumb_func
bar:
.fnstart
@ BB#0: @ %entry
ldr r0, .LCPI1_0
ldr r1, [r0]
subs r1, #1
str r1, [r0]
bx lr
.p2align 2
@ BB#1:
.LCPI1_0: ================> redundent CP entry here
.long g
For a module where each functions access a lot of GVs, a lot of space are
wasted.
Ideally, they should share the same cp.</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>