summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2018-01-09 21:55:10 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2018-01-09 21:55:10 +0000
commit07657a8d7faf7cf255858485453ed1e5a1bdc5cd (patch)
treed6261a15c24ba44140f4029835d530e037b4dbd0 /llvm/lib
parentf50534b127a2884bb5fc9cbda2e80b77aef0c464 (diff)
downloadbcm5719-llvm-07657a8d7faf7cf255858485453ed1e5a1bdc5cd.tar.gz
bcm5719-llvm-07657a8d7faf7cf255858485453ed1e5a1bdc5cd.zip
Don't create MCFillFragment directly.
Instead use higher level APIs that take care of most bookkeeping. llvm-svn: 322123
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCMachOStreamer.cpp28
-rw-r--r--llvm/lib/MC/MCWinCOFFStreamer.cpp19
2 files changed, 15 insertions, 32 deletions
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 82b75afabb3..3969143bb2c 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -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
diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index c2583d95c5e..8582d9adafb 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -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,
OpenPOWER on IntegriCloud