Commit Graph

13074 Commits

Author SHA1 Message Date
Anthony Latsis
bbd84429a0 Merge pull request #83400 from swiftlang/jepa-main
Address `llvm::PointerUnion::{is,get}` deprecations
2025-07-30 17:19:58 +01:00
Anthony Latsis
3f841b515c Merge remote-tracking branch 'origin/main' into jepa-rebranch 2025-07-30 14:31:33 +01:00
JanBaig
988a3dcf25 [SIL] Introduce new SILDeclRef 2025-07-29 21:16:11 -04:00
Doug Gregor
9194fa0ab7 Merge pull request #83364 from DougGregor/noncopyable-imported-c-struct-destroy
[Clang importer] Allow noncopyable C structs to define "destroy" operation
2025-07-29 18:16:05 -07:00
Anthony Latsis
fec049e5e4 Address llvm::PointerUnion::{is,get} deprecations
These were deprecated in
https://github.com/llvm/llvm-project/pull/122623.
2025-07-29 18:37:48 +01:00
Saleem Abdulrasool
07da452a2b build: check and add -fsized-deallocation
We use C++17 for the Swift compiler and IRGen uses the sized
deallocation for releasing memory it creates with over-allocation. That
triggers ASAN warnings due to the mismatched
`operator new`/`operator delete`.
2025-07-29 10:01:26 -07:00
Doug Gregor
6ba560fb4b [Clang importer] Allow noncopyable C structs to define "destroy" operation
A C struct can be imported as noncopyable, but C doesn't have
destructors, so there is no way to provide user-defined logic to
perform the destruction. Introduce a new swift_attr that applies to
imported noncopyable types and which provides such a "destroy"
operation. It can be used like this:

    typedef struct __attribute__((swift_attr("~Copyable")))
                   __attribute__((swift_attr("destroy:wgpuAdapterInfoFreeMembers")))
      WGPUAdapterInfo { /*...*/ } WGPUAdapterInfo;

    void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo);

This will bring the WGPUAdapterInfo struct in as a noncopyable type
that will be cleaned up by calling wgpuAdapterInfoFreeMembers once it
is no longer in use.

Implements rdar://156889370.
2025-07-28 00:02:31 -07:00
Saleem Abdulrasool
87b4b0ec46 IRGen: correct some type deletion
ASAN identified mismatched `operator new` and `operator delete` on these
types. The reason for this is the sized allocation for the tail packing
involved. Provide the associated `operator delete` that releases the
memory. Note that the `operator delete` is static and does not have the
implicit `this` pointer, and we cannot use the name `this` for the
variable.
2025-07-25 16:06:41 -07:00
Shubham Sandeep Rastogi
5b4fdd6e62 Revert "Set the Compilation directory when generating the Skeleton CU"
This reverts commit b286b1c3a5.

Reverted because fix for rdar://131726681 broke rdar://154247270

Reverting and will try to fix properly later
2025-07-24 10:59:11 -07:00
Anthony Latsis
7f8dc07f1c Merge pull request #83283 from swiftlang/jepa-rebranch
DebugInfo: Stop setting `FlagObjectPointer` without being certain tha…
2025-07-24 09:56:59 +01:00
Anthony Latsis
e246f0de59 DebugInfo: Stop setting FlagObjectPointer without being certain that the parameter is self
The stable/21.x branch is not happy with us setting the object pointer
flag here because it now asserts that this flag is set for at most one
function parameter. We should add a dedicated routine for instance
method parameters. For now, stop setting the flag altogether to unblock
the stdlib build on rebranch.
2025-07-24 09:17:00 +01:00
swift-ci
077ba17bee Merge remote-tracking branch 'origin/main' into rebranch 2025-07-23 23:18:26 -07:00
Augusto Noronha
c03831f70d [DebugInfo] Fix infinite recursion when opaque return type is defined
inside function returning it

A stack overflow would happen when the compiler tried emitting debug
info for a function whose opaque return type was declared inside the
function itself. This fixes the issue by emitting a forward declaration
for the function before emitting it.

