Skip to content

Commit ffa75c8

Browse files
author
git apple-llvm automerger
committed
Merge commit '1fbfa333f64b' from llvm.org/main into next
2 parents ad06db5 + 1ae4e30 commit ffa75c8

File tree

18 files changed

+67
-80
lines changed

18 files changed

+67
-80
lines changed

llvm/include/llvm/MC/MCELFStreamer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class MCELFStreamer : public MCObjectStreamer {
7070

7171
void emitIdent(StringRef IdentString) override;
7272

73-
void emitValueToAlignment(Align, int64_t, unsigned, unsigned) override;
73+
void emitValueToAlignment(Align, int64_t, uint8_t, unsigned) override;
7474

7575
void emitCGProfileEntry(const MCSymbolRefExpr *From,
7676
const MCSymbolRefExpr *To, uint64_t Count) override;

llvm/include/llvm/MC/MCObjectStreamer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ class MCObjectStreamer : public MCStreamer {
131131
void emitBundleLock(bool AlignToEnd) override;
132132
void emitBundleUnlock() override;
133133
void emitBytes(StringRef Data) override;
134-
void emitValueToAlignment(Align Alignment, int64_t Value = 0,
135-
unsigned ValueSize = 1,
134+
void emitValueToAlignment(Align Alignment, int64_t Fill = 0,
135+
uint8_t FillLen = 1,
136136
unsigned MaxBytesToEmit = 0) override;
137137
void emitCodeAlignment(Align ByteAlignment, const MCSubtargetInfo *STI,
138138
unsigned MaxBytesToEmit = 0) override;

llvm/include/llvm/MC/MCSection.h

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -470,39 +470,36 @@ class MCRelaxableFragment : public MCEncodedFragment {
470470
};
471471

472472
class MCAlignFragment : public MCFragment {
473-
/// The alignment to ensure, in bytes.
474-
Align Alignment;
475-
476473
/// Flag to indicate that (optimal) NOPs should be emitted instead
477474
/// of using the provided value. The exact interpretation of this flag is
478475
/// target dependent.
479476
bool EmitNops : 1;
480477

481-
/// Value to use for filling padding bytes.
482-
int64_t Value;
478+
/// The alignment to ensure, in bytes.
479+
Align Alignment;
483480

484481
/// The size of the integer (in bytes) of \p Value.
485-
unsigned ValueSize;
482+
uint8_t FillLen;
486483

487484
/// The maximum number of bytes to emit; if the alignment
488485
/// cannot be satisfied in this width then this fragment is ignored.
489486
unsigned MaxBytesToEmit;
490487

488+
/// Value to use for filling padding bytes.
489+
int64_t Fill;
490+
491491
/// When emitting Nops some subtargets have specific nop encodings.
492492
const MCSubtargetInfo *STI = nullptr;
493493

494494
public:
495-
MCAlignFragment(Align Alignment, int64_t Value, unsigned ValueSize,
495+
MCAlignFragment(Align Alignment, int64_t Fill, uint8_t FillLen,
496496
unsigned MaxBytesToEmit)
497-
: MCFragment(FT_Align, false), Alignment(Alignment), EmitNops(false),
498-
Value(Value), ValueSize(ValueSize), MaxBytesToEmit(MaxBytesToEmit) {}
497+
: MCFragment(FT_Align, false), EmitNops(false), Alignment(Alignment),
498+
FillLen(FillLen), MaxBytesToEmit(MaxBytesToEmit), Fill(Fill) {}
499499

500500
Align getAlignment() const { return Alignment; }
501-
502-
int64_t getValue() const { return Value; }
503-
504-
unsigned getValueSize() const { return ValueSize; }
505-
501+
int64_t getFill() const { return Fill; }
502+
uint8_t getFillLen() const { return FillLen; }
506503
unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; }
507504

508505
bool hasEmitNops() const { return EmitNops; }

llvm/include/llvm/MC/MCStreamer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -820,14 +820,14 @@ class LLVM_ABI MCStreamer {
820820
/// This used to implement the .align assembler directive.
821821
///
822822
/// \param Alignment - The alignment to reach.
823-
/// \param Value - The value to use when filling bytes.
824-
/// \param ValueSize - The size of the integer (in bytes) to emit for
823+
/// \param Fill - The value to use when filling bytes.
824+
/// \param FillLen - The size of the integer (in bytes) to emit for
825825
/// \p Value. This must match a native machine width.
826826
/// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
827827
/// the alignment cannot be reached in this many bytes, no bytes are
828828
/// emitted.
829-
virtual void emitValueToAlignment(Align Alignment, int64_t Value = 0,
830-
unsigned ValueSize = 1,
829+
virtual void emitValueToAlignment(Align Alignment, int64_t Fill = 0,
830+
uint8_t FillLen = 1,
831831
unsigned MaxBytesToEmit = 0);
832832

833833
/// Emit nops until the byte alignment \p ByteAlignment is reached.

llvm/lib/MC/MCAsmStreamer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ class MCAsmStreamer final : public MCStreamer {
271271
std::optional<int64_t> Value, unsigned ValueSize,
272272
unsigned MaxBytesToEmit);
273273

274-
void emitValueToAlignment(Align Alignment, int64_t Value = 0,
275-
unsigned ValueSize = 1,
274+
void emitValueToAlignment(Align Alignment, int64_t Fill = 0,
275+
uint8_t FillLen = 1,
276276
unsigned MaxBytesToEmit = 0) override;
277277

278278
void emitCodeAlignment(Align Alignment, const MCSubtargetInfo *STI,
@@ -1540,10 +1540,10 @@ void MCAsmStreamer::emitAlignmentDirective(uint64_t ByteAlignment,
15401540
EmitEOL();
15411541
}
15421542

1543-
void MCAsmStreamer::emitValueToAlignment(Align Alignment, int64_t Value,
1544-
unsigned ValueSize,
1543+
void MCAsmStreamer::emitValueToAlignment(Align Alignment, int64_t Fill,
1544+
uint8_t FillLen,
15451545
unsigned MaxBytesToEmit) {
1546-
emitAlignmentDirective(Alignment.value(), Value, ValueSize, MaxBytesToEmit);
1546+
emitAlignmentDirective(Alignment.value(), Fill, FillLen, MaxBytesToEmit);
15471547
}
15481548

15491549
void MCAsmStreamer::emitCodeAlignment(Align Alignment,

llvm/lib/MC/MCAssembler.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -553,18 +553,11 @@ static void writeFragment(raw_ostream &OS, const MCAssembler &Asm,
553553
case MCFragment::FT_Align: {
554554
++stats::EmittedAlignFragments;
555555
const MCAlignFragment &AF = cast<MCAlignFragment>(F);
556-
assert(AF.getValueSize() && "Invalid virtual align in concrete fragment!");
556+
assert(AF.getFillLen() && "Invalid virtual align in concrete fragment!");
557557

558-
uint64_t Count = FragmentSize / AF.getValueSize();
559-
560-
// FIXME: This error shouldn't actually occur (the front end should emit
561-
// multiple .align directives to enforce the semantics it wants), but is
562-
// severe enough that we want to report it. How to handle this?
563-
if (Count * AF.getValueSize() != FragmentSize)
564-
report_fatal_error("undefined .align directive, value size '" +
565-
Twine(AF.getValueSize()) +
566-
"' is not a divisor of padding size '" +
567-
Twine(FragmentSize) + "'");
558+
uint64_t Count = FragmentSize / AF.getFillLen();
559+
assert(FragmentSize % AF.getFillLen() == 0 &&
560+
"computeFragmentSize computed size is incorrect");
568561

569562
// See if we are aligning with nops, and if so do that first to try to fill
570563
// the Count bytes. Then if that did not fill any bytes or there are any
@@ -579,17 +572,19 @@ static void writeFragment(raw_ostream &OS, const MCAssembler &Asm,
579572

580573
// Otherwise, write out in multiples of the value size.
581574
for (uint64_t i = 0; i != Count; ++i) {
582-
switch (AF.getValueSize()) {
575+
switch (AF.getFillLen()) {
583576
default: llvm_unreachable("Invalid size!");
584-
case 1: OS << char(AF.getValue()); break;
577+
case 1:
578+
OS << char(AF.getFill());
579+
break;
585580
case 2:
586-
support::endian::write<uint16_t>(OS, AF.getValue(), Endian);
581+
support::endian::write<uint16_t>(OS, AF.getFill(), Endian);
587582
break;
588583
case 4:
589-
support::endian::write<uint32_t>(OS, AF.getValue(), Endian);
584+
support::endian::write<uint32_t>(OS, AF.getFill(), Endian);
590585
break;
591586
case 8:
592-
support::endian::write<uint64_t>(OS, AF.getValue(), Endian);
587+
support::endian::write<uint64_t>(OS, AF.getFill(), Endian);
593588
break;
594589
}
595590
}
@@ -733,8 +728,8 @@ void MCAssembler::writeSectionData(raw_ostream &OS,
733728
case MCFragment::FT_Align:
734729
// Check that we aren't trying to write a non-zero value into a virtual
735730
// section.
736-
assert((cast<MCAlignFragment>(F).getValueSize() == 0 ||
737-
cast<MCAlignFragment>(F).getValue() == 0) &&
731+
assert((cast<MCAlignFragment>(F).getFillLen() == 0 ||
732+
cast<MCAlignFragment>(F).getFill() == 0) &&
738733
"Invalid align in virtual section!");
739734
break;
740735
case MCFragment::FT_Fill:

llvm/lib/MC/MCELFStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ void MCELFStreamer::emitValueImpl(const MCExpr *Value, unsigned Size,
321321
}
322322

323323
void MCELFStreamer::emitValueToAlignment(Align Alignment, int64_t Value,
324-
unsigned ValueSize,
324+
uint8_t ValueSize,
325325
unsigned MaxBytesToEmit) {
326326
if (isBundleLocked())
327327
report_fatal_error("Emitting values inside a locked bundle is forbidden");

llvm/lib/MC/MCFragment.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ LLVM_DUMP_METHOD void MCFragment::dump() const {
7676
switch (getKind()) {
7777
case MCFragment::FT_Align: {
7878
const auto *AF = cast<MCAlignFragment>(this);
79-
OS << " Align:" << AF->getAlignment().value() << " Value:" << AF->getValue()
80-
<< " ValueSize:" << AF->getValueSize()
79+
OS << " Align:" << AF->getAlignment().value() << " Fill:" << AF->getFill()
80+
<< " FillLen:" << unsigned(AF->getFillLen())
8181
<< " MaxBytesToEmit:" << AF->getMaxBytesToEmit();
8282
if (AF->hasEmitNops())
8383
OS << " Nops";

llvm/lib/MC/MCObjectStreamer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,13 +580,13 @@ void MCObjectStreamer::emitBytes(StringRef Data) {
580580
DF->appendContents(ArrayRef(Data.data(), Data.size()));
581581
}
582582

583-
void MCObjectStreamer::emitValueToAlignment(Align Alignment, int64_t Value,
584-
unsigned ValueSize,
583+
void MCObjectStreamer::emitValueToAlignment(Align Alignment, int64_t Fill,
584+
uint8_t FillLen,
585585
unsigned MaxBytesToEmit) {
586586
if (MaxBytesToEmit == 0)
587587
MaxBytesToEmit = Alignment.value();
588-
insert(getContext().allocFragment<MCAlignFragment>(
589-
Alignment, Value, ValueSize, MaxBytesToEmit));
588+
insert(getContext().allocFragment<MCAlignFragment>(Alignment, Fill, FillLen,
589+
MaxBytesToEmit));
590590

591591
// Update the maximum alignment on the current section if necessary.
592592
MCSection *CurSec = getCurrentSectionOnly();

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ class AsmParser : public MCAsmParser {
567567
bool parseDirectiveSet(StringRef IDVal, AssignmentKind Kind);
568568
bool parseDirectiveOrg(); // ".org"
569569
// ".align{,32}", ".p2align{,w,l}"
570-
bool parseDirectiveAlign(bool IsPow2, unsigned ValueSize);
570+
bool parseDirectiveAlign(bool IsPow2, uint8_t ValueSize);
571571

572572
// ".file", ".line", ".loc", ".loc_label", ".stabs"
573573
bool parseDirectiveFile(SMLoc DirectiveLoc);
@@ -3340,7 +3340,7 @@ bool AsmParser::parseDirectiveOrg() {
33403340

33413341
/// parseDirectiveAlign
33423342
/// ::= {.align, ...} expression [ , expression [ , expression ]]
3343-
bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
3343+
bool AsmParser::parseDirectiveAlign(bool IsPow2, uint8_t ValueSize) {
33443344
SMLoc AlignmentLoc = getLexer().getLoc();
33453345
int64_t Alignment;
33463346
SMLoc MaxBytesLoc;

0 commit comments

Comments
 (0)