Commit Graph

1819 Commits

Author SHA1 Message Date
Rauhul Varma
6b9fb171bf Address rewview feedback
- Renames ExperimentalPlatformCCallingConvention to
  PlatformCCallingConvention.
- Removes non-arm calling convention support as this feature is working
  around a clang bug for some arm triples which we hope to see resolved.
- Removes misleading MetaVarName from platform-c-calling-convention
  argument.
- Replaces other uses of LLVM::CallingConv::C with
  IGM.getOptions().PlatformCCallingConvention().
2023-06-15 22:06:43 -07:00
Rauhul Varma
19f74e22e6 Add frontend flag for explicitly setting ccc
Adds a new swift-frontend flag to allow users to choose which calling
convention is used to make c function calls. This hidden flag is called
`-experimental-platform-c-calling-convention`.

This behavior is needed to workaround rdar://109431863 (Swift-frontend
produces trapping llvm ir for non-trapping sil). The root cause of this
issue is that IRGen always emits c function calls with llvm's default C
calling convention. However clang may select a different (incompatible)
calling convention for the function, eventually resulting--via
InstCombine and SimplifyCFG--in a trap instead of the function call.
This failure mode is most readily seen with the triple
`armv7em-apple-none-macho` when attempting to call functions taking
struct arguments. Example unoptimized ir below:

```llvm-ir
call void @bar([4 x i32] %17, i32 2), !dbg !109
...
define internal arm_aapcs_vfpcc void @bar(
  [4 x i32] %bar.coerce, i32 noundef %x)
```

In the future it would be better to use the clang importer or some other
tool to determine the calling convention for each function instead of
setting the calling convention frontend invocation wide.

Note: I don't know for sure whether or not clang should be explicitly
annotating these functions with a calling convention instead of
aliasing C to mean ARM_AAPCS_VFP for this particular combination of
`-target`, `-mfloat-abi`, and `-mcpu`.
2023-06-15 21:52:03 -07:00
Rintaro Ishizaki
5791a2cb37 [Macros] Plugin search options group
'load-plugin-library', 'load-plugin-executable', '-plugin-path' and
'-external-plugin-path' should be searched in the order they are
specified in the arguments.

