Skip to content

Commit e32bfaa

Browse files
committed
Merge branch 'users/kparzysz/spr/b02-unique' into users/kparzysz/spr/b03-rep1
2 parents 841f10e + edc050c commit e32bfaa

File tree

1,853 files changed

+88033
-43271
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,853 files changed

+88033
-43271
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ linux_projects=$(add-dependencies ${linux_projects_to_test} | sort | uniq)
233233

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

238241
# Generate the appropriate pipeline
239242
if [[ "${linux_projects}" != "" ]]; then

.github/workflows/approved-prs.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/docs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ on:
2828
- 'polly/docs/**'
2929
- 'flang/docs/**'
3030
- 'flang/include/flang/Optimizer/Dialect/FIROps.td'
31+
- '.github/workflows/docs.yml'
3132
pull_request:
3233
paths:
3334
- 'llvm/docs/**'
@@ -45,6 +46,7 @@ on:
4546
- 'polly/docs/**'
4647
- 'flang/docs/**'
4748
- 'flang/include/flang/Optimizer/Dialect/FIROps.td'
49+
- '.github/workflows/docs.yml'
4850

4951
jobs:
5052
check-docs-build:
@@ -162,8 +164,6 @@ jobs:
162164
TZ=UTC ninja -C polly-build docs-polly-html docs-polly-man
163165
- name: Build Flang docs
164166
if: steps.docs-changed-subprojects.outputs.flang_any_changed == 'true'
165-
# TODO(boomanaiden154): Remove the SPHINX_WARNINGS_AS_ERRORS from the
166-
# CMake invocation once the warnings in the flang docs build are fixed.
167167
run: |
168-
cmake -B flang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;mlir;flang" -DLLVM_ENABLE_SPHINX=ON -DSPHINX_WARNINGS_AS_ERRORS=OFF ./llvm
169-
TZ=UTC ninja -C flang-build docs-flang-html docs-flang-man
168+
cmake -B flang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;mlir;flang" -DLLVM_ENABLE_SPHINX=ON ./llvm
169+
TZ=UTC ninja -C flang-build docs-flang-html

.github/workflows/llvm-project-tests.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ jobs:
5858
lit-tests:
5959
name: Lit Tests
6060
runs-on: ${{ matrix.os }}
61+
container:
62+
image: ${{(startsWith(matrix.os, 'ubuntu') && 'ghcr.io/llvm/ci-ubuntu-22.04:latest') || null}}
63+
volumes:
64+
- /mnt/:/mnt/
6165
strategy:
6266
fail-fast: false
6367
matrix:
@@ -77,6 +81,7 @@ jobs:
7781
with:
7882
python-version: ${{ inputs.python_version }}
7983
- name: Install Ninja
84+
if: runner.os != 'Linux'
8085
uses: llvm/actions/install-ninja@main
8186
# actions/checkout deletes any existing files in the new git directory,
8287
# so this needs to either run before ccache-action or it has to use
@@ -108,8 +113,8 @@ jobs:
108113
run: |
109114
if [ "${{ runner.os }}" == "Linux" ]; then
110115
builddir="/mnt/build/"
111-
sudo mkdir -p $builddir
112-
sudo chown `whoami`:`whoami` $builddir
116+
mkdir -p $builddir
117+
extra_cmake_args="-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang"
113118
else
114119
builddir="$(pwd)"/build
115120
fi
@@ -123,6 +128,7 @@ jobs:
123128
-DLLDB_INCLUDE_TESTS=OFF \
124129
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
125130
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
131+
$extra_cmake_args \
126132
${{ inputs.extra_cmake_args }}
127133
ninja -C "$builddir" '${{ inputs.build_target }}'
128134

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ files needed to process intermediate representations and convert them into
1616
object files. Tools include an assembler, disassembler, bitcode analyzer, and
1717
bitcode optimizer.
1818

