Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
chapuni committed Feb 15, 2024
2 parents 06c0801 + 75f0d40 commit aa5b2f5
Show file tree
Hide file tree
Showing 846 changed files with 43,518 additions and 28,374 deletions.
5 changes: 4 additions & 1 deletion .ci/generate-buildkite-pipeline-premerge
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ linux_projects=$(add-dependencies ${linux_projects_to_test} | sort | uniq)

windows_projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects}))
windows_check_targets=$(check-targets ${windows_projects_to_test} | sort | uniq)
windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
# Temporary disable the windows job.
# See https://discourse.llvm.org/t/rfc-future-of-windows-pre-commit-ci/76840
#windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
windows_projects=""

# Generate the appropriate pipeline
if [[ "${linux_projects}" != "" ]]; then
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/llvm-project-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ jobs:
lit-tests:
name: Lit Tests
runs-on: ${{ matrix.os }}
container:
image: ${{(startsWith(matrix.os, 'ubuntu') && 'ghcr.io/llvm/ci-ubuntu-22.04:latest') || null}}
volumes:
- /mnt/:/mnt/
strategy:
fail-fast: false
matrix:
Expand All @@ -77,6 +81,7 @@ jobs:
with:
python-version: ${{ inputs.python_version }}
- name: Install Ninja
if: runner.os != 'Linux'
uses: llvm/actions/install-ninja@main
# actions/checkout deletes any existing files in the new git directory,
# so this needs to either run before ccache-action or it has to use
Expand Down Expand Up @@ -108,8 +113,8 @@ jobs:
run: |
if [ "${{ runner.os }}" == "Linux" ]; then
builddir="/mnt/build/"
sudo mkdir -p $builddir
sudo chown `whoami`:`whoami` $builddir
mkdir -p $builddir
extra_cmake_args="-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang"
else
builddir="$(pwd)"/build
fi
Expand All @@ -123,6 +128,7 @@ jobs:
-DLLDB_INCLUDE_TESTS=OFF \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
$extra_cmake_args \
${{ inputs.extra_cmake_args }}
ninja -C "$builddir" '${{ inputs.build_target }}'
Expand Down
45 changes: 19 additions & 26 deletions bolt/lib/Core/DebugData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ template <typename DebugVector, typename ListEntry, typename DebugAddressEntry>
static bool emitWithBase(raw_ostream &OS, const DebugVector &Entries,
DebugAddrWriter &AddrWriter, DWARFUnit &CU,
uint32_t &Index, const ListEntry BaseAddressx,
const ListEntry OffsetPair, const ListEntry EndOfList,
const ListEntry OffsetPair,
const std::function<void(uint32_t)> &Func) {
if (Entries.size() < 2)
return false;
Expand All @@ -241,7 +241,9 @@ static bool emitWithBase(raw_ostream &OS, const DebugVector &Entries,
const DebugAddressEntry &Entry = Entries[Index];
if (Entry.LowPC == 0)
break;
assert(Base <= Entry.LowPC && "Entry base is higher than low PC");
// In case rnglists or loclists are not sorted.
if (Base > Entry.LowPC)
break;
uint32_t StartOffset = Entry.LowPC - Base;
uint32_t EndOffset = Entry.HighPC - Base;
if (encodeULEB128(EndOffset, TempBuffer) > 2)
Expand All @@ -266,8 +268,6 @@ static bool emitWithBase(raw_ostream &OS, const DebugVector &Entries,
encodeULEB128(OffsetEntry.EndOffset, OS);
Func(OffsetEntry.Index);
}
support::endian::write(OS, static_cast<uint8_t>(EndOfList),
llvm::endianness::little);
return true;
}

Expand All @@ -276,19 +276,17 @@ DebugRangeListsSectionWriter::addRanges(DebugAddressRangesVector &Ranges) {
std::lock_guard<std::mutex> Lock(WriterMutex);

RangeEntries.push_back(CurrentOffset);
bool WrittenStartxLength = false;
std::sort(
Ranges.begin(), Ranges.end(),
[](const DebugAddressRange &R1, const DebugAddressRange &R2) -> bool {
return R1.LowPC < R2.LowPC;
});
for (unsigned I = 0; I < Ranges.size();) {
WrittenStartxLength = false;
if (emitWithBase<DebugAddressRangesVector, dwarf::RnglistEntries,
DebugAddressRange>(
*CUBodyStream, Ranges, *AddrWriter, *CU, I,
dwarf::DW_RLE_base_addressx, dwarf::DW_RLE_offset_pair,
dwarf::DW_RLE_end_of_list, [](uint32_t Index) -> void {}))
DebugAddressRange>(*CUBodyStream, Ranges, *AddrWriter, *CU,
I, dwarf::DW_RLE_base_addressx,
dwarf::DW_RLE_offset_pair,
[](uint32_t Index) -> void {}))
continue;

const DebugAddressRange &Range = Ranges[I];
Expand All @@ -299,12 +297,11 @@ DebugRangeListsSectionWriter::addRanges(DebugAddressRangesVector &Ranges) {
encodeULEB128(Index, *CUBodyStream);
encodeULEB128(Range.HighPC - Range.LowPC, *CUBodyStream);
++I;
WrittenStartxLength = true;
}
if (WrittenStartxLength)
support::endian::write(*CUBodyStream,
static_cast<uint8_t>(dwarf::DW_RLE_end_of_list),
llvm::endianness::little);

support::endian::write(*CUBodyStream,
static_cast<uint8_t>(dwarf::DW_RLE_end_of_list),
llvm::endianness::little);
CurrentOffset = CUBodyBuffer->size();
return RangeEntries.size() - 1;
}
Expand Down Expand Up @@ -688,20 +685,18 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo,
}

