Commit Graph

68 Commits

Author SHA1 Message Date
Michael Gottesman
36fc50370f [closure-lifetime-fixup] Use the SSAUpdater rather than memory to extend the lifetime to the end of the function.
This beyond being slightly cleaner ensures that we do not try to promote in
PredictableMemOpts any loads from the alloc_stack. Doing this would force us to
insert a copy in ossa which then would break is_escaping_closure even when we
don't escape.

rdar://problem/46188001
2019-02-25 19:13:56 -08:00
Arnold Schwaighofer
0c7b94ef7d ClosureLifetimeFixup: Don't insert dealloc_stack at unreachable 2019-01-17 15:30:17 -08:00
Arnold Schwaighofer
7e6588d830 Update closure lifetime fixup to use partial_apply [stack] 2019-01-16 13:55:03 -08:00
Arnold Schwaighofer
cb0c53abee SIL: Remove isEscapedByUser flag on convert_escape_to_noescape instruction
It was only used for materializeForSet and is now dead code.
2019-01-04 09:21:38 -08:00
Michael Gottesman
caa86c424e [gardening] Change a function with 4 space indent => 2 space indent and standardize variable names.
NFC.
2018-11-18 14:58:01 -08:00
Michael Gottesman
e4607a7191 [closure-lifetime-fixup] When emitting a load_borrow, make sure to emit the end_borrow for it as well.
In this commit I added a more convenient API for doing this sort of operation.
Specifically: SILBuilder::emitScopedBorrowOperation. This performs either a
load_borrow or begin_borrow, then calls a user provided closure, and finally
inserts the end_borrow after the scope has closed.

rdar://43398898
2018-10-26 11:11:01 -07:00
Robert Widmann
014fd952ef [NFC] Silence a bunch of Wunused-variable diagnostics 2018-08-24 15:16:40 -07:00
Andrew Trick
89ed064808 Fix several incorrect uses of ApplySite::getArgumentConvention.
At least most of these were latent bugs since the code was
unreachable in the PartialApply case. But that's no excuse to misuse
the API.

Also, whenever referring to an integer index, be explicit about
whether it is an applied argument or callee argument.
2018-07-28 00:05:40 -07:00
Jordan Rose
cefb0b62ba Replace old DEBUG macro with new LLVM_DEBUG
...using a sed command provided by Vedant:

$ find . -name \*.cpp -print -exec sed -i "" -E "s/ DEBUG\(/ LLVM_DEBUG(/g" {} \;
2018-07-20 14:37:26 -07:00
Arnold Schwaighofer
d735c1ef95 ClosureLifetimeFixup: Delete a dead store 2018-06-11 10:55:44 -07:00
Arnold Schwaighofer
968d2279a9 ClosureLifetimeFixup: Fix closure insertion point in deallocating deinits
We must not capture self beyond the call to super.deinit

rdar://40660799
2018-06-01 09:12:00 -07:00
Arnold Schwaighofer
261639d18d ClosureLifetimeFixup: We need to insert a None on the backedge of a loop after we destroyed the value
rdar://40221767
2018-05-15 08:02:39 -07:00
Arnold Schwaighofer
1f65ee25f6 Distinguish between withoutActuallyEscaping and passing @noescape
Objective C closures when reporting that a closure has escaped

rdar://39682865
2018-05-01 07:24:19 -07:00
Arnold Schwaighofer
1ae309c44c ClosureLifetimeFixup: Add support for copy_block_without_escaping instructions
Replace:

  %copy = copy_block_without_escaping %block withoutEscaping %closure

  ...
  destroy_value %copy

by (roughly) the instruction sequence:

  %copy = copy_block %block

  ...
  destroy_value %copy
  %e = is_escaping %closure
  cond_fail %e
  destroy_value %closure

rdar://39682865
2018-05-01 07:24:19 -07:00
Arnold Schwaighofer
b2d1554a2c ClosureLifetimeFixup: Add missing nullptr check
rdar://39548527
2018-04-19 08:14:08 -07:00
Arnold Schwaighofer
e6d3580b6b Add missing null check 2018-04-16 12:52:01 -07:00
Arnold Schwaighofer
37ed76e2b4 Make some functions static 2018-04-13 13:29:46 -07:00
Arnold Schwaighofer
f82dbef1b7 Add a ClosureLifetimeFixup pass
To replace the code in DI and eventually remove PostponedCleanup in a
follow-up.

When SILGen emits ``convert_escape_to_noescape [not_guaranteed]
%operand`` instructions it assumes that a later SIL pass (this pass)
comes along and inserts retain_value/release_value instructions such that
the lifetime of the operand for the duration of the trivial closure
result.

This commit introduces the pass but does not yet use it.
2018-04-13 13:25:07 -07:00