Pull in r322123 from upstream llvm trunk (by Rafael Espíndola):

Don't create MCFillFragment directly.

  Instead use higher level APIs that take care of most bookkeeping.
This commit is contained in:
Ed Maste 2018-01-30 16:42:08 +00:00
parent 00da656e30
commit 88e56272f9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=328595
2 changed files with 15 additions and 32 deletions

View File

@ -411,29 +411,19 @@ void MCMachOStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
uint64_t Size, unsigned ByteAlignment) {
getAssembler().registerSection(*Section);
// The symbol may not be present, which only creates the section.
if (!Symbol)
return;
// On darwin all virtual sections have zerofill type.
assert(Section->isVirtualSection() && "Section does not have zerofill type!");
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
PushSection();
SwitchSection(Section);
getAssembler().registerSymbol(*Symbol);
// Emit an align fragment if necessary.
if (ByteAlignment != 1)
new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, Section);
MCFragment *F = new MCFillFragment(0, Size, Section);
Symbol->setFragment(F);
// Update the maximum alignment on the zero fill section if necessary.
if (ByteAlignment > Section->getAlignment())
Section->setAlignment(ByteAlignment);
// The symbol may not be present, which only creates the section.
if (Symbol) {
EmitValueToAlignment(ByteAlignment, 0, 1, 0);
EmitLabel(Symbol);
EmitZeros(Size);
}
PopSection();
}
// This should always be called with the thread local bss section. Like the

View File

@ -257,20 +257,13 @@ void MCWinCOFFStreamer::EmitLocalCommonSymbol(MCSymbol *S, uint64_t Size,
auto *Symbol = cast<MCSymbolCOFF>(S);
MCSection *Section = getContext().getObjectFileInfo()->getBSSSection();
getAssembler().registerSection(*Section);
if (Section->getAlignment() < ByteAlignment)
Section->setAlignment(ByteAlignment);
getAssembler().registerSymbol(*Symbol);
PushSection();
SwitchSection(Section);
EmitValueToAlignment(ByteAlignment, 0, 1, 0);
EmitLabel(Symbol);
Symbol->setExternal(false);
if (ByteAlignment != 1)
new MCAlignFragment(ByteAlignment, /*Value=*/0, /*ValueSize=*/0,
ByteAlignment, Section);
MCFillFragment *Fragment = new MCFillFragment(
/*Value=*/0, Size, Section);
Symbol->setFragment(Fragment);
EmitZeros(Size);
PopSection();
}
void MCWinCOFFStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,