[NFC] Make getPreferredAlignment honor section markings.
This should more accurately reflect what the AsmPrinter will actually
do.
This is NFC, as far as I can tell; all the places that might be affected
already have an extra check to avoid using the result of
getPreferredAlignment in this situation.
Differential Revision: https://reviews.llvm.org/D51377
llvm-svn: 340999
diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
index f4526c6..69d1e13 100644
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -462,17 +462,8 @@
for (j = i; j != -1; j = GlobalSet.find_next(j)) {
Type *Ty = Globals[j]->getValueType();
- // Make sure we use the same alignment AsmPrinter would use. There
- // currently isn't any helper to compute that, so we compute it
- // explicitly here.
- //
- // getPreferredAlignment will sometimes return an alignment higher
- // than the explicitly specified alignment; we must ignore that
- // if the section is explicitly specified, to avoid inserting extra
- // padding into that section.
+ // Make sure we use the same alignment AsmPrinter would use.
unsigned Align = DL.getPreferredAlignment(Globals[j]);
- if (Globals[j]->hasSection() && Globals[j]->getAlignment())
- Align = Globals[j]->getAlignment();
unsigned Padding = alignTo(MergedSize, Align) - MergedSize;
MergedSize += Padding;
MergedSize += DL.getTypeAllocSize(Ty);