summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
diff options
context:
space:
mode:
authorOliver Stannard <oliver.stannard@arm.com>2016-10-07 08:48:24 +0000
committerOliver Stannard <oliver.stannard@arm.com>2016-10-07 08:48:24 +0000
commit4df1cc0b00f7ee72a1841de2080d9a4f7a1a6955 (patch)
tree5ee57a9ce646cdb5ce5858ca4d695e36f81741df /llvm/lib/Target/ARM/ARMTargetTransformInfo.h
parent68c6c8cd782d204e040e676f4bdfb8b4b7210a3e (diff)
downloadbcm5719-llvm-4df1cc0b00f7ee72a1841de2080d9a4f7a1a6955.tar.gz
bcm5719-llvm-4df1cc0b00f7ee72a1841de2080d9a4f7a1a6955.zip
[ARM] Don't convert switches to lookup tables of pointers with ROPI/RWPI
With the ROPI and RWPI relocation models we can't always have pointers to global data or functions in constant data, so don't try to convert switches into lookup tables if any value in the lookup table would require a relocation. We can still safely emit lookup tables of other values, such as simple constants. Differential Revision: https://reviews.llvm.org/D24462 llvm-svn: 283530
Diffstat (limited to 'llvm/lib/Target/ARM/ARMTargetTransformInfo.h')
-rw-r--r--llvm/lib/Target/ARM/ARMTargetTransformInfo.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
index a0ca9e64800..c8b057b6aaf 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
@@ -128,6 +128,16 @@ public:
int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor,
ArrayRef<unsigned> Indices, unsigned Alignment,
unsigned AddressSpace);
+
+ bool shouldBuildLookupTablesForConstant(Constant *C) const {
+ // In the ROPI and RWPI relocation models we can't have pointers to global
+ // variables or functions in constant data, so don't convert switches to
+ // lookup tables if any of the values would need relocation.
+ if (ST->isROPI() || ST->isRWPI())
+ return !C->needsRelocation();
+
+ return true;
+ }
/// @}
};
OpenPOWER on IntegriCloud