[llvm] 0ed8194 - [dsymutil] Add --linker parallel to more tests. (#78581)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 23 02:00:53 PST 2024
Author: Alexey Lapshin
Date: 2024-01-23T13:00:49+03:00
New Revision: 0ed8194256c6c96875ed9dd102d15ee8a9260fec
URL: https://github.com/llvm/llvm-project/commit/0ed8194256c6c96875ed9dd102d15ee8a9260fec
DIFF: https://github.com/llvm/llvm-project/commit/0ed8194256c6c96875ed9dd102d15ee8a9260fec.diff
LOG: [dsymutil] Add --linker parallel to more tests. (#78581)
This patch adds check for parallel linker to tests located in the root
of test/tools/dsymutil.
Added:
Modified:
llvm/include/llvm/DWARFLinker/AddressesMap.h
llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
llvm/lib/DWARFLinker/Parallel/DependencyTracker.cpp
llvm/test/tools/dsymutil/absolute_symbol.test
llvm/test/tools/dsymutil/arch-option.test
llvm/test/tools/dsymutil/archive-timestamp.test
llvm/test/tools/dsymutil/basic-linking.test
llvm/test/tools/dsymutil/debug-map-parsing.test
llvm/test/tools/dsymutil/dump-symtab.test
llvm/test/tools/dsymutil/fat-binary-output.test
llvm/test/tools/dsymutil/fat-header.test
llvm/test/tools/dsymutil/yaml-object-address-rewrite.test
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
llvm/tools/dsymutil/DwarfLinkerForBinary.h
llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/DWARFLinker/AddressesMap.h b/llvm/include/llvm/DWARFLinker/AddressesMap.h
index d8b3b4407471921..a232aafadc5ce9a 100644
--- a/llvm/include/llvm/DWARFLinker/AddressesMap.h
+++ b/llvm/include/llvm/DWARFLinker/AddressesMap.h
@@ -38,22 +38,22 @@ class AddressesMap {
/// Checks that the specified DWARF expression operand \p Op references live
/// code section and returns the relocation adjustment value (to get the
/// linked address this value might be added to the source expression operand
- /// address).
+ /// address). Print debug output if \p Verbose is true.
/// \returns relocation adjustment value or std::nullopt if there is no
/// corresponding live address.
- virtual std::optional<int64_t>
- getExprOpAddressRelocAdjustment(DWARFUnit &U,
- const DWARFExpression::Operation &Op,
- uint64_t StartOffset, uint64_t EndOffset) = 0;
+ virtual std::optional<int64_t> getExprOpAddressRelocAdjustment(
+ DWARFUnit &U, const DWARFExpression::Operation &Op, uint64_t StartOffset,
+ uint64_t EndOffset, bool Verbose) = 0;
/// Checks that the specified subprogram \p DIE references the live code
/// section and returns the relocation adjustment value (to get the linked
/// address this value might be added to the source subprogram address).
/// Allowed kinds of input DIE: DW_TAG_subprogram, DW_TAG_label.
+ /// Print debug output if \p Verbose is true.
/// \returns relocation adjustment value or std::nullopt if there is no
/// corresponding live address.
virtual std::optional<int64_t>
- getSubprogramRelocAdjustment(const DWARFDie &DIE) = 0;
+ getSubprogramRelocAdjustment(const DWARFDie &DIE, bool Verbose) = 0;
// Returns the library install name associated to the AddessesMap.
virtual std::optional<StringRef> getLibraryInstallName() = 0;
@@ -90,7 +90,7 @@ class AddressesMap {
/// second is the relocation adjustment value if the live address is
/// referenced.
std::pair<bool, std::optional<int64_t>>
- getVariableRelocAdjustment(const DWARFDie &DIE) {
+ getVariableRelocAdjustment(const DWARFDie &DIE, bool Verbose) {
assert((DIE.getTag() == dwarf::DW_TAG_variable ||
DIE.getTag() == dwarf::DW_TAG_constant) &&
"Wrong type of input die");
@@ -149,9 +149,9 @@ class AddressesMap {
HasLocationAddress = true;
// Check relocation for the address.
if (std::optional<int64_t> RelocAdjustment =
- getExprOpAddressRelocAdjustment(*U, Op,
- AttrOffset + CurExprOffset,
- AttrOffset + Op.getEndOffset()))
+ getExprOpAddressRelocAdjustment(
+ *U, Op, AttrOffset + CurExprOffset,
+ AttrOffset + Op.getEndOffset(), Verbose))
return std::make_pair(HasLocationAddress, *RelocAdjustment);
} break;
case dwarf::DW_OP_constx:
@@ -164,8 +164,8 @@ class AddressesMap {
if (std::optional<int64_t> RelocAdjustment =
getExprOpAddressRelocAdjustment(
*U, Op, *AddressOffset,
- *AddressOffset +
- DIE.getDwarfUnit()->getAddressByteSize()))
+ *AddressOffset + DIE.getDwarfUnit()->getAddressByteSize(),
+ Verbose))
return std::make_pair(HasLocationAddress, *RelocAdjustment);
}
} break;
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
index bcb8b94c1fa5afa..4f5a4e2ffc702ae 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
@@ -465,7 +465,7 @@ DWARFLinker::getVariableRelocAdjustment(AddressesMap &RelocMgr,
if (std::optional<int64_t> RelocAdjustment =
RelocMgr.getExprOpAddressRelocAdjustment(
*U, Op, AttrOffset + CurExprOffset,
- AttrOffset + Op.getEndOffset()))
+ AttrOffset + Op.getEndOffset(), Options.Verbose))
return std::make_pair(HasLocationAddress, *RelocAdjustment);
} break;
case dwarf::DW_OP_constx:
@@ -478,7 +478,8 @@ DWARFLinker::getVariableRelocAdjustment(AddressesMap &RelocMgr,
if (std::optional<int64_t> RelocAdjustment =
RelocMgr.getExprOpAddressRelocAdjustment(
*U, Op, *AddressOffset,
- *AddressOffset + DIE.getDwarfUnit()->getAddressByteSize()))
+ *AddressOffset + DIE.getDwarfUnit()->getAddressByteSize(),
+ Options.Verbose))
return std::make_pair(HasLocationAddress, *RelocAdjustment);
}
} break;
@@ -552,7 +553,7 @@ unsigned DWARFLinker::shouldKeepSubprogramDIE(
assert(LowPc && "low_pc attribute is not an address.");
std::optional<int64_t> RelocAdjustment =
- RelocMgr.getSubprogramRelocAdjustment(DIE);
+ RelocMgr.getSubprogramRelocAdjustment(DIE, Options.Verbose);
if (!RelocAdjustment)
return Flags;
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
index fe2748f79c06d85..8c52040fdbc92dc 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
@@ -1372,7 +1372,7 @@ DIE *CompileUnit::createPlainDIEandCloneAttributes(
// Get relocation adjustment value for the current function.
FuncAddressAdjustment =
getContaingFile().Addresses->getSubprogramRelocAdjustment(
- getDIE(InputDieEntry));
+ getDIE(InputDieEntry), false);
} else if (InputDieEntry->getTag() == dwarf::DW_TAG_label) {
// Get relocation adjustment value for the current label.
std::optional<uint64_t> lowPC =
@@ -1386,7 +1386,7 @@ DIE *CompileUnit::createPlainDIEandCloneAttributes(
// Get relocation adjustment value for the current variable.
std::pair<bool, std::optional<int64_t>> LocExprAddrAndRelocAdjustment =
getContaingFile().Addresses->getVariableRelocAdjustment(
- getDIE(InputDieEntry));
+ getDIE(InputDieEntry), false);
HasLocationExpressionAddress = LocExprAddrAndRelocAdjustment.first;
if (LocExprAddrAndRelocAdjustment.first &&
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
index 56828e75ac0b4a0..a052969e74c0f8d 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
@@ -115,7 +115,8 @@ Error DWARFLinkerImpl::link() {
}
if (GlobalData.getOptions().Verbose) {
- outs() << "OBJECT: " << Context->InputDWARFFile.FileName << "\n";
+ outs() << "DEBUG MAP OBJECT: " << Context->InputDWARFFile.FileName
+ << "\n";
for (const std::unique_ptr<DWARFUnit> &OrigCU :
Context->InputDWARFFile.Dwarf->compile_units()) {
diff --git a/llvm/lib/DWARFLinker/Parallel/DependencyTracker.cpp b/llvm/lib/DWARFLinker/Parallel/DependencyTracker.cpp
index 04152e7f9f2b0e2..5e30d9a8b6690e1 100644
--- a/llvm/lib/DWARFLinker/Parallel/DependencyTracker.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DependencyTracker.cpp
@@ -741,7 +741,7 @@ bool DependencyTracker::isLiveVariableEntry(const UnitEntryPairTy &Entry,
// enclosing function, unless requested explicitly.
std::pair<bool, std::optional<int64_t>> LocExprAddrAndRelocAdjustment =
Entry.CU->getContaingFile().Addresses->getVariableRelocAdjustment(
- DIE);
+ DIE, Entry.CU->getGlobalData().getOptions().Verbose);
if (LocExprAddrAndRelocAdjustment.first)
Info.setHasAnAddress();
@@ -784,7 +784,7 @@ bool DependencyTracker::isLiveSubprogramEntry(const UnitEntryPairTy &Entry) {
RelocAdjustment =
Entry.CU->getContaingFile().Addresses->getSubprogramRelocAdjustment(
- DIE);
+ DIE, Entry.CU->getGlobalData().getOptions().Verbose);
if (!RelocAdjustment)
return false;
diff --git a/llvm/test/tools/dsymutil/absolute_symbol.test b/llvm/test/tools/dsymutil/absolute_symbol.test
index 1724cb743662226..ae61bf750738e11 100644
--- a/llvm/test/tools/dsymutil/absolute_symbol.test
+++ b/llvm/test/tools/dsymutil/absolute_symbol.test
@@ -1,5 +1,7 @@
RUN: dsymutil -dump-debug-map -oso-prepend-path %p %p/Inputs/absolute_sym.macho.i386 | FileCheck %s
+RUN: dsymutil --linker parallel -dump-debug-map -oso-prepend-path %p %p/Inputs/absolute_sym.macho.i386 | FileCheck %s
+
The tested object file has been created by the dummy Objective-C code:
@interface Foo
@end
diff --git a/llvm/test/tools/dsymutil/arch-option.test b/llvm/test/tools/dsymutil/arch-option.test
index 723a9c3ac742cbb..d8b8e3d901f6d78 100644
--- a/llvm/test/tools/dsymutil/arch-option.test
+++ b/llvm/test/tools/dsymutil/arch-option.test
@@ -11,6 +11,17 @@ RUN: dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib
RUN: not dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm42 2>&1 | FileCheck %s -check-prefix=BADARCH
RUN: not dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch i386 2>&1 | FileCheck %s -check-prefix=EMPTY
+RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib | FileCheck %s -check-prefixes=ARM64,ARMV7S,ARMV7,CHECK
+RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch all | FileCheck %s -check-prefixes=ARM64,ARMV7S,ARMV7,CHECK
+RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch='*' | FileCheck %s -check-prefixes=ARM64,ARMV7S,ARMV7,CHECK
+RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm64 | FileCheck %s -check-prefixes=ARM64,CHECK
+RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm | FileCheck %s -check-prefixes=ARMV7S,ARMV7,CHECK
+RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch armv7 | FileCheck %s -check-prefixes=ARMV7,CHECK
+RUN: dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm64 -arch armv7s | FileCheck %s -check-prefixes=ARM64,ARMV7S,CHECK
+RUN: not dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm42 2>&1 | FileCheck %s -check-prefix=BADARCH
+RUN: not dsymutil --linker parallel -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch i386 2>&1 | FileCheck %s -check-prefix=EMPTY
+
+
ARMV7: ---
ARMV7-NOT: ...
diff --git a/llvm/test/tools/dsymutil/archive-timestamp.test b/llvm/test/tools/dsymutil/archive-timestamp.test
index 69fa261d59c8f6c..c86d19e57738cbd 100644
--- a/llvm/test/tools/dsymutil/archive-timestamp.test
+++ b/llvm/test/tools/dsymutil/archive-timestamp.test
@@ -1,5 +1,7 @@
# RUN: dsymutil -no-output -oso-prepend-path=%p -y %s 2>&1 | FileCheck -DMSG=%errc_ENOENT %s
+# RUN: dsymutil --linker parallel -no-output -oso-prepend-path=%p -y %s 2>&1 | FileCheck -DMSG=%errc_ENOENT %s
+
# This is the archive member part of basic-archive.macho.x86_64 debug map with corrupted timestamps.
# CHECK: warning: {{.*}}libbasic.a(basic2.macho.x86_64.o): [[MSG]]
diff --git a/llvm/test/tools/dsymutil/basic-linking.test b/llvm/test/tools/dsymutil/basic-linking.test
index 88cd3293efa2427..1e8027d05b3c327 100644
--- a/llvm/test/tools/dsymutil/basic-linking.test
+++ b/llvm/test/tools/dsymutil/basic-linking.test
@@ -6,6 +6,11 @@ RUN: dsymutil -no-output -verbose -oso-prepend-path=%p -D %p/Inputs %p/Inputs/ba
RUN: dsymutil -no-output -verbose -oso-prepend-path=%p -D %p/Inputs %p/Inputs/two-level-relink.macho.arm64.dylib | FileCheck %s --check-prefix=CHECK-RELINK-TWO
RUN: dsymutil -no-output -verbose -oso-prepend-path=%p -build-variant-suffix=_debug -D WrongPath -D %p/Inputs %p/Inputs/variant-relink.macho.arm64.dylib | FileCheck %s --check-prefix=CHECK-RELINK-VARIANT
+RUN: dsymutil --linker parallel -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s
+RUN: dsymutil --linker parallel -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO
+RUN: dsymutil --linker parallel -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefix=CHECK-ARCHIVE
+RUN: dsymutil --linker parallel -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 %p/Inputs/basic-lto.macho.x86_64 %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefixes=CHECK,CHECK-LTO,CHECK-ARCHIVE
+
This test check the basic Dwarf linking process through the debug dumps.
================================= Simple link ================================
diff --git a/llvm/test/tools/dsymutil/debug-map-parsing.test b/llvm/test/tools/dsymutil/debug-map-parsing.test
index 2f2bf6a2d2c5a24..29b9d65477207b8 100644
--- a/llvm/test/tools/dsymutil/debug-map-parsing.test
+++ b/llvm/test/tools/dsymutil/debug-map-parsing.test
@@ -4,6 +4,13 @@ RUN: dsymutil -verbose -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic-arch
RUN: dsymutil -dump-debug-map %p/Inputs/basic.macho.x86_64 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=NOT-FOUND
RUN: not dsymutil -dump-debug-map %p/Inputs/inexistant 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=NO-EXECUTABLE
+RUN: dsymutil --linker parallel -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s
+RUN: dsymutil --linker parallel -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO
+RUN: dsymutil --linker parallel -verbose -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 2>&1 | FileCheck %s --check-prefix=CHECK-ARCHIVE
+RUN: dsymutil --linker parallel -dump-debug-map %p/Inputs/basic.macho.x86_64 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=NOT-FOUND
+RUN: not dsymutil --linker parallel -dump-debug-map %p/Inputs/inexistant 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=NO-EXECUTABLE
+
+
Check that We can parse the debug map of the basic executable.
diff --git a/llvm/test/tools/dsymutil/dump-symtab.test b/llvm/test/tools/dsymutil/dump-symtab.test
index c0b51446c93f0d2..6c97140b3701702 100644
--- a/llvm/test/tools/dsymutil/dump-symtab.test
+++ b/llvm/test/tools/dsymutil/dump-symtab.test
@@ -1,6 +1,9 @@
RUN: dsymutil -s %p/Inputs/fat-test.dylib | FileCheck -check-prefixes=ALL,I386 %s
RUN: dsymutil -arch i386 -s %p/Inputs/fat-test.dylib | FileCheck -check-prefixes=I386,ONE %s
+RUN: dsymutil --linker parallel -s %p/Inputs/fat-test.dylib | FileCheck -check-prefixes=ALL,I386 %s
+RUN: dsymutil --linker parallel -arch i386 -s %p/Inputs/fat-test.dylib | FileCheck -check-prefixes=I386,ONE %s
+
ALL: ----------------------------------------------------------------------
ALL-NEXT: Symbol table for: '{{.*}}fat-test.dylib' (x86_64)
diff --git a/llvm/test/tools/dsymutil/fat-binary-output.test b/llvm/test/tools/dsymutil/fat-binary-output.test
index 7d379c8dc58b8dc..46b86b0513735d0 100644
--- a/llvm/test/tools/dsymutil/fat-binary-output.test
+++ b/llvm/test/tools/dsymutil/fat-binary-output.test
@@ -1,5 +1,7 @@
RUN: dsymutil -f -verbose -no-output %p/Inputs/fat-test.dylib -oso-prepend-path %p | FileCheck %s
+RUN: dsymutil --linker parallel -f -verbose -no-output %p/Inputs/fat-test.dylib -oso-prepend-path %p | FileCheck %s
+
This test doesn't produce any filesytstem output, we just look at the verbose
log output.
diff --git a/llvm/test/tools/dsymutil/fat-header.test b/llvm/test/tools/dsymutil/fat-header.test
index d605183737975b9..3130f4608476eee 100644
--- a/llvm/test/tools/dsymutil/fat-header.test
+++ b/llvm/test/tools/dsymutil/fat-header.test
@@ -3,8 +3,14 @@ REQUIRES: system-darwin,arm-registered-target,aarch64-registered-target
RUN: dsymutil -oso-prepend-path %p %p/Inputs/fat-test.arm.dylib -o %t.fat32.dSYM
RUN: llvm-objdump -m --universal-headers %t.fat32.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s -check-prefixes=FAT32
+RUN: dsymutil --linker parallel -oso-prepend-path %p %p/Inputs/fat-test.arm.dylib -o %t.fat32.dSYM
+RUN: llvm-objdump -m --universal-headers %t.fat32.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s -check-prefixes=FAT32
+
RUN: dsymutil -oso-prepend-path %p %p/Inputs/fat-test.arm.dylib -o %t.fat64.dSYM -fat64
RUN: llvm-objdump -m --universal-headers %t.fat64.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s -check-prefixes=FAT64
+RUN: dsymutil --linker parallel -oso-prepend-path %p %p/Inputs/fat-test.arm.dylib -o %t.fat64.dSYM -fat64
+RUN: llvm-objdump -m --universal-headers %t.fat64.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s -check-prefixes=FAT64
+
FAT32: fat_magic FAT_MAGIC
FAT64: fat_magic FAT_MAGIC_64
diff --git a/llvm/test/tools/dsymutil/yaml-object-address-rewrite.test b/llvm/test/tools/dsymutil/yaml-object-address-rewrite.test
index 09b5ccf1e6d5a51..dfa0f285c5ce577 100644
--- a/llvm/test/tools/dsymutil/yaml-object-address-rewrite.test
+++ b/llvm/test/tools/dsymutil/yaml-object-address-rewrite.test
@@ -1,5 +1,7 @@
# RUN: dsymutil -dump-debug-map -oso-prepend-path=%p -y %s | FileCheck %s
#
+# RUN: dsymutil --linker parallel -dump-debug-map -oso-prepend-path=%p -y %s | FileCheck %s
+#
# The YAML debug map bellow is the one from basic-archive.macho.x86_64 with
# the object addresses set to zero. Check that the YAML import is able to
# rewrite these addresses to the right values.
diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
index d09dcf678e1e994..5ae5ecd556adb7c 100644
--- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -1041,13 +1041,13 @@ DwarfLinkerForBinary::AddressManager::getRelocValue(const ValidReloc &Reloc) {
std::optional<int64_t>
DwarfLinkerForBinary::AddressManager::hasValidRelocationAt(
const std::vector<ValidReloc> &AllRelocs, uint64_t StartOffset,
- uint64_t EndOffset) {
+ uint64_t EndOffset, bool Verbose) {
std::vector<ValidReloc> Relocs =
getRelocations(AllRelocs, StartOffset, EndOffset);
if (Relocs.size() == 0)
return std::nullopt;
- if (Linker.Options.Verbose)
+ if (Verbose)
printReloc(Relocs[0]);
return getRelocValue(Relocs[0]);
@@ -1077,7 +1077,7 @@ getAttributeOffsets(const DWARFAbbreviationDeclaration *Abbrev, unsigned Idx,
std::optional<int64_t>
DwarfLinkerForBinary::AddressManager::getExprOpAddressRelocAdjustment(
DWARFUnit &U, const DWARFExpression::Operation &Op, uint64_t StartOffset,
- uint64_t EndOffset) {
+ uint64_t EndOffset, bool Verbose) {
switch (Op.getCode()) {
default: {
assert(false && "Specified operation does not have address operand");
@@ -1089,11 +1089,13 @@ DwarfLinkerForBinary::AddressManager::getExprOpAddressRelocAdjustment(
case dwarf::DW_OP_const4s:
case dwarf::DW_OP_const8s:
case dwarf::DW_OP_addr: {
- return hasValidRelocationAt(ValidDebugInfoRelocs, StartOffset, EndOffset);
+ return hasValidRelocationAt(ValidDebugInfoRelocs, StartOffset, EndOffset,
+ Verbose);
} break;
case dwarf::DW_OP_constx:
case dwarf::DW_OP_addrx: {
- return hasValidRelocationAt(ValidDebugAddrRelocs, StartOffset, EndOffset);
+ return hasValidRelocationAt(ValidDebugAddrRelocs, StartOffset, EndOffset,
+ Verbose);
} break;
}
@@ -1102,7 +1104,7 @@ DwarfLinkerForBinary::AddressManager::getExprOpAddressRelocAdjustment(
std::optional<int64_t>
DwarfLinkerForBinary::AddressManager::getSubprogramRelocAdjustment(
- const DWARFDie &DIE) {
+ const DWARFDie &DIE, bool Verbose) {
const auto *Abbrev = DIE.getAbbreviationDeclarationPtr();
std::optional<uint32_t> LowPcIdx =
@@ -1119,7 +1121,7 @@ DwarfLinkerForBinary::AddressManager::getSubprogramRelocAdjustment(
std::tie(LowPcOffset, LowPcEndOffset) =
getAttributeOffsets(Abbrev, *LowPcIdx, Offset, *DIE.getDwarfUnit());
return hasValidRelocationAt(ValidDebugInfoRelocs, LowPcOffset,
- LowPcEndOffset);
+ LowPcEndOffset, Verbose);
}
case dwarf::DW_FORM_addrx:
case dwarf::DW_FORM_addrx1:
@@ -1130,9 +1132,9 @@ DwarfLinkerForBinary::AddressManager::getSubprogramRelocAdjustment(
if (std::optional<uint64_t> AddressOffset =
DIE.getDwarfUnit()->getIndexedAddressOffset(
AddrValue->getRawUValue()))
- return hasValidRelocationAt(ValidDebugAddrRelocs, *AddressOffset,
- *AddressOffset +
- DIE.getDwarfUnit()->getAddressByteSize());
+ return hasValidRelocationAt(
+ ValidDebugAddrRelocs, *AddressOffset,
+ *AddressOffset + DIE.getDwarfUnit()->getAddressByteSize(), Verbose);
Linker.reportWarning("no base offset for address table", SrcFileName);
return std::nullopt;
diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.h b/llvm/tools/dsymutil/DwarfLinkerForBinary.h
index 14b9625117c2d68..53f9e183ebe88d2 100644
--- a/llvm/tools/dsymutil/DwarfLinkerForBinary.h
+++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.h
@@ -192,18 +192,20 @@ class DwarfLinkerForBinary {
/// Checks that there is a relocation in the \p Relocs array against a
/// debug map entry between \p StartOffset and \p NextOffset.
+ /// Print debug output if \p Verbose is set.
///
/// \returns relocation value if relocation exist, otherwise std::nullopt.
std::optional<int64_t>
hasValidRelocationAt(const std::vector<ValidReloc> &Relocs,
- uint64_t StartOffset, uint64_t EndOffset);
+ uint64_t StartOffset, uint64_t EndOffset,
+ bool Verbose);
std::optional<int64_t> getExprOpAddressRelocAdjustment(
DWARFUnit &U, const DWARFExpression::Operation &Op,
- uint64_t StartOffset, uint64_t EndOffset) override;
+ uint64_t StartOffset, uint64_t EndOffset, bool Verbose) override;
- std::optional<int64_t>
- getSubprogramRelocAdjustment(const DWARFDie &DIE) override;
+ std::optional<int64_t> getSubprogramRelocAdjustment(const DWARFDie &DIE,
+ bool Verbose) override;
std::optional<StringRef> getLibraryInstallName() override;
diff --git a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
index 19eb1bed7578bba..bd17f3c4a6595e2 100644
--- a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
+++ b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
@@ -80,8 +80,8 @@ class ObjFileAddressMap : public AddressesMap {
// should be renamed into has valid address ranges
bool hasValidRelocs() override { return HasValidAddressRanges; }
- std::optional<int64_t>
- getSubprogramRelocAdjustment(const DWARFDie &DIE) override {
+ std::optional<int64_t> getSubprogramRelocAdjustment(const DWARFDie &DIE,
+ bool Verbose) override {
assert((DIE.getTag() == dwarf::DW_TAG_subprogram ||
DIE.getTag() == dwarf::DW_TAG_label) &&
"Wrong type of input die");
@@ -101,7 +101,7 @@ class ObjFileAddressMap : public AddressesMap {
std::optional<int64_t>
getExprOpAddressRelocAdjustment(DWARFUnit &U,
const DWARFExpression::Operation &Op,
- uint64_t, uint64_t) override {
+ uint64_t, uint64_t, bool Verbose) override {
switch (Op.getCode()) {
default: {
assert(false && "Specified operation does not have address operand");
More information about the llvm-commits
mailing list