rdar://150313956
2025-07-23 15:24:34 -07:00
swift-ci
367f0082fc Merge remote-tracking branch 'origin/main' into rebranch 2025-07-22 22:17:45 -07:00
Anthony Latsis
c7b51edf0a Merge pull request #83204 from swiftlang/jepa-main
Address rebranch deprecations
2025-07-23 06:00:57 +01:00
swift-ci
7284a7f790 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-22 13:18:10 -07:00
eeckstein
18b02a7c70 Merge pull request #83172 from eeckstein/span-bounds-checking
Improve Span bounds check elimination by adding `_assumeNonNegative` to `count`
2025-07-22 22:00:43 +02:00
Erik Eckstein
27dc031d1e IRGen: better code generation for the _assumeNonNegative intrinsic
So far we only supported this for `load` and `call` arguments. Now we use `llvm.assume` for other kind of argument values.
This helps optimizing bounds checking for `Span`.
2025-07-22 12:42:54 +02:00
Erik Eckstein
b68cafb870 SIL: allow casts to class-bound archetypes to be done as scalar-casts instead of address-casts
This allows such casts to be done in embedded swift.

rdar://156302495
2025-07-22 07:04:37 +02:00
Anthony Latsis
b04d6085f3 IRGen: Address llvm::InsertPosition ctor deprecation
See https://github.com/llvm/llvm-project/pull/102608.
2025-07-21 12:50:39 +01:00
Anthony Latsis
b66a1aa8c5 DriverTool,IRGen: Address llvm::Target::createTargetMachine overload deprecation
See https://github.com/llvm/llvm-project/pull/130940.
2025-07-21 12:47:48 +01:00
Anthony Latsis
db58043b40 IRGen: Address llvm::Intrinsic::getDeclaration deprecation
See https://github.com/llvm/llvm-project/pull/112242.
2025-07-21 12:45:45 +01:00
Anthony Latsis
3ba8ab4094 IRGen: Address llvm::Instruction::{move,insert}Before deprecations
See 79499f010d.
2025-07-21 12:41:18 +01:00
Anthony Latsis
ed1d70fb3b IRGen: Address llvm::PointerType::get(Unqual) deprecations
See https://github.com/llvm/llvm-project/pull/134517.
2025-07-21 12:37:15 +01:00
Anthony Latsis
f8577a2731 IRGen: Address llvm::Type::getPointerTo deprecation
See https://github.com/llvm/llvm-project/pull/113331.
2025-07-21 12:37:15 +01:00
Anthony Latsis
d71d0f92b4 Merge pull request #83188 from swiftlang/jepa-rebranch
[rebranch] Get rebranch swift-frontend building again
2025-07-19 21:51:16 +01:00
Anthony Latsis
6132f529c8 IRBuilder: Resolve ambiguous call
It looks like the addition of a defaulted parameter to
`llvm::IRBuilderBase::CreateOr` in
https://github.com/llvm/llvm-project/pull/146350 caused it to conflict
with our own version of the method. Sync up their signatures.
2025-07-19 02:00:50 +01:00
Anthony Latsis
c1d794364b Adjust code after changes to llvm::TrailingObjects API
See:
- https://github.com/llvm/llvm-project/pull/138970
- https://github.com/llvm/llvm-project/pull/144930
2025-07-19 01:48:18 +01:00
swift-ci
9de927f857 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-18 12:17:41 -07:00
Allan Shortlidge
d19d4ee99b IRGen: Use AvailabilityRange::forDeploymentTarget().
It should be preferred over querying the deployment range from the availability
domain returned by `ASTContext::getTargetAvailabilityDomain()`.

