Skip to content
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

[DWARFLinker] Release input DWARF after object has been linked #68376

Merged
Merged
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
20 changes: 17 additions & 3 deletions llvm/include/llvm/DWARFLinker/DWARFLinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ class DWARFFile {
public:
using UnloadCallbackTy = std::function<void(StringRef FileName)>;
DWARFFile(StringRef Name, std::unique_ptr<DWARFContext> Dwarf,
std::unique_ptr<AddressesMap> Addresses, UnloadCallbackTy = nullptr)
std::unique_ptr<AddressesMap> Addresses,
UnloadCallbackTy UnloadFunc = nullptr)
: FileName(Name), Dwarf(std::move(Dwarf)),
Addresses(std::move(Addresses)) {}
Addresses(std::move(Addresses)), UnloadFunc(UnloadFunc) {}

/// The object file name.
StringRef FileName;
Expand All @@ -281,6 +282,18 @@ class DWARFFile {

/// Helpful address information(list of valid address ranges, relocations).
std::unique_ptr<AddressesMap> Addresses;

/// Callback to the module keeping object file to unload.
UnloadCallbackTy UnloadFunc;

/// Unloads object file and corresponding AddressesMap and Dwarf Context.
void unload() {
Addresses.reset();
Dwarf.reset();

if (UnloadFunc)
UnloadFunc(FileName);
}
};

typedef std::map<std::string, std::string> swiftInterfacesMap;
Expand Down Expand Up @@ -529,7 +542,8 @@ class DWARFLinker {
/// the debug object.
void clear() {
CompileUnits.clear();
File.Addresses->clear();
ModuleUnits.clear();
File.unload();
}
};

Expand Down
Loading