Commit Graph

2592 Commits

Author SHA1 Message Date
Arnold Schwaighofer
8d8951768c Revert "Merge pull request #76656 from nate-chandler/rdar136388508"
This reverts commit b9228c81d1, reversing
changes made to 6fb2989bcf.

After PR#76686 this bailout should no longer be neccessary.

rdar://136681998
2024-09-26 09:26:21 -07:00
Erik Eckstein
7ffd270008 embedded: move the VTableSpecializer pass into MandatoryPerformanceOptimizations
MandatoryPerformanceOptimizations already did most of the vtable specialization work.
So it makes sense to remove the VTableSpecializerPass completely and do everything in MandatoryPerformanceOptimizations.
2024-09-25 19:32:14 +02:00
Nate Chandler
c420b0e481 [Mem2Reg] Always bail on dynamic_lifetime.
rdar://136388508
2024-09-23 12:12:11 -07:00
nate-chandler
d177df981b Merge pull request #76440 from nate-chandler/rdar134198292
[Outliner] Handle multiple consumes of a value.
2024-09-13 07:45:02 -07:00
Nate Chandler
e7365aa857 [Outliner] Handle multiple consumes of a value.
If a single native value is bridged multiple times, it cannot be
consumed without other changes.  One option would be to copy it.  The
other option is taken here: sink the destroy of the native value to
after the apply and have the outlined function take the value
guaranteed.

rdar://134198292
2024-09-12 18:42:28 -07:00
Kavon Farvardin
ba0aac3f39 Merge pull request #76093 from kavon/coldsplit-2
ColdBlockInfo: overhaul analysis pass
2024-09-12 16:06:07 -07:00
Kavon Farvardin
7203a4fa73 ColdBlockInfo: overhaul analysis pass
The old analysis pass doesn't take into account profile data, nor does
it consider post-dominance. It primarily dealt with _fastPath/_slowPath.

A block that is dominated by a cold block is itself cold. That's true
whether it's forwards or backwards dominance.

We can also consider a call to any `Never` returning function as a
cold-exit, though the block(s) leading up to that call may be executed
frequently because of concurrency. For now, I'm ignoring the concurrency
case and assuming it's cold. To make use of this "no return" prediction,
use the `-enable-noreturn-prediction` flag, which is currently off by
default.
2024-09-03 15:41:10 -07:00
nate-chandler
c56a313d6c Merge pull request #76114 from nate-chandler/rdar133969821_2
[DAH] Bail on pointer use if ignoring barriers.
2024-08-27 21:57:39 -07:00
Nate Chandler
74c4bc9c55 [DAH] Bail on pointer use if ignoring barriers.
Unknown uses of raw pointers should not result in bailing out when an
address is lexical--the destroy of the address will already not be
hoisted over any instructions which may access pointers.  If the address
is not lexical however (such as any address when lexical lifetimes are
disabled), that rationale does not apply, so unknown uses of raw
pointers must cause hoisting to bail.

rdar://133969821
2024-08-27 16:18:39 -07:00
Slava Pestov
8315120eaf Merge pull request #76051 from slavapestov/archetype-get-parent
AST: Remove ArchetypeType::getParent()
2024-08-24 15:31:01 -04:00
Slava Pestov
63028be348 SILCloner: Redo local archetype remapping 2024-08-22 17:17:53 -04:00
eeckstein
b1a88beab5 Merge pull request #75836 from eeckstein/fix-vtable-specializer
VTableSpecializer: fix a crash for methods which have their own generic parameters
2024-08-22 08:20:19 +02:00
Slava Pestov
39b4bda1dc AST: Introduce SubstFlags::SubstituteLocalArchetypes 2024-08-21 14:23:37 -04:00
Slava Pestov
ae77d6f0c1 AST: Replace one-off predicates with SubstitutionMap::getRecursiveProperties() 2024-08-21 13:19:10 -04:00
Erik Eckstein
ba9bfaf5d5 VTableSpecializer: fix a crash for methods which have their own generic parameters
rdar://133334324
2024-08-21 17:01:35 +02:00
Erik Eckstein
9053cce8a4 SimplifyCFG: fix an ownership verifier error caused by switch_enum simplification
If constant folding a switch_enum ends up in branching to a no-payload case, the enum value still needs to be destroyed to satisfy the ownership verifier.

