[llvm] r302416 - [ARM] Clear the constant pool cache on explicit .ltorg directives
James Molloy via llvm-commits
llvm-commits at lists.llvm.org
Mon May 22 01:50:29 PDT 2017
Hi Martin,
Apologies, I have reverted this in r303536. I had to revert the
underlying r286006, which is what your patch was fixing. r286006 caused
PR32825 which wasn't addressed.
Cheers,
James
On Mon, 8 May 2017 at 11:39 Martin Storsjo via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: mstorsjo
> Date: Mon May 8 05:26:24 2017
> New Revision: 302416
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302416&view=rev
> Log:
> [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
>
> Added:
> llvm/trunk/test/MC/ARM/ltorg-range.s
> Modified:
> llvm/trunk/include/llvm/MC/ConstantPools.h
> llvm/trunk/lib/MC/ConstantPools.cpp
> llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
>
> Modified: llvm/trunk/include/llvm/MC/ConstantPools.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/ConstantPools.h?rev=302416&r1=302415&r2=302416&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/MC/ConstantPools.h (original)
> +++ llvm/trunk/include/llvm/MC/ConstantPools.h Mon May 8 05:26:24 2017
> @@ -63,6 +63,8 @@ public:
>
> // Return true if the constant pool is empty
> bool empty();
> +
> + void clearCache();
> };
>
> class AssemblerConstantPools {
> @@ -86,6 +88,7 @@ class AssemblerConstantPools {
> public:
> void emitAll(MCStreamer &Streamer);
> void emitForCurrentSection(MCStreamer &Streamer);
> + void clearCacheForCurrentSection(MCStreamer &Streamer);
> const MCExpr *addEntry(MCStreamer &Streamer, const MCExpr *Expr,
> unsigned Size, SMLoc Loc);
>
>
> Modified: llvm/trunk/lib/MC/ConstantPools.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ConstantPools.cpp?rev=302416&r1=302415&r2=302416&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/MC/ConstantPools.cpp (original)
> +++ llvm/trunk/lib/MC/ConstantPools.cpp Mon May 8 05:26:24 2017
> @@ -57,6 +57,10 @@ const MCExpr *ConstantPool::addEntry(con
>
> bool ConstantPool::empty() { return Entries.empty(); }
>
> +void ConstantPool::clearCache() {
> + CachedEntries.clear();
> +}
> +
> //
> // AssemblerConstantPools implementation
> //
> @@ -98,6 +102,13 @@ void AssemblerConstantPools::emitForCurr
> }
> }
>
> +void AssemblerConstantPools::clearCacheForCurrentSection(MCStreamer
> &Streamer) {
> + MCSection *Section = Streamer.getCurrentSectionOnly();
> + if (ConstantPool *CP = getConstantPool(Section)) {
> + CP->clearCache();
> + }
> +}
> +
> const MCExpr *AssemblerConstantPools::addEntry(MCStreamer &Streamer,
> const MCExpr *Expr,
> unsigned Size, SMLoc Loc) {
>
> Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp?rev=302416&r1=302415&r2=302416&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp Mon May
> 8 05:26:24 2017
> @@ -38,6 +38,7 @@ const MCExpr *ARMTargetStreamer::addCons
>
> void ARMTargetStreamer::emitCurrentConstantPool() {
> ConstantPools->emitForCurrentSection(Streamer);
> + ConstantPools->clearCacheForCurrentSection(Streamer);
> }
>
> // finish() - write out any non-empty assembler constant pools.
>
> Added: llvm/trunk/test/MC/ARM/ltorg-range.s
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/ltorg-range.s?rev=302416&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/MC/ARM/ltorg-range.s (added)
> +++ llvm/trunk/test/MC/ARM/ltorg-range.s Mon May 8 05:26:24 2017
> @@ -0,0 +1,27 @@
> +@ RUN: llvm-mc -triple armv7-unknown-linux-gnueabi -filetype obj -o - %s \
> +@ RUN: | llvm-objdump -d - | FileCheck %s
> +
> + ldr r0, =0x01020304
> +@ CHECK: ldr
> + .ltorg
> +@ CHECK: 0x01020304
> + ldr r0, =0x01020304
> + ldr r0, =0x01020304
> + ldr r0, =0x01020304
> +@ CHECK: ldr
> +@ CHECK: ldr
> +@ CHECK: ldr
> + .ltorg
> +@ CHECK: 0x01020304
> + .rep 1028
> + .word 0
> + .endr
> +@ CHECK: 0x00000000
> +
> + ldr r0, =0x01020304
> +@ CHECK: ldr
> + .ltorg
> +@ CHECK: 0x01020304
> + .rep 1028
> + .word 0
> + .endr
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170522/d1c698fc/attachment.html>
More information about the llvm-commits
mailing list