Commit Graph

12816 Commits

Author SHA1 Message Date
Egor Zhdan
276a232ea8 Merge pull request #67536 from apple/egorzhdan/unsafe-cxx-mutable-input-iterator
[cxx-interop] Add `UnsafeCxxMutableInputIterator` protocol
2023-07-26 22:15:57 +01:00
Egor Zhdan
8d7d0efe13 [cxx-interop] Add UnsafeCxxMutableInputIterator protocol
This is an inheritor of the existing `UnsafeCxxInputIterator` protocol, with the only difference being the ability to mutate `var pointee` via a non-const `operator*()`.

This is needed to support mutable subscripts for `std::map` via `CxxDictionary`.

rdar://105399019
2023-07-26 18:20:49 +01:00
Joe Groff
705e317c3f Merge pull request #67425 from jckarter/raw-storage
[WIP] Raw storage and locks/atomics prototype
2023-07-26 08:49:02 -07:00
Erik Eckstein
a3822cd2c5 IRGen: fix a problem with 24-bit enum payloads in statically initialized global variables
IRGen crashed in case an enum, which has a 24 bit payload (e.g. three `UInt8`), is used as a payload of another enum, e.g. `Optional`, in a statically initialized global variable.

rdar://112823823
2023-07-26 15:36:31 +02:00
Evan Wilde
dd5ffc5cd2 More header include fixes
MapVector started querying for constructability of stored types with
templates. As such, we need the definition of `LocalTypeDataKey` so that
it can instantiate the template.

We also lost a transitive include of `TinyPtrVector`, which we use, so
including it in `ConformanceLookupTable.h`.
2023-07-25 14:52:43 -07:00
Evan Wilde
3ed31d3bf7 Fixing StandardInstrumentation API
StandardInstrumentation now takes a reference to the module context and
registering callbacks takes the module analysis manager instead of the
function analysis manager.
2023-07-25 12:28:28 -07:00
Evan Wilde
f5cd20c34a llvm::Function basic block list fix
`llvm::Function` hid the basic block list. Making adjustments for
splicing and appending.
2023-07-25 12:28:28 -07:00
Evan Wilde
5bcdc57a81 Resolving PrintModulePass move
PrintModulePass moved to IRPrinter from IR. Handling the move here.
2023-07-25 12:28:28 -07:00
Evan Wilde
d574e6e7d0 Update DebugInfo option location 2023-07-25 12:28:28 -07:00
Evan Wilde
044002934b Remove Typed-Pointer cutouts
This removes some of the typed pointer cutouts in IRGen.
LLVM has removed the typed pointers, so `LLVMContext.setOpaquePointers`
doesn't make sense. Clang doesn't have opaque pointers either.

Also removing defunct assertions in IRGen were checking pointer-type
information. With llvm moving to opaque pointer types, these functions
are no longer returning useful information and are deprecated.

Specifically
 - `isOpaqueOrPointeeTypeMatches` always returns true
 - `supportsTypedPointers()` always returns false
 - `getNonOpaquePointerElementType()->isFunctionTy()` will never get hit
