Commit Graph

1105 Commits

Author SHA1 Message Date
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
Doug Gregor
d192bfc7e5 Merge pull request #63125 from DougGregor/debug-info-dump-macro-expansion-buffers 2023-01-21 07:43:45 -08:00
Adrian Prantl
6335f1dee5 Debug Info: Represent macro expansions as inlined functions.
This allows the debugger to choose whether to display the expanded macro
(inlined) or the original source code (parent frame).

rdar://102916513
2023-01-20 21:43:20 -08:00
Doug Gregor
456fbf84f5 [Debug info] Dump macro expansion buffers to disk for debug info to reference
When emitting debug info that references into a macro expansion, dump
the macro expansion buffer into a file on disk (in the temporary
directory) so that one can see the macro expansion buffers in the
source files themselves.

The test here validates that the generated LLVM IR looks correct, but
I'm having a problem getting LLDB to actually locate the source code
correctly.
2023-01-19 21:30:25 -08:00
John McCall
0e3a9adc32 Add Builtin.PackIndex 2023-01-19 23:57:13 -05:00
Adrian Prantl
06a54432ab Sink isFixedBuffer into DebugTypeInfo and ensure the enclosed types aren't
emitted with the size of the fixed buffer.
2022-12-14 14:18:28 -08:00
Adrian Prantl
7731ee9a83 Rename variables in assertion (NFC) 2022-12-14 12:36:26 -08:00
Adrian Prantl
1576c08137 Store size in DebugTypeInfo in Bits (NFC) 2022-12-14 12:36:26 -08:00
Adrian Prantl
e74aeed088 Add an assertion that verifies the size of cached debug info types.
Not yet enabled since it triggers when building Concurrency.

rdar://102367872
2022-12-14 12:36:26 -08:00
Adrian Prantl
8921b10417 Fix a bit versus byte confusion. 2022-12-14 12:32:27 -08:00
Adrian Prantl
9a4cb7999e Disambiguate constructors for type metadata (NFC) 2022-12-14 11:34:51 -08:00
Doug Gregor
5ab6b72604 [Macros] Turn Macro into a declaration node.
Although the declaration of macros doesn't appear in Swift source code
that uses macros, they still operate as declarations within the
language. Rework `Macro` as `MacroDecl`, a generic value declaration,
which appropriate models its place in the language.

The vast majority of this change is in extending all of the various
switches on declaration kinds to account for macros.
2022-11-13 12:21:29 -08:00
Slava Pestov
68514b10b5 AST: Introduce ElementArchetypeType 2022-10-21 21:55:35 -04:00
Alex Langford
686193b300 [DebugInfo] Respect debug-prefix-map when emitting path to PCM in Skeleton CUs 2022-10-17 11:53:28 -07:00
Holly Borla
9bb837a241 [AST] Rename SequenceArchetype to PackArchetype. 2022-10-10 16:25:26 -07:00
Anthony Latsis
2843e0c871 Gardening: Migrate compiler sources to GitHub issues 2022-09-29 23:58:55 +03:00
Slava Pestov
c1b8690401 AST: Introduce special Builtin.TheTupleType singleton 2022-09-10 00:26:42 -04:00
Mishal Shah
91b2abe996 Merge pull request #60531 from apple/pull-request-rebranch
Merge `rebranch` into  `main` to support llvm-project `stable/20220421`
2022-08-15 17:10:56 -07:00
zoecarver
39af79f491 [cxx-interop] Re-enable debug mangling. 2022-08-12 15:57:56 -07:00
swift-ci
5c8f1fcb12 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-02 17:03:37 -07:00