Commit Graph

1717 Commits

Author SHA1 Message Date
Doug Gregor
f36d2d3978 [Source manager] Improve the performance of findBufferContainingLocInternal()
This function was performing a linear scan through the set of known
buffers to find the buffer containing a given source location. This
linear scan can show up in hot loops, and the number of buffers in a
program is increasing due to macros, so this has become a performance
problem.

Replace the linear scan with a logarithmic lookup into a sorted vector
of the buffer IDs, with a one-element most-recently-used cache so that
repeated lookups in the same buffer require constant time.

This mirrors what we already do with source files in a module.
Unfortunately, we cannot reuse that code because there is no link from
buffers to source files. We should look to consolidate this in the
future.

Fixes rdar://116184248.
2023-10-04 14:37:34 -07:00
swift-ci
556272e95f Merge remote-tracking branch 'origin/main' into rebranch 2023-10-02 21:54:26 -07:00
swift-ci
c1df6db3f0 Merge pull request #68881 from apple/prefix-smashing
Diagnose possible enum common-prefix mistakes
2023-10-02 21:48:14 -07:00
Becca Royal-Gordon
78127ce5ee Diagnose possible enum common-prefix mistakes
Clang Importer strips prefixes from enum and option set case names. The logic to do this computes a common prefix from the type name and all non-deprecated case names (to oversimplify), which means that adding, removing, or changing one case can change the prefix that is removed from *all* cases. This typically causes the prefix to become shorter, meaning that additional words are prepended to each existing case name.

Existing diagnostics make it look like the case has disappeared, when in fact it still exists under a different name. A little more information may help developers to figure out what happened.

Add a tailored diagnostic for this scenario which kicks in when (a) a missing member is diagnosed, (b) the base is an imported enum or option set’s metatype, and (c) an enum case or static property exists which has the name we attempted to look up as a suffix.