2023-07-25 12:28:28 -07:00
Evan Wilde
f3cd71d2d1 [NFC] updating StringRef API
`StringRef::endswith_insensitive` and
`StringRef::startswith_insensitive` is deprecated and being replaced
with `StringRef::ends_with_insensitive` and
`StringRef::starts_with_insensitive` respectively.
2023-07-25 12:28:28 -07:00
Evan Wilde
544bcd300e Update llvm module APIs
llvm::Module made the direct access to the alias list and global list
private. This patch switches IRGen.cpp over to using the public
functions that run on top of the list without exposing them.
2023-07-25 12:28:28 -07:00
Evan Wilde
ecbccb9310 Update clang TargetInfo AddressSpace API usage
The TargetInfo pointer APIs updated to taking an "AddressSpace" type
instead of a raw integer. This goes through and updates the call
locations where this change caused build failures. In all cases, the
value passed was `0`, corresponding with the Default AddressSpace.
2023-07-25 12:28:28 -07:00
Evan Wilde
f4946e9718 Updating more alignment APIs
Adding a few more updates to places where the ABI Alignment functions
changed. `getABITypeAlignment` was replaced with `getABITypeAlign`,
which returns an `llvm::Align` instead of an unsigned int.
2023-07-25 12:28:28 -07:00
Evan Wilde
9b61bb4b8d More llvm::Optional::transform -> swift::transform
Translating more llvm::Optional::transform calls to swift::transform.
`llvm::Optional` had a transform function that ran a lambda on the
element stored in the optional if it existed. After migrating to
std::optional under the hood, that function went away. Replacing it with
calls to swift::optional in STLExtras.h.
2023-07-25 12:28:27 -07:00
Evan Wilde
fd156f2717 More APInt API updates
Updating more APInt and bit-manipulation API changes.
2023-07-25 12:28:27 -07:00
swift_jenkins
2c2ba785f3 Merge remote-tracking branch 'origin/main' into next 2023-07-25 07:23:34 -07:00
Joe Groff
aee071bf4e Introduce an experimental @_rawLayout attribute.
This attribute can be attached to a noncopyable struct to specify that its
storage is raw, meaning the type definition is (with some limitations)
able to do as it pleases with the storage. This provides a basis for
implementing types for things like atomics, locks, and data structures
that use inline storage to store conditionally-initialized values.
The example in `test/Prototypes/UnfairLock.swift` demonstrates the use
of a raw layout type to wrap Darwin's `os_unfair_lock` APIs, allowing
a lock value to be stored inside of classes or other types without
needing a separate allocation, and using the borrow model to enforce
safe access to lock-guarded storage.
2023-07-24 14:28:19 -07:00
Nate Chandler
3f069df550 [IRGen] Add metadata pack markers for destroys.
Destroys of values whose types feature a pack may require allocating the
pack on-stack.

Thanks to @slavapestov for the test case.

rdar://112792831
2023-07-24 14:19:24 -07:00
swift_jenkins
e4d6090728 Merge remote-tracking branch 'origin/main' into next 2023-07-21 10:05:25 -07:00
John McCall
33ccc004c8 Merge pull request #67445 from rjmccall/translate-expansion-pattern-for-layout
Translate the pattern type of a pack expansion when emitting type metadata for layout
2023-07-21 12:51:34 -04:00
swift_jenkins
81614b11ec Merge remote-tracking branch 'origin/main' into next 2023-07-21 07:09:38 -07:00
Alex Lorenz
15a0345857 Merge pull request #67268 from hyp/eng/windows-method-oh-no
[cxx-interop] windows methods fixes
2023-07-21 06:57:01 -07:00
John McCall
fdd3aa7ae6 Translate the pattern type of a pack expansion when emitting
type metadata for layout.

Fixes rdar://110971671
2023-07-20 22:38:38 -04:00
John McCall
61a09ef1a0 [NFC] Rename EmitTypeMetadataRefForLayout to reflect its actual job
This visitor used to directly return type metadata, but at some
point we simplified the code a lot by just doing a type rewrite
and then calling into the normal type metadata emitter.  Apparently
we didn't rename the visitor at the time, though, so it's got this
very misleading name.
2023-07-20 22:38:38 -04:00
swift_jenkins
c6e5e8024c Merge remote-tracking branch 'origin/main' into next 2023-07-19 19:43:35 -07:00
Dario Rexin
69c8ae6ff3 [IRGen] Fix extra inhabitant offset for simple single payload enums with layout strings 2023-07-19 16:03:52 -07:00
swift_jenkins
e1efedaeb3 Merge remote-tracking branch 'origin/main' into next 2023-07-18 13:25:21 -07:00
Dario Rexin
937d1727a3 [IRGen] Fix enum metadata instantiation for resilient payload
The metadata can't be constant when we generate a layout string at runtime.
2023-07-17 16:00:41 -07:00
Evan Wilde
6e59c42201 more APInt renames 2023-07-17 10:55:57 -07:00
Evan Wilde
bc904880d0 Handle new builtin cases: AArch64SVcount, WASMRefType
Clang and LLVM added some new builtins.

LLVM added IITDescriptor::AArch64Svcount, which I set to not be
decodable since Swift can't represent those at the moment.

Also added handling for the WASM reference type builtins in the Clang
type converter.
2023-07-17 10:55:57 -07:00
Evan Wilde
26a974e772 [NFC] Headers headers headers!
Including headers that were being transitively included from LLVM
before. Also pointing them at the new locations for some of them.
2023-07-17 10:55:55 -07:00
Evan Wilde
8ce6ee8dd1 Updating API usages
LLVM deprecated, renamed, and removed a bunch of APIs. This patch
contains a lot of the changes needed to deal with that.

