This unusual situation can happen if an address is converted to a raw pointer and that pointer is stored to a memory location.
In this case the walkers need to follow load instructions even if the visitor and current projection path don't say so.
Fixes a miscompile
rdar://122805546
Specifies that the optimizer and IRGen must not add runtime calls which are not in the function originally.
This attribute is set for functions with performance constraints or functions which are called from functions with performance.
We need to keep the original linkage because it would be illegal to call a shared not-serialized function from a serialized function.
Also, rename the API to create the specialized function.
Generic specialization already takes care of removing metatype arguments of generic functions.
But sometimes non-generic functions have metatype arguments which must be removed.
We need handle this case with a function signature optimization.
This enables, for example, to use `OptionSet` in embedded swift.
rdar://121206953
An object with tail allocated elements is in risk of being passed to malloc_size, which does not work for non-heap allocated objects.
Conservatively, disable objects with tail allocations.
rdar://121886093
Usually resilient classes cannot be promoted anyway, because their initializers are not visible and let the object appear to escape.
But in some rare situations this check is needed.
rdar://121558570
Mostly restore the behavior of getMemoryEffectsFn on builtins other than
`once` and `onceWithContext` to before
8a8a895239 but keeping the improvement to
return `Instruction.memoryEffects` in the face of escaping.
This is what you need to correctly analyze OSSA.
- computeLinearLiveness
- computeInteriorLiveness
- InteriorUseVisitor
- OwnershipUseVisitor
- LivenessBoundary
Along with BorrowUtils.swift, all of our OSSA transformations are
built on top of these fundamentals. With these APIs, we can build
anything OSSA-related in SwiftCompilerSources. These utilities are
immediately needed for borrowed arguments and lifetime dependence. In
the near future, we can also use them to complete OSSA lifetimes and
*correctly* fixup OSSA after transformation without introducing lots
of copies and creating lots of incorrect corner cases.
Key APIs necessary for using OSSA.
- BorrowingInstruction
- BeginBorrowValue
- scopeEndingOperands
- BorrowIntroducers
- EnclosingValues
- innerAdjacentPhis
These need to be complete to be correct.
Add a new mandatory BooleanLiteralFolding pass which constant folds conditional branches with boolean literals as operands.
```
%1 = integer_literal -1
%2 = apply %bool_init(%1) // Bool.init(_builtinBooleanLiteral:)
%3 = struct_extract %2, #Bool._value
cond_br %3, bb1, bb2
```
->
```
...
br bb1
```
This pass is intended to run before DefiniteInitialization, where mandatory inlining and constant folding didn't run, yet (which would perform this kind of optimization).
This optimization is required to let DefiniteInitialization handle boolean literals correctly.
For example in infinite loops:
```
init() {
while true { // DI need to know that there is no loop exit from this while-statement
if some_condition {
member_field = init_value
break
}
}
}
```
```
let c = SomeClass()
```
is turned into
```
private let outlinedVariable = SomeClass() // statically initialized and allocated in the data section
let c = outlinedVariable
```
rdar://111021230
rdar://115502043
Also, make the ObjectOutliner work for OSSA. Though, it currently doesn't run in the OSSA pipeline.
It notifies the pass manager that the optimization result of the current pass depends on the body (i.e. SIL instructions) of another function than the currently optimized one.