OSDN Git Service

[Thumb] set code alignment for 16-bit load from constant pool
authorSimon Wallis <simon.wallis2@arm.com>
Wed, 22 Jul 2020 09:11:57 +0000 (10:11 +0100)
committerSimon Wallis <simon.wallis2@arm.com>
Wed, 22 Jul 2020 09:12:41 +0000 (10:12 +0100)
commit94e4e37d5564c401dcdc7f98d36d87020b6759e1
treeae99e67e613db7c92175d7bc34db18bcb31448f4
parent5567c62afa559dc2f2604601ec9269f1e3fbfdab
[Thumb] set code alignment for 16-bit load from constant pool

Summary:
[Thumb] set code alignment for 16-bit load from constant pool

LLVM miscompiles this code when compiling for a target with v8.2-A FP16 and the Thumb ISA at -O0:

extern void bar(__fp16 P5);

int main() {
  __fp16 P5 = 1.96875;
  bar(P5);
}

The code section containing main has 2 byte alignment.
It needs to have 4 byte alignment,
because the load literal instruction has an offset from the
load address with the low 2 bits zeroed.

I do not include a test case in this check-in.
llc and llvm-mc do not exhibit this bug. They do not set code section alignment
in the same manner as clang.

Reviewers: dnsampaio

Reviewed By: dnsampaio

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D84169
llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
llvm/test/CodeGen/ARM/const-load-align-thumb.mir [new file with mode: 0644]