Previously, for example '-plugin-path' used to precede
'-external-plugin-path' regardless of the position in the arguments.
2023-06-14 15:46:39 -07:00
Steven Wu
b1f99b8e93 [CAS] swift dependency scanning using CAS for compiler caching (#66366)
Teach swift dependency scanner to use CAS to capture the full dependencies for a build and construct build commands with immutable inputs from CAS.

This allows swift compilation caching using CAS.
2023-06-12 10:55:53 -07:00
Alex Lorenz
ba8d4d7801 [cxx-interop] compilations that do not enable C++ interoperability should not be able to import modules that do enable C++ interoperability by default
A supplemental hidden frontend option allows advanced users to opt-out of this requirement.

Fixes https://github.com/apple/swift/issues/65833
Fixes https://github.com/apple/swift/issues/65832
2023-06-09 15:38:16 -07:00
swift-ci
4ef135cc10 Merge pull request #66201 from nate-chandler/dealloc-on-stack-packs
[IRGen] Dealloc on-stack metadata/wtable packs on the dominance frontier.
2023-06-05 13:30:18 -07:00
Nate Chandler
e200f164a9 [Frontend] Add flag for pack metadata stack promo. 2023-06-05 08:11:27 -07:00
Doug Gregor
234534e0ce [Member name lookup] Eliminate non-lazy member loading.
Lazy member loading has been in use and the default for several years
now. However, the lazy loading was disabled for any type whose primary
definition was parsed even though some of its extensions could have
been deserialized, e.g., from a Clang module. Moreover, the non-lazy
path walked all of the extensions of such a type for all member name
lookup operations. Faced with a large number of extensions to the same
type (in my example, 6,000), this walk of the list of the extensions
could dominate type-checking time.

Eliminate all effects of the `-disable-named-lazy-member-loading`
flag, and always use the "lazy" path, which effectively does no work
for parsed type definitions and extensions thereof. The example with
6,000 extensions of a single type goes from type checking in 6 seconds
down to type checking in 0.6 seconds, and name lookup completely
disappears from the profiling trace.

The deleted tests relied on the flag that is now inert. They aren't by
themselves providing much value nowadays, and it's better to have the
simpler (and more efficient) implementation of member name lookup be
the only one.
2023-06-02 14:56:03 -07:00
Alexis Laferrière
814ca434f0 Merge pull request #66186 from xymus/force-workaround
[Serialization] Add flag to force unsafe recovery from some xref failures
2023-05-30 08:55:17 -07:00
Alexis Laferrière
261f32cb84 Merge pull request #66139 from xymus/r-module-recovery 2023-05-26 16:00:43 -07:00
Alexis Laferrière
642980cbb1 [Serialization] Add flag to force unsafe recovery from some xref failures
Intro a deserialization mode controlled by the flag
`-experimental-force-workaround-broken-modules` to attempt unsafe
recovery from deserialization failures caused by project issues.

The one issue handled at this time is when a type moves from one module
to another. With this new mode the compiler may be able to pick a
matching type in a different module. This is risky to use, but may help
in a pinch for a client to fix and issue in a library over which they
have no control.
2023-05-26 14:36:28 -07:00
Alexis Laferrière
4f66fcfadb [Serialization] Intro -Rmodule-recovery to remark about silent errors
Deserialization recovery silently drops errors and the affected decls.
This can lead to surprises when a function from an imported module
simply disappears without an explanation.

This commit introduces the flag -Rmodule-recovery to report as remarks
some of these previously silently dropped issues. It can be used to
debug project configuration issues.
2023-05-25 10:44:08 -07:00
Dario Rexin
2bb08e37f6 [ModuleInterface] Add mechanism to exclude experimental flags from th… (#66088)
* [ModuleInterface] Add mechanism to exclude experimental flags from the module interface

rdar://109722548

* Separate filtered flags from the typical/unfiltered case
2023-05-24 09:03:01 -07:00
Artem Chikin
61ea49c840 Merge pull request #65869 from artemcm/ClangImporterExplicitBuildOptions
[Explicit Module Builds] Add 'ClangImporter' setting for explicitly-built modules
2023-05-15 15:46:29 -07:00
Artem Chikin
e2ea6cb824 [Explicit Module Builds] Add 'ClangImporter' setting for explicitly-built modules
This will mean that '-disable-implicit-swift-modules' also automatically implies two things:
1. Clang modules must also be explicit, and the importer's clang instance will get '-fno-implicit-modules' and '-fno-implicit-module-maps'
2. The importer's clang instance will no longer get a '-fmodules-cache-path=', since it is not needed in explicit builds
2023-05-15 09:45:42 -07:00
Slava Pestov
c2338aa0f6 Backward deployment shim for swift_allocate{Metadata,WitnessTable}Pack() 2023-05-12 15:44:12 -04:00
Erik Eckstein
85052a1489 deprecate the -experimental-performance-annotations option
Performance annotations can now be used without specifying this option
2023-05-11 08:03:19 +02:00
Allan Shortlidge
c7352728ff Frontend: Introduce stub mode for -unavailable-decl-optimization.
Part of rdar://107388493
2023-05-03 15:19:31 -07:00
Ellie Shin
b081404daa Print package-name in .private.swiftinterface only for better abstraction
Resolves rdar://107638447
2023-04-20 17:45:22 -07:00
Ellie Shin
578c63a372 Merge pull request #65111 from apple/es-str
Allow all unicode characters in package-name input
2023-04-20 17:13:37 -07:00
Ellie Shin
3a4cd362ac Allow all unicode characters in package-name input
Error if the input is empty
Resolves rdar://104617274
2023-04-20 11:16:30 -07:00
Steven Wu
b9f9eeb198 Merge pull request #65058 from cachemeifyoucan/eng/PR-swift-cas-fs
[CAS] Integrate CAS into swift compiler
2023-04-19 09:11:30 -07:00
Steven Wu
e2c494179d [CAS] Integrate CAS into swift compiler
Teach swift compiler about CAS to allow compiler caching in the future.
1) Add flags to initiate CAS inside swift-frontend
2) Teach swift to compile using a CAS file system.
2023-04-17 13:18:09 -07:00
Alejandro Alonso
bd5d24d558 Add AvailabilityMacro feature, kind of 2023-04-16 15:42:14 -07:00
Alexis Laferrière
5080898f9b [Serialization] Disable deserialization safety along with access control
Disabling access control is fundamentally incompatible with
deserialization safety. Let's turn off safety automatically when in use.