19-
C-like languages use the [Clang](http://clang.llvm.org/) frontend. This
19+
C-like languages use the [Clang](https://clang.llvm.org/) frontend. This
2020
component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode
2121
-- and from there into object files, using LLVM.
2222

bolt/include/bolt/Profile/BoltAddressTranslation.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <map>
1717
#include <optional>
1818
#include <system_error>
19+
#include <unordered_map>
1920

2021
namespace llvm {
2122
class raw_ostream;
@@ -111,6 +112,9 @@ class BoltAddressTranslation {
111112
/// addresses when aggregating profile
112113
bool enabledFor(llvm::object::ELFObjectFileBase *InputFile) const;
113114

115+
/// Save function and basic block hashes used for metadata dump.
116+
void saveMetadata(BinaryContext &BC);
117+
114118
private:
115119
/// Helper to update \p Map by inserting one or more BAT entries reflecting
116120
/// \p BB for function located at \p FuncAddress. At least one entry will be
@@ -140,6 +144,9 @@ class BoltAddressTranslation {
140144

141145
std::map<uint64_t, MapTy> Maps;
142146

147+
using BBHashMap = std::unordered_map<uint32_t, size_t>;
148+
std::unordered_map<uint64_t, std::pair<size_t, BBHashMap>> FuncHashes;
149+
143150
/// Links outlined cold bocks to their original function
144151
std::map<uint64_t, uint64_t> ColdPartSource;
145152

bolt/lib/Core/DebugData.cpp

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ template <typename DebugVector, typename ListEntry, typename DebugAddressEntry>
230230
static bool emitWithBase(raw_ostream &OS, const DebugVector &Entries,
231231
DebugAddrWriter &AddrWriter, DWARFUnit &CU,
232232
uint32_t &Index, const ListEntry BaseAddressx,
233-
const ListEntry OffsetPair, const ListEntry EndOfList,
233+
const ListEntry OffsetPair,
234234
const std::function<void(uint32_t)> &Func) {
235235
if (Entries.size() < 2)
236236
return false;
@@ -241,7 +241,9 @@ static bool emitWithBase(raw_ostream &OS, const DebugVector &Entries,
241241
const DebugAddressEntry &Entry = Entries[Index];
242242
if (Entry.LowPC == 0)
243243
break;
244-
assert(Base <= Entry.LowPC && "Entry base is higher than low PC");
244+
// In case rnglists or loclists are not sorted.
245+
if (Base > Entry.LowPC)
246+
break;
245247
uint32_t StartOffset = Entry.LowPC - Base;
246248
uint32_t EndOffset = Entry.HighPC - Base;
247249
if (encodeULEB128(EndOffset, TempBuffer) > 2)
@@ -266,8 +268,6 @@ static bool emitWithBase(raw_ostream &OS, const DebugVector &Entries,
266268
encodeULEB128(OffsetEntry.EndOffset, OS);
267269
Func(OffsetEntry.Index);
268270
}
269-
support::endian::write(OS, static_cast<uint8_t>(EndOfList),
270-
llvm::endianness::little);
271271
return true;
272272
}
273273

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

278278
RangeEntries.push_back(CurrentOffset);
279-
bool WrittenStartxLength = false;
280279
std::sort(
281280
Ranges.begin(), Ranges.end(),
282281
[](const DebugAddressRange &R1, const DebugAddressRange &R2) -> bool {
283282
return R1.LowPC < R2.LowPC;
284283
});
285284
for (unsigned I = 0; I < Ranges.size();) {
286-
WrittenStartxLength = false;
287285
if (emitWithBase<DebugAddressRangesVector, dwarf::RnglistEntries,
288-
DebugAddressRange>(
289-
*CUBodyStream, Ranges, *AddrWriter, *CU, I,
290-
dwarf::DW_RLE_base_addressx, dwarf::DW_RLE_offset_pair,
291-
dwarf::DW_RLE_end_of_list, [](uint32_t Index) -> void {}))
286+
DebugAddressRange>(*CUBodyStream, Ranges, *AddrWriter, *CU,
287+
I, dwarf::DW_RLE_base_addressx,
288+
dwarf::DW_RLE_offset_pair,
289+
[](uint32_t Index) -> void {}))
292290
continue;
293291

294292
const DebugAddressRange &Range = Ranges[I];
@@ -299,12 +297,11 @@ DebugRangeListsSectionWriter::addRanges(DebugAddressRangesVector &Ranges) {
299297
encodeULEB128(Index, *CUBodyStream);
300298
encodeULEB128(Range.HighPC - Range.LowPC, *CUBodyStream);
301299
++I;
302-
WrittenStartxLength = true;
303300
}
304-
if (WrittenStartxLength)
305-
support::endian::write(*CUBodyStream,
306-
static_cast<uint8_t>(dwarf::DW_RLE_end_of_list),
307-
llvm::endianness::little);
301+
302+
support::endian::write(*CUBodyStream,
303+
static_cast<uint8_t>(dwarf::DW_RLE_end_of_list),
304+
llvm::endianness::little);
308305
CurrentOffset = CUBodyBuffer->size();
309306
return RangeEntries.size() - 1;
310307
}
@@ -688,20 +685,18 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo,
688685
}
689686

690687
std::vector<uint64_t> OffsetsArray;
691-
bool WrittenStartxLength = false;
692688
auto writeExpression = [&](uint32_t Index) -> void {
693689
const DebugLocationEntry &Entry = LocList[Index];
694690
encodeULEB128(Entry.Expr.size(), LocBodyStream);
695691
LocBodyStream << StringRef(
696692
reinterpret_cast<const char *>(Entry.Expr.data()), Entry.Expr.size());
697693
};
698694
for (unsigned I = 0; I < LocList.size();) {
699-
WrittenStartxLength = false;
700695
if (emitWithBase<DebugLocationsVector, dwarf::LoclistEntries,
701-
DebugLocationEntry>(
702-
LocBodyStream, LocList, AddrWriter, CU, I,
703-
dwarf::DW_LLE_base_addressx, dwarf::DW_LLE_offset_pair,
704-
dwarf::DW_LLE_end_of_list, writeExpression))
696+
DebugLocationEntry>(LocBodyStream, LocList, AddrWriter, CU,
697+
I, dwarf::DW_LLE_base_addressx,
698+
dwarf::DW_LLE_offset_pair,
699+
writeExpression))
705700
continue;
706701

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

719-
if (WrittenStartxLength)
720-
support::endian::write(LocBodyStream,
721-
static_cast<uint8_t>(dwarf::DW_LLE_end_of_list),
722-
llvm::endianness::little);
713+
support::endian::write(LocBodyStream,
714+
static_cast<uint8_t>(dwarf::DW_LLE_end_of_list),
715+
llvm::endianness::little);
723716
}
724717

725718
void DebugLoclistWriter::addList(DIEBuilder &DIEBldr, DIE &Die,

bolt/lib/Profile/BoltAddressTranslation.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,5 +424,20 @@ bool BoltAddressTranslation::enabledFor(
424424
}
425425
return false;
426426
}
427+
428+
void BoltAddressTranslation::saveMetadata(BinaryContext &BC) {
429+
for (BinaryFunction &BF : llvm::make_second_range(BC.getBinaryFunctions())) {
430+
// We don't need a translation table if the body of the function hasn't
431+
// changed
432+
if (BF.isIgnored() || (!BC.HasRelocations && !BF.isSimple()))
433+
continue;
434+
// Prepare function and block hashes
435+
FuncHashes[BF.getAddress()].first = BF.computeHash();
436+
BF.computeBlockHashes();
437+
for (const BinaryBasicBlock &BB : BF)
438+
FuncHashes[BF.getAddress()].second.emplace(BB.getInputOffset(),
439+
BB.getHash());
440+
}
441+
}
427442
} // namespace bolt
428443
} // namespace llvm

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -720,12 +720,7 @@ void DWARFRewriter::updateDebugInfo() {
720720
TempRangesSectionWriter = RangeListsWritersByCU[*DWOId].get();
721721
} else {
722722
RangesBase = RangesSectionWriter->getSectionOffset();
723-
// For DWARF5 there is now .debug_rnglists.dwo, so don't need to
724-
// update rnglists base.
725-
if (RangesBase) {
726-
DwoRangesBase[*DWOId] = *RangesBase;
727-
setDwoRangesBase(*DWOId, *RangesBase);
728-
}
723+
setDwoRangesBase(*DWOId, *RangesBase);
729724
}
730725

731726
updateUnitDebugInfo(*(*SplitCU), DWODIEBuilder, DebugLocDWoWriter,
@@ -873,7 +868,9 @@ void DWARFRewriter::updateUnitDebugInfo(
873868
OutputRanges.push_back({0, 0});
874869
const uint64_t RangesSectionOffset =
875870
RangesSectionWriter.addRanges(OutputRanges);
876-
if (!Unit.isDWOUnit())
871+
// Don't emit the zero low_pc arange.
872+
if (!Unit.isDWOUnit() && !OutputRanges.empty() &&
873+
OutputRanges.back().LowPC)
877874
ARangesSectionWriter->addCURanges(Unit.getOffset(),
878875
std::move(OutputRanges));
879876
updateDWARFObjectAddressRanges(Unit, DIEBldr, *Die, RangesSectionOffset,
@@ -919,15 +916,10 @@ void DWARFRewriter::updateUnitDebugInfo(
919916
DIEValue LowPCVal = Die->findAttribute(dwarf::DW_AT_low_pc);
920917
DIEValue HighPCVal = Die->findAttribute(dwarf::DW_AT_high_pc);
921918
if (FunctionRanges.empty()) {
922-
if (LowPCVal && HighPCVal) {
919+
if (LowPCVal && HighPCVal)
923920
FunctionRanges.push_back({0, HighPCVal.getDIEInteger().getValue()});
924-
} else {
925-
// I haven't seen this case, but who knows what other compilers
926-
// generate.
921+
else
927922
FunctionRanges.push_back({0, 1});
928-
errs() << "BOLT-WARNING: [internal-dwarf-error]: subprogram got GCed "
929-
"by the linker, DW_AT_ranges is used\n";
930-
}
931923
}
932924

933925
if (FunctionRanges.size() == 1 && !opts::AlwaysConvertToRanges) {

0 commit comments

Comments
 (0)