The SetVector type changed the template parameters.

APInt updated multiple names, countPopulation became popcount,
getAllOnesValue became getAllOnes, getNullValue became getZero, etc...

Clang type nullability check stopped taking a clang AST context.

The LLVM IRGen Function type stopped exposing basic block list directly,
but gained enough API surface that the translation isn't too bad.
(GenControl.cpp, LLVMMergeFunctions.cpp)

llvm::Optional had a transform function. That was being used in a couple
of places, so I've added a new implementation under STLExtras that
transforms valid optionals, otherwise it returns nullopt.
2023-07-17 10:53:42 -07:00
Evan Wilde
df30fffcd1 Remove dbg addr intrinsic splitting pass
The llvm DbgAddr intrinsic was removed upstream, removing the DbgAddr
block splitting pass to get the compiler building.
2023-07-17 10:53:42 -07:00
Evan Wilde
41d59b215a Update Triple.h location
Triple moved from ADT to TargetParser. Updating includes to reflect
that.
2023-07-17 10:53:42 -07:00
Alex Lorenz
c09135b8f3 [cxx-interop] Fix the windows ABI for returning indirect values out of methods
Fixes https://github.com/apple/swift/issues/66326

This allows us to reneable Windows method tests. Note that Windows still has
a broken convention for non-trivial record with non-trivial destructor but
trivial copy-constructor, so classes in the methods.swift test need an explicit
copy constructor.

Fixes rdar://88391102
2023-07-14 15:56:05 -07:00
swift_jenkins
16a38121b7 Merge remote-tracking branch 'origin/main' into next 2023-07-14 11:26:19 -07:00
Evan Wilde
8232cba9a6 Merge pull request #67285 from etcwilde/ewilde/migrating-llvm-apis
[NFC] Migrating LLVM API usage on main
2023-07-14 11:04:31 -07:00
swift_jenkins
fd815a756f Merge remote-tracking branch 'origin/main' into next 2023-07-13 20:09:19 -07:00
Kuba (Brecka) Mracek
e34c20fdf5 Merge pull request #67243 from kubamracek/section-ump
Allow forced constant-folding of global initializers to work on UnsafeMutablePointer types
2023-07-13 20:07:05 -07:00
Evan Wilde
83b044f5fb Migrating LLVM API usage on main
This patch migrates the compiler off of the deprecated LLVM APIs where I
can.

 - APInt::getAllOnesValue -> APInt::getAllOnes
 - APInt::getNullValue -> APInt::getZero
 - APInt::isNullValue -> APInt::isZero
 - APInt::getMinSignedBits -> APInt::getSignificantBits
 - clang::Module::submodule_{begin,end} -> clang::Module::submodules
2023-07-13 11:22:35 -07:00
swift_jenkins
a57e588280 Merge remote-tracking branch 'origin/main' into next 2023-07-13 05:22:39 -07:00
Slava Pestov
aa026f4d06 Merge pull request #67266 from slavapestov/transform-type-parameter-packs
Fix various places where we didn't handle "bound" pack references correctly
2023-07-13 08:09:04 -04:00
Kuba Mracek
d4d5228534 Allow constant folding IntToPtr builtin (make it isValidInStaticInitializerOfGlobal) 2023-07-12 20:51:40 -07:00
Slava Pestov
0ca01ccd61 IRGen: Replace some usages of mapPackTypeIntoElementContext() with mapContextualPackTypeIntoElementContext() 2023-07-12 18:02:14 -04:00
swift_jenkins
d3d002b709 Merge remote-tracking branch 'origin/main' into next 2023-07-12 12:06:18 -07:00
Pavel Yaskevich
69cbb45aa0 Merge pull request #67240 from ktoso/wip-fix-indirect_in-handling-in-irgen-dist
[Distributed] Fix handling indirect @in convention params in distributed funcs
2023-07-12 11:59:49 -07:00
Konrad `ktoso` Malawski
1b74ea62b4 Add test to exercise Indirect_In codepaths in DistributedAccessor emit 2023-07-12 13:22:49 +09:00
Konrad `ktoso` Malawski
5abfc91291 [Distributed] Fix handling indirect @in convention params in distributed funcs
rdar://111887706
2023-07-12 10:24:38 +09:00
swift_jenkins
192c5ffffc Merge remote-tracking branch 'origin/main' into next 2023-07-11 16:44:38 -07:00