<div dir="ltr">Hi Martin,<div><br></div><div>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.</div><div><br></div><div>Cheers,</div><div><br></div><div>James</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, 8 May 2017 at 11:39 Martin Storsjo via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mstorsjo<br>
Date: Mon May  8 05:26:24 2017<br>
New Revision: 302416<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=302416&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=302416&view=rev</a><br>
Log:<br>
[ARM] Clear the constant pool cache on explicit .ltorg directives<br>
<br>
Multiple ldr pseudoinstructions with the same constant value will<br>
reuse the same constant pool entry. However, if the constant pool<br>
is explicitly flushed with a .ltorg directive, we should not try<br>
to reference constants in the previous pool any longer, since they<br>
may be out of range.<br>
<br>
This fixes assembling hand-written assembler source which repeatedly<br>
loads the same constant value, across a binary size larger than the<br>
pc-relative fixup range for ldr instructions (4096 bytes). Such<br>
assembler source already uses explicit .ltorg instructions to emit<br>
constant pools with regular intervals. However if we try to reuse<br>
constants emitted in earlier pools, they end up out of range.<br>
<br>
This makes the output of the testcase match what binutils gas does<br>
(prior to this patch, it would fail to assemble).<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D32847" rel="noreferrer" target="_blank">https://reviews.llvm.org/D32847</a><br>
<br>
Added:<br>
    llvm/trunk/test/MC/ARM/ltorg-range.s<br>
Modified:<br>
    llvm/trunk/include/llvm/MC/ConstantPools.h<br>
    llvm/trunk/lib/MC/ConstantPools.cpp<br>
    llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/MC/ConstantPools.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/ConstantPools.h?rev=302416&r1=302415&r2=302416&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/ConstantPools.h?rev=302416&r1=302415&r2=302416&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/MC/ConstantPools.h (original)<br>
+++ llvm/trunk/include/llvm/MC/ConstantPools.h Mon May  8 05:26:24 2017<br>
@@ -63,6 +63,8 @@ public:<br>
<br>
   // Return true if the constant pool is empty<br>
   bool empty();<br>
+<br>
+  void clearCache();<br>
 };<br>
<br>
 class AssemblerConstantPools {<br>
@@ -86,6 +88,7 @@ class AssemblerConstantPools {<br>
 public:<br>
   void emitAll(MCStreamer &Streamer);<br>
   void emitForCurrentSection(MCStreamer &Streamer);<br>
+  void clearCacheForCurrentSection(MCStreamer &Streamer);<br>
   const MCExpr *addEntry(MCStreamer &Streamer, const MCExpr *Expr,<br>
                          unsigned Size, SMLoc Loc);<br>
<br>
<br>
Modified: llvm/trunk/lib/MC/ConstantPools.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ConstantPools.cpp?rev=302416&r1=302415&r2=302416&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ConstantPools.cpp?rev=302416&r1=302415&r2=302416&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/MC/ConstantPools.cpp (original)<br>
+++ llvm/trunk/lib/MC/ConstantPools.cpp Mon May  8 05:26:24 2017<br>
@@ -57,6 +57,10 @@ const MCExpr *ConstantPool::addEntry(con<br>
<br>
 bool ConstantPool::empty() { return Entries.empty(); }<br>
<br>
+void ConstantPool::clearCache() {<br>
+  CachedEntries.clear();<br>
+}<br>
+<br>
 //<br>
 // AssemblerConstantPools implementation<br>
 //<br>
@@ -98,6 +102,13 @@ void AssemblerConstantPools::emitForCurr<br>
   }<br>
 }<br>
<br>
+void AssemblerConstantPools::clearCacheForCurrentSection(MCStreamer &Streamer) {<br>
+  MCSection *Section = Streamer.getCurrentSectionOnly();<br>
+  if (ConstantPool *CP = getConstantPool(Section)) {<br>
+    CP->clearCache();<br>
+  }<br>
+}<br>
+<br>
 const MCExpr *AssemblerConstantPools::addEntry(MCStreamer &Streamer,<br>
                                                const MCExpr *Expr,<br>
                                                unsigned Size, SMLoc Loc) {<br>
<br>
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp?rev=302416&r1=302415&r2=302416&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp?rev=302416&r1=302415&r2=302416&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp (original)<br>
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp Mon May  8 05:26:24 2017<br>
@@ -38,6 +38,7 @@ const MCExpr *ARMTargetStreamer::addCons<br>
<br>
 void ARMTargetStreamer::emitCurrentConstantPool() {<br>
   ConstantPools->emitForCurrentSection(Streamer);<br>
+  ConstantPools->clearCacheForCurrentSection(Streamer);<br>
 }<br>
<br>
 // finish() - write out any non-empty assembler constant pools.<br>
<br>
Added: llvm/trunk/test/MC/ARM/ltorg-range.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/ltorg-range.s?rev=302416&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/ltorg-range.s?rev=302416&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/MC/ARM/ltorg-range.s (added)<br>
+++ llvm/trunk/test/MC/ARM/ltorg-range.s Mon May  8 05:26:24 2017<br>
@@ -0,0 +1,27 @@<br>
+@ RUN: llvm-mc -triple armv7-unknown-linux-gnueabi -filetype obj -o - %s \<br>
+@ RUN:   | llvm-objdump -d - | FileCheck %s<br>
+<br>
+        ldr r0, =0x01020304<br>
+@ CHECK: ldr<br>
+        .ltorg<br>
+@ CHECK: 0x01020304<br>
+        ldr r0, =0x01020304<br>
+        ldr r0, =0x01020304<br>
+        ldr r0, =0x01020304<br>
+@ CHECK: ldr<br>
+@ CHECK: ldr<br>
+@ CHECK: ldr<br>
+        .ltorg<br>
+@ CHECK: 0x01020304<br>
+    .rep 1028<br>
+        .word 0<br>
+    .endr<br>
+@ CHECK: 0x00000000<br>
+<br>
+        ldr r0, =0x01020304<br>
+@ CHECK: ldr<br>
+        .ltorg<br>
+@ CHECK: 0x01020304<br>
+    .rep 1028<br>
+        .word 0<br>
+    .endr<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>