OSDN Git Service

[ARM] Clear the constant pool cache on explicit .ltorg directives
authorMartin Storsjo <martin@martin.st>
Mon, 8 May 2017 10:26:24 +0000 (10:26 +0000)
committerMartin Storsjo <martin@martin.st>
Mon, 8 May 2017 10:26:24 +0000 (10:26 +0000)
commitb7c80c3cd27667fd0ec91e5d29b9927beef5891b
tree7c081ba10413678156aa1830a70076ef7f2c6df2
parentb7a513409b1099523d3766b02be10302ca93022c
[ARM] Clear the constant pool cache on explicit .ltorg directives

Multiple ldr pseudoinstructions with the same constant value will
reuse the same constant pool entry. However, if the constant pool
is explicitly flushed with a .ltorg directive, we should not try
to reference constants in the previous pool any longer, since they
may be out of range.

This fixes assembling hand-written assembler source which repeatedly
loads the same constant value, across a binary size larger than the
pc-relative fixup range for ldr instructions (4096 bytes). Such
assembler source already uses explicit .ltorg instructions to emit
constant pools with regular intervals. However if we try to reuse
constants emitted in earlier pools, they end up out of range.

This makes the output of the testcase match what binutils gas does
(prior to this patch, it would fail to assemble).

Differential Revision: https://reviews.llvm.org/D32847

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302416 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/MC/ConstantPools.h
lib/MC/ConstantPools.cpp
lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
test/MC/ARM/ltorg-range.s [new file with mode: 0644]