Fixes rdar://116251319.
2023-10-02 16:50:54 -07:00
swift-ci
1b2f485222 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-30 12:53:10 -07:00
Alejandro Alonso
f58aa07d41 Merge pull request #68536 from Azoy/maxAtomicInlineWidth
[AST] Add #if _atomicBitWidth as a valid compilation conditional
2023-09-30 12:34:17 -07:00
Alejandro Alonso
a3f4361280 Add _atomicBitWidth compilation conditional
fix warning
2023-09-29 14:43:34 -07:00
swift-ci
17a5d30d54 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-15 16:14:15 -07:00
Hamish Knight
febb019a86 Avoid storing a SourceManager on JSONFixitWriter
Switch to storing the necessary edit information
instead.
2023-09-15 18:27:49 +01:00
swift-ci
5fefff41f6 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-11 07:14:12 -07:00
Pavel Yaskevich
bbe531c4ac [Basic] MaxMallocUsage statistic should cover all zones
Also for some reason passing `malloc_default_zone()` no longer
works, statistics return `0` use.
2023-09-08 16:25:36 -07:00
swift-ci
56aa4e6933 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-04 08:14:39 -07:00
Saleem Abdulrasool
219f6eadeb Update Program.cpp 2023-09-03 18:53:24 -07:00
Saleem Abdulrasool
06ad3a75b6 AST,Basic: update support for process execution on Windows
Implement process launching on Windows to support macros.  Prefer to use
the LLVM types wherever possible.  The pipes are converted into file
descriptors as the types are internal to the process.  This allows us to
have similar paths on both sides and avoid having to drag in `Windows.h`
for the definition of `HANDLE`.  This is the core missing functionality
for Windows to support macros.
2023-09-03 10:45:03 -07:00
swift-ci
6da5bed7fb Merge remote-tracking branch 'origin/main' into rebranch 2023-08-05 18:36:02 -07:00
Tony Allevato
300a952ede Replace u8 string literal prefixes with SWIFT_UTF8 macro.
In C++20, `u8` literals create values of type `char8_t` instead of
`char`, and these can't be implicitly converted. This macro
mitigates the difference and allows the same code to compile under
C++14/17 modes and C++20, preserving the `char` type while ensuring
that the text is interpreted as UTF-8.
2023-08-04 16:41:36 -04:00
swift-ci
1969199a8e Merge remote-tracking branch 'origin/main' into rebranch 2023-07-26 23:13:08 -07:00
Alex Lorenz
d7b62b3c40 [cxx-interop] add 'upcoming-swift' compat version
This version will be used to gate new source breaking changes for C++ interoperability
2023-07-25 16:19:58 -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
2c216e08eb Add new OS platforms
LLVM added UEFI and LiteOS platforms. We don't currently support them,
so we should crash on the unsupported OS for now to avoid accidents
later.
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
4b5d25935d [NFC] Adding a few missing llvm namespaces
I missed a few LLVM optional and llvm None usages. Fixing those now.
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
Kuba (Brecka) Mracek
47b73eb3fe When building for baremetal targets, accept any arch that LLVM supports (#67093) 2023-07-04 14:02:17 -07:00
Holly Borla
725374e0d8 [Macros] Implement attached extension macros. 2023-06-27 21:22:12 -07:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Ben Barham
ee3a47b624 [Frontend] Ignore adjacent swiftmodule in compiler host modules
`lib/swift/host` contains modules/libraries that are built by the host
compiler. Their `.swiftmodule` will never be able to be read, ignore
them entirely.
2023-06-12 16:53:48 -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
Ben Rimmington
9160f52b1c Simplify _endian and _pointerBitWidth conditions (#66070) 2023-05-23 19:00:37 +01:00
Ben Rimmington
ce951aa83a Add ppc to _endian and _pointerBitWidth conditions (#66067) 2023-05-23 04:50:26 +01:00
Hamish Knight
ffde684143 [Stats] Force the printing of 0 counters
This matches the behavior of `printAlwaysOnStatsAndTimers`,
which we use in a release build. This fixes the
diverging behavior, and ensures process-stats-dir
can handle comparing deltas between runs where
one of the runs had a 0 counter.
2023-05-22 14:55:17 +01:00
Hamish Knight
a06c1acc1d Merge pull request #66019 from hamishknight/cover-for-your-cover 2023-05-20 08:13:40 +01:00
Ben Rimmington
b18dff33be Add riscv64 to _pointerBitWidth platform condition (#66034) 2023-05-20 03:50:25 +01:00
Hamish Knight
a3848c62d5 [Profiler] Don't profile generated buffers
We may want to revisit this in the future, but for
now let's avoid profiling code in generated
buffers. To make this work we'll need to come up
with a scheme for writing out the generated buffers
such that tools like `llvm-cov` can reference them.

rdar://109562235
2023-05-20 00:32:20 +01:00
Slava Pestov
c2338aa0f6 Backward deployment shim for swift_allocate{Metadata,WitnessTable}Pack() 2023-05-12 15:44:12 -04:00
Kuba (Brecka) Mracek
d7e18cb554 Add 'none' to the list of available conditional compilation OS values, to support building for -none target triples (#65632) 2023-05-09 15:55:53 -07:00
Steven Wu
c7d66b8845 Teach swift to compute cache key for compiler outputs
Teach swift how to serialize its input into CAS to create a cache key
for compiler outputs. To compute the cache key for the output, it first
needs to compute a base-key for the compiler invocation. The base key is
computed from: swift compiler version and the command-line arguments for
the invocation.

Each compiler output from swift will gets its own key. The key for the
output is computed from: the base key for the compiler invocation + the
primary input for the output + the output type.
2023-04-24 13:55:38 -07:00
Rintaro Ishizaki
fe1eb469e4 [ASTGen] Avoid including C standard libary headers in brigdging headers
C stdlib headers are part of "Darwin"/"Glibc" clang module.
If a Swift file imports a bridging headers and that has '#include'
C stdlib headers, Swift compiler implicitly imports "Darwin"/"Glibc"
overlay modules. That violates dependency layering. I.e. Compiler
depends on Darwin overlay, Darwin overlay is created by the compiler.

rdar://107957117
2023-04-12 17:22:32 -07:00
Xi Ge
04f23fc0f9 Basics: refactor blocklist actions to a def file. NFC 2023-04-08 08:39:42 -07:00
Xi Ge
b758c4a6e2 Basics: define a YAML-based blocklist format
An example of this format is:

---
actionToTakeFor:
  ModuleName:
    - moduleName1
  ProjectName:
    - projectName1
2023-04-07 12:25:21 -07:00
Xi Ge
3c9ff9a5d5 Basics: only allow ASTContext to add block list path 2023-04-05 15:56:16 -07:00
Xi Ge
ba31c97d4f Basics: add a stub for centralized configurations for block list 2023-04-05 11:52:41 -07:00
Saleem Abdulrasool
08608390f0 cmake: extract version string and add PrintVersion.cmake
Add a helper to allow us to programatically extract the Swift version
string during the build. This is particularly useful for injection into
the packaging stages.

Co-authored-by: Evan Wilde <etceterawilde@gmail.com>
2023-03-27 11:53:36 -07:00
Dario Rexin
294342a1d3 Add _pointerBitWidth platform condition (#41534)
* Add _pointerBitWidth platform condition

* Fixes after rebasing

---------

Co-authored-by: Xiaodi Wu <xiaodi.wu@gmail.com>
2023-03-21 20:59:32 -07:00
Saleem Abdulrasool
19c7bb5a22 Driver: add support for baremetal targets
This allows building the Swift standard library for targets which may
not have an actual OS running.  This is identified by the OS field in
the target triple being set to `none`.
2023-03-20 17:59:13 -04:00
Erik Eckstein
564732e0fa fix an llvm::Optional deprecation warning 2023-03-06 10:35:22 +01:00
Rintaro Ishizaki
ddee67cbde [Macros] Update executable plugin sandbox profile to prohibit file-read
Except for dylibs.
2023-02-27 14:39:40 -08:00
Holly Borla
a3caacd309 [Macros] Initial implementation of conformance macros. 2023-02-23 20:43:11 -08:00
Rintaro Ishizaki
c6387a5450 [Macros] Small changes for review 2023-02-22 17:41:43 -08:00