diff options
author | Jiangning Liu <jiangning.liu@arm.com> | 2014-05-15 23:45:42 +0000 |
---|---|---|
committer | Jiangning Liu <jiangning.liu@arm.com> | 2014-05-15 23:45:42 +0000 |
commit | 932e1c392426b692d72c71a849ca94a0a20f9cb7 (patch) | |
tree | b2d76447857d9f811be484b708122cee37c24ca2 /llvm/lib/Target/ARM64 | |
parent | 962c9a2d54f8313cbe1050e08a41c4cf96a9ae0d (diff) | |
download | bcm5719-llvm-932e1c392426b692d72c71a849ca94a0a20f9cb7.tar.gz bcm5719-llvm-932e1c392426b692d72c71a849ca94a0a20f9cb7.zip |
Implement global merge optimization for global variables.
This commit implements two command line switches -global-merge-on-external
and -global-merge-aligned, and both of them are false by default, so this
optimization is disabled by default for all targets.
For ARM64, some back-end behaviors need to be tuned to get this optimization
further enabled.
llvm-svn: 208934
Diffstat (limited to 'llvm/lib/Target/ARM64')
-rw-r--r-- | llvm/lib/Target/ARM64/ARM64ISelLowering.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/Target/ARM64/ARM64ISelLowering.h | 4 |
2 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp b/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp index 118007fa70c..880df0c1a81 100644 --- a/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp +++ b/llvm/lib/Target/ARM64/ARM64ISelLowering.cpp @@ -630,6 +630,20 @@ unsigned ARM64TargetLowering::getMaximalGlobalOffset() const { return 4095; } +/// getGlobalMergeAlignment - Set alignment to be the max size of merged +/// global variable data structure, and make it aligned up to power of 2. +/// This way, we could guarantee the merged global variable data structure +/// doesn't cross page boundary, because usually OS always allocates page at +/// 4096-byte aligned boundary. +unsigned ARM64TargetLowering::getGlobalMergeAlignment( + StructType *MergedTy) const { + unsigned Align = getDataLayout()->getTypeAllocSize(MergedTy); + if (Align & (Align - 1)) + Align = llvm::NextPowerOf2(Align); + + return Align; +} + FastISel * ARM64TargetLowering::createFastISel(FunctionLoweringInfo &funcInfo, const TargetLibraryInfo *libInfo) const { diff --git a/llvm/lib/Target/ARM64/ARM64ISelLowering.h b/llvm/lib/Target/ARM64/ARM64ISelLowering.h index 55792317dba..00b2710a35c 100644 --- a/llvm/lib/Target/ARM64/ARM64ISelLowering.h +++ b/llvm/lib/Target/ARM64/ARM64ISelLowering.h @@ -236,6 +236,10 @@ public: /// be used for loads / stores from the global. unsigned getMaximalGlobalOffset() const override; + /// getGlobalMergeAlignment - Set alignment to be the max size of merged + /// global variable data structure, and make it aligned up to power of 2. + unsigned getGlobalMergeAlignment(StructType *MergedTy) const override; + /// Returns true if a cast between SrcAS and DestAS is a noop. bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override { // Addrspacecasts are always noops. |