Commit Graph

1174 Commits

Author SHA1 Message Date
swift-ci
af68664ed6 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-06 08:13:48 -07:00
Felipe de Azevedo Piovezan
2c3c3c1933 Merge pull request #67077 from DianQK/type-decl-disubprogram
[IRGen][DebugInfo] split method declaration and definition.
2023-09-06 11:08:39 -04:00
swift-ci
56b676b5e1 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-17 07:14:15 -07:00
Felipe de Azevedo Piovezan
af6599ff31 [IRGen] Delete no-op code
Commit 5c3ccf5050 added a number of blocks of code which were partially
removed by 39af79f491. This partial remove left lines of code doing nothin; we
remove them here.
2023-08-14 10:02:22 -04:00
DianQK
81953efcfb [IRGen][DebugInfo] Split method declaration and definition.
When the function is a method, we want a DW_AT_declaration there.
Because there's no good way to cross the CU boundary to insert a nested
DISubprogram definition in one CU into a type defined in another CU when
doing LTO builds.
2023-08-06 20:21:15 +08: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
6610561794 Merge remote-tracking branch 'origin/main' into rebranch 2023-07-28 08:53:26 -07:00
Adrian Prantl
1f6091aa45 Merge pull request #66744 from asavonic/debuginfo-fragment-distinct-inline-loc
[DebugInfo] Emit distinct DILocation for different inline instances
2023-07-28 08:45:53 -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
swift_jenkins
2ff66f1c25 Merge remote-tracking branch 'origin/main' into next 2023-07-07 08:05:35 -07:00
Hiroshi Yamauchi
fda6f9b62f Fix a round trip debug type failure with typealias
When checking equality of types with existential types removed,
recursively remove existential types inside an existential type.

Fixes: #66554
2023-06-30 14:04:28 -07:00
Evan Wilde
7c77fa6f45 Merge branch 'main' into ewilde/update-next
Automerger into next doesn't seem to be working. Manually merging.
2023-06-29 08:33:53 -07:00
Andrew Savonichev
ca6e74226d [DebugInfo] Emit distinct DILocation for different inline instances
LLVM seems to determine a variable instance as a combination of DILocalVariable
and DILocation. Therefore if multiple llvm.dbg.declare have the same
variable/location parameters, they are considered to be referencing the same
instance of variable.

Swift IRGen emits a set of llvm.dbg.declare calls for every variable
instance (with unique SILDebugScope), so it is important that these calls have
distinct variable/location parameters. Otherwise their DIExpression may be
incorrect when treated as referencing the same variable. For example, if they
have a DIExpression with fragments, we will see this as multiple declarations of
the same fragment. LLVM detects this and crashes with assertion failure:

DwarfExpression.cpp:679: void llvm::DwarfExpression::addFragmentOffset(const
llvm::DIExpression *): Assertion `FragmentOffset >= OffsetInBits &&
"overlapping or duplicate fragments"' failed.

The patch resolves #55703. The LIT test (debug_scope_distinct.swift) is the
reproducer from that issue.
2023-06-29 17:06:24 +09:00
Erik Eckstein
6b1697eb06 use new llvm::Optional APIs to fix deprecation warnings 2023-06-28 14:28:38 +02: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
Felipe de Azevedo Piovezan
73f39af392 Merge remote-tracking branch 'origin/main' into felipe/fix_merge_opaque
The following tests required conflict resolutions, since upstream LLVM did a lot of
work to remove dbg.addr, and this work is not available to swift's main. At the
same time, swift's main changed these tests to enable opaque pointers.

```
both modified:   test/DebugInfo/async-let-await.swift
both modified:   test/DebugInfo/move_function_dbginfo.swift
both modified:   test/DebugInfo/move_function_dbginfo_async.swift
```

The conflicts are fairly easy to fix: we keep the "structure" of the CHECK
lines present in `next`, but replace all pointers with `ptr`.
2023-06-26 17:13:02 -04:00
Andrew Savonichev
31e4465cd1 [DebugInfo] Merge fragments from SIL with fragments created in IRGen (#66448)
SIL variables can be split by SILSROA into separate allocations, each having
op_fragment expressions in debug_value (VarInfo.DIExpr). These allocations can
be further split by IRGen (multiple values in Storage argument).

These "nested" fragments refer to the same DI variable, so it is important to
merge them for the LLVM IR DI expression. The compiler used to ignore fragment
expressions from SIL when IRGen fragments were also present. This led to
incorrect DI info generation, and for some cases even triggered assertions in
LLVM X86 CodeGen:

  DwarfExpression.cpp:679: void llvm::DwarfExpression::addFragmentOffset(const
  llvm::DIExpression *): Assertion `FragmentOffset >= OffsetInBits &&
  "overlapping or duplicate fragments"' failed.

