Skip to content

Commit 14ddee5

Browse files
authored
merge main into amd-staging (#338)
2 parents 20410c0 + d04ce3d commit 14ddee5

File tree

188 files changed

+4524
-879
lines changed

Some content is hidden

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

188 files changed

+4524
-879
lines changed

.github/workflows/libcxx-run-benchmarks.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,21 @@ jobs:
6464
path: repo # Avoid nuking the workspace, where we have the Python virtualenv
6565

6666
- name: Run baseline
67+
env:
68+
BENCHMARKS: ${{ steps.vars.outputs.benchmarks }}
6769
run: |
6870
source .venv/bin/activate && cd repo
6971
python -m pip install -r libcxx/utils/requirements.txt
7072
baseline_commit=$(git merge-base ${{ steps.vars.outputs.pr_base }} ${{ steps.vars.outputs.pr_head }})
71-
./libcxx/utils/test-at-commit --commit ${baseline_commit} -B build/baseline -- -sv -j1 --param optimization=speed ${{ steps.vars.outputs.benchmarks }}
73+
./libcxx/utils/test-at-commit --commit ${baseline_commit} -B build/baseline -- -sv -j1 --param optimization=speed "$BENCHMARKS"
7274
./libcxx/utils/consolidate-benchmarks build/baseline | tee baseline.lnt
7375
7476
- name: Run candidate
77+
env:
78+
BENCHMARKS: ${{ steps.vars.outputs.benchmarks }}
7579
run: |
7680
source .venv/bin/activate && cd repo
77-
./libcxx/utils/test-at-commit --commit ${{ steps.vars.outputs.pr_head }} -B build/candidate -- -sv -j1 --param optimization=speed ${{ steps.vars.outputs.benchmarks }}
81+
./libcxx/utils/test-at-commit --commit ${{ steps.vars.outputs.pr_head }} -B build/candidate -- -sv -j1 --param optimization=speed "$BENCHMARKS"
7882
./libcxx/utils/consolidate-benchmarks build/candidate | tee candidate.lnt
7983
8084
- name: Compare baseline and candidate runs

.github/workflows/premerge.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ jobs:
193193
uses: llvm/actions/install-ninja@main
194194
- name: Build and Test
195195
run: |
196-
source <(git diff --name-only HEAD~2..HEAD | python3 .ci/compute_projects.py)
196+
source <(git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py)
197197
198198
if [[ "${projects_to_build}" == "" ]]; then
199199
echo "No projects to build"

.github/workflows/release-binaries.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ jobs:
5858
ref: ${{ steps.vars.outputs.ref }}
5959
upload: ${{ steps.vars.outputs.upload }}
6060
target-cmake-flags: ${{ steps.vars.outputs.target-cmake-flags }}
61-
ccache: ${{ steps.vars.outputs.ccache }}
6261
build-flang: ${{ steps.vars.outputs.build-flang }}
6362
release-binary-basename: ${{ steps.vars.outputs.release-binary-basename }}
6463
release-binary-filename: ${{ steps.vars.outputs.release-binary-filename }}
@@ -123,13 +122,6 @@ jobs:
123122
echo "release-binary-filename=$release_binary_basename.tar.xz" >> $GITHUB_OUTPUT
124123
125124
target="$RUNNER_OS-$RUNNER_ARCH"
126-
# The hendrikmuhs/ccache-action action does not support installing sccache
127-
# on arm64 Linux.
128-
if [ "$target" = "Linux-ARM64" ]; then
129-
echo ccache=ccache >> $GITHUB_OUTPUT
130-
else
131-
echo ccache=sccache >> $GITHUB_OUTPUT
132-
fi
133125
134126
# The macOS builds try to cross compile some libraries so we need to
135127
# add extra CMake args to disable them.
@@ -222,15 +214,12 @@ jobs:
222214
- name: Configure
223215
id: build
224216
shell: bash
225-
env:
226-
CCACHE_BIN: ${{ needs.prepare.outputs.ccache }}
227217
run: |
228218
# There were some issues on the ARM64 MacOS runners with trying to build x86 object,
229219
# so we need to set some extra cmake flags to disable this.
230220
cmake -G Ninja -S llvm -B ${{ steps.setup-stage.outputs.build-prefix }}/build \
231221
${{ needs.prepare.outputs.target-cmake-flags }} \
232222
-C clang/cmake/caches/Release.cmake \
233-
-DBOOTSTRAP_LLVM_PARALLEL_LINK_JOBS=1 \
234223
-DBOOTSTRAP_BOOTSTRAP_CPACK_PACKAGE_FILE_NAME="${{ needs.prepare.outputs.release-binary-basename }}"
235224
236225
- name: Build

.github/workflows/release-documentation.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ on:
2525
description: 'Upload documentation'
2626
required: false
2727
type: boolean
28+
secrets:
29+
WWW_RELEASES_TOKEN:
30+
description: "Secret used to create a PR with the documentation changes."
31+
required: false
2832

2933
jobs:
3034
release-documentation:

.github/workflows/release-tasks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ jobs:
5454
with:
5555
release-version: ${{ needs.validate-tag.outputs.release-version }}
5656
upload: true
57+
# Called workflows don't have access to secrets by default, so we need to explicitly pass secrets that we use.
58+
secrets:
59+
WWW_RELEASES_TOKEN: ${{ secrets.WWW_RELEASES_TOKEN }}
5760

5861
release-doxygen:
5962
name: Build and Upload Release Doxygen

clang-tools-extra/clang-doc/assets/clang-doc-mustache.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ body, html {
396396

397397
.sidebar {
398398
width: 250px;
399-
top: 0;
399+
top: 60px;
400400
left: 0;
401401
height: 100%;
402402
position: fixed;

clang/bindings/python/clang/cindex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3015,7 +3015,7 @@ class _CXUnsavedFile(Structure):
30153015

30163016

30173017
# Functions calls through the python interface are rather slow. Fortunately,
3018-
# for most symboles, we do not need to perform a function call. Their spelling
3018+
# for most symbols, we do not need to perform a function call. Their spelling
30193019
# never changes and is consequently provided by this spelling cache.
30203020
SPELLING_CACHE = {
30213021
# 0: CompletionChunk.Kind("Optional"),

clang/cmake/caches/Release.cmake

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
4444
set(LLVM_RELEASE_ENABLE_PGO ON CACHE BOOL "")
4545
set(LLVM_RELEASE_ENABLE_RUNTIMES ${DEFAULT_RUNTIMES} CACHE STRING "")
4646
set(LLVM_RELEASE_ENABLE_PROJECTS ${DEFAULT_PROJECTS} CACHE STRING "")
47+
48+
# This option enables linking stage2 clang statically with the runtimes
49+
# (libc++ and compiler-rt) from stage1. In theory this will give the
50+
# binaries better performance and make them more portable. However,
51+
# this configuration is not well tested and causes build failures with
52+
# the flang-rt tests cases, since the -stclib=libc++ flag does not
53+
# get propagated to the runtimes build. There is also a separate
54+
# issue on Darwin where clang will use the local libc++ headers, but
55+
# link with system libc++ which can cause some incompatibilities.
56+
# See https://github.com/llvm/llvm-project/issues/77653
57+
# Because of these problems, this option will default to OFF.
58+
set(LLVM_RELEASE_ENABLE_LINK_LOCAL_RUNTIMES OFF CACHE BOOL "")
59+
4760
# Note we don't need to add install here, since it is one of the pre-defined
4861
# steps.
4962
set(LLVM_RELEASE_FINAL_STAGE_TARGETS "clang;package;check-all;check-llvm;check-clang" CACHE STRING "")
@@ -55,8 +68,12 @@ set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
5568

5669
set(STAGE1_PROJECTS "clang")
5770

71+
# Need to build compiler-rt in order to use PGO for later stages.
72+
set(STAGE1_RUNTIMES "compiler-rt")
5873
# Build all runtimes so we can statically link them into the stage2 compiler.
59-
set(STAGE1_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind")
74+
if(LLVM_RELEASE_ENABLE_LINK_LOCAL_RUNTIMES)
75+
list(APPEND STAGE1_RUNTIMES "libcxx;libcxxabi;libunwind")
76+
endif()
6077

6178
if (LLVM_RELEASE_ENABLE_PGO)
6279
list(APPEND STAGE1_PROJECTS "lld")
@@ -118,21 +135,25 @@ set_instrument_and_final_stage_var(LLVM_ENABLE_LTO "${LLVM_RELEASE_ENABLE_LTO}"
118135
if (LLVM_RELEASE_ENABLE_LTO)
119136
set_instrument_and_final_stage_var(LLVM_ENABLE_LLD "ON" BOOL)
120137
endif()
121-
set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL)
122-
set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL)
123-
set(RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind")
124-
if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
125-
set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc")
138+
if(LLVM_RELEASE_ENABLE_LINK_LOCAL_RUNTIMES)
139+
set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL)
140+
set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL)
141+
set(RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind")
142+
if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
143+
set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc")
144+
endif()
126145
endif()
127146

128147
# Set flags for bolt
129148
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
130149
set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -Wl,--emit-relocs,-znow")
131150
endif()
132151

133-
set_instrument_and_final_stage_var(CMAKE_EXE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
134-
set_instrument_and_final_stage_var(CMAKE_SHARED_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
135-
set_instrument_and_final_stage_var(CMAKE_MODULE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
152+
if (RELEASE_LINKER_FLAGS)
153+
set_instrument_and_final_stage_var(CMAKE_EXE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
154+
set_instrument_and_final_stage_var(CMAKE_SHARED_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
155+
set_instrument_and_final_stage_var(CMAKE_MODULE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
156+
endif()
136157

137158
# Final Stage Config (stage2)
138159
set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING)

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ struct MissingFeatures {
219219
static bool checkBitfieldClipping() { return false; }
220220
static bool cirgenABIInfo() { return false; }
221221
static bool cleanupAfterErrorDiags() { return false; }
222+
static bool cleanupAppendInsts() { return false; }
223+
static bool cleanupBranchThrough() { return false; }
224+
static bool cleanupIndexAndBIAdjustment() { return false; }
222225
static bool cleanupsToDeactivate() { return false; }
223226
static bool constEmitterAggILE() { return false; }
224227
static bool constEmitterArrayILE() { return false; }
@@ -239,6 +242,7 @@ struct MissingFeatures {
239242
static bool deleteArray() { return false; }
240243
static bool devirtualizeMemberFunction() { return false; }
241244
static bool ehCleanupFlags() { return false; }
245+
static bool ehCleanupHasPrebranchedFallthrough() { return false; }
242246
static bool ehCleanupScope() { return false; }
243247
static bool ehCleanupScopeRequiresEHCleanup() { return false; }
244248
static bool ehCleanupBranchFixups() { return false; }
@@ -257,6 +261,7 @@ struct MissingFeatures {
257261
static bool generateDebugInfo() { return false; }
258262
static bool globalViewIndices() { return false; }
259263
static bool globalViewIntLowering() { return false; }
264+
static bool handleBuiltinICEArguments() { return false; }
260265
static bool hip() { return false; }
261266
static bool incrementProfileCounter() { return false; }
262267
static bool innermostEHScope() { return false; }
@@ -295,6 +300,7 @@ struct MissingFeatures {
295300
static bool setNonGC() { return false; }
296301
static bool setObjCGCLValueClass() { return false; }
297302
static bool setTargetAttributes() { return false; }
303+
static bool simplifyCleanupEntry() { return false; }
298304
static bool sourceLanguageCases() { return false; }
299305
static bool stackBase() { return false; }
300306
static bool stackSaveOp() { return false; }

clang/lib/Analysis/FlowSensitive/Models/UncheckedStatusOrAccessModel.cpp

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
2525
#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
2626
#include "clang/Analysis/FlowSensitive/MatchSwitch.h"
27+
#include "clang/Analysis/FlowSensitive/RecordOps.h"
2728
#include "clang/Analysis/FlowSensitive/StorageLocation.h"
2829
#include "clang/Analysis/FlowSensitive/Value.h"
2930
#include "clang/Basic/LLVM.h"
@@ -95,6 +96,18 @@ static QualType getStatusOrValueType(ClassTemplateSpecializationDecl *TRD) {
9596
return TRD->getTemplateArgs().get(0).getAsType();
9697
}
9798

99+
static auto ofClassStatus() {
100+
using namespace ::clang::ast_matchers; // NOLINT: Too many names
101+
return ofClass(hasName("::absl::Status"));
102+
}
103+
104+
static auto isStatusMemberCallWithName(llvm::StringRef member_name) {
105+
using namespace ::clang::ast_matchers; // NOLINT: Too many names
106+
return cxxMemberCallExpr(
107+
on(expr(unless(cxxThisExpr()))),
108+
callee(cxxMethodDecl(hasName(member_name), ofClassStatus())));
109+
}
110+
98111
static auto isStatusOrMemberCallWithName(llvm::StringRef member_name) {
99112
using namespace ::clang::ast_matchers; // NOLINT: Too many names
100113
return cxxMemberCallExpr(
@@ -244,13 +257,74 @@ static void transferStatusOrOkCall(const CXXMemberCallExpr *Expr,
244257
State.Env.setValue(*Expr, OkVal);
245258
}
246259

260+
static void transferStatusCall(const CXXMemberCallExpr *Expr,
261+
const MatchFinder::MatchResult &,
262+
LatticeTransferState &State) {
263+
RecordStorageLocation *StatusOrLoc =
264+
getImplicitObjectLocation(*Expr, State.Env);
265+
if (StatusOrLoc == nullptr)
266+
return;
267+
268+
RecordStorageLocation &StatusLoc = locForStatus(*StatusOrLoc);
269+
270+
if (State.Env.getValue(locForOk(StatusLoc)) == nullptr)
271+
initializeStatusOr(*StatusOrLoc, State.Env);
272+
273+
if (Expr->isPRValue())
274+
copyRecord(StatusLoc, State.Env.getResultObjectLocation(*Expr), State.Env);
275+
else
276+
State.Env.setStorageLocation(*Expr, StatusLoc);
277+
}
278+
279+
static void transferStatusOkCall(const CXXMemberCallExpr *Expr,
280+
const MatchFinder::MatchResult &,
281+
LatticeTransferState &State) {
282+
RecordStorageLocation *StatusLoc =
283+
getImplicitObjectLocation(*Expr, State.Env);
284+
if (StatusLoc == nullptr)
285+
return;
286+
287+
if (Value *Val = State.Env.getValue(locForOk(*StatusLoc)))
288+
State.Env.setValue(*Expr, *Val);
289+
}
290+
291+
static void transferStatusUpdateCall(const CXXMemberCallExpr *Expr,
292+
const MatchFinder::MatchResult &,
293+
LatticeTransferState &State) {
294+
// S.Update(OtherS) sets S to the error code of OtherS if it is OK,
295+
// otherwise does nothing.
296+
assert(Expr->getNumArgs() == 1);
297+
auto *Arg = Expr->getArg(0);
298+
RecordStorageLocation *ArgRecord =
299+
Arg->isPRValue() ? &State.Env.getResultObjectLocation(*Arg)
300+
: State.Env.get<RecordStorageLocation>(*Arg);
301+
RecordStorageLocation *ThisLoc = getImplicitObjectLocation(*Expr, State.Env);
302+
if (ThisLoc == nullptr || ArgRecord == nullptr)
303+
return;
304+
305+
auto &ThisOkVal = valForOk(*ThisLoc, State.Env);
306+
auto &ArgOkVal = valForOk(*ArgRecord, State.Env);
307+
auto &A = State.Env.arena();
308+
auto &NewVal = State.Env.makeAtomicBoolValue();
309+
State.Env.assume(A.makeImplies(A.makeNot(ThisOkVal.formula()),
310+
A.makeNot(NewVal.formula())));
311+
State.Env.assume(A.makeImplies(NewVal.formula(), ArgOkVal.formula()));
312+
State.Env.setValue(locForOk(*ThisLoc), NewVal);
313+
}
314+
247315
CFGMatchSwitch<LatticeTransferState>
248316
buildTransferMatchSwitch(ASTContext &Ctx,
249317
CFGMatchSwitchBuilder<LatticeTransferState> Builder) {
250318
using namespace ::clang::ast_matchers; // NOLINT: Too many names
251319
return std::move(Builder)
252320
.CaseOfCFGStmt<CXXMemberCallExpr>(isStatusOrMemberCallWithName("ok"),
253321
transferStatusOrOkCall)
322+
.CaseOfCFGStmt<CXXMemberCallExpr>(isStatusOrMemberCallWithName("status"),
323+
transferStatusCall)
324+
.CaseOfCFGStmt<CXXMemberCallExpr>(isStatusMemberCallWithName("ok"),
325+
transferStatusOkCall)
326+
.CaseOfCFGStmt<CXXMemberCallExpr>(isStatusMemberCallWithName("Update"),
327+
transferStatusUpdateCall)
254328
.Build();
255329
}
256330

0 commit comments

Comments
 (0)