llvm.org GIT mirror llvm / 8b2b7db
Don't create MCFillFragment directly. Instead use higher level APIs that take care of most bookkeeping. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322123 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 1 year, 10 months ago
2 changed file(s) with 16 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
410410
411411 void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
412412 uint64_t Size, unsigned ByteAlignment) {
413 getAssembler().registerSection(*Section);
414
415 // The symbol may not be present, which only creates the section.
416 if (!Symbol)
417 return;
418
419413 // On darwin all virtual sections have zerofill type.
420414 assert(Section->isVirtualSection() && "Section does not have zerofill type!");
421415
422 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
423
424 getAssembler().registerSymbol(*Symbol);
425
426 // Emit an align fragment if necessary.
427 if (ByteAlignment != 1)
428 new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, Section);
429
430 MCFragment *F = new MCFillFragment(0, Size, Section);
431 Symbol->setFragment(F);
432
433 // Update the maximum alignment on the zero fill section if necessary.
434 if (ByteAlignment > Section->getAlignment())
435 Section->setAlignment(ByteAlignment);
416 PushSection();
417 SwitchSection(Section);
418
419 // The symbol may not be present, which only creates the section.
420 if (Symbol) {
421 EmitValueToAlignment(ByteAlignment, 0, 1, 0);
422 EmitLabel(Symbol);
423 EmitZeros(Size);
424 }
425 PopSection();
436426 }
437427
438428 // This should always be called with the thread local bss section. Like the
256256 auto *Symbol = cast(S);
257257
258258 MCSection *Section = getContext().getObjectFileInfo()->getBSSSection();
259 getAssembler().registerSection(*Section);
260 if (Section->getAlignment() < ByteAlignment)
261 Section->setAlignment(ByteAlignment);
262
263 getAssembler().registerSymbol(*Symbol);
259 PushSection();
260 SwitchSection(Section);
261 EmitValueToAlignment(ByteAlignment, 0, 1, 0);
262 EmitLabel(Symbol);
264263 Symbol->setExternal(false);
265
266 if (ByteAlignment != 1)
267 new MCAlignFragment(ByteAlignment, /*Value=*/0, /*ValueSize=*/0,
268 ByteAlignment, Section);
269
270 MCFillFragment *Fragment = new MCFillFragment(
271 /*Value=*/0, Size, Section);
272 Symbol->setFragment(Fragment);
264 EmitZeros(Size);
265 PopSection();
273266 }
274267
275268 void MCWinCOFFStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,