The patch fixes issue #64642. The LIT test is a reduced reproducer from that issue.
2023-06-20 11:37:29 -07:00
swift_jenkins
2b8f6b4283 Merge remote-tracking branch 'origin/main' into next 2023-06-15 18:48:12 -07:00
swift-ci
14f71614e5 Merge pull request #66682 from adrian-prantl/109173022
Replace hardcoded special names with call into getUserfacingName()
2023-06-15 18:43:01 -07:00
swift_jenkins
c3773953d1 Merge remote-tracking branch 'origin/main' into next 2023-06-15 17:38:08 -07:00
Adrian Prantl
229ad8ba84 Replace hardcoded special names with call into getUserfacingName()
This fixes an assertion failure when encountering previously unhandled special names.

rdar://110841130
2023-06-15 13:24:59 -07:00
Arnold Schwaighofer
0d4dec1acb Attempt to fix debug info under opaque pointers
Based on https://github.com/apple/swift/pull/66409

With the observation that the pre-opaque world was using bitcast as an
indication that the storage type and the type of the variable were
different. We can recover this information from the storage type of the
alloca and the storage type of the type info.
2023-06-14 10:49:50 -07:00
swift_jenkins
55a12e91d1 Merge remote-tracking branch 'origin/main' into next 2023-06-07 08:18:30 -07:00
Holly Borla
684ef9c482 [AST] Add a new accessor kind for init accessors. 2023-06-06 18:57:31 -07:00
swift_jenkins
1e52cf9e7e Merge remote-tracking branch 'origin/main' into next 2023-05-26 06:22:34 -07:00
Slava Pestov
b2bc2c72ec AST: Introduce PackElementType 2023-05-25 11:17:30 -04:00
Felipe de Azevedo Piovezan
22aa61f13f [IRGenDebug] Remove generation of dbg.addr
These intrinsics were removed upstream LLVM and are equivalent to a dbg.value +
OP_deref.
2023-05-12 15:52:58 -04:00
Adrian Prantl
3901219eeb Add support for nested ASTScopes inside of macro expansions.
Before this patch the parents of SILDebugScopes representing macro expansions
were missing the inlinedAt field, which resulted in incorrent LLVM IR being
produced. This is fixed by first computing the inlined call site for a macro
expansion and then computing the nested SILDebugScope for the ASTScope of the
expanded nodes; adding the inlinedAt field to all of levels of parent scopes.

rdar://108323748
2023-04-24 14:11:19 -07:00
Augusto Noronha
dbaf5e53f0 Emit cxx interop into DW_AT_APPLE_flags
When compiling with interop enabled, emit the C++ interop compiler flag
into the DW_AT_APPLE_flags, to make it so LLDB can accurately match the
C++ interop mode when initializing its compiler instance.

rdar://97610458
(cherry picked from commit b1dbb0a321)
2023-04-11 10:40:09 -07:00
Adrian Prantl
158772c2ab Rebase SILScope generation on top of ASTScope.
This patch replaces the stateful generation of SILScope information in
SILGenFunction with data derived from the ASTScope hierarchy, which should be
100% in sync with the scopes needed for local variables. The goal is to
eliminate the surprising effects that the stack of cleanup operations can have
on the current state of SILBuilder leading to a fully deterministic (in the
sense of: predictible by a human) association of SILDebugScopes with
SILInstructions. The patch also eliminates the need to many workarounds. There
are still some accomodations for several Sema transformation passes such as
ResultBuilders, which don't correctly update the source locations when moving
around nodes. If these were implemented as macros, this problem would disappear.

This necessary rewrite of the macro scope handling included in this patch also
adds proper support nested macro expansions.

This fixes

rdar://88274783

and either fixes or at least partially addresses the following:

