[PATCH] D32847: [ARM] Clear the constant pool cache on explicit .ltorg directives

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 8 03:39:33 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL302416: [ARM] Clear the constant pool cache on explicit .ltorg directives (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D32847?vs=97781&id=98147#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32847

Files:
  llvm/trunk/include/llvm/MC/ConstantPools.h
  llvm/trunk/lib/MC/ConstantPools.cpp
  llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
  llvm/trunk/test/MC/ARM/ltorg-range.s


Index: llvm/trunk/include/llvm/MC/ConstantPools.h
===================================================================
--- llvm/trunk/include/llvm/MC/ConstantPools.h
+++ llvm/trunk/include/llvm/MC/ConstantPools.h
@@ -63,6 +63,8 @@
 
   // Return true if the constant pool is empty
   bool empty();
+
+  void clearCache();
 };
 
 class AssemblerConstantPools {
@@ -86,6 +88,7 @@
 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);
 
Index: llvm/trunk/test/MC/ARM/ltorg-range.s
===================================================================
--- llvm/trunk/test/MC/ARM/ltorg-range.s
+++ llvm/trunk/test/MC/ARM/ltorg-range.s
@@ -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
Index: llvm/trunk/lib/MC/ConstantPools.cpp
===================================================================
--- llvm/trunk/lib/MC/ConstantPools.cpp
+++ llvm/trunk/lib/MC/ConstantPools.cpp
@@ -57,6 +57,10 @@
 
 bool ConstantPool::empty() { return Entries.empty(); }
 
+void ConstantPool::clearCache() {
+  CachedEntries.clear();
+}
+
 //
 // AssemblerConstantPools implementation
 //
@@ -98,6 +102,13 @@
   }
 }
 
+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) {
Index: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
===================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
@@ -38,6 +38,7 @@
 
 void ARMTargetStreamer::emitCurrentConstantPool() {
   ConstantPools->emitForCurrentSection(Streamer);
+  ConstantPools->clearCacheForCurrentSection(Streamer);
 }
 
 // finish() - write out any non-empty assembler constant pools.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32847.98147.patch
Type: text/x-patch
Size: 2803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170508/4e2858ef/attachment.bin>


More information about the llvm-commits mailing list