<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 - [GlobalISel] CodeModel::Large sequences are not emitted"
href="https://bugs.llvm.org/show_bug.cgi?id=35958">35958</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[GlobalISel] CodeModel::Large sequences are not emitted
</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>roger.ferreribanez@arm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, qcolombet@apple.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19680" name="attach_19680" title="C Testcase">attachment 19680</a> <a href="attachment.cgi?id=19680&action=edit" title="C Testcase">[details]</a></span>
C Testcase
Hi all,
the following testcase needs to be built with -mcmodel=large as it accesses
huge arrays.
-- t.c
#define BIG (1024*1024*1024)
int foo1[BIG];
int foo2[BIG];
int main(void)
{
return foo1[0] + foo2[0];
}
-- end of t.c
unfortunately GlobalISel seems to be unable to select the "large" sequence of
instructions.
$ aarch64-linux-gnu-clang -DADJUST=0 -o t.exe t.c -mcmodel=large
/tmp/t-0e2765.o: In function `main':
t.c:(.text+0x4): relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21
against symbol `foo1' defined in COMMON section in /tmp/t-0e2765.o
clang-6.0: error: linker command failed with exit code 1 (use -v to see
invocation)
Looking at the generated GMir
%bb.1: derived from LLVM BB %entry
%1:_(s32) = G_CONSTANT i32 0
%4:_(p0) = G_GLOBAL_VALUE @foo1
%3:_(p0) = COPY %4(p0)
%7:_(p0) = G_GLOBAL_VALUE @foo2
%6:_(p0) = COPY %7(p0)
...
looks like G_GLOBAL_VALUE is lowered by the InstructionSelector to the pseudo
MOVaddr:
Selecting:
%4:gpr(p0) = G_GLOBAL_VALUE @foo1
(... tons of gibberish ...)
Into:
%4:gpr64(p0) = MOVaddr target-flags(aarch64-page) @foo1,
target-flags(aarch64-pageoff, aarch64-nc) @foo1
which is later expanded to
%x8 = ADRP target-flags(aarch64-page) @foo1
renamable %x8 = ADDXri %x8, target-flags(aarch64-pageoff, aarch64-nc) @foo1, 0
which ends being
adrp x8, foo1
add x8, x8, :lo12:foo1
which will cause the linker failure.
Disabling GlobalISel via -mllvm -global-isel=0 we see that the expected
sequence is generated
movz x9, #:abs_g0_nc:foo1
movk x9, #:abs_g1_nc:foo1
movk x9, #:abs_g2_nc:foo1
movk x9, #:abs_g3:foo1
SelectionDAG strategy is a bit different: it wraps the ISD::GlobalAddress
during legalization into a AArch64ISD::WrapperLarge and then uses a Pat<...> to
expand it.
Kind regards,
Roger</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>