diff options
author | James Y Knight <jyknight@google.com> | 2016-01-13 23:59:19 +0000 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2016-01-13 23:59:19 +0000 |
commit | 9de6d7becc82f1e7f0d76b3124d52cd20a96d601 (patch) | |
tree | 5c010b6c451344cbeb3d8e1e2a00806d98afb1c0 /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 578864007baa81366d2a98a307e016b78bed82af (diff) | |
download | bcm5719-llvm-9de6d7becc82f1e7f0d76b3124d52cd20a96d601.tar.gz bcm5719-llvm-9de6d7becc82f1e7f0d76b3124d52cd20a96d601.zip |
Stop increasing alignment of externally-visible globals on ELF
platforms.
With ELF, the alignment of a global variable in a shared library will
get copied into an executables linked against it, if the executable even
accesss the variable. So, it's not possible to implicitly increase
alignment based on access patterns, or you'll break existing binaries.
This happened to affect libc++'s std::cout symbol, for example. See
thread: http://thread.gmane.org/gmane.comp.compilers.clang.devel/45311
llvm-svn: 257719
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 03e57787307..fd4ee464337 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -1742,8 +1742,8 @@ bool CodeGenPrepare::optimizeCallInst(CallInst *CI, bool& ModifiedDT) { // 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 && + if ((GV = dyn_cast<GlobalVariable>(Val)) && GV->canIncreaseAlignment() && + GV->getAlignment() < PrefAlign && DL->getTypeAllocSize(GV->getType()->getElementType()) >= MinSize + Offset2) GV->setAlignment(PrefAlign); |