mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
[ARM] Align global variables passed to memory intrinsics
Fill in the TODO in CodeGenPrepare::OptimizeCallInst so that global variables that are passed to memory intrinsics are aligned in the same way that allocas are. Differential Revision: http://reviews.llvm.org/D8421 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234735 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1288,13 +1288,25 @@ bool CodeGenPrepare::OptimizeCallInst(CallInst *CI, bool& ModifiedDT) {
|
||||
cast<PointerType>(Arg->getType())->getAddressSpace()), 0);
|
||||
Value *Val = Arg->stripAndAccumulateInBoundsConstantOffsets(*TD, Offset);
|
||||
uint64_t Offset2 = Offset.getLimitedValue();
|
||||
if ((Offset2 & (PrefAlign-1)) != 0)
|
||||
continue;
|
||||
AllocaInst *AI;
|
||||
if ((Offset2 & (PrefAlign-1)) == 0 &&
|
||||
(AI = dyn_cast<AllocaInst>(Val)) &&
|
||||
if ((AI = dyn_cast<AllocaInst>(Val)) &&
|
||||
AI->getAlignment() < PrefAlign &&
|
||||
TD->getTypeAllocSize(AI->getAllocatedType()) >= MinSize + Offset2)
|
||||
AI->setAlignment(PrefAlign);
|
||||
// TODO: Also align GlobalVariables
|
||||
// Global variables can only be aligned if they are defined in this
|
||||
// object (i.e. they are uniquely initialized in this object), and
|
||||
// over-aligning global variables that have an explicit section is
|
||||
// forbidden.
|
||||
GlobalVariable *GV;
|
||||
if ((GV = dyn_cast<GlobalVariable>(Val)) &&
|
||||
GV->hasUniqueInitializer() &&
|
||||
!GV->hasSection() &&
|
||||
GV->getAlignment() < PrefAlign &&
|
||||
TD->getTypeAllocSize(
|
||||
GV->getType()->getElementType()) >= MinSize + Offset2)
|
||||
GV->setAlignment(PrefAlign);
|
||||
}
|
||||
// If this is a memcpy (or similar) then we may be able to improve the
|
||||
// alignment
|
||||
|
Reference in New Issue
Block a user