Changes in directory llvm/lib/CodeGen:
AsmPrinter.cpp updated: 1.163 -> 1.164 --- Log message: 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. --- Diffs of the changes: (+18 -5) AsmPrinter.cpp | 23 ++++++++++++++++++----- 1 files changed, 18 insertions(+), 5 deletions(-) Index: llvm/lib/CodeGen/AsmPrinter.cpp diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.163 llvm/lib/CodeGen/AsmPrinter.cpp:1.164 --- llvm/lib/CodeGen/AsmPrinter.cpp:1.163 Wed May 2 20:11:53 2007 +++ llvm/lib/CodeGen/AsmPrinter.cpp Thu May 31 13:57:45 2007 @@ -605,12 +605,25 @@ //===----------------------------------------------------------------------===// -// 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"; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits