Skip to content

[llvm] annotate interfaces in llvm/DWARFLinker, llvm/DWP, and llvm/Demangle for DLL export #140782

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 14 additions & 10 deletions llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
#include "llvm/Support/Compiler.h"
#include <map>

namespace llvm {
Expand Down Expand Up @@ -211,7 +212,7 @@ using UnitListTy = std::vector<std::unique_ptr<CompileUnit>>;
/// a variable). These relocations are called ValidRelocs in the
/// AddressesInfo and are gathered as a very first step when we start
/// processing a object file.
class DWARFLinker : public DWARFLinkerBase {
class LLVM_ABI DWARFLinker : public DWARFLinkerBase {
public:
DWARFLinker(MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler,
std::function<StringRef(StringRef)> StringsTranslator)
Expand Down Expand Up @@ -586,28 +587,31 @@ class DWARFLinker : public DWARFLinkerBase {
/// applied to the entry point of the function to get the linked address.
/// \param Die the output DIE to use, pass NULL to create one.
/// \returns the root of the cloned tree or null if nothing was selected.
DIE *cloneDIE(const DWARFDie &InputDIE, const DWARFFile &File,
CompileUnit &U, int64_t PCOffset, uint32_t OutOffset,
unsigned Flags, bool IsLittleEndian, DIE *Die = nullptr);
LLVM_ABI DIE *cloneDIE(const DWARFDie &InputDIE, const DWARFFile &File,
CompileUnit &U, int64_t PCOffset, uint32_t OutOffset,
unsigned Flags, bool IsLittleEndian,
DIE *Die = nullptr);

/// Construct the output DIE tree by cloning the DIEs we
/// chose to keep above. If there are no valid relocs, then there's
/// nothing to clone/emit.
uint64_t cloneAllCompileUnits(DWARFContext &DwarfContext,
const DWARFFile &File, bool IsLittleEndian);
LLVM_ABI uint64_t cloneAllCompileUnits(DWARFContext &DwarfContext,
const DWARFFile &File,
bool IsLittleEndian);

/// Emit the .debug_addr section for the \p Unit.
void emitDebugAddrSection(CompileUnit &Unit,
const uint16_t DwarfVersion) const;
LLVM_ABI void emitDebugAddrSection(CompileUnit &Unit,
const uint16_t DwarfVersion) const;

using ExpressionHandlerRef = function_ref<void(
SmallVectorImpl<uint8_t> &, SmallVectorImpl<uint8_t> &,
int64_t AddrRelocAdjustment)>;

/// Compute and emit debug locations (.debug_loc, .debug_loclists)
/// for \p Unit, patch the attributes referencing it.
void generateUnitLocations(CompileUnit &Unit, const DWARFFile &File,
ExpressionHandlerRef ExprHandler);
LLVM_ABI void generateUnitLocations(CompileUnit &Unit,
const DWARFFile &File,
ExpressionHandlerRef ExprHandler);

private:
using AttributeSpec = DWARFAbbreviationDeclaration::AttributeSpec;
Expand Down
43 changes: 23 additions & 20 deletions llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/CodeGen/DIE.h"
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
#include "llvm/Support/Compiler.h"
#include <optional>

namespace llvm {
Expand Down Expand Up @@ -142,9 +143,9 @@ class CompileUnit {

bool hasODR() const { return HasODR; }
bool isClangModule() const { return !ClangModuleName.empty(); }
uint16_t getLanguage();
LLVM_ABI uint16_t getLanguage();
/// Return the DW_AT_LLVM_sysroot of the compile unit or an empty StringRef.
StringRef getSysRoot();
LLVM_ABI StringRef getSysRoot();

const std::string &getClangModuleName() const { return ClangModuleName; }

Expand Down Expand Up @@ -185,60 +186,62 @@ class CompileUnit {
/// Mark every DIE in this unit as kept. This function also
/// marks variables as InDebugMap so that they appear in the
/// reconstructed accelerator tables.
void markEverythingAsKept();
LLVM_ABI void markEverythingAsKept();

/// Compute the end offset for this unit. Must be called after the CU's DIEs
/// have been cloned. \returns the next unit offset (which is also the
/// current debug_info section size).
uint64_t computeNextUnitOffset(uint16_t DwarfVersion);
LLVM_ABI uint64_t computeNextUnitOffset(uint16_t DwarfVersion);

/// Keep track of a forward reference to DIE \p Die in \p RefUnit by \p
/// Attr. The attribute should be fixed up later to point to the absolute
/// offset of \p Die in the debug_info section or to the canonical offset of
/// \p Ctxt if it is non-null.
void noteForwardReference(DIE *Die, const CompileUnit *RefUnit,
DeclContext *Ctxt, PatchLocation Attr);
LLVM_ABI void noteForwardReference(DIE *Die, const CompileUnit *RefUnit,
DeclContext *Ctxt, PatchLocation Attr);

/// Apply all fixups recorded by noteForwardReference().
void fixupForwardReferences();
LLVM_ABI void fixupForwardReferences();

/// Add the low_pc of a label that is relocated by applying
/// offset \p PCOffset.
void addLabelLowPc(uint64_t LabelLowPc, int64_t PcOffset);
LLVM_ABI void addLabelLowPc(uint64_t LabelLowPc, int64_t PcOffset);

/// Add a function range [\p LowPC, \p HighPC) that is relocated by applying
/// offset \p PCOffset.
void addFunctionRange(uint64_t LowPC, uint64_t HighPC, int64_t PCOffset);
LLVM_ABI void addFunctionRange(uint64_t LowPC, uint64_t HighPC,
int64_t PCOffset);

/// Keep track of a DW_AT_range attribute that we will need to patch up later.
void noteRangeAttribute(const DIE &Die, PatchLocation Attr);
LLVM_ABI void noteRangeAttribute(const DIE &Die, PatchLocation Attr);

/// Keep track of a location attribute pointing to a location list in the
/// debug_loc section.
void noteLocationAttribute(PatchLocation Attr);
LLVM_ABI void noteLocationAttribute(PatchLocation Attr);

// Record that the given DW_AT_LLVM_stmt_sequence attribute may need to be
// patched later.
void noteStmtSeqListAttribute(PatchLocation Attr);
LLVM_ABI void noteStmtSeqListAttribute(PatchLocation Attr);

/// Add a name accelerator entry for \a Die with \a Name.
void addNamespaceAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name);
LLVM_ABI void addNamespaceAccelerator(const DIE *Die,
DwarfStringPoolEntryRef Name);

/// Add a name accelerator entry for \a Die with \a Name.
void addNameAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name,
bool SkipPubnamesSection = false);
LLVM_ABI void addNameAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name,
bool SkipPubnamesSection = false);

/// Add various accelerator entries for \p Die with \p Name which is stored
/// in the string table at \p Offset. \p Name must be an Objective-C
/// selector.
void addObjCAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name,
bool SkipPubnamesSection = false);
LLVM_ABI void addObjCAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name,
bool SkipPubnamesSection = false);

/// Add a type accelerator entry for \p Die with \p Name which is stored in
/// the string table at \p Offset.
void addTypeAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name,
bool ObjcClassImplementation,
uint32_t QualifiedNameHash);
LLVM_ABI void addTypeAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name,
bool ObjcClassImplementation,
uint32_t QualifiedNameHash);

struct AccelInfo {
/// Name of the entry.
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Target/TargetMachine.h"

namespace llvm {
Expand All @@ -41,7 +42,7 @@ namespace classic {
///
/// All interactions with the MC layer that is used to build the debug
/// information binary representation are handled in this class.
class DwarfStreamer : public DwarfEmitter {
class LLVM_ABI DwarfStreamer : public DwarfEmitter {
public:
DwarfStreamer(DWARFLinkerBase::OutputFileType OutFileType,
raw_pwrite_stream &OutFile,
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
#include "llvm/Support/Compiler.h"
#include <map>
namespace llvm {
class DWARFUnit;
Expand Down Expand Up @@ -68,7 +69,7 @@ getSectionName(DebugSectionKind SectionKind) {
}

/// Recognise the table name and match it with the DebugSectionKind.
std::optional<DebugSectionKind> parseDebugTableName(StringRef Name);
LLVM_ABI std::optional<DebugSectionKind> parseDebugTableName(StringRef Name);

/// The base interface for DWARFLinker implementations.
class DWARFLinkerBase {
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/Support/Compiler.h"
#include "llvm/TargetParser/Triple.h"

/// ------------------------------------------------------------------
Expand Down Expand Up @@ -122,7 +123,7 @@ class DWARFLinker : public DWARFLinkerBase {
virtual ~DWARFLinker() = default;

/// Creates dwarf linker instance.
static std::unique_ptr<DWARFLinker>
LLVM_ABI static std::unique_ptr<DWARFLinker>
createLinker(MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler);

/// Set output DWARF handler. Result of linking DWARF is set of sections
Expand Down
36 changes: 21 additions & 15 deletions llvm/include/llvm/DWP/DWP.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include <deque>
#include <vector>
Expand Down Expand Up @@ -66,12 +67,13 @@ struct CompileUnitIdentifiers {
const char *DWOName = "";
};

Error write(MCStreamer &Out, ArrayRef<std::string> Inputs,
OnCuIndexOverflow OverflowOptValue);
LLVM_ABI Error write(MCStreamer &Out, ArrayRef<std::string> Inputs,
OnCuIndexOverflow OverflowOptValue);

unsigned getContributionIndex(DWARFSectionKind Kind, uint32_t IndexVersion);
LLVM_ABI unsigned getContributionIndex(DWARFSectionKind Kind,
uint32_t IndexVersion);

Error handleSection(
LLVM_ABI Error handleSection(
const StringMap<std::pair<MCSection *, DWARFSectionKind>> &KnownSections,
const MCSection *StrSection, const MCSection *StrOffsetSection,
const MCSection *TypesSection, const MCSection *CUIndexSection,
Expand All @@ -85,20 +87,24 @@ Error handleSection(
StringRef &CurCUIndexSection, StringRef &CurTUIndexSection,
std::vector<std::pair<DWARFSectionKind, uint32_t>> &SectionLength);

Expected<InfoSectionUnitHeader> parseInfoSectionUnitHeader(StringRef Info);
LLVM_ABI Expected<InfoSectionUnitHeader>
parseInfoSectionUnitHeader(StringRef Info);

void writeStringsAndOffsets(MCStreamer &Out, DWPStringPool &Strings,
MCSection *StrOffsetSection,
StringRef CurStrSection,
StringRef CurStrOffsetSection, uint16_t Version);
LLVM_ABI void writeStringsAndOffsets(MCStreamer &Out, DWPStringPool &Strings,
MCSection *StrOffsetSection,
StringRef CurStrSection,
StringRef CurStrOffsetSection,
uint16_t Version);

Error buildDuplicateError(const std::pair<uint64_t, UnitIndexEntry> &PrevE,
const CompileUnitIdentifiers &ID, StringRef DWPName);
LLVM_ABI Error
buildDuplicateError(const std::pair<uint64_t, UnitIndexEntry> &PrevE,
const CompileUnitIdentifiers &ID, StringRef DWPName);

void writeIndex(MCStreamer &Out, MCSection *Section,
ArrayRef<unsigned> ContributionOffsets,
const MapVector<uint64_t, UnitIndexEntry> &IndexEntries,
uint32_t IndexVersion);
LLVM_ABI void
writeIndex(MCStreamer &Out, MCSection *Section,
ArrayRef<unsigned> ContributionOffsets,
const MapVector<uint64_t, UnitIndexEntry> &IndexEntries,
uint32_t IndexVersion);

} // namespace llvm
#endif // LLVM_DWP_DWP_H
3 changes: 2 additions & 1 deletion llvm/include/llvm/DWP/DWPError.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef LLVM_DWP_DWPERROR_H
#define LLVM_DWP_DWPERROR_H

#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include <string>
Expand All @@ -13,7 +14,7 @@ class DWPError : public ErrorInfo<DWPError> {
std::error_code convertToErrorCode() const override {
llvm_unreachable("Not implemented");
}
static char ID;
LLVM_ABI static char ID;

private:
std::string Info;
Expand Down
Loading