Commit Graph

168 Commits

Author SHA1 Message Date
Steven Wu
ae69713639 [Caching] Mark -emit-module-source-info-path as CacheInvariant
For the options that specifies the output, it should be cache invariant.
Fix the one remaining option that is not correctly labelled and add an
unittest to make sure all the options with output path naming convertion
are correctly marked as CacheInvariant.

rdar://146155049
2025-03-04 16:20:26 -08:00
Michael Gottesman
4763251427 [sil] Add the ability for the frontend to dump LoweredSIL before IRGen.
This is something that I have wanted to add for a while and have never had the
need to. I need it now to fix a bug in the bots where I am forced to use IRGen
output to test ThunkLowering which causes platform level differences to show up
in the FileCheck output. With this, I can just emit the actual lowered SIL
output and just test it at that level. There are other cases like this where we
are unable to test lowered SIL so we use IRGen creating this brittleness.
Hopefully this stops this problem from showing up in the future.

rdar://138845396
2024-11-01 03:16:55 -07:00
swift-ci
32d286280a Merge remote-tracking branch 'origin/main' into rebranch 2024-10-02 20:36:43 -07:00
Nate Chandler
9718aa5b29 [Driver] Pass -emit-irgen thru to frontend.
Add a new filetype for this mode option: "Raw LLVM IR". When the mode
option is emit-irgen, the new filetype will be the output kind;
conversely when determining the mode option to use, if the output kind
is the new filetype, the mode option will be emit-irgen.
2024-10-02 08:25:30 -07:00
swift-ci
a655fe5edc Merge remote-tracking branch 'origin/main' into rebranch 2024-09-27 09:56:29 -07:00
Steven Wu
82c9fdf68b [Blocklist] Make sure blocklist config is read through VFS
Make sure block-list file is read through VFS so CASFS can be used to
read the configuration to ensure sound caching, and also the path of the
blocklist can be canonicalized via path remapping.
2024-09-26 17:02:10 -07:00
Ben Barham
efe1c97824 [Basic] Update moveFileIfDifferent tests to not rely on getUniqueID
These tests were relying on specifics of `getUniqueID` that aren't
necessarily true - namely that moving a file from `source` to `dest`
doesn't change the returned ID. They are really just testing
`moveFileIfDifferent`, which doesn't need to make this assumption.
2024-09-20 15:32:36 -07:00
Dmitrii Galimzianov
df9ecd9a4c [Demangler] Stable parent identifier in OpaqueReturnTypeParent
`OpaqueReturnTypeParent` node now references the parent with a mangled parent name, rather than a parent pointer. This makes trees obtained from different demanglers (or calls to `Demangler::demangleSymbol`) for the same symbol equal.
2024-09-18 01:14:38 +02:00
Michael Gottesman
0445a855a5 Revert "[cmake] Prevent linker errors by linking libswiftAST into SwiftBasicTests since libswiftBasic can include contents from libswiftAST."
This reverts commit aac3cd7c93.
2024-03-21 14:29:34 -07:00
Michael Gottesman
aac3cd7c93 [cmake] Prevent linker errors by linking libswiftAST into SwiftBasicTests since libswiftBasic can include contents from libswiftAST.
I hit this in https://github.com/apple/swift/pull/72476. I put the declaration
that hit this in a header, but as I thought about it... there was no real harm
in just fixing the issue and preventing future breakage.
2024-03-20 22:06:25 -07:00
Ben Barham
9779c18da3 Rename startswith to starts_with
LLVM is presumably moving towards `std::string_view` -
`StringRef::startswith` is deprecated on tip. `SmallString::startswith`
was just renamed there (maybe with some small deprecation inbetween, but
if so, we've missed it).

The `SmallString::startswith` references were moved to
`.str().starts_with()`, rather than adding the `starts_with` on
`stable/20230725` as we only had a few of them. Open to switching that
over if anyone feels strongly though.
2024-03-13 22:25:47 -07:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Guillaume Lessard
114f235d17 Merge pull request #71167 from vanvoorden/vanvoorden/inclusive-language
[Inclusive Language][Comments][Documentation] migrate "sanity" checks to "soundness" checks
2024-02-02 10:27:34 -08:00
John McCall
e345c85e26 Add some optimized data structures for maps on a small number of
keys, especially enumerated keys.
2024-01-28 22:30:26 -05:00
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Steven Wu
7150e54003 [Caching] Identify input type from filename correctly
When loading input from CAS, `swift-frontend` relies on the input file
name to determine the type to look from CAS entry. In the case where
file extension is `.private.swiftinterface`, swift mis-identify that as
`.swiftinterface` file and look up the wrong input file. Add a new
file type lookup function that can figure out the type from the full
filename.

Also add few diagnostics during the CAS lookup for the input file to
error out immediately, rather than rely on the lookup failure later.
2024-01-05 13:48:32 -08:00
Michael Gottesman
59cc595f7a Fix unittest 2023-12-01 15:06:51 -08:00
Stéphan Kochen
7b460ce495 build: fix accidental cmake expansions
As of CMake 3.25, there are now global variables `LINUX=1`, `ANDROID=1`,
etc. These conflict with expressions that used these names as unquoted
strings in positions where CMake accepts 'variable|string', for example:

- `if(sdk STREQUAL LINUX)` would fail, because `LINUX` is now defined and
  expands to 1, where it would previously coerce to a string.

- `if(${sdk} STREQUAL "LINUX")` would fail if `sdk=LINUX`, because the
  left-hand side expands twice.

In this patch, I looked for a number of patterns to fix up, sometimes a
little defensively:

- Quoted right-hand side of `STREQUAL` where I was confident it was
  intended to be a string literal.

- Removed manual variable expansion on left-hand side of `STREQUAL`,
  `MATCHES` and `IN_LIST` where I was confident it was unintended.

Fixes #65028.
2023-07-17 21:50:50 +02: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
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
Ben Barham
3ec878d918 Update llvm::Optional API uses
Use the std-equivalent names as the LLVM ones are now deprecated
(eventually `llvm::Optional` will disappear):
  - `getValue` -> `value`
  - `getValueOr` -> `value_or`
  - `hasValue` -> `has_value`

Follow up from ab1b343dad and
7d8bf37e5e with some missing cases.
2023-01-25 16:28:10 -08:00
Ben Barham
0d96000b94 [next] Add missing chrono include
`std::chrono::high_resolution_clock` is being used in
`FrozenMultiMapTest.cpp` but it was relying on `chrono` being included
transitively. Include it directly.
2022-06-09 12:50:01 -07:00
Alastair Houghton
210b772800 [UnitTests][Windows] Link with Synchronization.lib
The runtime unit tests also need to link with Synchronization.lib.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
6d1b6dbd1c [Threading] Fix the Linux build.
A few fixes specifically for the Linux build.

rdar://90776105
2022-06-07 07:39:52 +01:00
Alex Hoppen
4aa2bbbf06 Revert "Merge pull request #42447 from al45tair/eng/PR-90776105"
This reverts commit 8bcb71140f, reversing
changes made to c4dd271d36.
2022-06-02 18:03:23 +02:00
Alastair Houghton
dadd23e5e2 [UnitTests][Windows] Link with Synchronization.lib
The runtime unit tests also need to link with Synchronization.lib.

rdar://90776105
2022-05-24 14:57:41 +01:00
Alastair Houghton
fc90280e34 [Threading] Fix the Linux build.
A few fixes specifically for the Linux build.

rdar://90776105
2022-05-24 14:57:39 +01:00
Josh Soref
66663b1286 Spelling basic (#42541)
* spelling: add

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: attributes

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: bridging

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: deserialization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialize

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: invariants

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: lazily

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: occurred

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: offset

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: optimization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: our

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: process

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: substitution

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: the operation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: the

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-05-04 14:53:24 -07:00
John McCall
abfe16574d [NFC] Add FixedBitSet
I wanted a bit vector that I could use as a compact sorted
set of enum values: an inline-allocated, fixed-size array
of bits supporting efficient and convenient set operations
and iteration.

The C++ standard library offers std::bitset, but the API
is far from ideal for this purpose.  It's positioned as
an abstract bit-vector rather than as a set.  To use it
as a set, you have to turn your values into indices, which
for enums means explicitly casting them all in the caller.
There's also no iteration operation, so to find the
elements of the set, you have to iterate over all possible
indices, test whether they're in the set, and (if so)
cast the current index back to the enum.  Not only is that
much more awkward than normal iteration, but it's also
substantially less efficient than what you can get by
counting trailing zeroes in a mask.

LLVM and Swift offer a number of other bit vectors, but
they're all dynamically allocated because they're meant
to track arbitrary sets.  That's not a non-starter for my
use case, which is in textual serialization and so rather
slow anyway, but it's also not very hard to whip together
the optimal data structure here.

I have committed the cardinal sin of C++ data structure
design and provided the operations as ordinary methods
instead of operators.
2022-02-16 12:52:47 -05:00
swift-ci
c51550f30e Merge remote-tracking branch 'origin/main' into rebranch 2021-09-30 15:11:41 -07:00
Richard Howell
58d67be645 Add ClangImporterOptions::getRemappedExtraArgs
This commit adds a function to remap the clang arguments passed
during compilation. This is intented to be shared across the
Swift compiler and LLDB to apply path remapping for debug info
paths.
2021-09-30 08:13:28 -07:00
swift-ci
8fe89a6f5e Merge remote-tracking branch 'origin/main' into rebranch 2021-08-11 14:54:54 -07:00
Argyrios Kyrtzidis
35f0744b1c [CMake] Declare the precise dependencies of the gyb custom command invocations 2021-08-10 13:51:54 -07:00
Arnold Schwaighofer
aeff108072 TYPED_TEST_CASE -> TYPED_TEST_SUITE 2021-08-05 12:15:23 -07:00
Evan Wilde
0aafd09835 F_None was renamed OF_None
This patch updates usages of F_None to OF_None, as LLVM changed that in
commit 3302af9d4c39642bebe64dd60a3aa162fefc44b2.
2021-06-23 10:36:39 -07:00
Erik Eckstein
772e675efd remove the ValueEnumerator utility
It's not needed anymore
2021-05-26 21:57:54 +02:00
Mike Ash
4988127e99 Merge pull request #35525 from mikeash/swift_asprintf-static-checking
[Runtime] Mark swift_asprintf with __attribute__((__format__))
2021-01-22 15:04:39 -05:00
Mike Ash
216e555ad6 [Runtime] Mark swift_asprintf with __attribute__((__format__))
This gives us build-time warnings about format string mistakes, like we would get if we called the built-in asprintf directly.

Make TypeLookupError's format string constructor a macro instead so that its callers can get these build-time warnings.

This reveals various mistakes in format strings and arguments in the runtime, which are now fixed.

rdar://73417805
2021-01-22 10:54:45 -05:00
Robert Widmann
f5cb08e3d1 Add a Stable Hash Algorithm
Use SipHash-2-4 to replace llvm::MD5 as the hashing implementation backing Fingerprints and the interface hash.
2021-01-21 17:19:38 -08:00
Evan Wilde
6dac520b66 NFC: Fix signed unsigned comparison warnings
This patch fixes the unsigned/signed comparison warnings in the
unittests caused by comparing an unsigned integer with the signed
integer literal. The offending signed integer literals have been
replaced with unsigned integer literals.
2020-12-10 16:02:33 -08:00
Slava Pestov
6e0e87f9d2 Remove TreeScopedHashTable.h 2020-11-16 22:39:44 -05:00
Mike Ash
b9bed06c97 [Runtime] Fix incorrect free() of constant strings in TypeLookupError. 2020-11-06 13:36:29 -05:00
Michael Gottesman
9568d53c8f [frozen-multimap] Add support for erasing once we have finished constructing the map.
I implemented this in a similar way to the way blotting is implemented in a blot
map vector:

1. I changed this to store (Key, Optional<Value>) pairs.

2. I made it so that once frozen, we can "erase" things from the multimap by
setting all Optional<Value> to none.

3. I changed the range we vend to be an OptionalTransformRange instead of just a
TransformRange so we skip all keys with .none values, meaning that a user will
get the nice behavior that getRange() still works after erasing.

One interesting thing to note is that one /cannot/ erase elements when
initializing the frozen multi-map since we haven't sorted it yet. At first this
seems weird, but it actually fits with the use case of this data structure:
building up state by processing IR in a readonly way and then later working with
it in a worklist like way (and perhaps checking for unhandled cases at the end
of processing).

The nice thing additional thing is that I was able to ensure that the actual
exposed API did not change in terms of how one uses it. I just changed the
underlying iterators/etc.
2020-04-28 15:03:45 -07:00
Michael Gottesman
dd7f780993 [multimapcache] Change multi-map cache to use a std::function instead of CRTP.
This makes it so one uses a passed in std::function, instead of an impl class to
map a key to a list of values to be cached.
2020-04-15 12:23:10 -07:00
Michael Gottesman
00d4576977 [multimapcache] Add an efficient CRTP based write-once multimap cache that can be small.
The properties of this multimap cache are:

1. Values are stored (inline if Small) in a Vector and our map internally maps
   keys to (start, length) of slices of the Vector. This is done instead of
   storing arrays refs to ensure that if our array goes from small -> large, we
   do not have stale pointers.

2. Values are only allowed to be inserted all at once. This is ok, since this is
   a cache.

3. One is not storing individual small vectors in a map (or state storing
   SmallVectors). This can inadvertantly add up to using a lot of memory and is
   not needed for homogenous data.
2020-03-31 15:12:37 -07:00
Michael Gottesman
c5f6038a0a [blotmapvector] Add support for try_emplace.
I am going to use this in a forthcoming commit.
2020-03-25 14:24:56 -07:00
Michael Forster
32d2b1486c Fix build breaks for master-next against llvm.org.
StringRef conversion to std::string needs to be explicit now.
2020-03-13 19:08:22 +01:00
Michael Gottesman
6b88599412 Revert "Merge pull request #30327 from rintaro/revert-30289"
This reverts commit 0a6ccd802f, reversing
changes made to 7c5d74e86b.
2020-03-10 16:52:58 -07:00
Rintaro Ishizaki
fad1b431c2 Revert "[semantic-arc-opts] Implement @owned phi web elimination for phi webs with a single phi node that only have copy_value introducers."
This reverts commit 6fee59bd6a.
2020-03-10 08:43:46 -07:00