Fixes a know issue in which load splitting drops debug info.
After splitting the load, create a new debug_value instruction for the
loaded memory location, inserting a dereference expression if needed.
This fixes debug information for -Onone debugging. Later, after fixing
optimizations, it will also be called at -O, but not on 5.9.
Fixes rdar://104700920 (At -Onone preserve debug info after splitting loads)
Issue: LLDB missing variables in certain case #62241
Before deleting a load, simply rewrite its debug info to refer to the
loaded address:
%l = load %a
debug_value %l, loc0, scope0, var0
--->
debug_value %a, loc0, scope0, var0, expr op_deref
%l = load %a
Note that alloc_stack addresses do not require the addition of
op_deref because they are already special-cased in IRGen.
This will be called from salvageDebugInfo when it is supported by
optmizations. Until then, it is only called selectively at -Onone.
"reborrow" flag on the SILArgument avoids transitive walk over the phi operandsi
to determine if it is a reborrow in multiple utilities.
SIL transforms must keep the flag up-to-date by calling SILArgument::setReborrow.
SILVerifier checks to ensure the flag is not invalidated.
Currently "escaping" is not used anywhere.
* move the apply of partial_apply transformation from simplify-apply to simplify-partial_apply
* delete dead partial_apply instructions
* devirtualize apply, try_apply and begin_apply
Instead bail when trying to deleted a dead closure or when performing the apply-of-partial_apply optimization.
TODO: In OSSA this should be solvable without the need of copies to temporaries.
When dropping the self metatype parameter of a method, it must become a "thin" function.
Fixes a crash when using performance annotations.
rdar://107202455
Now that we handle inlined global initializers in LICM, CSE and the StringOptimization, we don't need to have a separate mid-level inliner pass, which treats global accessors specially.
When rewriting outer uses of the borrow, `recursivelyRewriterOuterUses`
is called recursively. First, it is called with the borrow itself.
Subsequently, it is called with forwarding users of the borrow. Such a
user may not be rewriteable as outer uses. If it isn't
`innerToOuterMap` won't have an entry for it.
Previously, failing to find an entry would raise an assertion. Here,
the function is made to return a "null" SILValue. Its caller
RewriteOuterBorrowUses::visitForwardingUse was already written to handle
such a result.
to work with aggregates containing unknown values. Such aggregates
can be generated when an instruction is skipped during constant
evaluation and its results are used to create a struct.
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
When canonicalizing a lexical lifetime, don't treat applies which
consume a copy of the value as deinit barriers. Doing so forces another
copy of the def being canonicalized to remain after the apply.
Instead, allow the lifetime to be transferred into the callee. This is
the same behavior that already exists for lexical lifetimes represented
with the `begin_borrow [lexical]` + `copy_value` instruction sequence.
Previously, the utility bailed out on lexical lifetimes because it
didn't respect deinit barriers. Here, deinit barriers are found and
added to liveness if the value is lexical. This enables copies to be
propagated without hoisting destroys over deinit barriers.
rdar://104630103
If multiple terminators which branch to the same merge block are added
to the boundary, depending on whether a destroy_value can be found
within the block either (a) every terminator must be added to the
boundary or (b) the destroy_value must be added to the boundary exactly
once.
Now that destory_values implicitly end borrow scopes for
`partial_apply [on_stack]`s, they show up as users of values whose
lifetimes are being canonicalized. Handle that properly by
(1) only adding the `destroy_value`s whose operand is a transitive copy
of the def to the set of destroys
(2) not considering a `destroy_value` with another operand (i.e. one
which does not destroy a transitive copy of the def) to be lifetime
ending
rdar://107198526
Whenever attempting to determine whether a given instruction is a
destroy of the def being canonicalized, just check for membership in the
set of destroys that's already collected.