Skip to content

Commit b35599b

Browse files
committed
Merge remote-tracking branch 'upstream/release/19.x' into rustc/19.1-2024-09-17
Update to LLVM 19.1.3
2 parents 3a17f74 + ab51ecc commit b35599b

File tree

112 files changed

+1528
-1424
lines changed

Some content is hidden

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

112 files changed

+1528
-1424
lines changed

.github/workflows/release-binaries.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,14 @@ jobs:
420420
attestations: write # For artifact attestations
421421

422422
steps:
423+
- name: Checkout Release Scripts
424+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
425+
with:
426+
sparse-checkout: |
427+
llvm/utils/release/github-upload-release.py
428+
llvm/utils/git/requirements.txt
429+
sparse-checkout-cone-mode: false
430+
423431
- name: 'Download artifact'
424432
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
425433
with:
@@ -442,14 +450,6 @@ jobs:
442450
name: ${{ needs.prepare.outputs.release-binary-filename }}-attestation
443451
path: ${{ needs.prepare.outputs.release-binary-filename }}.jsonl
444452

445-
- name: Checkout Release Scripts
446-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
447-
with:
448-
sparse-checkout: |
449-
llvm/utils/release/github-upload-release.py
450-
llvm/utils/git/requirements.txt
451-
sparse-checkout-cone-mode: false
452-
453453
- name: Install Python Requirements
454454
run: |
455455
pip install --require-hashes -r ./llvm/utils/git/requirements.txt

.github/workflows/release-documentation.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,20 @@ jobs:
7272
ref: main
7373
fetch-depth: 0
7474
path: www-releases
75+
persist-credentials: false
7576

