diff options
author | James Y Knight <jyknight@google.com> | 2016-01-14 16:33:21 +0000 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2016-01-14 16:33:21 +0000 |
commit | 582f556251615bb6483ed5fcc83acd0e5ac4b84c (patch) | |
tree | 32ce9cab42f4668d817519e6dd170696dcc8c2ba /llvm/lib/Transforms/Utils | |
parent | 6ad8f61297194f990e759ccc3e107b36800e56dc (diff) | |
download | bcm5719-llvm-582f556251615bb6483ed5fcc83acd0e5ac4b84c.tar.gz bcm5719-llvm-582f556251615bb6483ed5fcc83acd0e5ac4b84c.zip |
Revert "Stop increasing alignment of externally-visible globals on ELF platforms."
This reverts commit r257719, due to PR26144.
llvm-svn: 257775
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 91b3499407c..d2793e5ecb5 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -944,31 +944,37 @@ bool llvm::EliminateDuplicatePHINodes(BasicBlock *BB) { static unsigned enforceKnownAlignment(Value *V, unsigned Align, unsigned PrefAlign, const DataLayout &DL) { - assert(PrefAlign > Align); - V = V->stripPointerCasts(); if (AllocaInst *AI = dyn_cast<AllocaInst>(V)) { - assert(AI->getAlignment() <= Align); // If the preferred alignment is greater than the natural stack alignment // then don't round up. This avoids dynamic stack realignment. if (DL.exceedsNaturalStackAlignment(PrefAlign)) return Align; + // If there is a requested alignment and if this is an alloca, round up. + if (AI->getAlignment() >= PrefAlign) + return AI->getAlignment(); AI->setAlignment(PrefAlign); return PrefAlign; } if (auto *GO = dyn_cast<GlobalObject>(V)) { - assert(GO->getAlignment() <= Align); // If there is a large requested alignment and we can, bump up the alignment // of the global. If the memory we set aside for the global may not be the // memory used by the final program then it is impossible for us to reliably // enforce the preferred alignment. - if (!GO->canIncreaseAlignment()) + if (!GO->isStrongDefinitionForLinker()) return Align; - GO->setAlignment(PrefAlign); - return PrefAlign; + if (GO->getAlignment() >= PrefAlign) + return GO->getAlignment(); + // We can only increase the alignment of the global if it has no alignment + // specified or if it is not assigned a section. If it is assigned a + // section, the global could be densely packed with other objects in the + // section, increasing the alignment could cause padding issues. + if (!GO->hasSection() || GO->getAlignment() == 0) + GO->setAlignment(PrefAlign); + return GO->getAlignment(); } return Align; |