Commit Graph

20 Commits

Author SHA1 Message Date
Doug Gregor
d2e0582a92 Move workaround for swifterror miscompile earlier
Thank you, Arnold for noting this miscompile on x86!
2023-11-13 11:44:25 -08:00
Alex Lorenz
4858cb6225 [IRGen][interop] do not add 'nocapture' to not bitwise takable types
The use of 'nocapture' for parameters and return values is incorrect for C++ types, as they can actually capture a pointer into its own value (e.g. std::string in libstdc++)

rdar://115062687
2023-09-25 17:43:34 -07:00
Arnold Schwaighofer
3b5ebaa46c Fix some tests in IRGen folder 2023-06-21 10:10:32 -07:00
Arnold Schwaighofer
c1a93e0bde Move tests over to use the %use_no_opaque_pointers option 2023-06-14 10:49:48 -07:00
Anthony Latsis
c1908f688e Gardening: Migrate test suite to GH issues: IRGen 2022-09-01 06:35:57 +03:00
Andrew Trick
4eb7351f4d Disable MandatoryCopyPropagation.
Mandatory copy propagation was primarily a stop-gap until lexcial
lifetimes were implemented. It supposedly made variables lifetimes
more consistent between -O and -Onone builds. Now that lexical
lifetimes are enabled, it is no longer needed for that purpose (and
will never satisfactorily meet that goal anyway).

Mandatory copy propagation may be enabled again later as a -Onone "
optimization. But that requires a more careful audit of the effect on
debug information.

For now, it should be disabled.
2022-02-18 17:29:04 -08:00
Nate Chandler
ea42e2f334 Enabling copy propagation enables lexical lifetimes.
The effect of passing -enable-copy-propagation is both to enable the
CopyPropagation pass to shorten object lifetimes and also to enable
lexical lifetimes to ensure that object lifetimes aren't shortened while
a variable is still in scope and used.

Add a new flag, -enable-lexical-borrow-scopes=true to override
-enable-copy-propagation's effect (setting it to ::ExperimentalLate) on
SILOptions::LexicalLifetimes that sets it to ::Early even in the face of
-enable-copy-propagation.  The old flag -disable-lexical-lifetimes is
renamed to -enable-lexical-borrow-scopes=false but continues to set that
option to ::Off even when -enable-copy-propagation is passed.
2021-12-08 19:13:21 -08:00
Andrew Trick
b1b2eff075 Disable mandatory-copy-propagation (-Onone only)
This feature degrades the debugging experience and causes a large
number of unit test failures.

These were both known issues, but our planned debugger improvements
won't be ready for a while. Until then, we'll leave the feature under
a compiler option, and developers can adopt it at there own speed for
now when they are ready to fix lifetime issues in their code.

rdar://76177280 (Disable mandatory-copy-propagation (-Onone only))
2021-04-02 22:33:50 -07:00
Andrew Trick
11a641ff03 Enable mandatory copy propagation SIL pass.
This shortens -Onone lifetimes.

To eliminate ARC traffic, the optimizer reorders object
destruction. This changes observable program behavior. If a custom
deinitializer produces side effects, code may observe those side
effects earlier after optimization. Similarly, code that dereferences
a weak reference may observe a 'nil' reference after optimization,
while the unoptimized code observed a valid object.

Developers have overwhelmingly requested that object lifetimes have
similar behavior in -Onone and -O builds in order to find and diagnose
program bugs involving weak references and other lifetime assumptions.

Enabling the copy propagation at -Onone is simply a matter of flipping
a switch. -Onone runtime and code size will improve. By design, copy
propagation, has no direct affect on compile time. It will indirectly
improve optimized compile times, but in debug builds, it simply isn't
a factor.

To support debugging, a "poison" flag was (in prior commits) added to
new destroy_value instructions generated by copy propagation.  When
OwnershipModelEliminator lowers destroy_value [poison] it will
generate new debug_value instructions with a “poison” flag.

These additional poison stores to the stack could increase both code
size and -Onone runtime.

rdar://75012368 (-Onone compiler support for early object deinitialization with sentinel dead references)
2021-03-12 19:34:39 -08:00
Varun Gandhi
0dd36591cb [AST] Fix conversion for Unmanaged<T> in ClangTypeConverter. 2020-12-01 16:25:20 -08:00
Ben Langmuir
dd92ed5818 [test] Disable IRGen/unmanaged_objc_throw_func.swift with non-optimized stdlib
Pending investigation rdar://71857262
2020-12-01 11:08:11 -08:00
Erik Eckstein
1559fe333f SIL: a new library intrinsic to "finalize" array literals
For COW support in SIL it's required to "finalize" array literals.
_finalizeUninitializedArray is a compiler known stdlib function which is called after all elements of an array literal are stored.
This runtime function marks the array literal as finished.

  %uninitialized_result_tuple = apply %_allocateUninitializedArray(%count)
  %mutable_array = tuple_extract %uninitialized_result_tuple, 0
  %elem_base_address = tuple_extract %uninitialized_result_tuple, 1
  ...
  store %elem_0 to %elem_addr_0
  store %elem_1 to %elem_addr_1
  ...
  %final_array = apply %_finalizeUninitializedArray(%mutable_array)

In this commit _finalizeUninitializedArray is still a no-op because the COW support is not used in the Array implementation yet.
2020-06-08 10:24:29 +02:00
Vedant Kumar
a83bfabc8b [DebugInfo] Stop relying on asm gadgets to extend variable ranges (#29029)
The 'fake use' asm gadget does not always keep variables alive. E.g., in
rdar://57754659, llvm was unable to preserve two local variables despite
the use of these gadgets. These variables were backed by a LoadInst and
an ExtractValueInst respectively. Instead of emitting shadow copies for
just those kinds of instructions, use shadow copies exclusively. This
may cause more variables to appear in the debugger window before they
are initialized, but should result in fewer variables being dropped.

rdar://57754659
2020-01-10 16:31:51 -08:00
Ben Cohen
28aa25ec11 Fix a couple of IRGen tests on master-next (#26358)
* objc symbols changed from private to internal

* Update LLVM label syntax
2019-08-20 17:19:24 -07:00
Suyash Srijan
42847a488b [Test] Trim CHECK-LABEL 2019-04-26 16:56:36 +01:00
Suyash Srijan
8bdc916832 [test] Update IRGen test 2019-04-25 22:02:58 +01:00
Suyash Srijan
a1ffae5c10 [test] Update IRGen test with patterns, etc 2019-04-19 20:41:14 +01:00
Suyash Srijan
77b6b1b151 [test] remove -primary-file flag as it's not needed 2019-04-19 01:35:23 +01:00
Suyash Srijan
b0ab515f8f [test] Updates IRGen test file 2019-04-19 00:04:36 +01:00
Suyash Srijan
b67d23642d [test] Adds an IRGen test 2019-04-18 23:32:01 +01:00