summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2017-05-22 09:42:07 +0000
committerJames Molloy <james.molloy@arm.com>2017-05-22 09:42:07 +0000
commit6110be9759f6accf215c793c31278d6d4849bf6f (patch)
tree62ec6add4269987b3075d7c21e1f585f76e2314f /llvm/lib/MC
parent5193c80830995d951049db7bcf510e38b0b1521e (diff)
downloadbcm5719-llvm-6110be9759f6accf215c793c31278d6d4849bf6f.tar.gz
bcm5719-llvm-6110be9759f6accf215c793c31278d6d4849bf6f.zip
Re-apply r302416: [ARM] Clear the constant pool cache on explicit .ltorg directives
Re-applying now that PR32825 which was raised on the commit this fixed up is now known to have also been fixed by this commit. Original commit message: 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 llvm-svn: 303540
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/ConstantPools.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/MC/ConstantPools.cpp b/llvm/lib/MC/ConstantPools.cpp
index 8c94e278099..ca5440237e4 100644
--- a/llvm/lib/MC/ConstantPools.cpp
+++ b/llvm/lib/MC/ConstantPools.cpp
@@ -57,6 +57,10 @@ const MCExpr *ConstantPool::addEntry(const MCExpr *Value, MCContext &Context,
bool ConstantPool::empty() { return Entries.empty(); }
+void ConstantPool::clearCache() {
+ CachedEntries.clear();
+}
+
//
// AssemblerConstantPools implementation
//
@@ -98,6 +102,13 @@ void AssemblerConstantPools::emitForCurrentSection(MCStreamer &Streamer) {
}
}
+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) {
OpenPOWER on IntegriCloud