Skip to content

Commit

Permalink
Merge pull request #287 from sx-aurora-dev/feature/merge-upstream-202…
Browse files Browse the repository at this point in the history
…31019

Feature/merge upstream 20231019
  • Loading branch information
kaz7 authored Jan 24, 2024
2 parents 02954b3 + f35f990 commit bbf4055
Show file tree
Hide file tree
Showing 2,990 changed files with 181,178 additions and 64,036 deletions.
5 changes: 4 additions & 1 deletion .ci/generate-buildkite-pipeline-premerge
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ set -eu
set -o pipefail

# Environment variables script works with:

# Fetch origin/main to have an up to date merge base for main...HEAD diff.
git fetch origin main:main
# List of files affected by this commit
: ${MODIFIED_FILES:=$(git diff --name-only HEAD~1)}
: ${MODIFIED_FILES:=$(git diff --name-only main...HEAD)}
# Filter rules for generic windows tests
: ${WINDOWS_AGENTS:='{"queue": "windows"}'}
# Filter rules for generic linux tests
Expand Down
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@
/clang/test/CXX/drs/ @Endilll
/clang/www/cxx_dr_status.html @Endilll
/clang/www/make_cxx_dr_status @Endilll

/lldb/ @JDevlieghere
32 changes: 32 additions & 0 deletions .github/new-prs-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -794,3 +794,35 @@ llvm:binary-utilities:
- llvm/tools/llvm-size/**
- llvm/tools/llvm-strings/**
- llvm/tools/llvm-symbolizer/**

clang:openmp:
- clang/include/clang/Basic/OpenMP*
- clang/include/clang/AST/OpenMPClause.h
- clang/include/clang/AST/DeclOpenMP.h
- clang/include/clang/AST/ExprOpenMP.h
- clang/include/clang/AST/StmtOpenMP.h
- clang/lib/AST/DeclOpenMP.cpp
- clang/lib/AST/OpenMPClause.cpp
- clang/lib/AST/StmtOpenMP.cpp
- clang/lib/Headers/openmp_wrappers/**
- clang/lib/Parse/ParseOpenMP.cpp
- clang/lib/Basic/OpenMPKinds.cpp
- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
- clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
- clang/lib/CodeGen/CgStmtOpenMP.cpp
- clang/lib/CodeGen/CGOpenMP*
- clang/lib/Sema/SemaOpenMP.cpp
- clang/test/OpenMP/**
- clang/test/AST/ast-dump-openmp-*
- llvm/lib/Frontend/OpenMP/**
- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
- llvm/include/llvm/Frontend/OpenMP/**
- llvm/include/llvm/Transforms/IPO/OpenMPOpt.h
- llvm/unittests/Frontend/OpenMP*
- llvm/test/Transforms/OpenMP/**

openmp:libomp:
- any: ['openmp/**', '!openmp/libomptarget/**']

openmp:libomptarget:
- any: ['openmp/**', '!openmp/runtime/**']
63 changes: 63 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# LLVM Documentation CI
# 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

name: "Test documentation build"

permissions:
contents: read

on:
push:
branches:
- 'main'
paths:
- 'llvm/docs/**'
- 'clang/docs/**'
pull_request:
paths:
- 'llvm/docs/**'
- 'clang/docs/**'

jobs:
check-docs-build:
name: "Test documentation build"
runs-on: ubuntu-latest
steps:
- name: Fetch LLVM sources
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Python env
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: 'llvm/docs/requirements.txt'
- name: Install python dependencies
run: pip install -r llvm/docs/requirements.txt
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build
- name: Get subprojects that have doc changes
id: docs-changed-subprojects
uses: tj-actions/changed-files@v39
with:
files_yaml: |
llvm:
- 'llvm/docs/**'
clang:
- 'clang/docs/**'
- name: Build LLVM docs
if: steps.docs-changed-subprojects.outputs.llvm_any_changed == 'true'
run: |
cmake -B llvm-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_SPHINX=ON -DSPHINX_OUTPUT_HTML=ON -DSPHINX_OUTPUT_MAN=ON ./llvm
TZ=UTC ninja -C llvm-build docs-llvm-html docs-llvm-man
- name: Build Clang docs
if: steps.docs-changed-subprojects.outputs.clang_any_changed == 'true'
run: |
cmake -B clang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_SPHINX=ON -DSPHINX_OUTPUT_HTML=ON -DSPHINX_OUTPUT_MAN=ON ./llvm
TZ=UTC ninja -C clang-build docs-clang-html docs-clang-man
21 changes: 21 additions & 0 deletions .github/workflows/libcxx-check-generated-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Check libc++ generated files"
on:
pull_request:
paths:
- 'libcxx/**'

jobs:
check_generated_files:
runs-on: ubuntu-latest
steps:
- name: Fetch LLVM sources
uses: actions/checkout@v4

- name: Install dependencies
uses: aminya/setup-cpp@v1
with:
clangformat: 17.0.1
ninja: true

- name: Check generated files
run: libcxx/utils/ci/run-buildbot check-generated-output
4 changes: 3 additions & 1 deletion .github/workflows/release-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,18 @@ jobs:
run: |
cd llvm/utils/lit
# Remove 'dev' suffix from lit version.
sed -i "s/ + 'dev'//g" lit/__init__.py
sed -i 's/ + "dev"//g' lit/__init__.py
python3 setup.py sdist
- name: Upload lit to test.pypi.org
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.LLVM_LIT_TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
packages-dir: llvm/utils/lit/dist/

- name: Upload lit to pypi.org
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.LLVM_LIT_PYPI_API_TOKEN }}
packages-dir: llvm/utils/lit/dist/
21 changes: 17 additions & 4 deletions bolt/include/bolt/Core/BinaryFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@ class BinaryFunction {
static constexpr uint64_t COUNT_NO_PROFILE =
BinaryBasicBlock::COUNT_NO_PROFILE;

/// We have to use at least 2-byte alignment for functions because of C++ ABI.
static constexpr unsigned MinAlign = 2;

static const char TimerGroupName[];
static const char TimerGroupDesc[];

Expand Down Expand Up @@ -1720,8 +1717,24 @@ class BinaryFunction {
return *this;
}

Align getAlign() const { return Align(Alignment); }
uint16_t getMinAlignment() const {
// Align data in code BFs minimum to CI alignment
if (!size() && hasIslandsInfo())
return getConstantIslandAlignment();

// Minimal code alignment on AArch64 and RISCV is 4
if (BC.isAArch64() || BC.isRISCV())
return 4;

// We have to use at least 2-byte alignment for functions because
// of C++ ABI.
return 2;
}

Align getMinAlign() const { return Align(getMinAlignment()); }

uint16_t getAlignment() const { return Alignment; }
Align getAlign() const { return Align(getAlignment()); }

BinaryFunction &setMaxAlignmentBytes(uint16_t MaxAlignBytes) {
MaxAlignmentBytes = MaxAlignBytes;
Expand Down
1 change: 1 addition & 0 deletions bolt/include/bolt/Core/MCPlus.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class MCAnnotation {
kTailCall, /// Tail call.
kConditionalTailCall, /// CTC.
kOffset, /// Offset in the function.
kLabel, /// MCSymbol pointing to this instruction.
kGeneric /// First generic annotation.
};

Expand Down
21 changes: 16 additions & 5 deletions bolt/include/bolt/Core/MCPlusBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class MCPlusBuilder {
const MCInstrAnalysis *Analysis;
const MCInstrInfo *Info;
const MCRegisterInfo *RegInfo;
const MCSubtargetInfo *STI;

/// Map annotation name into an annotation index.
StringMap<uint64_t> AnnotationNameIndexMap;
Expand Down Expand Up @@ -331,8 +332,8 @@ class MCPlusBuilder {

public:
MCPlusBuilder(const MCInstrAnalysis *Analysis, const MCInstrInfo *Info,
const MCRegisterInfo *RegInfo)
: Analysis(Analysis), Info(Info), RegInfo(RegInfo) {
const MCRegisterInfo *RegInfo, const MCSubtargetInfo *STI)
: Analysis(Analysis), Info(Info), RegInfo(RegInfo), STI(STI) {
// Initialize the default annotation allocator with id 0
AnnotationAllocators.emplace(0, AnnotationAllocator());
MaxAllocatorId++;
Expand Down Expand Up @@ -1179,6 +1180,13 @@ class MCPlusBuilder {
/// Remove offset annotation.
bool clearOffset(MCInst &Inst);

/// Return the label of \p Inst, if available.
std::optional<MCSymbol *> getLabel(const MCInst &Inst) const;

/// Set the label of \p Inst. This label will be emitted right before \p Inst
/// is emitted to MCStreamer.
bool setLabel(MCInst &Inst, MCSymbol *Label, AllocatorIdTy AllocatorId = 0);

/// Return MCSymbol that represents a target of this instruction at a given
/// operand number \p OpNum. If there's no symbol associated with
/// the operand - return nullptr.
Expand Down Expand Up @@ -2079,15 +2087,18 @@ class MCPlusBuilder {

MCPlusBuilder *createX86MCPlusBuilder(const MCInstrAnalysis *,
const MCInstrInfo *,
const MCRegisterInfo *);
const MCRegisterInfo *,
const MCSubtargetInfo *);

MCPlusBuilder *createAArch64MCPlusBuilder(const MCInstrAnalysis *,
const MCInstrInfo *,
const MCRegisterInfo *);
const MCRegisterInfo *,
const MCSubtargetInfo *);

MCPlusBuilder *createRISCVMCPlusBuilder(const MCInstrAnalysis *,
const MCInstrInfo *,
const MCRegisterInfo *);
const MCRegisterInfo *,
const MCSubtargetInfo *);

} // namespace bolt
} // namespace llvm
Expand Down
4 changes: 4 additions & 0 deletions bolt/include/bolt/Core/Relocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ struct Relocation {
/// Return true if relocation type is for thread local storage.
static bool isTLS(uint64_t Type);

/// Return true of relocation type is for referencing a specific instruction
/// (as opposed to a function, basic block, etc).
static bool isInstructionReference(uint64_t Type);

/// Return code for a NONE relocation
static uint64_t getNone();

Expand Down
3 changes: 2 additions & 1 deletion bolt/include/bolt/Rewrite/RewriteInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ class RewriteInstance {
MCPlusBuilder *createMCPlusBuilder(const Triple::ArchType Arch,
const MCInstrAnalysis *Analysis,
const MCInstrInfo *Info,
const MCRegisterInfo *RegInfo);
const MCRegisterInfo *RegInfo,
const MCSubtargetInfo *STI);

} // namespace bolt
} // namespace llvm
Expand Down
6 changes: 6 additions & 0 deletions bolt/lib/Core/BinaryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1803,6 +1803,10 @@ MarkerSymType BinaryContext::getMarkerType(const SymbolRef &Symbol) const {
if (*NameOrError == "$x" || NameOrError->startswith("$x."))
return MarkerSymType::CODE;

// $x<ISA>
if (isRISCV() && NameOrError->startswith("$x"))
return MarkerSymType::CODE;

if (*NameOrError == "$d" || NameOrError->startswith("$d."))
return MarkerSymType::DATA;

Expand Down Expand Up @@ -1888,6 +1892,8 @@ void BinaryContext::printInstruction(raw_ostream &OS, const MCInst &Instruction,
}
if (std::optional<uint32_t> Offset = MIB->getOffset(Instruction))
OS << " # Offset: " << *Offset;
if (auto Label = MIB->getLabel(Instruction))
OS << " # Label: " << **Label;

MIB->printAnnotations(Instruction, OS);

Expand Down
5 changes: 4 additions & 1 deletion bolt/lib/Core/BinaryEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function,
// tentative layout.
Section->ensureMinAlignment(Align(opts::AlignFunctions));

Streamer.emitCodeAlignment(Align(BinaryFunction::MinAlign), &*BC.STI);
Streamer.emitCodeAlignment(Function.getMinAlign(), &*BC.STI);
uint16_t MaxAlignBytes = FF.isSplitFragment()
? Function.getMaxColdAlignmentBytes()
: Function.getMaxAlignmentBytes();
Expand Down Expand Up @@ -498,6 +498,9 @@ void BinaryEmitter::emitFunctionBody(BinaryFunction &BF, FunctionFragment &FF,
BB->getLocSyms().emplace_back(Offset, LocSym);
}

if (auto Label = BC.MIB->getLabel(Instr))
Streamer.emitLabel(*Label);

Streamer.emitInstruction(Instr, *BC.STI);
LastIsPrefix = BC.MIB->isPrefix(Instr);
}
Expand Down
34 changes: 30 additions & 4 deletions bolt/lib/Core/BinaryFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ bool shouldPrint(const BinaryFunction &Function) {
namespace llvm {
namespace bolt {

constexpr unsigned BinaryFunction::MinAlign;

template <typename R> static bool emptyRange(const R &Range) {
return Range.begin() == Range.end();
}
Expand Down Expand Up @@ -1173,6 +1171,13 @@ bool BinaryFunction::disassemble() {
// basic block.
Labels[0] = Ctx->createNamedTempSymbol("BB0");

// Map offsets in the function to a label that should always point to the
// corresponding instruction. This is used for labels that shouldn't point to
// the start of a basic block but always to a specific instruction. This is
// used, for example, on RISC-V where %pcrel_lo relocations point to the
// corresponding %pcrel_hi.
LabelsMapType InstructionLabels;

uint64_t Size = 0; // instruction size
for (uint64_t Offset = 0; Offset < getSize(); Offset += Size) {
MCInst Instruction;
Expand Down Expand Up @@ -1329,9 +1334,23 @@ bool BinaryFunction::disassemble() {
ItrE = Relocations.lower_bound(Offset + Size);
Itr != ItrE; ++Itr) {
const Relocation &Relocation = Itr->second;
MCSymbol *Symbol = Relocation.Symbol;

if (Relocation::isInstructionReference(Relocation.Type)) {
uint64_t RefOffset = Relocation.Value - getAddress();
LabelsMapType::iterator LI = InstructionLabels.find(RefOffset);

if (LI == InstructionLabels.end()) {
Symbol = BC.Ctx->createNamedTempSymbol();
InstructionLabels.emplace(RefOffset, Symbol);
} else {
Symbol = LI->second;
}
}

int64_t Value = Relocation.Value;
const bool Result = BC.MIB->replaceImmWithSymbolRef(
Instruction, Relocation.Symbol, Relocation.Addend, Ctx.get(), Value,
Instruction, Symbol, Relocation.Addend, Ctx.get(), Value,
Relocation.Type);
(void)Result;
assert(Result && "cannot replace immediate with relocation");
Expand Down Expand Up @@ -1366,6 +1385,13 @@ bool BinaryFunction::disassemble() {
addInstruction(Offset, std::move(Instruction));
}

for (auto [Offset, Label] : InstructionLabels) {
InstrMapType::iterator II = Instructions.find(Offset);
assert(II != Instructions.end() && "reference to non-existing instruction");

BC.MIB->setLabel(II->second, Label);
}

// Reset symbolizer for the disassembler.
BC.SymbolicDisAsm->setSymbolizer(nullptr);

Expand Down Expand Up @@ -4489,7 +4515,7 @@ void BinaryFunction::addRelocation(uint64_t Address, MCSymbol *Symbol,
uint64_t Offset = Address - getAddress();
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: addRelocation in "
<< formatv("{0}@{1:x} against {2}\n", *this, Offset,
Symbol->getName()));
(Symbol ? Symbol->getName() : "<undef>")));
bool IsCI = BC.isAArch64() && isInConstantIsland(Address);
std::map<uint64_t, Relocation> &Rels =
IsCI ? Islands->Relocations : Relocations;
Expand Down
Loading

0 comments on commit bbf4055

Please sign in to comment.