Skip to content

Commit

Permalink
[BOLT][DWARF] Fix for Handle zero size DW_TAG_inlined_subroutine
Browse files Browse the repository at this point in the history
Managed to introduce an error when changing code to fix other tests and the unit
test was no adequate due to --nostdlib being passed in in llvm testing
enviroment.
Original diff: https://reviews.llvm.org/D132059

Updated a test to make sure that original address and the new address are
different.

Reviewed By: maksfb, #bolt

Differential Revision: https://reviews.llvm.org/D132782
  • Loading branch information
ayermolo committed Dec 14, 2022
1 parent 765f3ca commit 2afc90a
Show file tree
Hide file tree
Showing 2 changed files with 226 additions and 143 deletions.
13 changes: 8 additions & 5 deletions bolt/lib/Rewrite/DWARFRewriter.cpp
Expand Up @@ -463,28 +463,31 @@ void DWARFRewriter::updateUnitDebugInfo(
? BC.getBinaryFunctionContainingAddress(
RangesOrError->front().LowPC)
: nullptr;
DebugAddressRangesVector OutputRanges;
bool ErrorState = false;
std::optional<uint64_t> NewLowPC;
if (Function) {
OutputRanges = Function->translateInputToOutputRanges(*RangesOrError);
DebugAddressRangesVector OutputRanges =
Function->translateInputToOutputRanges(*RangesOrError);
LLVM_DEBUG(if (OutputRanges.empty() != RangesOrError->empty()) {
dbgs() << "BOLT-DEBUG: problem with DIE at 0x"
<< Twine::utohexstr(DIE.getOffset()) << " in CU at 0x"
<< Twine::utohexstr(Unit.getOffset()) << '\n';
});

if (!OutputRanges.empty())
NewLowPC = OutputRanges.front().LowPC;
RangesSectionOffset = RangesSectionWriter.addRanges(
std::move(OutputRanges), CachedRanges);
} else if (!RangesOrError) {
ErrorState = true;
consumeError(RangesOrError.takeError());
}

uint64_t LowPCToUse = 0;
if (!ErrorState && RangesOrError.get().size() == 1 &&
RangesOrError.get().begin()->LowPC ==
RangesOrError.get().begin()->HighPC) {
if (!OutputRanges.empty())
LowPCToUse = OutputRanges.front().LowPC;
if (NewLowPC)
LowPCToUse = NewLowPC.value();
else
LowPCToUse = RangesOrError.get().begin()->LowPC;
}
Expand Down

0 comments on commit 2afc90a

Please sign in to comment.