Skip to content

Commit 20ed224

Browse files
committed
Merge branch 'main' into ptrauth-constants-in-data
2 parents 9633e04 + c0b65a2 commit 20ed224

File tree

777 files changed

+26619
-12129
lines changed

Some content is hidden

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

777 files changed

+26619
-12129
lines changed

.ci/generate-buildkite-pipeline-premerge

+2-3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ function exclude-linux() {
153153
for project in ${projects}; do
154154
case ${project} in
155155
cross-project-tests) ;; # tests failing
156-
lldb) ;; # tests failing
157156
openmp) ;; # https://github.com/google/llvm-premerge-checks/issues/410
158157
*)
159158
echo "${project}"
@@ -170,7 +169,7 @@ function exclude-windows() {
170169
compiler-rt) ;; # tests taking too long
171170
openmp) ;; # TODO: having trouble with the Perl installation
172171
libc) ;; # no Windows support
173-
lldb) ;; # tests failing
172+
lldb) ;; # custom environment requirements (https://github.com/llvm/llvm-project/pull/94208#issuecomment-2146256857)
174173
bolt) ;; # tests are not supported yet
175174
*)
176175
echo "${project}"
@@ -213,7 +212,7 @@ function check-targets() {
213212
echo "check-unwind"
214213
;;
215214
lldb)
216-
echo "check-all" # TODO: check-lldb may not include all the LLDB tests?
215+
echo "check-lldb"
217216
;;
218217
pstl)
219218
echo "check-all"

.ci/monolithic-linux.sh

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ targets="${2}"
3939

4040
echo "--- cmake"
4141
pip install -q -r "${MONOREPO_ROOT}"/mlir/python/requirements.txt
42+
pip install -q -r "${MONOREPO_ROOT}"/lldb/test/requirements.txt
4243
cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
4344
-D LLVM_ENABLE_PROJECTS="${projects}" \
4445
-G Ninja \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import json
2+
import multiprocessing
3+
import os
4+
import re
5+
import subprocess
6+
import sys
7+
8+
9+
def run_analyzer(data):
10+
os.chdir(data["directory"])
11+
command = (
12+
data["command"]
13+
+ f" --analyze --analyzer-output html -o analyzer-results -Xclang -analyzer-config -Xclang max-nodes=75000"
14+
)
15+
print(command)
16+
subprocess.run(command, shell=True, check=True)
17+
18+
19+
def pool_error(e):
20+
print("Error analyzing file:", e)
21+
22+
23+
def main():
24+
db_path = sys.argv[1]
25+
database = json.load(open(db_path))
26+
27+
with multiprocessing.Pool() as pool:
28+
pool.map_async(run_analyzer, [k for k in database], error_callback=pool_error)
29+
pool.close()
30+
pool.join()
31+
32+
33+
if __name__ == "__main__":
34+
main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Post-Commit Static Analyzer
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- 'release/**'
10+
paths:
11+
- 'clang/**'
12+
- 'llvm/**'
13+
- '.github/workflows/ci-post-commit-analyzer.yml'
14+
pull_request:
15+
types:
16+
- opened
17+
- synchronize
18+
- reopened
19+
- closed
20+
paths:
21+
- '.github/workflows/ci-post-commit-analyzer.yml'
22+
- '.github/workflows/ci-post-commit-analyzer-run.py'
23+
schedule:
24+
- cron: '30 0 * * *'
25+
26+
concurrency:
27+
group: >-
28+
llvm-project-${{ github.workflow }}-${{ github.event_name == 'pull_request' &&
29+
( github.event.pull_request.number || github.ref) }}
30+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
31+
32+
jobs:
33+
post-commit-analyzer:
34+
if: >-
35+
github.repository_owner == 'llvm' &&
36+
github.event.action != 'closed'
37+
runs-on: ubuntu-22.04
38+
container:
39+
image: 'ghcr.io/llvm/ci-ubuntu-22.04:latest'
40+
env:
41+
LLVM_VERSION: 18
42+
steps:
43+
- name: Checkout Source
44+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
45+
46+
- name: Setup ccache
47+
uses: hendrikmuhs/ccache-action@v1
48+
with:
49+
# A full build of llvm, clang, lld, and lldb takes about 250MB
50+
# of ccache space. There's not much reason to have more than this,
51+
# because we usually won't need to save cache entries from older
52+
# builds. Also, there is an overall 10GB cache limit, and each
53+
# run creates a new cache entry so we want to ensure that we have
54+
# enough cache space for all the tests to run at once and still
55+
# fit under the 10 GB limit.
56+
# Default to 2G to workaround: https://github.com/hendrikmuhs/ccache-action/issues/174
57+
max-size: 2G
58+
key: post-commit-analyzer
59+
variant: sccache
60+
61+
- name: Configure
62+
run: |
63+
cmake -B build -S llvm -G Ninja \
64+
-DLLVM_ENABLE_ASSERTIONS=ON \
65+
-DLLVM_ENABLE_PROJECTS=clang \
66+
-DLLVM_BUILD_LLVM_DYLIB=ON \
67+
-DLLVM_LINK_LLVM_DYLIB=ON \
68+
-DCMAKE_CXX_COMPILER=clang++ \
69+
-DCMAKE_C_COMPILER=clang \
70+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
71+
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
72+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
73+
-DLLVM_INCLUDE_TESTS=OFF \
74+
-DCLANG_INCLUDE_TESTS=OFF \
75+
-DCMAKE_BUILD_TYPE=Release
76+
77+
- name: Build
78+
run: |
79+
# FIXME: We need to build all the generated header files in order to be able to run
80+
# the analyzer on every file. Building libLLVM and libclang is probably overkill for
81+
# this, but it's better than building every target.
82+
ninja -v -C build libLLVM.so libclang.so
83+
84+
# Run the analyzer.
85+
python3 .github/workflows/ci-post-commit-analyzer-run.py build/compile_commands.json
86+
87+
scan-build --generate-index-only build/analyzer-results
88+
89+
- name: Upload Results
90+
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
91+
if: always()
92+
with:
93+
name: analyzer-results
94+
path: 'build/analyzer-results/*'
95+