https://github.com/swiftlang/swift/issues/74903
rdar://131726690
2024-08-20 10:13:52 +02:00
Meghana Gupta
920c5603fc Merge pull request #75807 from meg-gupta/fixdebuginfodoe
Fix debug info in DeadObjectElimination in OSSA
2024-08-10 11:28:43 +05:30
Meghana Gupta
f71ab17e7a Fix debug info in DeadObjectElimination in OSSA
Move debug_value insertion before destroy_value insertion.
2024-08-09 22:39:38 +05:30
Slava Pestov
375363a473 AST: Move global conformance lookup entry points to ConformanceLookup.h 2024-08-08 23:35:58 -04:00
Erik Eckstein
80a0da9615 Optimizer: update borrowed-from instructions in some passes
Fixes verifier crashes (once the borrowed-from verifier is fixed).
2024-08-07 18:02:38 +02:00
Erik Eckstein
f9b524b1cb AliasAnalysis: a complete overhaul of alias- and memory-behavior analysis
The main changes are:

*) Rewrite everything in swift. So far, parts of memory-behavior analysis were already implemented in swift. Now everything is done in swift and lives in `AliasAnalysis.swift`. This is a big code simplification.

*) Support many more instructions in the memory-behavior analysis - especially OSSA instructions, like `begin_borrow`, `end_borrow`, `store_borrow`, `load_borrow`. The computation of end_borrow effects is now much more precise. Also, partial_apply is now handled more precisely.

*) Simplify and reduce type-based alias analysis (TBAA). The complexity of the old TBAA comes from old days where the language and SIL didn't have strict aliasing and exclusivity rules (e.g. for inout arguments). Now TBAA is only needed for code using unsafe pointers. The new TBAA handles this - and not more. Note that TBAA for classes is already done in `AccessBase.isDistinct`.

*) Handle aliasing in `begin_access [modify]` scopes. We already supported truly immutable scopes like `begin_access [read]` or `ref_element_addr [immutable]`. For `begin_access [modify]` we know that there are no other reads or writes to the access-address within the scope.

*) Don't cache memory-behavior results. It turned out that the hit-miss rate was pretty bad (~ 1:7). The overhead of the cache lookup took as long as recomputing the memory behavior.
2024-07-29 17:33:46 +02:00
Erik Eckstein
04e0907ab0 SIL: rename Type.instanceTypeOfMetatype -> Type.loweredInstanceTypeOfMetatype
The same for SILType

It needs to be made clear that this is not the "original", but the lowered SIL type.

NFC
2024-07-29 17:33:36 +02:00
Nate Chandler
9825b26e3a [Test] Underscored simplify_cfg_simplify_argument.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
2878b053ec [Test] Underscored simplify_cfg_simplify_block_args.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
dd19acdf68 [Test] Underscored simplify_cfg_canonicalize_switch_enum.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
4329512fb0 [Test] Underscored simplify_cfg_simplify_term_with_identical_dest_blocks.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
b0bb97467f [Test] Underscored simplify_cfg_simplify_switch_enum_block.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
c0d95c121b [Test] Underscored simplify_cfg_simplify_switch_enum_on_objc_class_optional.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:14 -07:00
Nate Chandler
7470c29cfe [Test] Underscored simplify_cfg_simplify_switch_enum_unreachable_blocks.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:48:22 -07:00
Nate Chandler
8d3a5a17d9 [Test] Underscored simplify_cfg_try_jump_threading.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:47:45 -07:00
Allan Shortlidge
e4331af916 IRGen: Introduce macCatalyst target variant version check builtins. 2024-07-23 17:00:10 -07:00
Nate Chandler
4a397cc018 [NFC] OwnedLifetimeCan: Take DeadEndBlocksAnalysis
All clients of OwnedLifetimeCanonicalization pass an instance of the
analysis in.  For now, it's unused.
2024-07-22 21:51:28 -07:00
Nate Chandler
b5e4fcf100 [NFC] CopyPropagation: Extracted verification.
It makes it easier to temporarily hack in new calls to verify.
2024-07-22 20:35:30 -07:00
Nate Chandler
d55c169d80 [CopyPropagation] Destroy hoist -> canonicalize.
Replace usages of lexical destroy hoisting with owned value
canonicalization now that the latter supports lexical values.
2024-07-22 20:35:30 -07:00
nate-chandler
e9279e2f23 Merge pull request #75292 from nate-chandler/rdar131882748
[Mem2Reg] Bail on address-only types.
2024-07-18 10:52:03 -07:00
Nate Chandler
1b9567b1d3 [Mem2Reg] Bail on address-only types.
It is impossible to have a value of address-only type, so don't try
promoting.