rdar://89252827
rdar://105186946
rdar://105757810
rdar://105997826
rdar://105102288
2023-04-04 15:20:11 -07:00
Richard Wei
eb8e984b97 [Macros] Private discriminators for outermost-private MacroExpansionDecl (#64813)
Add a private discriminator to the mangling of an outermost-private `MacroExpansionDecl` so that declaration macros in different files won't have colliding macro expansion buffer names.

rdar://107462515
2023-03-31 20:36:29 -07:00
Doug Gregor
cff79e632a [Assertions] Provide the flag to dodge the "type reconstruction" assertions.
When the compiler aborts due to a type reconstruction error, ask the
user to submit a bug report and provide the flag needed to disable
this check.
2023-03-30 10:09:00 -07:00
Alexis Laferrière
205a2edf38 [Sema] Intro set of import filters for general use
Calling getImportedModules requires to list the desired kind of imports.
With the new kind of imports this has become cumbersome. Let's simplify
it by offering common sets of imports. Advanced call sites can still
list the desired imports explicitly.
2023-03-17 16:05:44 -07:00
Konrad `ktoso` Malawski
41f99fc2ae [Executors][Distributed] custom executors for distributed actor (#64237)
* [Executors][Distributed] custom executors for distributed actor

* harden ordering guarantees of synthesised fields

* the issue was that a non-default actor must implement the is remote check differently

* NonDefaultDistributedActor to complete support and remote flag handling

* invoke nonDefaultDistributedActorInitialize when necessary in SILGen

* refactor inline assertion into method

* cleanup

* [Executors][Distributed] Update module version for NonDefaultDistributedActor

* Minor docs cleanup

* we solved those fixme's

* add mangling test for non-def-dist-actor
2023-03-15 23:42:55 +09:00
John McCall
ce9013a3f6 Fix IRGen to not use outlining for types with any kind of local archetype.
Previously it was testing for opened existentials specifically.

We should really teach outlining to handle local archetypes properly.
We'd have to build a generic signature for the lowered type, and that
probably means also adding requirements that are relevant to value
operations, but it would mean outlining would benefit all types, and
it would let us avoid bundling in unnecessary information from the
enclosing generic environment.

A minor side-effect of this is that we no longer bind names to
opened element type values.  The names were things like \tau_1_0,
which is not very useful, especially in LLVM IR where \tau is
printed with two UTF-8 escapes.
2023-03-10 19:00:28 -05:00
Adrian Prantl
e6aa779aec Let pack_count helper variables be zero-indexed. 2023-03-06 16:04:18 -08:00
Ellie Shin
7d23db3646 Create PackageUnit class, and Package entries to DeclContext / ASTHierarchy
Previously enum AccessLimitKind was
added to distinguish access scopes b/t package and public while keeping
DeclContext null but it proved to be too limiting. This PR creates package specific entries for DeclContext and
ASTHierarchy. It create a new class PackageUnit that can be set as the parent DeclContext of ModuleDecl. This PR
contains addition of such entries but not the use of them; the actual use of them will be in the upcoming PRs.

Resolves rdar://106155600
2023-03-02 13:20:51 -08:00
Slava Pestov
5c718cf67a IRGen: Fix edge case where we emit debug info type with the wrong generic signature
PR #63789 introduced verification of the generic parameters appearing in
debug info, but I missed an edge case where we have to push a different
generic signature.

Fixes #63869.
2023-02-24 15:10:16 -05:00
swift-ci
b2d7d7d2f2 Merge pull request #63426 from adrian-prantl/104842055
Debug info support for variadic generics.
2023-02-22 22:39:43 -08:00
Adrian Prantl
ccd22cc491 Don't emit throw types at -gline-tables-only. (#63847)
* Caught by the debug-stdlib bots.

rdar://105651154

* Revert "[test] disable test for simulators"

This reverts commit 8a25ffaa13.
2023-02-23 00:14:32 -06:00
Adrian Prantl
97964f1ba9 Emit debug info for pack count parameters. 2023-02-22 16:16:21 -08:00
Adrian Prantl
0bda3f5483 Debug info support for variadic generics.
rdar://104842055
2023-02-22 16:16:21 -08:00
Slava Pestov
4855621b0a ASTDemangler: Pass down a generic signature so that we can reconstruct pack generic parameters 2023-02-21 15:33:19 -05:00
swift-ci
1bfb3e6e1c Merge pull request #62499 from adrian-prantl/102367872
Add an assertion that verifies the size of cached debug info types.
2023-02-08 19:47:10 -08:00
Adrian Prantl
0f4429b224 DebugTypeInfo: Prefer the size of the Storage type derived from the TypeInfo.
Previously type sizes would be inconsistently sourced from either the LLVM type
or the FixedTypeInfo, depending on the call site. This was problematic because
TypeInfo operates with a resolution of whole bytes, which means that types such
as i1 would get a reported as having a size of 8. This patch now asserts that
all occurrences of the same type have the same size as the first, cached
occurence.

To avoid triggering the cached type verification assertion, this patch avoids
caching of storage-sized containers. It also removes the unique identifier from
forward declarations, which could lead to type confusion during LTO.

rdar://102367872
2023-02-08 15:09:53 -08:00
Adrian Prantl
5ff139dd6e Wire up mangled macro names in debug info.
rdar://104894694
2023-02-03 10:30:48 -08:00
John McCall
d25a8aec8b Add explicit lowering for value packs and pack expansions.
- SILPackType carries whether the elements are stored directly
  in the pack, which we're not currently using in the lowering,
  but it's probably something we'll want in the final ABI.
  Having this also makes it clear that we're doing the right
  thing with substitution and element lowering.  I also toyed
  with making this a scalar type, which made it necessary in
  various places, although eventually I pulled back to the
  design where we always use packs as addresses.

- Pack boundaries are a core ABI concept, so the lowering has
  to wrap parameter pack expansions up as packs.  There are huge
  unimplemented holes here where the abstraction pattern will
  need to tell us how many elements to gather into the pack,
  but a naive approach is good enough to get things off the
  ground.

- Pack conventions are related to the existing parameter and
  result conventions, but they're different on enough grounds
  that they deserve to be separated.
2023-01-29 03:29:06 -05:00