Skip to content

Commit 461feb5

Browse files
Merge branch 'main' into exegesis-debug-print-latencies
2 parents e622234 + 63dd08b commit 461feb5

File tree

2,974 files changed

+141335
-74092
lines changed

Some content is hidden

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

2,974 files changed

+141335
-74092
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

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ f6d557ee34b6bbdb1dc32f29e34b4a4a8ad35e81
7878
082b89b25faae3e45a023caf51b65ca0f02f377f
7979
0ba22f51d128bee9d69756c56c4678097270e10b
8080
84da0e1bb75f8666cf222d2f600f37bebb9ea389
81+
82+
# [NFC] clang-format utils/TableGen (#80973)
83+
b9079baaddfed5e604fbfaa1d81a7a1c38e78c26

.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/issue-release-workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,5 @@ jobs:
6565
release-workflow \
6666
--branch-repo-token ${{ secrets.RELEASE_WORKFLOW_PUSH_SECRET }} \
6767
--issue-number ${{ github.event.issue.number }} \
68+
--requested-by ${{ github.event.issue.user.login }} \
6869
auto

.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
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow will test the llvm-project-tests workflow in PRs
2+
# targetting the main branch. Since this workflow doesn't normally
3+
# run on main PRs, we need some way to test it to ensure new updates
4+
# don't break it.
5+
6+
name: LLVM Workflow Test
7+
8+
permissions:
9+
contents: read
10+
11+
on:
12+
pull_request:
13+
branches:
14+
- 'main'
15+
paths:
16+
- '.github/workflows/llvm-project-tests.yml'
17+
- '.github/workflows/llvm-project-workflow-tests.yml'
18+
19+
concurrency:
20+
# Skip intermediate builds: always.
21+
# Cancel intermediate builds: only if it is a pull request build.
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
24+
25+
jobs:
26+
llvm-test:
27+
if: github.repository_owner == 'llvm'
28+
name: Build and Test
29+
uses: ./.github/workflows/llvm-project-tests.yml
30+
with:
31+
build_target: check-all
32+
projects: clang;lld;libclc;lldb

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: 47 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

@@ -1349,8 +1384,12 @@ class BinaryContext {
13491384
return Offset;
13501385
}
13511386

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