.github/workflows/release-binaries.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ jobs:
216216
217217
- id: package-info
218218
run: |
219-
filename="LLVM-${{ needs.prepare.outputs.release-version }}-Linux.tar.gz"
219+
filename="LLVM-${{ needs.prepare.outputs.release-version }}-Linux.tar.xz"
220220
echo "filename=$filename" >> $GITHUB_OUTPUT
221221
echo "path=/mnt/build/tools/clang/stage2-bins/$filename" >> $GITHUB_OUTPUT
222222

bolt/include/bolt/Core/MCPlusBuilder.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -1706,12 +1706,9 @@ class MCPlusBuilder {
17061706
}
17071707

17081708
/// Reverses the branch condition in Inst and update its taken target to TBB.
1709-
///
1710-
/// Returns true on success.
1711-
virtual bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
1709+
virtual void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
17121710
MCContext *Ctx) const {
17131711
llvm_unreachable("not implemented");
1714-
return false;
17151712
}
17161713

17171714
virtual bool replaceBranchCondition(MCInst &Inst, const MCSymbol *TBB,
@@ -1751,12 +1748,9 @@ class MCPlusBuilder {
17511748
}
17521749

17531750
/// Sets the taken target of the branch instruction to Target.
1754-
///
1755-
/// Returns true on success.
1756-
virtual bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
1751+
virtual void replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
17571752
MCContext *Ctx) const {
17581753
llvm_unreachable("not implemented");
1759-
return false;
17601754
}
17611755

17621756
/// Extract a symbol and an addend out of the fixup value expression.

