[llvm] [DWARFLinker][DWARFLinkerParallel][NFC] Refactor DWARFLinker&DWARFLinkerParallel to have a common library. Part 1. (PR #75925)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 22 00:55:38 PST 2023
================
@@ -0,0 +1,98 @@
+//===- DWARFLinkerBase.h ----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DWARFLINKER_DWARFLINKERBASE_H
+#define LLVM_DWARFLINKER_DWARFLINKERBASE_H
+#include "AddressesMap.h"
+#include "DWARFFile.h"
+#include "llvm/ADT/AddressRanges.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/DebugInfo/DWARF/DWARFContext.h"
+#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
+#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
+#include "llvm/DebugInfo/DWARF/DWARFDie.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
+#include <map>
+namespace llvm {
+class DWARFUnit;
+
+namespace dwarflinker {
+
+/// The base interface for DWARFLinker implementations.
+class DWARFLinkerBase {
+public:
+ virtual ~DWARFLinkerBase() = default;
+ using MessageHandlerTy = std::function<void(
+ const Twine &Warning, StringRef Context, const DWARFDie *DIE)>;
+ using ObjFileLoaderTy = std::function<ErrorOr<DWARFFile &>(
+ StringRef ContainerName, StringRef Path)>;
+ using InputVerificationHandlerTy =
+ std::function<void(const DWARFFile &File, llvm::StringRef Output)>;
+ using ObjectPrefixMapTy = std::map<std::string, std::string>;
+ using CompileUnitHandlerTy = function_ref<void(const DWARFUnit &Unit)>;
+ using TranslatorFuncTy = std::function<StringRef(StringRef)>;
+ using SwiftInterfacesMapTy = std::map<std::string, std::string>;
+ /// Type of output file.
+ enum class OutputFileType : uint8_t {
+ Object,
+ Assembly,
+ };
+ /// The kind of accelerator tables we should emit.
+ enum class AccelTableKind : uint8_t {
+ Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
+ Pub, ///< .debug_pubnames, .debug_pubtypes
+ DebugNames ///< .debug_names.
+ };
+ /// Add object file to be linked. Pre-load compile unit die. Call
----------------
avl-llvm wrote:
> > Add object file to be linked
>
> Add _an_ object file to be linked.
>
> > Pre-load compile unit die
>
> Can you elaborate on this sentence? I'm not sure what pre-loading means.
When an object file is added to be linked, part of input DWARF Context corresponding to this object file is loaded. Specifically, The DWARFUnit::getUnitDIE( /* ExtractUnitDIEOnly == true */) is called for each compile unit:
```
for (const std::unique_ptr<DWARFUnit> &CU :
ObjectContexts.back().File.Dwarf->compile_units()) {
DWARFDie CUDie = CU->getUnitDIE();
}
```
>
> > If specified \p File has reference to the Clang module then such module would be pre-loaded by \p Loader for !Update case.
>
> I'm not sure I understand this, but if I am reading this correctly, we can say something like:
>
> "If \p File has reference to a Clang module then the module is be pre-loaded by \p Loader ... ?"
>
> Actually, what is the meaning of "pre-loaded by \p Loader for !Update case."?
Clang module is represented as a compile unit referencing another file. If such Clang module reference is discovered during adding object file then DWARFLinker goes through the reference, load DWARFFile by calling ErrorOr<DWARFFile &> ObjFileLoaderTy(StringRef ContainerName, StringRef Path), creates CompileUnit for referenced file, adds created CompileUnit into the "ModuleUnits" list. Expansion of clang module reference is done only in !Update case.
https://github.com/llvm/llvm-project/pull/75925
More information about the llvm-commits
mailing list