13551394
struct IndependentCodeEmitter {
13561395
std::unique_ptr<MCObjectFileInfo> LocalMOFI;
@@ -1398,6 +1437,10 @@ class BinaryContext {
13981437
assert(IOAddressMap && "Address map not set yet");
13991438
return *IOAddressMap;
14001439
}
1440+
1441+
raw_ostream &outs() const { return Logger.Out; }
1442+
1443+
raw_ostream &errs() const { return Logger.Err; }
14011444
};
14021445

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

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 11 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,10 @@ class BinaryFunction {
20542054
/// state to State:Disassembled.
20552055
///
20562056
/// Returns false if disassembly failed.
2057-
bool disassemble();
2057+
Error disassemble();
20582058

2059-
void handlePCRelOperand(MCInst &Instruction, uint64_t Address, uint64_t Size);
2059+
Error handlePCRelOperand(MCInst &Instruction, uint64_t Address,
2060+
uint64_t Size);
20602061

20612062
MCSymbol *handleExternalReference(MCInst &Instruction, uint64_t Size,
20622063
uint64_t Offset, uint64_t TargetAddress,
@@ -2100,7 +2101,7 @@ class BinaryFunction {
21002101
///
21012102
/// Returns true on success and update the current function state to
21022103
/// State::CFG. Returns false if CFG cannot be built.
2103-
bool buildCFG(MCPlusBuilder::AllocatorIdTy);
2104+
Error buildCFG(MCPlusBuilder::AllocatorIdTy);
21042105

21052106
/// Perform post-processing of the CFG.
21062107
void postProcessCFG();
@@ -2217,7 +2218,7 @@ class BinaryFunction {
22172218
}
22182219

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

22222223
/// Update exception handling ranges for the function.
22232224
void updateEHRanges();

bolt/include/bolt/Core/BinarySection.h

Lines changed: 2 additions & 2 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();
@@ -159,7 +159,7 @@ class BinarySection {
159159

160160
BinarySection(BinaryContext &BC, SectionRef Section)
161161
: BC(BC), Name(getName(Section)), Section(Section),
162-
Contents(getContents(Section)), Address(Section.getAddress()),
162+
Contents(getContentsOrQuit(Section)), Address(Section.getAddress()),
163163
Size(Section.getSize()), Alignment(Section.getAlignment().value()),
164164
OutputName(Name), SectionNumber(++Count) {
165165
if (isELF()) {

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef BOLT_CORE_DIE_BUILDER_H
1616
#define BOLT_CORE_DIE_BUILDER_H
1717

18+
#include "bolt/Core/BinaryContext.h"
1819
#include "llvm/CodeGen/DIE.h"
1920
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
2021
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
@@ -32,6 +33,7 @@
3233
namespace llvm {
3334

3435
namespace bolt {
36+
3537
class DIEStreamer;
3638
class DebugStrOffsetsWriter;
3739

@@ -120,6 +122,7 @@ class DIEBuilder {
120122
std::unique_ptr<State> BuilderState;
121123
FoldingSet<DIEAbbrev> AbbreviationsSet;
122124
std::vector<std::unique_ptr<DIEAbbrev>> Abbreviations;
125+
BinaryContext &BC;
123126
DWARFContext *DwarfContext{nullptr};
124127
bool IsDWO{false};
125128
uint64_t UnitSize{0};
@@ -219,9 +222,10 @@ class DIEBuilder {
219222
if (getState().CloneUnitCtxMap[UnitId].DieInfoVector.size() > DIEId)
220223
return *getState().CloneUnitCtxMap[UnitId].DieInfoVector[DIEId].get();
221224

222-
errs() << "BOLT-WARNING: [internal-dwarf-error]: The DIE is not allocated "
223-
"before looking up, some"
224-
<< "unexpected corner cases happened.\n";
225+
BC.errs()
226+
<< "BOLT-WARNING: [internal-dwarf-error]: The DIE is not allocated "
227+
"before looking up, some"
228+
<< "unexpected corner cases happened.\n";
225229
return *getState().CloneUnitCtxMap[UnitId].DieInfoVector.front().get();
226230
}
227231

@@ -261,7 +265,7 @@ class DIEBuilder {
261265
DIE *constructDIEFast(DWARFDie &DDie, DWARFUnit &U, uint32_t UnitId);
262266

263267
public:
264-
DIEBuilder(DWARFContext *DwarfContext, bool IsDWO = false);
268+
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext, bool IsDWO = false);
265269

266270
/// Returns enum to what we are currently processing.
267271
ProcessingType getCurrentProcessingState() { return getState().Type; }
@@ -295,8 +299,9 @@ class DIEBuilder {
295299
if (getState().TypeDIEMap.count(&DU))
296300
return getState().TypeDIEMap[&DU];
297301

298-
errs() << "BOLT-ERROR: unable to find TypeUnit for Type Unit at offset 0x"
299-
<< DU.getOffset() << "\n";
302+
BC.errs()
303+
<< "BOLT-ERROR: unable to find TypeUnit for Type Unit at offset 0x"
304+
<< DU.getOffset() << "\n";
300305
return nullptr;
301306
}
302307

bolt/include/bolt/Core/DynoStats.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ inline DynoStats getDynoStats(FuncsType &Funcs, bool IsAArch64) {
159159

160160
/// Call a function with optional before and after dynostats printing.
161161
template <typename FnType, typename FuncsType>
162-
inline void callWithDynoStats(FnType &&Func, FuncsType &Funcs, StringRef Phase,
163-
const bool Flag, bool IsAArch64) {
162+
inline void callWithDynoStats(raw_ostream &OS, FnType &&Func, FuncsType &Funcs,
163+
StringRef Phase, const bool Flag,
164+
bool IsAArch64) {
164165
DynoStats DynoStatsBefore(IsAArch64);
165166
if (Flag)
166167
DynoStatsBefore = getDynoStats(Funcs, IsAArch64);
@@ -170,12 +171,12 @@ inline void callWithDynoStats(FnType &&Func, FuncsType &Funcs, StringRef Phase,
170171
if (Flag) {
171172
const DynoStats DynoStatsAfter = getDynoStats(Funcs, IsAArch64);
172173
const bool Changed = (DynoStatsAfter != DynoStatsBefore);
173-
outs() << "BOLT-INFO: program-wide dynostats after running " << Phase
174-
<< (Changed ? "" : " (no change)") << ":\n\n"
175-
<< DynoStatsBefore << '\n';
174+
OS << "BOLT-INFO: program-wide dynostats after running " << Phase
175+
<< (Changed ? "" : " (no change)") << ":\n\n"
176+
<< DynoStatsBefore << '\n';
176177
if (Changed)
177-
DynoStatsAfter.print(outs(), &DynoStatsBefore);
178-
outs() << '\n';
178+
DynoStatsAfter.print(OS, &DynoStatsBefore);
179+
OS << '\n';
179180
}
180181
}
181182

0 commit comments

Comments
 (0)