rdar://131882748
2024-07-17 08:11:35 -07:00
Erik Eckstein
823036d5a1 embedded: fix vtable specialization for nested classes
Fixes a crash in case of an inner class (with no generic parameters), which is nested inside another generic type, like
```
struct G<T> {
  class Inner {}
}
```

rdar://131311511
2024-07-12 21:44:49 +02:00
Slava Pestov
977b444eb3 AST: Add a new overload of getContextSubstitutionMap() 2024-07-10 13:28:26 -04:00
Slava Pestov
86d567f95a AST: ModuleDecl::lookupConformance() is a static method 2024-07-06 12:05:47 -04:00
Slava Pestov
fae01d9776 AST: Remove ModuleDecl parameter from more places 2024-07-06 12:05:46 -04:00
nate-chandler
04debd3536 Merge pull request #74922 from nate-chandler/lifetime-completion/20240701/1
[LifetimeCompletion] Flag ends synthesized in dead-ends.
2024-07-04 00:23:57 -07:00
eeckstein
46256f5cd7 Merge pull request #74897 from eeckstein/fix-vtable-specializer
Fix a SourceKitCrash in the VTableSpecializer pass
2024-07-04 08:16:30 +02:00
Nate Chandler
02c28f5de5 [AllocBoxToStack] Drop dead_end dealloc_boxes.
When creating `dealloc_stack`s corresponding to `dealloc_box`es, don't
bother to create a dealloc_stack if the `dealloc_box` is flagged
`dead_end`.
2024-07-03 17:33:51 -07:00
Nate Chandler
dd730b849c [LifetimeCompletion] Flag instructions dead_end. 2024-07-03 16:44:35 -07:00
Erik Eckstein
9360c76cd8 Fix a SourceKitCrash in the VTableSpecializer pass
Replace the assert-check if a vtable is available with a regular error message.
This cannot occur in regular builds - only if built with embedded swift and without wmo.
The command line compiler prevents this combination, but it  can happen in SourceKit.

rdar://130167087
2024-07-03 17:13:53 +02:00
Erik Eckstein
3e750f9f1c SimplifyCFG: Fix a missing borrowed-from when doing jump threading
Fixes a compiler crash

rdar://129805179
2024-07-03 13:52:52 +02:00
Meghana Gupta
ab3eaf2441 Merge pull request #71881 from meg-gupta/fixmem2reg
Fix mem2reg of lexical enum stack locations
2024-06-30 05:31:24 -07:00
Nate Chandler
7edf36ff6a [Mem2Reg] Cleanup and refactoring. 2024-06-29 14:49:06 -07:00
Ben Barham
d8f381e660 Merge pull request #74804 from bnbarham/rename-equals
Update `StringRef::equals` references to `operator==`
2024-06-28 11:22:20 -07:00
Meghana Gupta
b1fc313f22 Merge pull request #74802 from meg-gupta/temprvalueedgecase
Allow TempRValueOpt of lexical alloc_stacks when base of copy source is @in_guaranteed
2024-06-27 22:00:05 -07:00