summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-26 18:46:46 +0000
committerChris Lattner <sabre@nondot.org>2010-04-26 18:46:46 +0000
commitf740a8ceebdc5eb626b7d8c075d7c998cc29cc9e (patch)
tree46027fd73de4ab1d178c75529a547df9a50a471a /llvm/lib/CodeGen
parentc72d8a7dad755dd33148f84660afdb223797e5a0 (diff)
downloadbcm5719-llvm-f740a8ceebdc5eb626b7d8c075d7c998cc29cc9e.tar.gz
bcm5719-llvm-f740a8ceebdc5eb626b7d8c075d7c998cc29cc9e.zip
fix PR6921 a different way. Intead of increasing the
alignment of globals with a specified alignment, we fix common variables to obey their alignment. Add a comment explaining why this behavior is important. llvm-svn: 102365
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 4660e1b2ccd..6fc883359be 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -228,7 +228,15 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
const TargetData *TD = TM.getTargetData();
unsigned Size = TD->getTypeAllocSize(GV->getType()->getElementType());
- unsigned AlignLog = TD->getPreferredAlignmentLog(GV);
+
+ // If the alignment is specified, we *must* obey it. Overaligning a global
+ // with a specified alignment is a prompt way to break globals emitted to
+ // sections and expected to be contiguous (e.g. ObjC metadata).
+ unsigned AlignLog;
+ if (unsigned GVAlign = GV->getAlignment())
+ AlignLog = Log2_32(GVAlign);
+ else
+ AlignLog = TD->getPreferredAlignmentLog(GV);
// Handle common and BSS local symbols (.lcomm).
if (GVKind.isCommon() || GVKind.isBSSLocal()) {
OpenPOWER on IntegriCloud