Skip to content

Commit fd66e81

Browse files
authored
Merge branch 'main' into main
2 parents 5ff2197 + 76ce3c1 commit fd66e81

File tree

5,848 files changed

+271646
-132688
lines changed

Some content is hidden

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

5,848 files changed

+271646
-132688
lines changed

.ci/monolithic-windows.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ targets="${2}"
3838

3939
echo "--- cmake"
4040
pip install -q -r ${MONOREPO_ROOT}/mlir/python/requirements.txt
41+
42+
# The CMAKE_*_LINKER_FLAGS to disable the manifest come from research
43+
# on fixing a build reliability issue on the build server, please
44+
# see https://github.com/llvm/llvm-project/pull/82393 and
45+
# https://discourse.llvm.org/t/rfc-future-of-windows-pre-commit-ci/76840/40
46+
# for further information.
4147
cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \
4248
-D LLVM_ENABLE_PROJECTS="${projects}" \
4349
-G Ninja \
@@ -49,7 +55,10 @@ cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \
4955
-D COMPILER_RT_BUILD_ORC=OFF \
5056
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
5157
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
52-
-D MLIR_ENABLE_BINDINGS_PYTHON=ON
58+
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
59+
-D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \
60+
-D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \
61+
-D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO"
5362

5463
echo "--- ninja"
5564
# Targets are not escaped as they are passed as separate arguments.

.github/new-prs-labeler.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,56 @@ backend:X86:
822822
- llvm/lib/TargetParser/X86*
823823
- llvm/utils/TableGen/X86*
824824