This was reported by a few tests:

stdlib/Dictionary.swift
stdlib/Set.swift
stdlib/SetOperations.swift.gyb
stdlib/SwiftNativeNSBase.swift
2023-04-13 13:39:14 -07:00
Xi Ge
1f395ec1a8 Frontend: infer default blocklists to use when the explicit paths aren't given by swift-driver
Although swift-driver always passes down these blocklist for the compiler to consume, some frontend
tools, like ABI checker, are invoked by the build system directly. Therefore, we need to teach
the compiler to infer these blocklist files like prebuilt module cache.
2023-04-11 12:25:07 -07:00
Xi Ge
68e6b22230 ModuleInterface: pass down block list file paths to module interface building context and command lines 2023-04-08 18:29:51 -07:00
Xi Ge
2836ee357b Frontend: pass down blocklist file paths from frontend options. NFC 2023-04-07 21:26:19 -07:00
Dario Rexin
57dc5a6d42 [IRGen] Add flags to enable or disable generation of layout string value witnesses (#64819)
rdar://107477762
2023-04-07 13:45:52 -07:00
Xi Ge
0488c5a037 Merge pull request #64943 from nkcsgexi/block-list 2023-04-05 19:52:56 -07:00
Alex Lorenz
ce443011c0 Merge pull request #64924 from hyp/eng/cxx-interop-default-mode
[interop] support 'default' mode for '-cxx-interoperability-mode' option
2023-04-05 15:51:11 -07:00
Xi Ge
aa76845042 Merge branch 'main' into block-list 2023-04-05 12:21:40 -07:00
Xi Ge
2c2431e2da Frontend: add a frontend argument to pass down block list config file path 2023-04-05 12:20:49 -07:00
Steven Wu
09b8af86fb Virtualize swift compiler outputs (#63206)
Using a virutal output backend to capture all the outputs from
swift-frontend invocation. This allows redirecting and/or mirroring
compiler outputs to multiple location using different OutputBackend.

As an example usage for the virtual outputs, teach swift compiler to
check its output determinism by running the compiler invocation
twice and compare the hash of all its outputs.

Virtual output will be used to enable caching in the future.
2023-04-05 23:34:37 +08:00
Alex Lorenz
00181138fd [interop] support 'default' mode for '-cxx-interoperability-mode' option
Default corresponds to the Swift language version used to compile the input. Swift-5.9 is still supported for now, but will be removed shortly
2023-04-04 15:35:48 -07:00
Hamish Knight
af7134b884 Fully enable ExperimentalStringProcessing
Previously we would only enable by default when
`parseArgs` was called. However this wouldn't
enable it for clients such as LLDB, who provide
their own invocation. Switch the default to `true`
in the `LangOptions`, and remove some redundant
uses of `-enable-experimental-string-processing`.
The frontend flag remains, as it may be useful to
disable.

rdar://107419385
rdar://101765556
2023-03-31 18:10:39 +01:00
Alejandro Alonso
4a681160dc Merge pull request #64673 from Azoy/builtin-module-feature
[Frontend] Add BuiltinModule experimental feature
2023-03-29 23:12:40 -07:00
Nuri Amari
564621e330 Create feature flag for SE-0384 2023-03-29 10:25:22 -07:00
swift-ci
3be14e0a4a Merge pull request #64622 from kavon/bifurcate-moveonly-featureflag
Fix minimal stdlib builds with noncopyable types
2023-03-28 14:44:24 -07:00
Alejandro Alonso
c21899ee0f Add BuiltinModule experimental feature 2023-03-28 09:41:37 -07:00
Allan Shortlidge
7d1d7a35bb Frontend: Introduce the -unavailable-decl-optimization flag.
Part of rdar://106674022
2023-03-27 11:40:53 -07:00
Kavon Farvardin
6f98e9a2c6 trifurcate the MoveOnly feature
I want to reserve Feature::MoveOnly only for move-only types and other
things that are part of SE-390. Other prototyped features like
noimplicitcopy and some older names for consume were left behind
as guarded by this Feature. That's really not the right way to do it,
as people will expect that the feature is enabled all the time, which
would put those unofficial features into on-by-default. So this change
introduces two new Features to guard those unofficial features.
2023-03-24 15:43:35 -07:00
Rintaro Ishizaki
d8c8574e9b [Macros] Load '-load-plugin-library' plugins lazily
* Argument to '-load-plugin-library' now must have a filename that's
  '{libprefix}{modulename}.{sharedlibraryextension}'
* Load '-load-plugin-library' plugins are now lazily loaded in
  'CompilerPluginLoadRequest'
* Remove ASTContext.LoadedSymbols cache because they are cached by
  'ExternalMacroDefinitionRequest' anyway
* `-load-plugin-executable` format validation is now in
  'ParseSearchPathArgs'
2023-03-24 14:11:24 -07:00
Allan Shortlidge
a58ad6ba33 Frontend: Remove support for the -check-api-availability-only flag.
The functionality for this flag is no longer necessary because the emit module jobs for deprecated architectures no longer use an artificially low deployment target.

Resolves rdar://104758113
2023-03-23 23:02:13 -07:00
Rintaro Ishizaki
b2542a7ce9 [Macros] Small review changes
* New struct to store a pair of plugin search path and the server path
* typo
2023-03-17 19:15:06 -07:00
Rintaro Ishizaki
c4b3edd6df [Macros] Add swift-plugin-server executable
This executable is intended to be installed in the toolchain and act as
an executable compiler plugin just like other 'macro' plugins.

This plugin server has an optional method 'loadPluginLibrary' that
dynamically loads dylib plugins.
The compiler has a newly added option '-external-plugin-path'. This
option receives a pair of the plugin library search path (just like
'-plugin-path') and the corresponding "plugin server" path, separated
by '#'. i.e.

  -external-plugin-path
    <plugin library search path>#<plugin server executable path>

For exmaple, when there's a macro decl:

  @freestanding(expression)
  macro stringify<T>(T) -> (T, String) =
      #externalMacro(module: "BasicMacro", type: "StringifyMacro")

The compiler look for 'libBasicMacro.dylib' in '-plugin-path' paths,
if not found, it falls back to '-external-plugin-path' and tries to find
'libBasicMacro.dylib' in them. If it's found, the "plugin server" path
is launched just like an executable plugin, then 'loadPluginLibrary'
method is invoked via IPC, which 'dlopen' the library path in the plugin
server. At the actual macro expansion, the mangled name for
'BasicMacro.StringifyMacro' is used to resolve the macro  just like
dylib plugins in the compiler.

This is useful for
 * Isolating the plugin process, so the plugin crashes doesn't result
   the compiler crash
 * Being able to use library plugins linked with other `swift-syntax`
   versions

rdar://105104850
2023-03-16 14:00:45 -07:00
Ellie Shin
0fe0d6d221 Allow Swift as a package name
Update AccessScope::isChildOf
Add more tests for package access level
Resolves rdar://106728606
2023-03-14 17:17:14 -07:00
Puyan Lotfi
d55cfd26da Merge pull request #61606 from NuriAmari/fwd-declarations
Import Forward Declared Objective-C Interfaces and Protocols
2023-03-08 21:44:47 -08:00
Saleem Abdulrasool
09ade25b31 Merge pull request #64151 from compnerd/control
Driver: introduce additional Windows controls
2023-03-08 13:24:19 -08:00
Nuri Amari
86c5698780 Implement importing of forward declared objc protocols and interfaces
This modifies the ClangImporter to introduce an opaque placeholder
representation for forward declared Objective-C interfaces and
protocols when imported into Swift.

In the compiler, the new functionality is hidden behind a frontend
flag -enable-import-objc-forward-declarations, and is on by default
for language mode >6.

The feature is disabled entirely in LLDB expression evaluation / Swift
REPL, regardless of language version.
2023-03-07 16:00:16 -08:00