Skip to content

Commit df629ba

Browse files
authored
Merge branch 'main' into lldb-expose-queue-thread-plan-for-single-instruction
2 parents 1faea15 + 63fcce6 commit df629ba

File tree

62 files changed

+1764
-442
lines changed

Some content is hidden

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

62 files changed

+1764
-442
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1859,12 +1859,18 @@ The following type trait primitives are supported by Clang. Those traits marked
18591859
* ``__is_trivially_constructible`` (C++, GNU, Microsoft)
18601860
* ``__is_trivially_copyable`` (C++, GNU, Microsoft)
18611861
* ``__is_trivially_destructible`` (C++, MSVC 2013)
1862-
* ``__is_trivially_relocatable`` (Clang): Returns true if moving an object
1862+
* ``__is_trivially_relocatable`` (Clang) (Deprecated,
1863+
use ``__builtin_is_cpp_trivially_relocatable`` instead).
1864+
Returns true if moving an object
18631865
of the given type, and then destroying the source object, is known to be
18641866
functionally equivalent to copying the underlying bytes and then dropping the
18651867
source object on the floor. This is true of trivial types,
18661868
C++26 relocatable types, and types which
18671869
were made trivially relocatable via the ``clang::trivial_abi`` attribute.
1870+
This trait is deprecated and should be replaced by
1871+
``__builtin_is_cpp_trivially_relocatable``. Note however that it is generally
1872+
unsafe to relocate a C++-relocatable type with ``memcpy`` or ``memmove``;
1873+
use ``__builtin_trivially_relocate``.
18681874
* ``__builtin_is_cpp_trivially_relocatable`` (C++): Returns true if an object
18691875
is trivially relocatable, as defined by the C++26 standard [meta.unary.prop].
18701876
Note that when relocating the caller code should ensure that if the object is polymorphic,

clang/docs/ReleaseNotes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,15 @@ Bug Fixes to Compiler Builtins
574574
- ``__has_unique_object_representations(Incomplete[])`` is no longer accepted, per
575575
`LWG4113 <https://cplusplus.github.io/LWG/issue4113>`_.
576576

577+
- ``__builtin_is_cpp_trivially_relocatable``, ``__builtin_is_replaceable`` and
578+
``__builtin_trivially_relocate`` have been added to support standard C++26 relocation.
579+
580+
- ``__is_trivially_relocatable`` has been deprecated, and uses should be replaced by
581+
``__builtin_is_cpp_trivially_relocatable``.
582+
Note that, it is generally unsafe to ``memcpy`` non-trivially copyable types that
583+
are ``__builtin_is_cpp_trivially_relocatable``. It is recommended to use
584+
``__builtin_trivially_relocate`` instead.
585+
577586
Bug Fixes to Attribute Support
578587
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
579588
- Fixed crash when a parameter to the ``clang::annotate`` attribute evaluates to ``void``. See #GH119125

