diff options
author | Sam Clegg <sbc@chromium.org> | 2018-06-14 17:11:19 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2018-06-14 17:11:19 +0000 |
commit | c0dba0af0145b4d0933019287b4f88e3b9433149 (patch) | |
tree | 9238699b22dc463ccc674a3dfc49f320c71bdc9e | |
parent | e2f3e1091307425decd500d738a94feafe873734 (diff) | |
download | bcm5719-llvm-c0dba0af0145b4d0933019287b4f88e3b9433149.tar.gz bcm5719-llvm-c0dba0af0145b4d0933019287b4f88e3b9433149.zip |
Revert "[MC] Factor MCObjectStreamer::addFragmentAtoms out of MachO streamer."
This reverts rL331412. We didn't up using fragment atoms
in the wasm object writer after all.
Differential Revision: https://reviews.llvm.org/D48173
llvm-svn: 334734
-rw-r--r-- | llvm/include/llvm/MC/MCObjectStreamer.h | 2 | ||||
-rw-r--r-- | llvm/lib/MC/MCMachOStreamer.cpp | 25 | ||||
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 26 | ||||
-rw-r--r-- | llvm/lib/MC/MCWasmStreamer.cpp | 3 |
4 files changed, 24 insertions, 32 deletions
diff --git a/llvm/include/llvm/MC/MCObjectStreamer.h b/llvm/include/llvm/MC/MCObjectStreamer.h index 8715a16e705..ac204de31a3 100644 --- a/llvm/include/llvm/MC/MCObjectStreamer.h +++ b/llvm/include/llvm/MC/MCObjectStreamer.h @@ -87,8 +87,6 @@ protected: /// 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; diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp index 4b74c569531..69995fa11d2 100644 --- a/llvm/lib/MC/MCMachOStreamer.cpp +++ b/llvm/lib/MC/MCMachOStreamer.cpp @@ -459,7 +459,30 @@ void MCMachOStreamer::FinishImpl() { // 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(); } diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 5159cfee7a8..432f4c242a8 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -59,32 +59,6 @@ void MCObjectStreamer::flushPendingLabels(MCFragment *F, uint64_t FOffset) { 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, diff --git a/llvm/lib/MC/MCWasmStreamer.cpp b/llvm/lib/MC/MCWasmStreamer.cpp index 2c65371cf3a..c950ac778ea 100644 --- a/llvm/lib/MC/MCWasmStreamer.cpp +++ b/llvm/lib/MC/MCWasmStreamer.cpp @@ -191,9 +191,6 @@ void MCWasmStreamer::EmitInstToData(const MCInst &Inst, void MCWasmStreamer::FinishImpl() { EmitFrames(nullptr); - // Set fragment atoms so we can map from code fragment to defining symbol - addFragmentAtoms(); - this->MCObjectStreamer::FinishImpl(); } |