mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-05 18:49:06 +00:00
Simplify local common output.
We now create them as they are found and use higher level APIs. This is a step in avoiding creating unnecessary sections. llvm-svn: 251958
This commit is contained in:
parent
691dbb68d2
commit
7953bd5d91
@ -36,7 +36,6 @@ public:
|
||||
/// state management
|
||||
void reset() override {
|
||||
SeenIdent = false;
|
||||
LocalCommons.clear();
|
||||
BundleGroups.clear();
|
||||
MCObjectStreamer::reset();
|
||||
}
|
||||
@ -97,14 +96,6 @@ private:
|
||||
|
||||
bool SeenIdent;
|
||||
|
||||
struct LocalCommon {
|
||||
const MCSymbol *Symbol;
|
||||
uint64_t Size;
|
||||
unsigned ByteAlignment;
|
||||
};
|
||||
|
||||
std::vector<LocalCommon> LocalCommons;
|
||||
|
||||
/// BundleGroups - The stack of fragments holding the bundle-locked
|
||||
/// instructions.
|
||||
llvm::SmallVector<MCDataFragment *, 4> BundleGroups;
|
||||
|
@ -311,8 +311,20 @@ void MCELFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size,
|
||||
Symbol->setType(ELF::STT_OBJECT);
|
||||
|
||||
if (Symbol->getBinding() == ELF::STB_LOCAL) {
|
||||
struct LocalCommon L = {Symbol, Size, ByteAlignment};
|
||||
LocalCommons.push_back(L);
|
||||
MCSection &Section = *getAssembler().getContext().getELFSection(
|
||||
".bss", ELF::SHT_NOBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
|
||||
MCSectionSubPair P = getCurrentSection();
|
||||
SwitchSection(&Section);
|
||||
|
||||
EmitValueToAlignment(ByteAlignment, 0, 1, 0);
|
||||
EmitLabel(Symbol);
|
||||
EmitZeros(Size);
|
||||
|
||||
// Update the maximum alignment of the section if necessary.
|
||||
if (ByteAlignment > Section.getAlignment())
|
||||
Section.setAlignment(ByteAlignment);
|
||||
|
||||
SwitchSection(P.first, P.second);
|
||||
} else {
|
||||
if(Symbol->declareCommon(Size, ByteAlignment))
|
||||
report_fatal_error("Symbol: " + Symbol->getName() +
|
||||
@ -619,25 +631,7 @@ void MCELFStreamer::EmitBundleUnlock() {
|
||||
}
|
||||
|
||||
void MCELFStreamer::Flush() {
|
||||
MCSection &Section = *getAssembler().getContext().getELFSection(
|
||||
".bss", ELF::SHT_NOBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
|
||||
getAssembler().registerSection(Section);
|
||||
|
||||
for (const LocalCommon &L : LocalCommons) {
|
||||
const MCSymbol &Symbol = *L.Symbol;
|
||||
uint64_t Size = L.Size;
|
||||
unsigned ByteAlignment = L.ByteAlignment;
|
||||
new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &Section);
|
||||
|
||||
MCFragment *F = new MCFillFragment(0, 0, Size, &Section);
|
||||
Symbol.setFragment(F);
|
||||
|
||||
// Update the maximum alignment of the section if necessary.
|
||||
if (ByteAlignment > Section.getAlignment())
|
||||
Section.setAlignment(ByteAlignment);
|
||||
}
|
||||
|
||||
LocalCommons.clear();
|
||||
}
|
||||
|
||||
void MCELFStreamer::FinishImpl() {
|
||||
|
@ -1,7 +1,8 @@
|
||||
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s | FileCheck %s
|
||||
|
||||
// Test that the common symbols are placed at the end of .bss. In this example
|
||||
// it causes .bss to have size 9 instead of 8.
|
||||
// Test local common construction.
|
||||
// Unlike gas, common symbols are created when found, not at the end of .bss.
|
||||
// In this example it causes .bss to have size 8 instead of 9.
|
||||
|
||||
.local vimvardict
|
||||
.comm vimvardict,1,8
|
||||
@ -16,7 +17,7 @@
|
||||
// CHECK: ]
|
||||
// CHECK-NEXT: Address:
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 9
|
||||
// CHECK-NEXT: Size: 8
|
||||
// CHECK-NEXT: Link:
|
||||
// CHECK-NEXT: Info:
|
||||
// CHECK-NEXT: AddressAlignment:
|
||||
|
Loading…
Reference in New Issue
Block a user