To make it possible to change the implementation of
_stdlib_isOSVersionAtLeast(), remove the @inlinable attribute from it.
Since it is currently inlinable and calls the helper function
_swift_stdlib_operatingSystemVersion(), we’ll have to keep the
helper around as ABI.
This change causes a minor pessimization where the LLVM optimizer can no
longer reason that, for example, a successful check for 10.12 availability
means that a later check for 10.11 will always succeed. I don't expect this
pessimization to be a problem, but if needed we could write a custom SIL
optimizer pass to claw back the performance.
<rdar://problem/59447474>
First, remove the AvailabilityContext parameter; it was confusing because
we actually always want to use the deployment target here.
Then, split this method up into three methods:
- isAlwaysWeakImported(): simply checks for a @_weakLinked attribute, either
on the declaration itself or one of its parent contexts.
- getAvailabilityForLinkage(): returns the OS version availability when
this declaration was introduced, or if the declaration does not have
explicit availability, check it's storage (if its an accessor), or its
parent contexts.
- isWeakImported(ModuleDecl *fromModule): combines these two checks to
determine if the declaration should be weak linked when referenced from
the given module, or if it might be weak referenced from some module
(if the module parameter is null).
With the advent of dynamic_function_ref the actual callee of such a ref
my vary. Optimizations should not assume to know the content of a
function referenced by dynamic_function_ref. Introduce
getReferencedFunctionOrNull which will return null for such function
refs. And getInitialReferencedFunction to return the referenced
function.
Use as appropriate.
rdar://50959798
This disables inlinability of _stdlib_isOSVersionAtLeast. I don't see
value in making it inlinable as long as _swift_stdlib_operatingSystemVersion is
opaque.
rdar://41849700
And unbreak the LLDB testsuite.
This patch fixes three problems with the original implementation:
- Use SILBuilderWithScope instead of SILBuilder to avoid holes in the
lexical scopes.
- Use an artificial location for stores to the alloca to avoid the debugger
stopping before the variable is initialized.
- Recognize debug_value_addr instructions referring to an alloc_stack
instruction to avoid introducing an extra indirection in the debug info.
rdar://problem/31975108
This is a very easily misused API since it allows for users to leak instructions
if they are not careful. This commit removes this API and replaces the small
number of uses of this API with higher level APIs that accomplish the same task
without using removeFromParent(). There were no API users that specifically
required removeFromParent.
An example of one way we were using removeFromParent is to move a SILInstruction
to the front of a block. That does not require exposing an API like
removeFromParent()... we can just create a higher level API like the one added
in this commit: SILInstruction::moveFront(SILBasicBlock *).
rdar://31276565
At some point, pass definitions were heavily macro-ized. Pass
descriptive names were added in two places. This is not only redundant
but a source of confusion. You could waste a lot of time grepping for
the wrong string. I removed all the getName() overrides which, at
around 90 passes, was a fairly significant amount of code bloat.
Any pass that we want to be able to invoke by name from a tool
(sil-opt) or pipeline plan *should* have unique type name, enum value,
commend-line string, and name string. I removed a comment about the
various inliner passes that contradicted that.
Side note: We should be consistent with the policy that a pass is
identified by its type. We have a couple passes, LICM and CSE, which
currently violate that convention.
We hit an assert in AllocStackHoisting that is only triggered in a release lto
build.
Clang forwards the read of parent basic block of 'AssignedLoc' in the next
statement:
auto *EntryBB = AssignedLoc->getFunction()->getEntryBlock(); // read AssignedLoc->ParentBB
AssignedLoc->removeFromParent(); // writes AssignedLoc->ParentBB
To this read:
EntryBB->push_front(AssignedLoc); // read AssignedLoc->ParentBB and assert if non-null, *should reload*
As a temporary workaround outline code to prevent the miscompile.
rdar://29982182
Hoist alloc_stack instructions of 'generic' or resilient type to the entry
block. At the same time also perform a very simple stack coloring analysis.
This does not use a true liveness-analysis yet but rather employs some simple
conservative checks to see whether the live ranges of two alloc_stacks might
interfere.
AllocStackHoisting is an IRGen SIL pass. This allows for using IRGen's type
lowering information. Furthermore, hoisting and merging the alloc_stack
instructions this late does not interfere with SIL optimizations because the
resulting SIL never gets serialized.