diff options
author | Chris Lattner <sabre@nondot.org> | 2007-05-31 18:57:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-05-31 18:57:45 +0000 |
commit | 3a4205367dc845d4cd804b47e061f8281777c9da (patch) | |
tree | 3c7493d7370bf2d3777ce68c247be3bca2b48cbd /lib/CodeGen/AsmPrinter.cpp | |
parent | 4f3485c0da50e9722c8414f95e2f04d0f51757f0 (diff) |
Fix the asmprinter so that a globalvalue can specify an explicit alignment
smaller than the preferred alignment, but so that the target can actually
specify a minimum alignment if needed. This fixes some objc protocol
failures Devang tracked down.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37373 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter.cpp')
-rw-r--r-- | lib/CodeGen/AsmPrinter.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp index fd112a3531..07319d595a 100644 --- a/lib/CodeGen/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter.cpp @@ -605,12 +605,25 @@ void AsmPrinter::EmitString(const std::string &String) const { //===----------------------------------------------------------------------===// -// EmitAlignment - Emit an alignment directive to the specified power of two. -// Use the maximum of the specified alignment and the alignment from the -// specified GlobalValue (if any). -void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const { +// EmitAlignment - Emit an alignment directive to the specified power of +// two boundary. For example, if you pass in 3 here, you will get an 8 +// byte alignment. If a global value is specified, and if that global has +// an explicit alignment requested, it will unconditionally override the +// alignment request. However, if ForcedAlignBits is specified, this value +// has final say: the ultimate alignment will be the max of ForcedAlignBits +// and the alignment computed with NumBits and the global. +// +// The algorithm is: +// Align = NumBits; +// if (GV && GV->hasalignment) Align = GV->getalignment(); +// Align = std::max(Align, ForcedAlignBits); +// +void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV, + unsigned ForcedAlignBits) const { if (GV && GV->getAlignment()) - NumBits = std::max(NumBits, Log2_32(GV->getAlignment())); + NumBits = Log2_32(GV->getAlignment()); + NumBits = std::max(NumBits, ForcedAlignBits); + if (NumBits == 0) return; // No need to emit alignment. if (TAI->getAlignmentIsInBytes()) NumBits = 1 << NumBits; O << TAI->getAlignDirective() << NumBits << "\n"; |