Skip to content

[DWARFLinker][DWARFLinkerParallel][NFC] Refactor DWARFLinker&DWARFLinkerParallel to have a common library. #74725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bolt/lib/Rewrite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
MC
Object
Support
DWARFLinkerBase
DWARFLinker
AsmPrinter
TargetParser
Expand Down
18 changes: 7 additions & 11 deletions bolt/lib/Rewrite/DWARFRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/DIE.h"
#include "llvm/DWARFLinker/DWARFStreamer.h"
#include "llvm/DWARFLinker/Apple/DWARFStreamer.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
Expand Down Expand Up @@ -181,7 +181,7 @@ translateInputToOutputLocationList(const BinaryFunction &BF,
namespace llvm {
namespace bolt {
/// Emits debug information into .debug_info or .debug_types section.
class DIEStreamer : public DwarfStreamer {
class DIEStreamer : public dwarflinker::DwarfStreamer {
DIEBuilder *DIEBldr;
DWARFRewriter &Rewriter;

Expand Down Expand Up @@ -271,25 +271,20 @@ class DIEStreamer : public DwarfStreamer {
emitCompileUnitHeader(Unit, UnitDIE, Unit.getVersion());
}

void emitDIE(DIE &Die) override {
AsmPrinter &Asm = getAsmPrinter();
Asm.emitDwarfDIE(Die);
}

public:
DIEStreamer(DIEBuilder *DIEBldr, DWARFRewriter &Rewriter,
DWARFLinker::OutputFileType OutFileType,
dwarflinker::DWARFLinkerBase::OutputFileType OutFileType,
raw_pwrite_stream &OutFile,
std::function<StringRef(StringRef Input)> Translator,
DWARFLinker::messageHandler Warning)
dwarflinker::DWARFLinker::MessageHandlerTy Warning)
: DwarfStreamer(OutFileType, OutFile, Translator, Warning),
DIEBldr(DIEBldr), Rewriter(Rewriter){};

using DwarfStreamer::emitCompileUnitHeader;

void emitUnit(DWARFUnit &Unit, DIE &UnitDIE) {
emitUnitHeader(Unit, UnitDIE);
emitDIE(UnitDIE);
Asm->emitDwarfDIE(UnitDIE);
}
};

Expand Down Expand Up @@ -457,7 +452,8 @@ createDIEStreamer(const Triple &TheTriple, raw_pwrite_stream &OutFile,
DWARFRewriter &Rewriter) {

std::unique_ptr<DIEStreamer> Streamer = std::make_unique<DIEStreamer>(
&DIEBldr, Rewriter, llvm::DWARFLinker::OutputFileType::Object, OutFile,
&DIEBldr, Rewriter,
llvm::dwarflinker::DWARFLinker::OutputFileType::Object, OutFile,
[](StringRef Input) -> StringRef { return Input; },
[&](const Twine &Warning, StringRef Context, const DWARFDie *) {});
Error Err = Streamer->init(TheTriple, Swift5ReflectionSegmentName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_DWARFLINKERPARALLEL_ADDRESSESMAP_H
#define LLVM_DWARFLINKERPARALLEL_ADDRESSESMAP_H
#ifndef LLVM_DWARFLINKER_ADDRESSESMAP_H
#define LLVM_DWARFLINKER_ADDRESSESMAP_H

#include "llvm/ADT/AddressRanges.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
Expand All @@ -17,7 +17,7 @@
#include <cstdint>

namespace llvm {
namespace dwarflinker_parallel {
namespace dwarflinker {

/// Mapped value in the address map is the offset to apply to the
/// linked address.
Expand Down Expand Up @@ -186,7 +186,7 @@ class AddressesMap {
}
};

} // end of namespace dwarflinker_parallel
} // end namespace dwarflinker
} // end namespace llvm

#endif // LLVM_DWARFLINKERPARALLEL_ADDRESSESMAP_H
#endif // LLVM_DWARFLINKER_ADDRESSESMAP_H
Loading