bolt/lib/Core/BinaryEmitter.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ class BinaryEmitter {
194194

195195
void BinaryEmitter::emitAll(StringRef OrgSecPrefix) {
196196
Streamer.initSections(false, *BC.STI);
197+
Streamer.setUseAssemblerInfoForParsing(false);
197198

198199
if (opts::UpdateDebugSections && BC.isELF()) {
199200
// Force the emission of debug line info into allocatable section to ensure
@@ -226,6 +227,7 @@ void BinaryEmitter::emitAll(StringRef OrgSecPrefix) {
226227
// TODO Enable for Mach-O once BinaryContext::getDataSection supports it.
227228
if (BC.isELF())
228229
AddressMap::emit(Streamer, BC);
230+
Streamer.setUseAssemblerInfoForParsing(true);
229231
}
230232

231233
void BinaryEmitter::emitFunctions() {

bolt/lib/Passes/VeneerElimination.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,8 @@ Error VeneerElimination::runOnFunctions(BinaryContext &BC) {
7777
continue;
7878

7979
VeneerCallers++;
80-
if (!BC.MIB->replaceBranchTarget(
81-
Instr, VeneerDestinations[TargetSymbol], BC.Ctx.get())) {
82-
return createFatalBOLTError(
83-
"BOLT-ERROR: updating veneer call destination failed\n");
84-
}
80+
BC.MIB->replaceBranchTarget(Instr, VeneerDestinations[TargetSymbol],
81+
BC.Ctx.get());
8582
}
8683
}
8784
}

bolt/lib/Profile/BoltAddressTranslation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ std::error_code BoltAddressTranslation::parse(raw_ostream &OS, StringRef Buf) {
304304

305305
StringRef Name = Buf.slice(Offset, Offset + NameSz);
306306
Offset = alignTo(Offset + NameSz, 4);
307-
if (Name.substr(0, 4) != "BOLT")
307+
if (!Name.starts_with("BOLT"))
308308
return make_error_code(llvm::errc::io_error);
309309

310310
Error Err(Error::success());

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
616616
return getTargetAddend(Op.getExpr());
617617
}
618618

619-
bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
619+
void replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
620620
MCContext *Ctx) const override {
621621
assert((isCall(Inst) || isBranch(Inst)) && !isIndirectBranch(Inst) &&
622622
"Invalid instruction");
@@ -638,7 +638,6 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
638638

639639
*OI = MCOperand::createExpr(
640640
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx));
641-
return true;
642641
}
643642

644643
/// Matches indirect branch patterns in AArch64 related to a jump table (JT),
@@ -969,7 +968,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
969968
}
970969
}
971970

972-
bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
971+
void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
973972
MCContext *Ctx) const override {
974973
if (isTB(Inst) || isCB(Inst)) {
975974
Inst.setOpcode(getInvertedBranchOpcode(Inst.getOpcode()));
@@ -984,7 +983,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
984983
LLVM_DEBUG(Inst.dump());
985984
llvm_unreachable("Unrecognized branch instruction");
986985
}
987-
return replaceBranchTarget(Inst, TBB, Ctx);
986+
replaceBranchTarget(Inst, TBB, Ctx);
988987
}
989988

990989
int getPCRelEncodingSize(const MCInst &Inst) const override {

bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
151151
}
152152
}
153153

154-
bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
154+
void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
155155
MCContext *Ctx) const override {
156156
auto Opcode = getInvertedBranchOpcode(Inst.getOpcode());
157157
Inst.setOpcode(Opcode);
158-
return replaceBranchTarget(Inst, TBB, Ctx);
158+
replaceBranchTarget(Inst, TBB, Ctx);
159159
}
160160

161-
bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
161+
void replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
162162
MCContext *Ctx) const override {
163163
assert((isCall(Inst) || isBranch(Inst)) && !isIndirectBranch(Inst) &&
164164
"Invalid instruction");
@@ -170,7 +170,6 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
170170

171171
Inst.getOperand(SymOpIndex) = MCOperand::createExpr(
172172
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx));
173-
return true;
174173
}
175174

176175
IndirectBranchType analyzeIndirectBranch(

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -2794,14 +2794,13 @@ class X86MCPlusBuilder : public MCPlusBuilder {
27942794
Inst.addOperand(MCOperand::createImm(CC));
27952795
}
27962796

2797-
bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
2797+
void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
27982798
MCContext *Ctx) const override {
27992799
unsigned InvCC = getInvertedCondCode(getCondCode(Inst));
28002800
assert(InvCC != X86::COND_INVALID && "invalid branch instruction");
28012801
Inst.getOperand(Info->get(Inst.getOpcode()).NumOperands - 1).setImm(InvCC);
28022802
Inst.getOperand(0) = MCOperand::createExpr(
28032803
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx));
2804-
return true;
28052804
}
28062805