7677
- name: Upload Release Notes
7778
if: env.upload
7879
env:
79-
WWW_RELEASES_TOKEN: ${{ secrets.WWW_RELEASES_TOKEN }}
80+
GH_TOKEN: ${{ secrets.WWW_RELEASES_TOKEN }}
8081
run: |
81-
mkdir -p ../www-releases/${{ inputs.release-version }}
82-
mv ./docs-build/html-export/* ../www-releases/${{ inputs.release-version }}
83-
cd ../www-releases
82+
mkdir -p www-releases/${{ inputs.release-version }}
83+
mv ./docs-build/html-export/* www-releases/${{ inputs.release-version }}
84+
cd www-releases
85+
git checkout -b ${{ inputs.release-version }}
8486
git add ${{ inputs.release-version }}
8587
git config user.email "[email protected]"
8688
git config user.name "llvmbot"
8789
git commit -a -m "Add ${{ inputs.release-version }} documentation"
88-
git push "https://[email protected]/${{ github.repository_owner }}/www-releases" main:main
90+
git push --force "https://[email protected]/llvmbot/www-releases.git" HEAD:refs/heads/${{ inputs.release-version }}
91+
gh pr create -f -B main -H ${{ inputs.release-version }} -R llvmbot/www-releases

clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ utils::UseRangesCheck::ReplacerMap UseRangesCheck::getReplacerMap() const {
204204
ReplacerMap Results;
205205
static const Signature SingleSig = {{0}};
206206
static const Signature TwoSig = {{0}, {2}};
207-
static const auto AddFrom =
207+
const auto AddFrom =
208208
[&Results](llvm::IntrusiveRefCntPtr<UseRangesCheck::Replacer> Replacer,
209209
std::initializer_list<StringRef> Names, StringRef Prefix) {
210210
llvm::SmallString<64> Buffer;
@@ -214,17 +214,17 @@ utils::UseRangesCheck::ReplacerMap UseRangesCheck::getReplacerMap() const {
214214
}
215215
};
216216

217-
static const auto AddFromStd =
218-
[](llvm::IntrusiveRefCntPtr<UseRangesCheck::Replacer> Replacer,
219-
std::initializer_list<StringRef> Names) {
217+
const auto AddFromStd =
218+
[&](llvm::IntrusiveRefCntPtr<UseRangesCheck::Replacer> Replacer,
219+
std::initializer_list<StringRef> Names) {
220220
AddFrom(Replacer, Names, "std");
221221
};
222222

223-
static const auto AddFromBoost =
224-
[](llvm::IntrusiveRefCntPtr<UseRangesCheck::Replacer> Replacer,
225-
std::initializer_list<
226-
std::pair<StringRef, std::initializer_list<StringRef>>>
227-
NamespaceAndNames) {
223+
const auto AddFromBoost =
224+
[&](llvm::IntrusiveRefCntPtr<UseRangesCheck::Replacer> Replacer,
225+
std::initializer_list<
226+
std::pair<StringRef, std::initializer_list<StringRef>>>
227+
NamespaceAndNames) {
228228
for (auto [Namespace, Names] : NamespaceAndNames)
229229
AddFrom(Replacer, Names,
230230
SmallString<64>{"boost", (Namespace.empty() ? "" : "::"),

clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,22 @@ TEST_F(LSPTest, ClangTidyRename) {
262262
EXPECT_EQ(Params, std::vector{llvm::json::Value(std::move(ExpectedEdit))});
263263
}
264264

265+
TEST_F(LSPTest, ClangTidyCrash_Issue109367) {
266+
// This test requires clang-tidy checks to be linked in.
267+
if (!CLANGD_TIDY_CHECKS)
268+
return;
269+
Opts.ClangTidyProvider = [](tidy::ClangTidyOptions &ClangTidyOpts,
270+
llvm::StringRef) {
271+
ClangTidyOpts.Checks = {"-*,boost-use-ranges"};
272+
};
273+
// Check that registering the boost-use-ranges checker's matchers
274+
// on two different threads does not cause a crash.
275+
auto &Client = start();
276+
Client.didOpen("a.cpp", "");
277+
Client.didOpen("b.cpp", "");
278+
Client.sync();
279+
}
280+
265281
TEST_F(LSPTest, IncomingCalls) {
266282
Annotations Code(R"cpp(
267283
void calle^e(int);

clang/cmake/caches/Release.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,6 @@ set_final_stage_var(LLVM_ENABLE_PROJECTS "${LLVM_RELEASE_ENABLE_PROJECTS}" STRIN
101101
set_final_stage_var(CPACK_GENERATOR "TXZ" STRING)
102102
set_final_stage_var(CPACK_ARCHIVE_THREADS "0" STRING)
103103

104+
if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
105+
set_final_stage_var(LLVM_USE_STATIC_ZSTD "ON" BOOL)
106+
endif()

clang/include/clang/AST/ExternalASTSource.h

+35-13
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
#include "llvm/ADT/SmallVector.h"
2626
#include "llvm/ADT/iterator.h"
2727
#include "llvm/Support/PointerLikeTypeTraits.h"
28+
#include <algorithm>
2829
#include <cassert>
2930
#include <cstddef>
3031
#include <cstdint>
3132
#include <iterator>
33+
#include <new>
3234
#include <optional>
3335
#include <utility>
3436

@@ -326,45 +328,65 @@ struct LazyOffsetPtr {
326328
///
327329
/// If the low bit is clear, a pointer to the AST node. If the low
328330
/// bit is set, the upper 63 bits are the offset.
329-
mutable uint64_t Ptr = 0;
331+
static constexpr size_t DataSize = std::max(sizeof(uint64_t), sizeof(T *));
332+
alignas(uint64_t) alignas(T *) mutable unsigned char Data[DataSize] = {};
333+
334+
unsigned char GetLSB() const {
335+
return Data[llvm::sys::IsBigEndianHost ? DataSize - 1 : 0];
336+
}
337+
338+
template <typename U> U &As(bool New) const {
339+
unsigned char *Obj =
340+
Data + (llvm::sys::IsBigEndianHost ? DataSize - sizeof(U) : 0);
341+
if (New)
342+
return *new (Obj) U;
343+
return *std::launder(reinterpret_cast<U *>(Obj));
344+
}
345+
346+
T *&GetPtr() const { return As<T *>(false); }
347+
uint64_t &GetU64() const { return As<uint64_t>(false); }
348+
void SetPtr(T *Ptr) const { As<T *>(true) = Ptr; }
349+
void SetU64(uint64_t U64) const { As<uint64_t>(true) = U64; }
330350

331351
public:
332352
LazyOffsetPtr() = default;
333-
explicit LazyOffsetPtr(T *Ptr) : Ptr(reinterpret_cast<uint64_t>(Ptr)) {}
353+
explicit LazyOffsetPtr(T *Ptr) : Data() { SetPtr(Ptr); }
334354

335-
explicit LazyOffsetPtr(uint64_t Offset) : Ptr((Offset << 1) | 0x01) {
355+
explicit LazyOffsetPtr(uint64_t Offset) : Data() {
336356
assert((Offset << 1 >> 1) == Offset && "Offsets must require < 63 bits");
337357
if (Offset == 0)
338-
Ptr = 0;
358+
SetPtr(nullptr);
359+
else
360+
SetU64((Offset << 1) | 0x01);
339361
}
340362

341363
LazyOffsetPtr &operator=(T *Ptr) {
342-
this->Ptr = reinterpret_cast<uint64_t>(Ptr);
364+
SetPtr(Ptr);
343365
return *this;
344366
}
345367

346368
LazyOffsetPtr &operator=(uint64_t Offset) {
347369
assert((Offset << 1 >> 1) == Offset && "Offsets must require < 63 bits");
348370
if (Offset == 0)
349-
Ptr = 0;
371+
SetPtr(nullptr);
350372
else
351-
Ptr = (Offset << 1) | 0x01;
373+
SetU64((Offset << 1) | 0x01);
352374

353375
return *this;
354376
}
355377

356378
/// Whether this pointer is non-NULL.
357379
///
358380
/// This operation does not require the AST node to be deserialized.
359-
explicit operator bool() const { return Ptr != 0; }
381+
explicit operator bool() const { return isOffset() || GetPtr() != nullptr; }
360382

361383
/// Whether this pointer is non-NULL.
362384
///
363385
/// This operation does not require the AST node to be deserialized.
364-
bool isValid() const { return Ptr != 0; }
386+
bool isValid() const { return isOffset() || GetPtr() != nullptr; }
365387

366388
/// Whether this pointer is currently stored as an offset.
367-
bool isOffset() const { return Ptr & 0x01; }
389+
bool isOffset() const { return GetLSB() & 0x01; }
368390

369391
/// Retrieve the pointer to the AST node that this lazy pointer points to.
370392
///
@@ -375,17 +397,17 @@ struct LazyOffsetPtr {
375397
if (isOffset()) {
376398
assert(Source &&
377399
"Cannot deserialize a lazy pointer without an AST source");
378-
Ptr = reinterpret_cast<uint64_t>((Source->*Get)(OffsT(Ptr >> 1)));
400+
SetPtr((Source->*Get)(OffsT(GetU64() >> 1)));
379401
}
380-
return reinterpret_cast<T*>(Ptr);
402+
return GetPtr();
381403
}
382404

383405
/// Retrieve the address of the AST node pointer. Deserializes the pointee if
384406
/// necessary.
385407
T **getAddressOfPointer(ExternalASTSource *Source) const {
386408
// Ensure the integer is in pointer form.
387409
(void)get(Source);
388-
return reinterpret_cast<T**>(&Ptr);
410+
return &GetPtr();
389411
}
390412
};
391413

clang/include/clang/Basic/TokenKinds.def

+4-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
#ifndef EXPRESSION_TRAIT
6565
#define EXPRESSION_TRAIT(I,E,K) KEYWORD(I,K)
6666
#endif
67+
#ifndef TRANSFORM_TYPE_TRAIT_DEF
68+
#define TRANSFORM_TYPE_TRAIT_DEF(K, Trait) KEYWORD(__##Trait, KEYCXX)
69+
#endif
70+
6771
#ifndef ALIAS
6872
#define ALIAS(X,Y,Z)
6973
#endif
@@ -534,7 +538,6 @@ TYPE_TRAIT_1(__has_unique_object_representations,
534538
TYPE_TRAIT_2(__is_layout_compatible, IsLayoutCompatible, KEYCXX)
535539
TYPE_TRAIT_2(__is_pointer_interconvertible_base_of, IsPointerInterconvertibleBaseOf, KEYCXX)
536540

537-
#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) KEYWORD(__##Trait, KEYCXX)
538541
#include "clang/Basic/TransformTypeTraits.def"
539542

540543
// Clang-only C++ Type Traits

clang/lib/Basic/Targets/ARM.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,9 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple,
311311
switch (Triple.getEnvironment()) {
312312
case llvm::Triple::Android:
313313
case llvm::Triple::GNUEABI:
314+
case llvm::Triple::GNUEABIT64:
314315
case llvm::Triple::GNUEABIHF:
316+
case llvm::Triple::GNUEABIHFT64:
315317
case llvm::Triple::MuslEABI:
316318
case llvm::Triple::MuslEABIHF:
317319
case llvm::Triple::OpenHOS:

clang/lib/Basic/Targets/OSTargets.h

+4
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public OSTargetInfo<Target> {
337337
Builder.defineMacro("_GNU_SOURCE");
338338
if (this->HasFloat128)
339339
Builder.defineMacro("__FLOAT128__");
340+
if (Triple.isTime64ABI()) {
341+
Builder.defineMacro("_FILE_OFFSET_BITS", "64");
342+
Builder.defineMacro("_TIME_BITS", "64");
343+
}
340344
}
341345

342346
public:

clang/lib/CodeGen/CGBuiltin.cpp

+20-25
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,24 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type,
10011001
// Can't find the field referenced by the "counted_by" attribute.
10021002
return nullptr;
10031003

1004+
if (isa<DeclRefExpr>(Base))
1005+
// The whole struct is specificed in the __bdos. The calculation of the
1006+
// whole size of the structure can be done in two ways:
1007+
//
1008+
// 1) sizeof(struct S) + count * sizeof(typeof(fam))
1009+
// 2) offsetof(struct S, fam) + count * sizeof(typeof(fam))
1010+
//
1011+
// The first will add additional padding after the end of the array,
1012+
// allocation while the second method is more precise, but not quite
1013+
// expected from programmers. See
1014+
// https://lore.kernel.org/lkml/ZvV6X5FPBBW7CO1f@archlinux/ for a
1015+
// discussion of the topic.
1016+
//
1017+
// GCC isn't (currently) able to calculate __bdos on a pointer to the whole
1018+
// structure. Therefore, because of the above issue, we'll choose to match
1019+
// what GCC does for consistency's sake.
1020+
return nullptr;
1021+
10041022
// Build a load of the counted_by field.
10051023
bool IsSigned = CountedByFD->getType()->isSignedIntegerType();
10061024
Value *CountedByInst = EmitCountedByFieldExpr(Base, FAMDecl, CountedByFD);
@@ -1031,32 +1049,9 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type,
10311049
CharUnits Size = Ctx.getTypeSizeInChars(ArrayTy->getElementType());
10321050
llvm::Constant *ElemSize =
10331051
llvm::ConstantInt::get(ResType, Size.getQuantity(), IsSigned);
1034-
Value *FAMSize =
1052+
Value *Res =
10351053
Builder.CreateMul(CountedByInst, ElemSize, "", !IsSigned, IsSigned);
1036-
FAMSize = Builder.CreateIntCast(FAMSize, ResType, IsSigned);
1037-
Value *Res = FAMSize;
1038-
1039-
if (isa<DeclRefExpr>(Base)) {
1040-
// The whole struct is specificed in the __bdos.
1041-
const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(OuterRD);
1042-
1043-
// Get the offset of the FAM.
1044-
llvm::Constant *FAMOffset = ConstantInt::get(ResType, Offset, IsSigned);
1045-
Value *OffsetAndFAMSize =
1046-
Builder.CreateAdd(FAMOffset, Res, "", !IsSigned, IsSigned);
1047-
1048-
// Get the full size of the struct.
1049-
llvm::Constant *SizeofStruct =
1050-
ConstantInt::get(ResType, Layout.getSize().getQuantity(), IsSigned);
1051-
1052-
// max(sizeof(struct s),
1053-
// offsetof(struct s, array) + p->count * sizeof(*p->array))
1054-
Res = IsSigned
1055-
? Builder.CreateBinaryIntrinsic(llvm::Intrinsic::smax,
1056-
OffsetAndFAMSize, SizeofStruct)
1057-
: Builder.CreateBinaryIntrinsic(llvm::Intrinsic::umax,
1058-
OffsetAndFAMSize, SizeofStruct);
1059-
}
1054+
Res = Builder.CreateIntCast(Res, ResType, IsSigned);
10601055

10611056
// A negative \p IdxInst or \p CountedByInst means that the index lands
10621057
// outside of the flexible array member. If that's the case, we want to

0 commit comments

Comments
 (0)