clang/include/clang/APINotes/Types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ class TagInfo : public CommonTypeInfo {
737737
std::optional<std::string> SwiftImportAs;
738738
std::optional<std::string> SwiftRetainOp;
739739
std::optional<std::string> SwiftReleaseOp;
740+
std::optional<std::string> SwiftDefaultOwnership;
740741

741742
/// The Swift protocol that this type should be automatically conformed to.
742743
std::optional<std::string> SwiftConformance;
@@ -786,6 +787,8 @@ class TagInfo : public CommonTypeInfo {
786787
SwiftRetainOp = RHS.SwiftRetainOp;
787788
if (!SwiftReleaseOp)
788789
SwiftReleaseOp = RHS.SwiftReleaseOp;
790+
if (!SwiftDefaultOwnership)
791+
SwiftDefaultOwnership = RHS.SwiftDefaultOwnership;
789792

790793
if (!SwiftConformance)
791794
SwiftConformance = RHS.SwiftConformance;
@@ -815,6 +818,7 @@ inline bool operator==(const TagInfo &LHS, const TagInfo &RHS) {
815818
LHS.SwiftImportAs == RHS.SwiftImportAs &&
816819
LHS.SwiftRetainOp == RHS.SwiftRetainOp &&
817820
LHS.SwiftReleaseOp == RHS.SwiftReleaseOp &&
821+
LHS.SwiftDefaultOwnership == RHS.SwiftDefaultOwnership &&
818822
LHS.SwiftConformance == RHS.SwiftConformance &&
819823
LHS.isFlagEnum() == RHS.isFlagEnum() &&
820824
LHS.isSwiftCopyable() == RHS.isSwiftCopyable() &&

clang/include/clang/Basic/TokenKinds.def

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,6 @@ TYPE_TRAIT_2(__is_pointer_interconvertible_base_of, IsPointerInterconvertibleBas
544544
#include "clang/Basic/TransformTypeTraits.def"
545545

546546
// Clang-only C++ Type Traits
547-
TYPE_TRAIT_1(__is_trivially_relocatable, IsTriviallyRelocatable, KEYCXX)
548547
TYPE_TRAIT_1(__is_trivially_equality_comparable, IsTriviallyEqualityComparable, KEYCXX)
549548
TYPE_TRAIT_1(__is_bounded_array, IsBoundedArray, KEYCXX)
550549
TYPE_TRAIT_1(__is_unbounded_array, IsUnboundedArray, KEYCXX)
@@ -556,8 +555,11 @@ TYPE_TRAIT_2(__reference_converts_from_temporary, ReferenceConvertsFromTemporary
556555
// IsDeducible is only used internally by clang for CTAD implementation and
557556
// is not exposed to users.
558557
TYPE_TRAIT_2(/*EmptySpellingName*/, IsDeducible, KEYCXX)
559-
TYPE_TRAIT_1(__is_bitwise_cloneable, IsBitwiseCloneable, KEYALL)
558+
559+
// __is_trivially_relocatable is deprecated
560560
TYPE_TRAIT_1(__builtin_is_cpp_trivially_relocatable, IsCppTriviallyRelocatable, KEYCXX)
561+
TYPE_TRAIT_1(__is_trivially_relocatable, IsTriviallyRelocatable, KEYCXX)
562+
TYPE_TRAIT_1(__is_bitwise_cloneable, IsBitwiseCloneable, KEYALL)
561563
TYPE_TRAIT_1(__builtin_is_replaceable, IsReplaceable, KEYCXX)
562564
TYPE_TRAIT_1(__builtin_structured_binding_size, StructuredBindingSize, KEYCXX)
563565

clang/include/clang/Serialization/ModuleCache.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "clang/Basic/LLVM.h"
1313
#include "llvm/ADT/IntrusiveRefCntPtr.h"
1414

15+
#include <ctime>
16+
1517
namespace llvm {
1618
class AdvisoryLock;
1719
} // namespace llvm
@@ -31,11 +33,23 @@ class ModuleCache : public RefCountedBase<ModuleCache> {
3133
virtual std::unique_ptr<llvm::AdvisoryLock>
3234
getLock(StringRef ModuleFilename) = 0;
3335

36+
// TODO: Abstract away timestamps with isUpToDate() and markUpToDate().
37+
// TODO: Consider exposing a "validation lock" API to prevent multiple clients
38+
// concurrently noticing an out-of-date module file and validating its inputs.
39+
40+
/// Returns the timestamp denoting the last time inputs of the module file
41+
/// were validated.
42+
virtual std::time_t getModuleTimestamp(StringRef ModuleFilename) = 0;
43+
44+
/// Updates the timestamp denoting the last time inputs of the module file
45+
/// were validated.
46+
virtual void updateModuleTimestamp(StringRef ModuleFilename) = 0;
47+
3448
/// Returns this process's view of the module cache.
3549
virtual InMemoryModuleCache &getInMemoryModuleCache() = 0;
3650
virtual const InMemoryModuleCache &getInMemoryModuleCache() const = 0;
3751

38-
// TODO: Virtualize writing/reading PCM files, timestamping, pruning, etc.
52+
// TODO: Virtualize writing/reading PCM files, pruning, etc.
3953

4054
virtual ~ModuleCache() = default;
4155
};

clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h"
1313
#include "clang/Tooling/DependencyScanning/InProcessModuleCache.h"
1414
#include "llvm/ADT/BitmaskEnum.h"
15+
#include "llvm/Support/Chrono.h"
1516

1617
namespace clang {
1718
namespace tooling {
@@ -84,7 +85,9 @@ class DependencyScanningService {
8485
DependencyScanningService(
8586
ScanningMode Mode, ScanningOutputFormat Format,
8687
ScanningOptimizations OptimizeArgs = ScanningOptimizations::Default,
87-
bool EagerLoadModules = false, bool TraceVFS = false);
88+
bool EagerLoadModules = false, bool TraceVFS = false,
89+
std::time_t BuildSessionTimestamp =
90+
llvm::sys::toTimeT(std::chrono::system_clock::now()));
8891

8992
ScanningMode getMode() const { return Mode; }
9093

@@ -100,7 +103,9 @@ class DependencyScanningService {
100103
return SharedCache;
101104
}
102105

103-
ModuleCacheMutexes &getModuleCacheMutexes() { return ModCacheMutexes; }
106+
ModuleCacheEntries &getModuleCacheEntries() { return ModCacheEntries; }
107+
108+
std::time_t getBuildSessionTimestamp() const { return BuildSessionTimestamp; }
104109

105110
private:
106111
const ScanningMode Mode;
@@ -113,8 +118,10 @@ class DependencyScanningService {
113118
const bool TraceVFS;
114119
/// The global file system cache.
115120
DependencyScanningFilesystemSharedCache SharedCache;
116-
/// The global module cache mutexes.
117-
ModuleCacheMutexes ModCacheMutexes;
121+
/// The global module cache entries.
122+
ModuleCacheEntries ModCacheEntries;
123+
/// The build session timestamp.
124+
std::time_t BuildSessionTimestamp;
118125
};
119126

120127
} // end namespace dependencies

clang/include/clang/Tooling/DependencyScanning/InProcessModuleCache.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
namespace clang {
1919
namespace tooling {
2020
namespace dependencies {
21-
struct ModuleCacheMutexes {
21+
struct ModuleCacheEntry {
22+
std::shared_mutex CompilationMutex;
23+
std::atomic<std::time_t> Timestamp = 0;
24+
};
25+
26+
struct ModuleCacheEntries {
2227
std::mutex Mutex;
23-
llvm::StringMap<std::unique_ptr<std::shared_mutex>> Map;
28+
llvm::StringMap<std::unique_ptr<ModuleCacheEntry>> Map;
2429
};
2530

2631
IntrusiveRefCntPtr<ModuleCache>
27-
makeInProcessModuleCache(ModuleCacheMutexes &Mutexes);
32+
makeInProcessModuleCache(ModuleCacheEntries &Entries);
2833
} // namespace dependencies
2934
} // namespace tooling
3035
} // namespace clang

clang/lib/APINotes/APINotesFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const uint16_t VERSION_MAJOR = 0;
2424
/// API notes file minor version number.
2525
///
2626
/// When the format changes IN ANY WAY, this number should be incremented.
27-
const uint16_t VERSION_MINOR = 34; // SwiftReturnOwnership
27+
const uint16_t VERSION_MINOR = 35; // SwiftDefaultOwnership
2828

2929
const uint8_t kSwiftConforms = 1;
3030
const uint8_t kSwiftDoesNotConform = 2;

clang/lib/APINotes/APINotesReader.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,13 @@ class TagTableInfo
624624
ReleaseOpLength - 1);
625625
Data += ReleaseOpLength - 1;
626626
}
627+
unsigned DefaultOwnershipLength =
628+
endian::readNext<uint16_t, llvm::endianness::little>(Data);
629+
if (DefaultOwnershipLength > 0) {
630+
Info.SwiftDefaultOwnership = std::string(
631+
reinterpret_cast<const char *>(Data), DefaultOwnershipLength - 1);
632+
Data += DefaultOwnershipLength - 1;
633+
}
627634
if (unsigned ConformanceLength =
628635
endian::readNext<uint16_t, llvm::endianness::little>(Data)) {
629636
Info.SwiftConformance = std::string(reinterpret_cast<const char *>(Data),

clang/lib/APINotes/APINotesWriter.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,7 @@ class TagTableInfo : public CommonTypeTableInfo<TagTableInfo, TagInfo> {
12741274
return 2 + (TI.SwiftImportAs ? TI.SwiftImportAs->size() : 0) +
12751275
2 + (TI.SwiftRetainOp ? TI.SwiftRetainOp->size() : 0) +
12761276
2 + (TI.SwiftReleaseOp ? TI.SwiftReleaseOp->size() : 0) +
1277+
2 + (TI.SwiftDefaultOwnership ? TI.SwiftDefaultOwnership->size() : 0) +
12771278
2 + (TI.SwiftConformance ? TI.SwiftConformance->size() : 0) +
12781279
3 + getCommonTypeInfoSize(TI);
12791280
// clang-format on
@@ -1322,6 +1323,12 @@ class TagTableInfo : public CommonTypeTableInfo<TagTableInfo, TagInfo> {
13221323
} else {
13231324
writer.write<uint16_t>(0);
13241325
}
1326+
if (auto DefaultOwnership = TI.SwiftDefaultOwnership) {
1327+
writer.write<uint16_t>(DefaultOwnership->size() + 1);
1328+
OS.write(DefaultOwnership->c_str(), DefaultOwnership->size());
1329+
} else {
1330+
writer.write<uint16_t>(0);
1331+
}
13251332
if (auto Conformance = TI.SwiftConformance) {
13261333
writer.write<uint16_t>(Conformance->size() + 1);
13271334
OS.write(Conformance->c_str(), Conformance->size());

0 commit comments

Comments
 (0)