#13624: loadObj() does not respect alignment
-------------------------------------+-------------------------------------
Reporter: tmcdonell | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Runtime | Version: 8.0.1
System (Linker) |
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
This is perhaps known, but I'll write it down here in case somebody else
runs into this problem as well.
Since `loadObj()` just `mmap()`s the entire object file and decodes it
''in place'', it does not respect the alignment requirements specified in
the section headers. This is problematic for instructions which require
alignment, e.g. SSE, AVX.
The attached `map.ll` program is `map (+1)` over an array of floating
point numbers. In particular, the core loop is 8-way SIMD vectorised x
4-way unrolled, for 32-elements per loop iteration. A tail loop handles
any remainder one-at-a-time.
You can compile it using `llc -filetype=obj -mcpu=native map.ll`. For a
CPU with AVX instructions (sandy bridge or later) you should get the
following:
{{{
$ objdump -d map.o
Disassembly of section .text:
0000000000000000 <map>:
0: 49 89 f3 mov %rsi,%r11
3: 49 29 fb sub %rdi,%r11
6: 0f 8e f9 00 00 00 jle 105