So there is no need to initialize global string variables dynamically (with dispatch_once) anymore.
This is much more efficient, both in terms of code size and performance
In an upcoming bug fix, I want to pass SILBuilderContext to a
utility. I could continue reusing SILBuilder, even though the utility
must set its own insertion point and debug location. However, this is
terrible practice that I don't want to perpetuate.
The lifetime of a SILBuilder should correspond to a single insertion
point and debug location. That's the only sane way to preserve debug
information in SIL passes.
There are various pieces of contextual state that we've been adding to
the SILBuilder. Those have made it impossible to use SILBuilder
correctly. I'm pulling the context out, so clients can begin using
better practices. In the future, we can make SILBuilderContext
polymorphic, so passes can extend it easily with arbitrary
callbacks. We can also make it self-contained so we don't need to pass
around pointers to an InsertedInst list anymore.
This ensures that DI creates dealloc_box in cases where the box is uninitialized
conditionally.
In the process, I also discovered that we were missing a test case for DI being
used by LLDB. Long term we shouldn't support that code pattern in the general
case, but for now we at least need a test case for it.
rdar://40332620
Assume we have:
Protocol P
An intenal extension to Optional - conforming to P
Compiling under whole module mode
Use of Optional type T?
Given a dynamic cast from T? to P, that cast might succeed even if T itself does not conform to P
rdar://problem/40500142
Upstream has renamed the DEBUG() macro to LLVM_DEBUG. This updates swift
accordingly:
$ find . -name \*.cpp -print -exec sed -i "" -E "s/ DEBUG\(/ LLVM_DEBUG(/g" {} \;
This is necessary for the correctness of optimizations that remove markers. We
must know that an unidentified access can never see class or global properties.
SubstitutionMaps are now just a trivial pointer-sized value, so
pass them by value instead.
I did have to move a couple of functors from Type.h to SubstitutionMap.h
to resolve some issues with forward declarations.
We'd like to match what Clang does as closely as possible, but more
importantly 'mutableCopy' is two words. Comment and test case in
following commit.
This reverts commit 3cca85f435.
These helpers make it easier to debug how profiling state and coverage
mappings are built up (just add -Xllvm -debug-only=SILProfiler to your
swiftc invocation).
SILModules built for the debugger have special powers to access
metadata for types in other files/modules. Thanks to John McCall for
suggesting the fix. This should fix a verifier failure in the lldb
testsuite. The reason why it wasn't caught during PR testing is that
this test wasn't run as part of the standard swift-pr cycle. I'm
going to submit another PR in lldb next to make sure it runs (and,
therefore, we can catch other regressions).
<rdar://problem/40336275>