std::vector<uint64_t> OffsetsArray;
bool WrittenStartxLength = false;
auto writeExpression = [&](uint32_t Index) -> void {
const DebugLocationEntry &Entry = LocList[Index];
encodeULEB128(Entry.Expr.size(), LocBodyStream);
LocBodyStream << StringRef(
reinterpret_cast<const char *>(Entry.Expr.data()), Entry.Expr.size());
};
for (unsigned I = 0; I < LocList.size();) {
WrittenStartxLength = false;
if (emitWithBase<DebugLocationsVector, dwarf::LoclistEntries,
DebugLocationEntry>(
LocBodyStream, LocList, AddrWriter, CU, I,
dwarf::DW_LLE_base_addressx, dwarf::DW_LLE_offset_pair,
dwarf::DW_LLE_end_of_list, writeExpression))
DebugLocationEntry>(LocBodyStream, LocList, AddrWriter, CU,
I, dwarf::DW_LLE_base_addressx,
dwarf::DW_LLE_offset_pair,
writeExpression))
continue;

const DebugLocationEntry &Entry = LocList[I];
Expand All @@ -713,13 +708,11 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo,
encodeULEB128(Entry.HighPC - Entry.LowPC, LocBodyStream);
writeExpression(I);
++I;
WrittenStartxLength = true;
}

if (WrittenStartxLength)
support::endian::write(LocBodyStream,
static_cast<uint8_t>(dwarf::DW_LLE_end_of_list),
llvm::endianness::little);
support::endian::write(LocBodyStream,
static_cast<uint8_t>(dwarf::DW_LLE_end_of_list),
llvm::endianness::little);
}

void DebugLoclistWriter::addList(DIEBuilder &DIEBldr, DIE &Die,
Expand Down
9 changes: 2 additions & 7 deletions bolt/lib/Rewrite/DWARFRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,15 +919,10 @@ void DWARFRewriter::updateUnitDebugInfo(
DIEValue LowPCVal = Die->findAttribute(dwarf::DW_AT_low_pc);
DIEValue HighPCVal = Die->findAttribute(dwarf::DW_AT_high_pc);
if (FunctionRanges.empty()) {
if (LowPCVal && HighPCVal) {
if (LowPCVal && HighPCVal)
FunctionRanges.push_back({0, HighPCVal.getDIEInteger().getValue()});
} else {
// I haven't seen this case, but who knows what other compilers
// generate.
else
FunctionRanges.push_back({0, 1});
errs() << "BOLT-WARNING: [internal-dwarf-error]: subprogram got GCed "
"by the linker, DW_AT_ranges is used\n";
}
}

if (FunctionRanges.size() == 1 && !opts::AlwaysConvertToRanges) {
Expand Down
6 changes: 2 additions & 4 deletions bolt/test/X86/dwarf4-subprogram-single-gc-ranges.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-subprogram-single-gc-ranges-main.s -o %t1.o
# RUN: %clang %cflags %t1.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections &> %t1.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t1.txt
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt > %t1.txt
# RUN: cat %t1.txt | FileCheck --check-prefix=POSTCHECK %s

# This test checks BOLT correctly handles DW_TAG_subprogram with Ranges with single entry, when function was GCed.

# POSTCHECK: BOLT-WARNING: [internal-dwarf-error]: subprogram got GCed by the linker, DW_AT_ranges is used

# POSTCHECK: DW_TAG_subprogram
# POSTCHECK-NEXT: DW_AT_frame_base
# POSTCHECK-NEXT: DW_AT_linkage_name
Expand Down
Loading

0 comments on commit aa5b2f5

Please sign in to comment.