NFC.
2025-07-17 14:14:21 -07:00
swift-ci
53d799f9b8 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-15 21:35:21 -07:00
Slava Pestov
de068cb130 Merge pull request #83070 from slavapestov/remove-redundant-functor
AST: Remove MakeAbstractConformanceForGenericType
2025-07-15 23:44:59 -04:00
swift-ci
3787a312d7 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-15 17:17:19 -07:00
Allan Shortlidge
fa267fefff Merge pull request #83051 from tshortli/diagnose-more-invalid-os-versions
Sema: Diagnose invalid platform versions in more places
2025-07-15 17:06:39 -07:00
Slava Pestov
ee440f3c91 AST: Remove MakeAbstractConformanceForGenericType
While the intent behind this functor was noble, it has grown in complexity
considerably over the years, and it seems to be nothing but a source of
crashes in practice. I don't want to deal with it anymore, so I've decided
to just subsume all usages with LookUpConformanceInModule instead.
2025-07-15 16:34:11 -04:00
swift-ci
2c5edc4fd0 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-15 09:41:03 -07:00
Meghana Gupta
a4ad806319 Merge pull request #82890 from meg-gupta/simplifyendcowaddr
Add simplification for end_cow_mutation_addr
2025-07-15 07:37:13 -07:00
Allan Shortlidge
910989c2c2 AST: Store parsed version in OriginallyDefinedInAttr instead of canonical.
Canonicalize the version on-demand instead.

NFC, part of rdar://155558161.
2025-07-14 16:04:04 -07:00
Meghana Gupta
e317a603fc Add simplification for end_cow_mutation_addr
We insert end_cow_mutation_addr for lifetime dependent values dependent on mutable addresses.
end_cow_mutation_addr can be simplified to end_cow_mutation after other optimizations like inlining, specialization etc

This PR adds an instruction simplification to transform end_cow_mutation_addr to end_cow_mutation.
This can enable array optimizations which look for end_cow_mutation.
2025-07-14 13:46:13 -07:00
swift-ci
d7abf372e4 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-12 09:55:31 -07:00
Doug Gregor
badba55bf1 [IRGen] Mangling of nonisolated(nonsending) function types was introduced in Swift 6.2
We can't use mangled named when back-deploying earlier.
2025-07-11 14:24:54 -07:00
Doug Gregor
f3eca93e7f [IRGen] Don't use mangled names for metadata including Span et al when back-deploying
If back-deploying prior to the introduction of name mangling and
runtime support for invertible constraints (~Copyable, ~Escapable),
don't use mangled names to access metadata. The code already existed
for this, but had a carve-out that still used mangled names for
standard library types that have always existed but got generalized to
support non-copyable & non-escapable types.

Tweak that carve-out to not apply to types like Span that come from a
back-deployment library. Fixes crashes when using metadata for Span et
al on older platforms.

Fixes rdar://155639204.
2025-07-11 14:24:53 -07:00
swift-ci
26f4401fbe Merge remote-tracking branch 'origin/main' into rebranch 2025-07-02 10:45:20 -07:00
Arnold Schwaighofer
0442c7c417 Merge pull request #82646 from aschwaighofer/wip_opt_remarks_wmo
Support LLVM optimization remarks in WMO mode
2025-07-02 10:40:35 -07:00
swift-ci
6b4bc80f19 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-01 21:01:28 -07:00
Doug Gregor
46572f80a2 Merge pull request #82661 from DougGregor/back-deploy-main-actor-isolated-deinit
[SE-0371] Back-deploy support for main-actor-isolated deinit
2025-07-01 20:50:19 -07:00
swift-ci
57a59c7755 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-01 13:20:53 -07:00
Joe Groff
1c75d3b740 Merge pull request #82323 from jckarter/addressable-for-dependencies-vw-flag
Add an "addressable for dependencies" flag to value witness flags.
2025-07-01 13:02:17 -07:00
Arnold Schwaighofer
b30bd40b83 Add code to create llvm::RemarkStreamer objects for all the LLVMModules in WMO mode
rdar://154403078
2025-07-01 07:19:33 -07:00
swift-ci
bd5eb5b972 Merge remote-tracking branch 'origin/main' into rebranch 2025-06-30 20:18:41 -07:00