Skip to content

Commit f71dc6f

Browse files
committed
merge main into amd-staging
2 parents 9bc87db + 59d4d5c commit f71dc6f

File tree

167 files changed

+4410
-716
lines changed

Some content is hidden

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

167 files changed

+4410
-716
lines changed

.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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ jobs:
230230
cmake -G Ninja -S llvm -B ${{ steps.setup-stage.outputs.build-prefix }}/build \
231231
${{ needs.prepare.outputs.target-cmake-flags }} \
232232
-C clang/cmake/caches/Release.cmake \
233-
-DBOOTSTRAP_LLVM_PARALLEL_LINK_JOBS=1 \
234233
-DBOOTSTRAP_BOOTSTRAP_CPACK_PACKAGE_FILE_NAME="${{ needs.prepare.outputs.release-binary-basename }}"
235234
236235
- 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/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

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,107 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
463463
return emitLibraryCall(*this, fd, e,
464464
cgm.getBuiltinLibFunction(fd, builtinID));
465465

466+
// Some target-specific builtins can have aggregate return values, e.g.
467+
// __builtin_arm_mve_vld2q_u32. So if the result is an aggregate, force
468+
// returnValue to be non-null, so that the target-specific emission code can
469+
// always just emit into it.
470+
cir::TypeEvaluationKind evalKind = getEvaluationKind(e->getType());
471+
if (evalKind == cir::TEK_Aggregate && returnValue.isNull()) {
472+
cgm.errorNYI(e->getSourceRange(), "aggregate return value from builtin");
473+
return getUndefRValue(e->getType());
474+
}
475+
476+
// Now see if we can emit a target-specific builtin.
477+
if (mlir::Value v = emitTargetBuiltinExpr(builtinID, e, returnValue)) {
478+
switch (evalKind) {
479+
case cir::TEK_Scalar:
480+
if (mlir::isa<cir::VoidType>(v.getType()))
481+
return RValue::get(nullptr);
482+
return RValue::get(v);
483+
case cir::TEK_Aggregate:
484+
cgm.errorNYI(e->getSourceRange(), "aggregate return value from builtin");
485+
return getUndefRValue(e->getType());
486+
case cir::TEK_Complex:
487+
llvm_unreachable("No current target builtin returns complex");
488+
}
489+
llvm_unreachable("Bad evaluation kind in EmitBuiltinExpr");
490+
}
491+
466492
cgm.errorNYI(e->getSourceRange(),
467493
std::string("unimplemented builtin call: ") +
468494
getContext().BuiltinInfo.getName(builtinID));
469495
return getUndefRValue(e->getType());
470496
}
471497

498+
static mlir::Value emitTargetArchBuiltinExpr(CIRGenFunction *cgf,
499+
unsigned builtinID,
500+
const CallExpr *e,
501+
ReturnValueSlot &returnValue,
502+
llvm::Triple::ArchType arch) {
503+
// When compiling in HipStdPar mode we have to be conservative in rejecting
504+
// target specific features in the FE, and defer the possible error to the
505+
// AcceleratorCodeSelection pass, wherein iff an unsupported target builtin is
506+
// referenced by an accelerator executable function, we emit an error.
507+
// Returning nullptr here leads to the builtin being handled in
508+
// EmitStdParUnsupportedBuiltin.
509+
if (cgf->getLangOpts().HIPStdPar && cgf->getLangOpts().CUDAIsDevice &&
510+
arch != cgf->getTarget().getTriple().getArch())
511+
return {};
512+
513+
switch (arch) {
514+
case llvm::Triple::arm:
515+
case llvm::Triple::armeb:
516+
case llvm::Triple::thumb:
517+
case llvm::Triple::thumbeb:
518+
case llvm::Triple::aarch64:
519+
case llvm::Triple::aarch64_32:
520+
case llvm::Triple::aarch64_be:
521+
case llvm::Triple::bpfeb:
522+
case llvm::Triple::bpfel:
523+
// These are actually NYI, but that will be reported by emitBuiltinExpr.
524+
// At this point, we don't even know that the builtin is target-specific.
525+
return nullptr;
526+
527+
case llvm::Triple::x86:
528+
case llvm::Triple::x86_64:
529+
return cgf->emitX86BuiltinExpr(builtinID, e);
530+
531+
case llvm::Triple::ppc:
532+
case llvm::Triple::ppcle:
533+
case llvm::Triple::ppc64:
534+
case llvm::Triple::ppc64le:
535+
case llvm::Triple::r600:
536+
case llvm::Triple::amdgcn:
537+
case llvm::Triple::systemz:
538+
case llvm::Triple::nvptx:
539+
case llvm::Triple::nvptx64:
540+
case llvm::Triple::wasm32:
541+
case llvm::Triple::wasm64:
542+
case llvm::Triple::hexagon:
543+
case llvm::Triple::riscv32:
544+
case llvm::Triple::riscv64:
545+
// These are actually NYI, but that will be reported by emitBuiltinExpr.
546+
// At this point, we don't even know that the builtin is target-specific.
547+
return {};
548+
default:
549+
return {};
550+
}
551+
}
552+
553+
mlir::Value
554+
CIRGenFunction::emitTargetBuiltinExpr(unsigned builtinID, const CallExpr *e,
555+
ReturnValueSlot &returnValue) {
556+
if (getContext().BuiltinInfo.isAuxBuiltinID(builtinID)) {
557+
assert(getContext().getAuxTargetInfo() && "Missing aux target info");
558+
return emitTargetArchBuiltinExpr(
559+
this, getContext().BuiltinInfo.getAuxBuiltinID(builtinID), e,
560+
returnValue, getContext().getAuxTargetInfo()->getTriple().getArch());
561+
}
562+
563+
return emitTargetArchBuiltinExpr(this, builtinID, e, returnValue,
564+
getTarget().getTriple().getArch());
565+
}
566+
472567
/// Given a builtin id for a function like "__builtin_fabsf", return a Function*
473568
/// for "fabsf".
474569
cir::FuncOp CIRGenModule::getBuiltinLibFunction(const FunctionDecl *fd,

0 commit comments

Comments
 (0)