@@ -381,6 +381,8 @@ uint64_t MCAssembler::computeFragmentSize(const MCFragment &F) const {
381381 llvm_unreachable (" invalid fragment kind" );
382382}
383383
384+ MCAsmLayout::MCAsmLayout (MCAssembler &Asm) : Assembler(Asm) {}
385+
384386// Compute the amount of padding required before the fragment \p F to
385387// obey bundling restrictions, where \p FOffset is the fragment's offset in
386388// its section and \p FSize is the fragment's size.
@@ -539,14 +541,13 @@ bool MCAssembler::getSymbolOffset(const MCSymbol &S, uint64_t &Val) const {
539541}
540542
541543uint64_t MCAssembler::getSymbolOffset (const MCSymbol &S) const {
542- assert (HasLayout);
543544 uint64_t Val;
544545 getSymbolOffsetImpl (*this , S, true , Val);
545546 return Val;
546547}
547548
548549const MCSymbol *MCAssembler::getBaseSymbol (const MCSymbol &Symbol) const {
549- assert (HasLayout );
550+ assert (Layout );
550551 if (!Symbol.isVariable ())
551552 return &Symbol;
552553
@@ -583,7 +584,6 @@ const MCSymbol *MCAssembler::getBaseSymbol(const MCSymbol &Symbol) const {
583584}
584585
585586uint64_t MCAssembler::getSectionAddressSize (const MCSection &Sec) const {
586- assert (HasLayout);
587587 // The size is the last fragment's end offset.
588588 const MCFragment &F = *Sec.curFragList ()->Tail ;
589589 return getFragmentOffset (F) + computeFragmentSize (F);
@@ -968,7 +968,7 @@ void MCAssembler::layout(MCAsmLayout &Layout) {
968968 }
969969
970970 // Layout until everything fits.
971- this ->HasLayout = true ;
971+ this ->Layout = &Layout ;
972972 while (layoutOnce ()) {
973973 if (getContext ().hadError ())
974974 return ;
@@ -1081,7 +1081,7 @@ void MCAssembler::Finish() {
10811081 // Write the object file.
10821082 stats::ObjectBytes += getWriter ().writeObject (*this );
10831083
1084- HasLayout = false ;
1084+ this -> Layout = nullptr ;
10851085}
10861086
10871087bool MCAssembler::fixupNeedsRelaxation (const MCFixup &Fixup,
0 commit comments