This reverts rL331412. We didn't up using fragment atoms
in the wasm object writer after all.
Differential Revision: https://reviews.llvm.org/D48173
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334734
91177308-0d34-0410-b5e6-
96231b3b80d8
/// will be used as a symbol offset within the fragment.
void flushPendingLabels(MCFragment *F, uint64_t FOffset = 0);
- void addFragmentAtoms();
-
public:
void visitUsedSymbol(const MCSymbol &Sym) override;
// We have to set the fragment atom associations so we can relax properly for
// Mach-O.
- addFragmentAtoms();
+
+ // First, scan the symbol table to build a lookup table from fragments to
+ // defining symbols.
+ DenseMap<const MCFragment *, const MCSymbol *> DefiningSymbolMap;
+ for (const MCSymbol &Symbol : getAssembler().symbols()) {
+ if (getAssembler().isSymbolLinkerVisible(Symbol) && Symbol.isInSection() &&
+ !Symbol.isVariable()) {
+ // An atom defining symbol should never be internal to a fragment.
+ assert(Symbol.getOffset() == 0 &&
+ "Invalid offset in atom defining symbol!");
+ DefiningSymbolMap[Symbol.getFragment()] = &Symbol;
+ }
+ }
+
+ // Set the fragment atom associations by tracking the last seen atom defining
+ // symbol.
+ for (MCSection &Sec : getAssembler()) {
+ const MCSymbol *CurrentAtom = nullptr;
+ for (MCFragment &Frag : Sec) {
+ if (const MCSymbol *Symbol = DefiningSymbolMap.lookup(&Frag))
+ CurrentAtom = Symbol;
+ Frag.setAtom(CurrentAtom);
+ }
+ }
this->MCObjectStreamer::FinishImpl();
}
PendingLabels.clear();
}
-void MCObjectStreamer::addFragmentAtoms() {
- // First, scan the symbol table to build a lookup table from fragments to
- // defining symbols.
- DenseMap<const MCFragment *, const MCSymbol *> DefiningSymbolMap;
- for (const MCSymbol &Symbol : getAssembler().symbols()) {
- if (getAssembler().isSymbolLinkerVisible(Symbol) && Symbol.isInSection() &&
- !Symbol.isVariable()) {
- // An atom defining symbol should never be internal to a fragment.
- assert(Symbol.getOffset() == 0 &&
- "Invalid offset in atom defining symbol!");
- DefiningSymbolMap[Symbol.getFragment()] = &Symbol;
- }
- }
-
- // Set the fragment atom associations by tracking the last seen atom defining
- // symbol.
- for (MCSection &Sec : getAssembler()) {
- const MCSymbol *CurrentAtom = nullptr;
- for (MCFragment &Frag : Sec) {
- if (const MCSymbol *Symbol = DefiningSymbolMap.lookup(&Frag))
- CurrentAtom = Symbol;
- Frag.setAtom(CurrentAtom);
- }
- }
-}
-
// As a compile-time optimization, avoid allocating and evaluating an MCExpr
// tree for (Hi - Lo) when Hi and Lo are offsets into the same fragment.
static Optional<uint64_t> absoluteSymbolDiff(const MCSymbol *Hi,
void MCWasmStreamer::FinishImpl() {
EmitFrames(nullptr);
- // Set fragment atoms so we can map from code fragment to defining symbol
- addFragmentAtoms();
-
this->MCObjectStreamer::FinishImpl();
}