28072806
bool replaceBranchCondition(MCInst &Inst, const MCSymbol *TBB, MCContext *Ctx,
@@ -2844,13 +2843,12 @@ class X86MCPlusBuilder : public MCPlusBuilder {
28442843
}
28452844
}
28462845

2847-
bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
2846+
void replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
28482847
MCContext *Ctx) const override {
28492848
assert((isCall(Inst) || isBranch(Inst)) && !isIndirectBranch(Inst) &&
28502849
"Invalid instruction");
28512850
Inst.getOperand(0) = MCOperand::createExpr(
28522851
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx));
2853-
return true;
28542852
}
28552853

28562854
MCPhysReg getX86R11() const override { return X86::R11; }

clang-tools-extra/clang-query/QueryParser.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,11 @@ QueryRef QueryParser::endQuery(QueryRef Q) {
144144
StringRef Extra = Line;
145145
StringRef ExtraTrimmed = Extra.ltrim(" \t\v\f\r");
146146

147-
if ((!ExtraTrimmed.empty() && ExtraTrimmed[0] == '\n') ||
148-
(ExtraTrimmed.size() >= 2 && ExtraTrimmed[0] == '\r' &&
149-
ExtraTrimmed[1] == '\n'))
147+
if (ExtraTrimmed.starts_with('\n') || ExtraTrimmed.starts_with("\r\n"))
150148
Q->RemainingContent = Extra;
151149
else {
152150
StringRef TrailingWord = lexWord();
153-
if (!TrailingWord.empty() && TrailingWord.front() == '#') {
151+
if (TrailingWord.starts_with('#')) {
154152
Line = Line.drop_until([](char c) { return c == '\n'; });
155153
Line = Line.drop_while([](char c) { return c == '\n'; });
156154
return endQuery(Q);

clang-tools-extra/clang-tidy/bugprone/MultiLevelImplicitPointerConversionCheck.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,21 @@ AST_MATCHER(ImplicitCastExpr, isMultiLevelPointerConversion) {
4848
return SourcePtrLevel != TargetPtrLevel;
4949
}
5050

51+
AST_MATCHER(QualType, isPointerType) {
52+
const QualType Type =
53+
Node.getCanonicalType().getNonReferenceType().getUnqualifiedType();
54+
55+
return !Type.isNull() && Type->isPointerType();
56+
}
57+
5158
} // namespace
5259

5360
void MultiLevelImplicitPointerConversionCheck::registerMatchers(
5461
MatchFinder *Finder) {
5562
Finder->addMatcher(
56-
implicitCastExpr(hasCastKind(CK_BitCast), isMultiLevelPointerConversion())
63+
implicitCastExpr(hasCastKind(CK_BitCast), isMultiLevelPointerConversion(),
64+
unless(hasParent(explicitCastExpr(
65+
hasDestinationType(isPointerType())))))
5766
.bind("expr"),
5867
this);
5968
}

clang-tools-extra/clang-tidy/misc/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ add_clang_library(clangTidyMiscModule
4141
UnusedParametersCheck.cpp
4242
UnusedUsingDeclsCheck.cpp
4343
UseAnonymousNamespaceCheck.cpp
44+
UseInternalLinkageCheck.cpp
4445

4546
LINK_LIBS
4647
clangTidy

clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "UnusedParametersCheck.h"
3232
#include "UnusedUsingDeclsCheck.h"
3333
#include "UseAnonymousNamespaceCheck.h"
34+
#include "UseInternalLinkageCheck.h"
3435

3536
namespace clang::tidy {
3637
namespace misc {
@@ -78,6 +79,8 @@ class MiscModule : public ClangTidyModule {
7879
"misc-unused-using-decls");
7980
CheckFactories.registerCheck<UseAnonymousNamespaceCheck>(
8081
"misc-use-anonymous-namespace");
82+
CheckFactories.registerCheck<UseInternalLinkageCheck>(
83+
"misc-use-internal-linkage");
8184
}
8285
};
8386

0 commit comments

Comments
 (0)