Skip to content

Commit e849a30

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:6d160a49c2e7f36367de3f61f0460e28921450d5 into amd-gfx:71200611d382
Local branch amd-gfx 7120061 Merged main:96b17043507caec02a2ef440b369506122bdeb11 into amd-gfx:d4bdcbc628f2 Remote branch main 6d160a4 [AMDGPU][TableGen][NFC] Combine predicates without using classes. (llvm#82346)
2 parents 7120061 + 6d160a4 commit e849a30

File tree

206 files changed

+4137
-1516
lines changed

Some content is hidden

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

206 files changed

+4137
-1516
lines changed

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

clang/docs/LanguageExtensions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ to ``float``; see below for more information on this emulation.
833833
* 32-bit ARM (natively on some architecture versions)
834834
* 64-bit ARM (AArch64) (natively on ARMv8.2a and above)
835835
* AMDGPU (natively)
836+
* NVPTX (natively)
836837
* SPIR (natively)
837838
* X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
838839
* RISC-V (natively if Zfh or Zhinx is available)

clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,9 +753,12 @@ RecordStorageLocation *getImplicitObjectLocation(const CXXMemberCallExpr &MCE,
753753
RecordStorageLocation *getBaseObjectLocation(const MemberExpr &ME,
754754
const Environment &Env);
755755

756-
/// Returns the fields of `RD` that are initialized by an `InitListExpr`, in the
757-
/// order in which they appear in `InitListExpr::inits()`.
758-
std::vector<FieldDecl *> getFieldsForInitListExpr(const RecordDecl *RD);
756+
/// Returns the fields of a `RecordDecl` that are initialized by an
757+
/// `InitListExpr`, in the order in which they appear in
758+
/// `InitListExpr::inits()`.
759+
/// `Init->getType()` must be a record type.
760+
std::vector<const FieldDecl *>
761+
getFieldsForInitListExpr(const InitListExpr *InitList);
759762

760763
/// Associates a new `RecordValue` with `Loc` and returns the new value.
761764
RecordValue &refreshRecordValue(RecordStorageLocation &Loc, Environment &Env);

clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ getFieldsGlobalsAndFuncs(const Stmt &S, FieldSet &Fields,
361361
if (const auto *FD = dyn_cast<FieldDecl>(VD))
362362
Fields.insert(FD);
363363
} else if (auto *InitList = dyn_cast<InitListExpr>(&S)) {
364-
if (RecordDecl *RD = InitList->getType()->getAsRecordDecl())
365-
for (const auto *FD : getFieldsForInitListExpr(RD))
364+
if (InitList->getType()->isRecordType())
365+
for (const auto *FD : getFieldsForInitListExpr(InitList))
366366
Fields.insert(FD);
367367
}
368368
}
@@ -1104,12 +1104,22 @@ RecordStorageLocation *getBaseObjectLocation(const MemberExpr &ME,
11041104
return Env.get<RecordStorageLocation>(*Base);
11051105
}
11061106

1107-
std::vector<FieldDecl *> getFieldsForInitListExpr(const RecordDecl *RD) {
1107+
std::vector<const FieldDecl *>
1108+
getFieldsForInitListExpr(const InitListExpr *InitList) {
1109+
const RecordDecl *RD = InitList->getType()->getAsRecordDecl();
1110+
assert(RD != nullptr);
1111+
1112+
std::vector<const FieldDecl *> Fields;
1113+
1114+
if (InitList->getType()->isUnionType()) {
1115+
Fields.push_back(InitList->getInitializedFieldInUnion());
1116+
return Fields;
1117+
}
1118+
11081119
// Unnamed bitfields are only used for padding and do not appear in
11091120
// `InitListExpr`'s inits. However, those fields do appear in `RecordDecl`'s
11101121
// field list, and we thus need to remove them before mapping inits to
11111122
// fields to avoid mapping inits to the wrongs fields.
1112-
std::vector<FieldDecl *> Fields;
11131123
llvm::copy_if(
11141124
RD->fields(), std::back_inserter(Fields),
11151125
[](const FieldDecl *Field) { return !Field->isUnnamedBitfield(); });

clang/lib/Analysis/FlowSensitive/Transfer.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -663,14 +663,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
663663
void VisitInitListExpr(const InitListExpr *S) {
664664
QualType Type = S->getType();
665665

666-
if (Type->isUnionType()) {
667-
// FIXME: Initialize unions properly.
668-
if (auto *Val = Env.createValue(Type))
669-
Env.setValue(*S, *Val);
670-
return;
671-
}
672-
673-
if (!Type->isStructureOrClassType()) {
666+
if (!Type->isRecordType()) {
674667
// Until array initialization is implemented, we don't need to care about
675668
// cases where `getNumInits() > 1`.
676669
if (S->getNumInits() == 1)
@@ -688,10 +681,9 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
688681
llvm::DenseMap<const ValueDecl *, StorageLocation *> FieldLocs;
689682

690683
// This only contains the direct fields for the given type.
691-
std::vector<FieldDecl *> FieldsForInit =
692-
getFieldsForInitListExpr(Type->getAsRecordDecl());
684+
std::vector<const FieldDecl *> FieldsForInit = getFieldsForInitListExpr(S);
693685

694-
// `S->inits()` contains all the initializer epressions, including the
686+
// `S->inits()` contains all the initializer expressions, including the
695687
// ones for direct base classes.
696688
auto Inits = S->inits();
697689
size_t InitIdx = 0;
@@ -731,6 +723,17 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
731723
FieldLocs.insert({Field, &Loc});
732724
}
733725

726+
// In the case of a union, we don't in general have initializers for all
727+
// of the fields. Create storage locations for the remaining fields (but
728+
// don't associate them with values).
729+
if (Type->isUnionType()) {
730+
for (const FieldDecl *Field :
731+
Env.getDataflowAnalysisContext().getModeledFields(Type)) {
732+
if (auto [it, inserted] = FieldLocs.insert({Field, nullptr}); inserted)
733+
it->second = &Env.createStorageLocation(Field->getType());
734+
}
735+
}
736+
734737
// Check that we satisfy the invariant that a `RecordStorageLoation`
735738
// contains exactly the set of modeled fields for that type.
736739
// `ModeledFields` includes fields from all the bases, but only the

clang/lib/Basic/Targets/NVPTX.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ NVPTXTargetInfo::NVPTXTargetInfo(const llvm::Triple &Triple,
6161
NoAsmVariants = true;
6262
GPU = CudaArch::UNUSED;
6363

64+
// PTX supports f16 as a fundamental type.
65+
HasLegalHalfType = true;
66+
HasFloat16 = true;
67+
6468
if (TargetPointerWidth == 32)
6569
resetDataLayout("e-p:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64");
6670
else if (Opts.NVPTXUseShortPointers)

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,7 @@ void BareMetal::AddLinkRuntimeLib(const ArgList &Args,
368368
ToolChain::RuntimeLibType RLT = GetRuntimeLibType(Args);
369369
switch (RLT) {
370370
case ToolChain::RLT_CompilerRT: {
371-
const std::string FileName = getCompilerRT(Args, "builtins");
372-
llvm::StringRef BaseName = llvm::sys::path::filename(FileName);
373-
BaseName.consume_front("lib");
374-
BaseName.consume_back(".a");
375-
CmdArgs.push_back(Args.MakeArgString("-l" + BaseName));
371+
CmdArgs.push_back(getCompilerRTArgString(Args, "builtins"));
376372
return;
377373
}
378374
case ToolChain::RLT_Libgcc:
@@ -462,11 +458,6 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
462458
for (const auto &LibPath : TC.getLibraryPaths())
463459
CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-L", LibPath)));
464460

465-
const std::string FileName = TC.getCompilerRT(Args, "builtins");
466-
llvm::SmallString<128> PathBuf{FileName};
467-
llvm::sys::path::remove_filename(PathBuf);
468-
CmdArgs.push_back(Args.MakeArgString("-L" + PathBuf));
469-
470461
if (TC.ShouldLinkCXXStdlib(Args))
471462
TC.AddCXXStdlibLibArgs(Args, CmdArgs);
472463

clang/lib/Format/Format.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,27 +2261,36 @@ class SemiRemover : public TokenAnalyzer {
22612261
FormatTokenLexer &Tokens) override {
22622262
AffectedRangeMgr.computeAffectedLines(AnnotatedLines);
22632263
tooling::Replacements Result;
2264-
removeSemi(AnnotatedLines, Result);
2264+
removeSemi(Annotator, AnnotatedLines, Result);
22652265
return {Result, 0};
22662266
}
22672267

22682268
private:
2269-
void removeSemi(SmallVectorImpl<AnnotatedLine *> &Lines,
2269+
void removeSemi(TokenAnnotator &Annotator,
2270+
SmallVectorImpl<AnnotatedLine *> &Lines,
22702271
tooling::Replacements &Result) {
2272+
auto PrecededByFunctionRBrace = [](const FormatToken &Tok) {
2273+
const auto *Prev = Tok.Previous;
2274+
if (!Prev || Prev->isNot(tok::r_brace))
2275+
return false;
2276+
const auto *LBrace = Prev->MatchingParen;
2277+
return LBrace && LBrace->is(TT_FunctionLBrace);
2278+
};
22712279
const auto &SourceMgr = Env.getSourceManager();
22722280
const auto End = Lines.end();
22732281
for (auto I = Lines.begin(); I != End; ++I) {
22742282
const auto Line = *I;
2275-
removeSemi(Line->Children, Result);
2283+
removeSemi(Annotator, Line->Children, Result);
22762284
if (!Line->Affected)
22772285
continue;
2286+
Annotator.calculateFormattingInformation(*Line);
22782287
const auto NextLine = I + 1 == End ? nullptr : I[1];
22792288
for (auto Token = Line->First; Token && !Token->Finalized;
22802289
Token = Token->Next) {
2281-
if (!Token->Optional)
2282-
continue;
2283-
if (Token->isNot(tok::semi))
2290+
if (Token->isNot(tok::semi) ||
2291+
(!Token->Optional && !PrecededByFunctionRBrace(*Token))) {
22842292
continue;
2293+
}
22852294
auto Next = Token->Next;
22862295
assert(Next || Token == Line->Last);
22872296
if (!Next && NextLine)
@@ -3677,7 +3686,7 @@ reformat(const FormatStyle &Style, StringRef Code,
36773686
FormatStyle S = Expanded;
36783687
S.RemoveSemicolon = true;
36793688
Passes.emplace_back([&, S = std::move(S)](const Environment &Env) {
3680-
return SemiRemover(Env, S).process(/*SkipAnnotation=*/true);
3689+
return SemiRemover(Env, S).process();
36813690
});
36823691
}
36833692

clang/lib/Sema/TreeTransform.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6561,7 +6561,11 @@ TreeTransform<Derived>::TransformPackIndexingType(TypeLocBuilder &TLB,
65616561
return QualType();
65626562
if (!ShouldExpand) {
65636563
Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6564-
QualType Pack = getDerived().TransformType(T);
6564+
// FIXME: should we keep TypeLoc for individual expansions in
6565+
// PackIndexingTypeLoc?
6566+
TypeSourceInfo *TI =
6567+
SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
6568+
QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
65656569
if (Pack.isNull())
65666570
return QualType();
65676571
if (NotYetExpanded) {

clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,12 +2388,15 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
23882388
.ArgConstraint(NotNull(ArgNo(0))));
23892389

23902390
// int fileno(FILE *stream);
2391+
// According to POSIX 'fileno' may fail and set 'errno'.
2392+
// But in Linux it may fail only if the specified file pointer is invalid.
2393+
// At many places 'fileno' is used without check for failure and a failure
2394+
// case here would produce a large amount of likely false positive warnings.
2395+
// To avoid this, we assume here that it does not fail.
23912396
addToFunctionSummaryMap(
23922397
"fileno", Signature(ArgTypes{FilePtrTy}, RetType{IntTy}),
23932398
Summary(NoEvalCall)
2394-
.Case(ReturnsValidFileDescriptor, ErrnoMustNotBeChecked,
2395-
GenericSuccessMsg)
2396-
.Case(ReturnsMinusOne, ErrnoNEZeroIrrelevant, GenericFailureMsg)
2399+
.Case(ReturnsValidFileDescriptor, ErrnoUnchanged, GenericSuccessMsg)
23972400
.ArgConstraint(NotNull(ArgNo(0))));
23982401

23992402
// void rewind(FILE *stream);

0 commit comments

Comments
 (0)