Skip to content

Commit

Permalink
Merge branch 'llvm:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinanto authored Feb 28, 2024
2 parents 8fe8738 + 07d8a45 commit c480120
Show file tree
Hide file tree
Showing 2,984 changed files with 127,878 additions and 62,412 deletions.
5 changes: 1 addition & 4 deletions .ci/generate-buildkite-pipeline-premerge
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,7 @@ 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)
# 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=""
windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)

# Generate the appropriate pipeline
if [[ "${linux_projects}" != "" ]]; then
Expand Down
11 changes: 10 additions & 1 deletion .ci/monolithic-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ targets="${2}"

echo "--- cmake"
pip install -q -r ${MONOREPO_ROOT}/mlir/python/requirements.txt

# The CMAKE_*_LINKER_FLAGS to disable the manifest come from research
# on fixing a build reliability issue on the build server, please
# see https://github.com/llvm/llvm-project/pull/82393 and
# https://discourse.llvm.org/t/rfc-future-of-windows-pre-commit-ci/76840/40
# for further information.
cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \
-D LLVM_ENABLE_PROJECTS="${projects}" \
-G Ninja \
Expand All @@ -49,7 +55,10 @@ cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \
-D COMPILER_RT_BUILD_ORC=OFF \
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
-D MLIR_ENABLE_BINDINGS_PYTHON=ON
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
-D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \
-D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \
-D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO"