825+
backend:PowerPC:
826+
- llvm/include/llvm/BinaryFormat/ELFRelocs/PowerPC*
827+
- llvm/include/llvm/BinaryFormat/XCOFF.h
828+
- llvm/include/llvm/IR/IntrinsicsPowerPC.td
829+
- llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
830+
- llvm/lib/Target/PowerPC/**
831+
- llvm/test/Analysis/**/PowerPC/**
832+
- llvm/test/CodeGen/PowerPC/**
833+
- llvm/test/CodeGen/MIR/PowerPC/**
834+
- llvm/test/DebugInfo/XCOFF/**
835+
- llvm/test/DebugInfo/PowerPC/**
836+
- llvm/test/LTO/PowerPC/**
837+
- llvm/test/MC/Disassembler/PowerPC/**
838+
- llvm/test/MC/PowerPC/**
839+
- llvm/test/MC/XCOFF/**
840+
- llvm/test/Transforms/**/PowerPC/**
841+
- clang/include/clang/Basic/BuiltinsPPC.*
842+
- clang/lib/Basic/Targets/PPC.*
843+
- clang/lib/CodeGen/Targets/PPC.cpp
844+
- clang/lib/Driver/ToolChains/PPC*
845+
- clang/lib/Driver/ToolChains/AIX*
846+
- clang/lib/Driver/ToolChains/Arch/PPC.*
847+
- clang/test/CodeGen/PowerPC/**
848+
849+
backend:SystemZ:
850+
- llvm/include/llvm/BinaryFormat/ELFRelocs/SystemZ*
851+
- llvm/include/llvm/BinaryFormat/GOFF.h
852+
- llvm/include/llvm/IR/IntrinsicsSystemZ.td
853+
- llvm/lib/Target/SystemZ/**
854+
- llvm/test/Analysis/**/SystemZ/**
855+
- llvm/test/CodeGen/SystemZ/**
856+
- llvm/test/DebugInfo/SystemZ/**
857+
- llvm/test/ExecutionEngine/**/SystemZ/**
858+
- llvm/test/MC/Disassembler/SystemZ/**
859+
- llvm/test/MC/GOFF/**
860+
- llvm/test/MC/SystemZ/**
861+
- llvm/test/Transforms/**/SystemZ/**
862+
- clang/include/clang/Basic/BuiltinsSystemZ.*
863+
- clang/lib/Basic/Targets/SystemZ.*
864+
- clang/lib/CodeGen/Targets/SystemZ.cpp
865+
- clang/lib/Driver/ToolChains/ZOS*
866+
- clang/lib/Driver/ToolChains/Arch/SystemZ.*
867+
- clang/test/CodeGen/SystemZ/**
868+
825869
third-party:unittests:
826870
- third-party/unittests/**
827871

872+
third-party:benchmark:
873+
- third-party/benchmark/**
874+
828875
llvm:binary-utilities:
829876
- llvm/docs/CommandGuide/llvm-*
830877
- llvm/include/llvm/BinaryFormat/**

.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

.github/workflows/release-tasks.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
name: Create a New Release
2929
runs-on: ubuntu-latest
3030
needs: validate-tag
31+
3132
steps:
3233
- name: Install Dependencies
3334
run: |
@@ -40,8 +41,9 @@ jobs:
4041
- name: Create Release
4142
env:
4243
GITHUB_TOKEN: ${{ github.token }}
44+
USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
4345
run: |
44-
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --release ${{ needs.validate-tag.outputs.release-version }} --user ${{ github.actor }} create
46+
./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
4547
release-documentation:
4648
name: Build and Upload Release Documentation
4749
needs:

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/Core/BinaryContext.h

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,35 @@ class FilterIterator {
145145
}
146146
};
147147

148+
/// BOLT-exclusive errors generated in core BOLT libraries, optionally holding a
149+
/// string message and whether it is fatal or not. In case it is fatal and if
150+
/// BOLT is running as a standalone process, the process might be killed as soon
151+
/// as the error is checked.
152+
class BOLTError : public ErrorInfo<BOLTError> {
153+
public:
154+
static char ID;
155+
156+
BOLTError(bool IsFatal, const Twine &S = Twine());
157+
void log(raw_ostream &OS) const override;
158+
bool isFatal() const { return IsFatal; }
159+
160+
const std::string &getMessage() const { return Msg; }
161+
std::error_code convertToErrorCode() const override;
162+
163+
private:
164+
bool IsFatal;
165+
std::string Msg;
166+
};
167+
168+
/// Streams used by BOLT to log regular or error events
169+
struct JournalingStreams {
170+
raw_ostream &Out;
171+
raw_ostream &Err;
172+
};
173+
174+
Error createNonFatalBOLTError(const Twine &S);
175+
Error createFatalBOLTError(const Twine &S);
176+
148177
class BinaryContext {
149178
BinaryContext() = delete;
150179

@@ -237,7 +266,8 @@ class BinaryContext {
237266
public:
238267
static Expected<std::unique_ptr<BinaryContext>>
239268
createBinaryContext(const ObjectFile *File, bool IsPIC,
240-
std::unique_ptr<DWARFContext> DwCtx);
269+
std::unique_ptr<DWARFContext> DwCtx,
270+
JournalingStreams Logger);
241271

242272
/// Superset of compiler units that will contain overwritten code that needs
243273
/// new debug info. In a few cases, functions may end up not being
@@ -605,6 +635,10 @@ class BinaryContext {
605635

606636
std::unique_ptr<MCAsmBackend> MAB;
607637

638+
/// Allows BOLT to print to log whenever it is necessary (with or without
639+
/// const references)
640+
mutable JournalingStreams Logger;
641+
608642
/// Indicates if the binary is Linux kernel.
609643
bool IsLinuxKernel{false};
610644

@@ -737,7 +771,8 @@ class BinaryContext {
737771
std::unique_ptr<const MCInstrAnalysis> MIA,
738772
std::unique_ptr<MCPlusBuilder> MIB,
739773
std::unique_ptr<const MCRegisterInfo> MRI,
740-
std::unique_ptr<MCDisassembler> DisAsm);
774+
std::unique_ptr<MCDisassembler> DisAsm,
775+
JournalingStreams Logger);
741776

742777
~BinaryContext();
743778

@@ -962,6 +997,10 @@ class BinaryContext {
962997
return getUniqueSectionByName(".gdb_index");
963998
}
964999

1000+
ErrorOr<BinarySection &> getDebugNamesSection() const {
1001+
return getUniqueSectionByName(".debug_names");
1002+
}
1003+
9651004
/// @}
9661005

9671006
/// Register \p TargetFunction as a fragment of \p Function if checks pass:
@@ -1349,8 +1388,12 @@ class BinaryContext {
13491388
return Offset;
13501389
}
13511390

1352-
void exitWithBugReport(StringRef Message,
1353-
const BinaryFunction &Function) const;
1391+
/// Log BOLT errors to journaling streams and quit process with non-zero error
1392+
/// code 1 if error is fatal.
1393+
void logBOLTErrorsAndQuitOnFatal(Error E);
1394+
1395+
std::string generateBugReportMessage(StringRef Message,
1396+
const BinaryFunction &Function) const;
13541397

13551398
struct IndependentCodeEmitter {
13561399
std::unique_ptr<MCObjectFileInfo> LocalMOFI;
@@ -1398,6 +1441,10 @@ class BinaryContext {
13981441
assert(IOAddressMap && "Address map not set yet");
13991442
return *IOAddressMap;
14001443
}
1444+
1445+
raw_ostream &outs() const { return Logger.Out; }
1446+
1447+
raw_ostream &errs() const { return Logger.Err; }
14011448
};
14021449

14031450
template <typename T, typename = std::enable_if_t<sizeof(T) == 1>>

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,12 +1910,11 @@ class BinaryFunction {
19101910

19111911
/// Support dynamic relocations in constant islands, which may happen if
19121912
/// binary is linked with -z notext option.
1913-
void markIslandDynamicRelocationAtAddress(uint64_t Address) {
1914-
if (!isInConstantIsland(Address)) {
1915-
errs() << "BOLT-ERROR: dynamic relocation found for text section at 0x"
1916-
<< Twine::utohexstr(Address) << "\n";
1917-
exit(1);
1918-
}
1913+
Error markIslandDynamicRelocationAtAddress(uint64_t Address) {
1914+
if (!isInConstantIsland(Address))
1915+
return createFatalBOLTError(
1916+
Twine("dynamic relocation found for text section at 0x") +
1917+
Twine::utohexstr(Address) + Twine("\n"));
19191918

19201919
// Mark island to have dynamic relocation
19211920
Islands->HasDynamicRelocations = true;
@@ -1924,6 +1923,7 @@ class BinaryFunction {
19241923
// move binary data during updateOutputValues, making us emit
19251924
// dynamic relocation with the right offset value.
19261925
getOrCreateIslandAccess(Address);
1926+
return Error::success();
19271927
}
19281928

19291929
bool hasDynamicRelocationAtIsland() const {
@@ -2054,9 +2054,18 @@ class BinaryFunction {
20542054
/// state to State:Disassembled.
20552055
///
20562056
/// Returns false if disassembly failed.
2057-
bool disassemble();
2057+
Error disassemble();
2058+
2059+
/// An external interface to register a branch while the function is in
2060+
/// disassembled state. Allows to make custom modifications to the
2061+
/// disassembler. E.g., a pre-CFG pass can add an instruction and register
2062+
/// a branch that will later be used during the CFG construction.
2063+
///
2064+
/// Return a label at the branch destination.
2065+
MCSymbol *registerBranch(uint64_t Src, uint64_t Dst);
20582066

2059-
void handlePCRelOperand(MCInst &Instruction, uint64_t Address, uint64_t Size);
2067+
Error handlePCRelOperand(MCInst &Instruction, uint64_t Address,
2068+
uint64_t Size);
20602069

20612070
MCSymbol *handleExternalReference(MCInst &Instruction, uint64_t Size,
20622071
uint64_t Offset, uint64_t TargetAddress,
@@ -2100,7 +2109,7 @@ class BinaryFunction {
21002109
///
21012110
/// Returns true on success and update the current function state to
21022111
/// State::CFG. Returns false if CFG cannot be built.
2103-
bool buildCFG(MCPlusBuilder::AllocatorIdTy);
2112+
Error buildCFG(MCPlusBuilder::AllocatorIdTy);
21042113

21052114
/// Perform post-processing of the CFG.
21062115
void postProcessCFG();
@@ -2217,7 +2226,7 @@ class BinaryFunction {
22172226
}
22182227

22192228
/// Process LSDA information for the function.
2220-
void parseLSDA(ArrayRef<uint8_t> LSDAData, uint64_t LSDAAddress);
2229+
Error parseLSDA(ArrayRef<uint8_t> LSDAData, uint64_t LSDAAddress);
22212230

22222231
/// Update exception handling ranges for the function.
22232232
void updateEHRanges();

bolt/include/bolt/Core/BinarySection.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class BinarySection {
112112
static StringRef getName(SectionRef Section) {
113113
return cantFail(Section.getName());
114114
}
115-
static StringRef getContents(SectionRef Section) {
115+
static StringRef getContentsOrQuit(SectionRef Section) {
116116
if (Section.getObject()->isELF() &&
117117
ELFSectionRef(Section).getType() == ELF::SHT_NOBITS)
118118
return StringRef();
@@ -139,10 +139,7 @@ class BinarySection {
139139
Alignment = NewAlignment;
140140
ELFType = NewELFType;
141141
ELFFlags = NewELFFlags;
142-
OutputSize = NewSize;
143-
OutputContents = StringRef(reinterpret_cast<const char *>(NewData),
144-
NewData ? NewSize : 0);
145-
IsFinalized = true;
142+
updateContents(NewData, NewSize);
146143
}
147144

148145
public:
@@ -159,7 +156,7 @@ class BinarySection {
159156

160157
BinarySection(BinaryContext &BC, SectionRef Section)
161158
: BC(BC), Name(getName(Section)), Section(Section),
162-
Contents(getContents(Section)), Address(Section.getAddress()),
159+
Contents(getContentsOrQuit(Section)), Address(Section.getAddress()),
163160
Size(Section.getSize()), Alignment(Section.getAlignment().value()),
164161
OutputName(Name), SectionNumber(++Count) {
165162
if (isELF()) {
@@ -484,9 +481,18 @@ class BinarySection {
484481
void flushPendingRelocations(raw_pwrite_stream &OS,
485482
SymbolResolverFuncTy Resolver);
486483

487-
/// Change contents of the section.
488-
void updateContents(const uint8_t *Data, size_t NewSize) {
489-
OutputContents = StringRef(reinterpret_cast<const char *>(Data), NewSize);
484+
/// Change contents of the section. Unless the section has a valid SectionID,
485+
/// the memory passed in \p NewData will be managed by the instance of
486+
/// BinarySection.
487+
void updateContents(const uint8_t *NewData, size_t NewSize) {
488+
if (getOutputData() && !hasValidSectionID() &&
489+
(!hasSectionRef() ||
490+
OutputContents.data() != getContentsOrQuit(Section).data())) {
491+
delete[] getOutputData();
492+
}
493+
494+
OutputContents = StringRef(reinterpret_cast<const char *>(NewData),
495+
NewData ? NewSize : 0);
490496
OutputSize = NewSize;
491497
IsFinalized = true;
492498
}

0 commit comments

Comments
 (0)