echo "--- ninja"
# Targets are not escaped as they are passed as separate arguments.
Expand Down
20 changes: 20 additions & 0 deletions .github/new-prs-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,26 @@ backend:PowerPC:
- clang/lib/Driver/ToolChains/Arch/PPC.*
- clang/test/CodeGen/PowerPC/**

backend:SystemZ:
- llvm/include/llvm/BinaryFormat/ELFRelocs/SystemZ*
- llvm/include/llvm/BinaryFormat/GOFF.h
- llvm/include/llvm/IR/IntrinsicsSystemZ.td
- llvm/lib/Target/SystemZ/**
- llvm/test/Analysis/**/SystemZ/**
- llvm/test/CodeGen/SystemZ/**
- llvm/test/DebugInfo/SystemZ/**
- llvm/test/ExecutionEngine/**/SystemZ/**
- llvm/test/MC/Disassembler/SystemZ/**
- llvm/test/MC/GOFF/**
- llvm/test/MC/SystemZ/**
- llvm/test/Transforms/**/SystemZ/**
- clang/include/clang/Basic/BuiltinsSystemZ.*
- clang/lib/Basic/Targets/SystemZ.*
- clang/lib/CodeGen/Targets/SystemZ.cpp
- clang/lib/Driver/ToolChains/ZOS*
- clang/lib/Driver/ToolChains/Arch/SystemZ.*
- clang/test/CodeGen/SystemZ/**

third-party:unittests:
- third-party/unittests/**

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
name: Create a New Release
runs-on: ubuntu-latest
needs: validate-tag

steps:
- name: Install Dependencies
run: |
Expand All @@ -40,8 +41,9 @@ jobs:
- name: Create Release
env:
GITHUB_TOKEN: ${{ github.token }}
USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
run: |
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --release ${{ needs.validate-tag.outputs.release-version }} --user ${{ github.actor }} create
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --release ${{ needs.validate-tag.outputs.release-version }} --user ${{ github.actor }} --user-token "$USER_TOKEN" create
release-documentation:
name: Build and Upload Release Documentation
needs:
Expand Down
4 changes: 4 additions & 0 deletions bolt/include/bolt/Core/BinaryContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,10 @@ class BinaryContext {
return getUniqueSectionByName(".gdb_index");
}

ErrorOr<BinarySection &> getDebugNamesSection() const {
return getUniqueSectionByName(".debug_names");
}

/// @}

/// Register \p TargetFunction as a fragment of \p Function if checks pass:
Expand Down
20 changes: 13 additions & 7 deletions bolt/include/bolt/Core/BinarySection.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ class BinarySection {
Alignment = NewAlignment;
ELFType = NewELFType;
ELFFlags = NewELFFlags;
OutputSize = NewSize;
OutputContents = StringRef(reinterpret_cast<const char *>(NewData),
NewData ? NewSize : 0);
IsFinalized = true;
updateContents(NewData, NewSize);
}

public:
Expand Down Expand Up @@ -484,9 +481,18 @@ class BinarySection {
void flushPendingRelocations(raw_pwrite_stream &OS,
SymbolResolverFuncTy Resolver);

/// Change contents of the section.
void updateContents(const uint8_t *Data, size_t NewSize) {
OutputContents = StringRef(reinterpret_cast<const char *>(Data), NewSize);
/// Change contents of the section. Unless the section has a valid SectionID,
/// the memory passed in \p NewData will be managed by the instance of
/// BinarySection.
void updateContents(const uint8_t *NewData, size_t NewSize) {
if (getOutputData() && !hasValidSectionID() &&
(!hasSectionRef() ||
OutputContents.data() != getContentsOrQuit(Section).data())) {
delete[] getOutputData();
}

OutputContents = StringRef(reinterpret_cast<const char *>(NewData),
NewData ? NewSize : 0);
OutputSize = NewSize;
IsFinalized = true;
}
Expand Down
15 changes: 11 additions & 4 deletions bolt/include/bolt/Core/DIEBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define BOLT_CORE_DIE_BUILDER_H

#include "bolt/Core/BinaryContext.h"
#include "bolt/Core/DebugNames.h"
#include "llvm/CodeGen/DIE.h"
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
Expand Down Expand Up @@ -124,9 +125,10 @@ class DIEBuilder {
std::vector<std::unique_ptr<DIEAbbrev>> Abbreviations;
BinaryContext &BC;
DWARFContext *DwarfContext{nullptr};
bool IsDWO{false};
DWARFUnit *SkeletonCU{nullptr};
uint64_t UnitSize{0};
llvm::DenseSet<uint64_t> AllProcessed;
DWARF5AcceleratorTable &DebugNamesTable;

/// Returns current state of the DIEBuilder
State &getState() { return *BuilderState.get(); }
Expand Down Expand Up @@ -206,8 +208,8 @@ class DIEBuilder {
/// Update references once the layout is finalized.
void updateReferences();

/// Update the Offset and Size of DIE.
uint32_t computeDIEOffset(const DWARFUnit &CU, DIE &Die, uint32_t &CurOffset);
/// Update the Offset and Size of DIE, populate DebugNames table.
uint32_t finalizeDIEs(DWARFUnit &CU, DIE &Die, uint32_t &CurOffset);

void registerUnit(DWARFUnit &DU, bool NeedSort);

Expand Down Expand Up @@ -264,8 +266,13 @@ class DIEBuilder {
/// current Section.
DIE *constructDIEFast(DWARFDie &DDie, DWARFUnit &U, uint32_t UnitId);

/// Returns true if this DIEBUilder is for DWO Unit.
bool isDWO() const { return SkeletonCU != nullptr; }

public:
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext, bool IsDWO = false);
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
DWARF5AcceleratorTable &DebugNamesTable,
DWARFUnit *SkeletonCU = nullptr);

/// Returns enum to what we are currently processing.
ProcessingType getCurrentProcessingState() { return getState().Type; }
Expand Down
17 changes: 13 additions & 4 deletions bolt/include/bolt/Core/DebugData.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ class DebugStrOffsetsWriter {
/// Update Str offset in .debug_str in .debug_str_offsets.
void updateAddressMap(uint32_t Index, uint32_t Address);

/// Get offset for given index in original .debug_str_offsets section.
uint64_t getOffset(uint32_t Index) const { return StrOffsets[Index]; }
/// Writes out current sections entry into .debug_str_offsets.
void finalizeSection(DWARFUnit &Unit, DIEBuilder &DIEBldr);

Expand All @@ -450,14 +452,20 @@ class DebugStrOffsetsWriter {
return std::move(StrOffsetsBuffer);
}

private:
/// Initializes Buffer and Stream.
void initialize(DWARFUnit &Unit);

/// Clear data.
void clear() {
IndexToAddressMap.clear();
StrOffsets.clear();
}

private:
std::unique_ptr<DebugStrOffsetsBufferVector> StrOffsetsBuffer;
std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
std::map<uint32_t, uint32_t> IndexToAddressMap;
std::vector<uint32_t> StrOffsets;
SmallVector<uint32_t, 5> StrOffsets;
std::unordered_map<uint64_t, uint64_t> ProcessedBaseOffsets;
bool StrOffsetSectionWasModified = false;
};
Expand All @@ -478,11 +486,12 @@ class DebugStrWriter {
/// Returns False if no strings were added to .debug_str.
bool isInitialized() const { return !StrBuffer->empty(); }

/// Initializes Buffer and Stream.
void initialize();

private:
/// Mutex used for parallel processing of debug info.
std::mutex WriterMutex;
/// Initializes Buffer and Stream.
void initialize();
/// Creates internal data structures.
void create();
std::unique_ptr<DebugStrBufferVector> StrBuffer;
Expand Down
172 changes: 172 additions & 0 deletions bolt/include/bolt/Core/DebugNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
//===- bolt/Core/DebugNames.h - Debug names support ---*- 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
//
//===----------------------------------------------------------------------===//
//
// This file contains declaration of classes required for generation of
// .debug_names section.
//
//===----------------------------------------------------------------------===//

#ifndef BOLT_CORE_DEBUG_NAMES_H
#define BOLT_CORE_DEBUG_NAMES_H

#include "DebugData.h"
#include "llvm/CodeGen/AccelTable.h"

namespace llvm {
namespace bolt {
class BOLTDWARF5AccelTableData : public DWARF5AccelTableData {
public:
BOLTDWARF5AccelTableData(const uint64_t DieOffset,
const std::optional<uint64_t> DefiningParentOffset,
const unsigned DieTag, const unsigned UnitID,
const bool IsTU,
const std::optional<unsigned> SecondUnitID)
: DWARF5AccelTableData(DieOffset, DefiningParentOffset, DieTag, UnitID,
IsTU),
SecondUnitID(SecondUnitID) {}

uint64_t getDieOffset() const { return DWARF5AccelTableData::getDieOffset(); }
unsigned getDieTag() const { return DWARF5AccelTableData::getDieTag(); }
unsigned getUnitID() const { return DWARF5AccelTableData::getUnitID(); }
bool isTU() const { return DWARF5AccelTableData::isTU(); }
std::optional<unsigned> getSecondUnitID() const { return SecondUnitID; }

private:
std::optional<unsigned> SecondUnitID;
};

class DWARF5AcceleratorTable {
public:
DWARF5AcceleratorTable(const bool CreateDebugNames, BinaryContext &BC,
DebugStrWriter &MainBinaryStrWriter);
~DWARF5AcceleratorTable() {
for (DebugNamesAbbrev *Abbrev : AbbreviationsVector)
Abbrev->~DebugNamesAbbrev();
}
/// Add DWARF5 Accelerator table entry.
/// Input is DWARFUnit being processed, DIE that belongs to it, and potential
/// SkeletonCU if the Unit comes from a DWO section.
void addAccelTableEntry(DWARFUnit &Unit, const DIE &Die,
const std::optional<uint64_t> &DWOID);
/// Set current unit being processed.
void setCurrentUnit(DWARFUnit &Unit, const uint64_t UnitStartOffset);
/// Emit Accelerator table.
void emitAccelTable();
/// Returns true if the table was crated.
bool isCreated() const { return NeedToCreate; }
/// Returns buffer containing the accelerator table.
std::unique_ptr<DebugBufferVector> releaseBuffer() {
return std::move(FullTableBuffer);
}

private:
BinaryContext &BC;
bool NeedToCreate = false;
BumpPtrAllocator Allocator;
DebugStrWriter &MainBinaryStrWriter;
StringRef StrSection;
uint64_t CurrentUnitOffset = 0;
const DWARFUnit *CurrentUnit = nullptr;
std::unordered_map<uint32_t, uint32_t> AbbrevTagToIndexMap;

/// Represents a group of entries with identical name (and hence, hash value).
struct HashData {
uint64_t StrOffset;
uint32_t HashValue;
uint32_t EntryOffset;
std::vector<BOLTDWARF5AccelTableData *> Values;
};
using HashList = std::vector<HashData *>;
using BucketList = std::vector<HashList>;
/// Contains all the offsets of CUs.
SmallVector<uint32_t, 1> CUList;
/// Contains all the offsets of local TUs.
SmallVector<uint32_t, 1> LocalTUList;
/// Contains all the type hashes for split dwarf TUs.
SmallVector<uint64_t, 1> ForeignTUList;
using StringEntries =
MapVector<std::string, HashData, llvm::StringMap<unsigned>>;
StringEntries Entries;
/// FoldingSet that uniques the abbreviations.
FoldingSet<DebugNamesAbbrev> AbbreviationsSet;
/// Vector containing DebugNames abbreviations for iteration in order.
SmallVector<DebugNamesAbbrev *, 5> AbbreviationsVector;
/// The bump allocator to use when creating DIEAbbrev objects in the uniqued
/// storage container.
BumpPtrAllocator Alloc;
uint32_t BucketCount = 0;
uint32_t UniqueHashCount = 0;
uint32_t AbbrevTableSize = 0;
uint32_t CUIndexEncodingSize = 4;
uint32_t TUIndexEncodingSize = 4;
uint32_t AugmentationStringSize = 0;
dwarf::Form CUIndexForm = dwarf::DW_FORM_data4;
dwarf::Form TUIndexForm = dwarf::DW_FORM_data4;

BucketList Buckets;

std::unique_ptr<DebugBufferVector> FullTableBuffer;
std::unique_ptr<raw_svector_ostream> FullTableStream;
std::unique_ptr<DebugBufferVector> StrBuffer;
std::unique_ptr<raw_svector_ostream> StrStream;
std::unique_ptr<DebugBufferVector> EntriesBuffer;
std::unique_ptr<raw_svector_ostream> Entriestream;
std::unique_ptr<DebugBufferVector> AugStringBuffer;
std::unique_ptr<raw_svector_ostream> AugStringtream;
llvm::DenseMap<llvm::hash_code, uint64_t> StrCacheToOffsetMap;
// Contains DWO ID to CUList Index.
llvm::DenseMap<uint64_t, uint32_t> CUOffsetsToPatch;
/// Adds Unit to either CUList, LocalTUList or ForeignTUList.
/// Input Unit being processed, and DWO ID if Unit is being processed comes
/// from a DWO section.
void addUnit(DWARFUnit &Unit, const std::optional<uint64_t> &DWOID);
/// Returns number of buckets in .debug_name table.
ArrayRef<HashList> getBuckets() const { return Buckets; }
/// Get encoding for a given attribute.
std::optional<DWARF5AccelTable::UnitIndexAndEncoding>
getIndexForEntry(const BOLTDWARF5AccelTableData &Value) const;
/// Get encoding for a given attribute for second index.
/// Returns nullopt if there is no second index.
std::optional<DWARF5AccelTable::UnitIndexAndEncoding>
getSecondIndexForEntry(const BOLTDWARF5AccelTableData &Value) const;
/// Uniquify Entries.
void finalize();
/// Computes bucket count.
void computeBucketCount();
/// Populate Abbreviations Map.
void populateAbbrevsMap();
/// Write Entries.
void writeEntries();
/// Write an Entry.
void writeEntry(const BOLTDWARF5AccelTableData &Entry);
/// Write augmentation_string for BOLT.
void writeAugmentationString();
/// Emit out Header for DWARF5 Accelerator table.
void emitHeader() const;
/// Emit out CU list.
void emitCUList() const;
/// Emit out TU List. Combination of LocalTUList and ForeignTUList.
void emitTUList() const;
/// Emit buckets.
void emitBuckets() const;
/// Emit hashes for hash table.
void emitHashes() const;
/// Emit string offsets for hash table.
void emitStringOffsets() const;
/// Emit Entry Offsets for hash table.
void emitOffsets() const;
/// Emit abbreviation table.
void emitAbbrevs();
/// Emit entries.
void emitData();
/// Emit augmentation string.
void emitAugmentationString() const;
};
} // namespace bolt
} // namespace llvm
#endif
Loading

0 comments on commit c480120

Please sign in to comment.