Skip to content

Commit caf1ce1

Browse files
Merge pull request #4927 from swiftwasm/main
[pull] swiftwasm from main
2 parents 7b57c21 + 28ab0bd commit caf1ce1

File tree

8 files changed

+68
-41
lines changed

8 files changed

+68
-41
lines changed

lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,25 @@ SILInstruction *DIMemoryObjectInfo::getFunctionEntryPoint() const {
169169
return &*getFunction().begin()->begin();
170170
}
171171

172+
static SingleValueInstruction *
173+
getUninitializedValue(MarkUninitializedInst *MemoryInst) {
174+
SILValue inst = MemoryInst;
175+
if (auto *bbi = MemoryInst->getSingleUserOfType<BeginBorrowInst>()) {
176+
inst = bbi;
177+
}
178+
179+
if (SingleValueInstruction *svi =
180+
inst->getSingleUserOfType<ProjectBoxInst>()) {
181+
return svi;
182+
}
183+
184+
return MemoryInst;
185+
}
186+
187+
SingleValueInstruction *DIMemoryObjectInfo::getUninitializedValue() const {
188+
return ::getUninitializedValue(MemoryInst);
189+
}
190+
172191
/// Given a symbolic element number, return the type of the element.
173192
static SILType getElementTypeRec(TypeExpansionContext context,
174193
SILModule &Module, SILType T, unsigned EltNo,
@@ -478,6 +497,31 @@ bool DIMemoryObjectInfo::isElementLetProperty(unsigned Element) const {
478497
return false;
479498
}
480499

500+
SingleValueInstruction *DIMemoryObjectInfo::findUninitializedSelfValue() const {
501+
// If the object is 'self', return its uninitialized value.
502+
if (isAnyInitSelf())
503+
return getUninitializedValue();
504+
505+
// Otherwise we need to scan entry block to find mark_uninitialized
506+
// instruction that belongs to `self`.
507+
508+
auto *BB = getFunction().getEntryBlock();
509+
if (!BB)
510+
return nullptr;
511+
512+
for (auto &I : *BB) {
513+
SILInstruction *Inst = &I;
514+
if (auto *MUI = dyn_cast<MarkUninitializedInst>(Inst)) {
515+
// If instruction is not a local variable, it could only
516+
// be some kind of `self` (root, delegating, derived etc.)
517+
// see \c MarkUninitializedInst::Kind for more details.
518+
if (!MUI->isVar())
519+
return ::getUninitializedValue(MUI);
520+
}
521+
}
522+
return nullptr;
523+
}
524+
481525
ConstructorDecl *DIMemoryObjectInfo::getActorInitSelf() const {
482526
// is it 'self'?
483527
if (!MemoryInst->isVar())

lib/SILOptimizer/Mandatory/DIMemoryUseCollector.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,7 @@ class DIMemoryObjectInfo {
100100
/// alloc_stack, this always just returns the actual mark_uninitialized
101101
/// instruction. For alloc_box though it returns the project_box associated
102102
/// with the memory info.
103-
SingleValueInstruction *getUninitializedValue() const {
104-
if (IsBox) {
105-
SILValue inst = MemoryInst;
106-
if (auto *bbi = MemoryInst->getSingleUserOfType<BeginBorrowInst>()) {
107-
inst = bbi;
108-
}
109-
// TODO: consider just storing the ProjectBoxInst in this case.
110-
SingleValueInstruction *svi = inst->getSingleUserOfType<ProjectBoxInst>();
111-
assert(svi);
112-
return svi;
113-
}
114-
return MemoryInst;
115-
}
103+
SingleValueInstruction *getUninitializedValue() const;
116104

117105
/// Return the number of elements, without the extra "super.init" tracker in
118106
/// initializers of derived classes.
@@ -130,6 +118,10 @@ class DIMemoryObjectInfo {
130118
/// Return true if this is 'self' in any kind of initializer.
131119
bool isAnyInitSelf() const { return !MemoryInst->isVar(); }
132120

121+
/// Return uninitialized value of 'self' if current memory object
122+
/// is located in an initializer (of any kind).
123+
SingleValueInstruction *findUninitializedSelfValue() const;
124+
133125
/// True if the memory object is the 'self' argument of a struct initializer.
134126
bool isStructInitSelf() const {
135127
if (MemoryInst->isRootSelf() || MemoryInst->isCrossModuleRootSelf()) {

lib/Sema/CSBindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,7 @@ void BindingSet::dump(llvm::raw_ostream &out, unsigned indent) const {
17651765
out << "(default type of literal) ";
17661766
break;
17671767
}
1768-
BindingType.print(out);
1768+
BindingType.print(out, PO);
17691769
}
17701770
};
17711771

utils/build-script-impl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ KNOWN_SETTINGS=(
234234
swift-disable-dead-stripping "0" "turns off Darwin-specific dead stripping for Swift host tools"
235235
common-swift-flags "" "Flags used for Swift targets other than the stdlib, like the corelibs"
236236
swift-enable-experimental-string-processing "1" "whether to build experimental string processing feature"
237+
swift-earlyswiftsyntax "0" "use the early SwiftSyntax"
237238

238239
## FREESTANDING Stdlib Options
239240
swift-freestanding-flavor "" "when building the FREESTANDING stdlib, which build style to use (options: apple, linux)"
@@ -855,6 +856,16 @@ function set_build_options_for_host() {
855856
swift_cmake_options+=(
856857
-DCOVERAGE_DB="${COVERAGE_DB}"
857858
)
859+
860+
if [[ "$(true_false ${SWIFT_EARLYSWIFTSYNTAX})" == "TRUE" ]]; then
861+
early_swiftsyntax_build_dir="$(build_directory ${host} earlyswiftsyntax)"
862+
swift_cmake_options+=(
863+
-DSWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR:PATH="${early_swiftsyntax_build_dir}"
864+
)
865+
lldb_cmake_options+=(
866+
-DSWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR:PATH="${early_swiftsyntax_build_dir}"
867+
)
868+
fi
858869
}
859870

860871
function configure_default_options() {
@@ -1238,6 +1249,7 @@ LIBDISPATCH_STATIC_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
12381249
LIBICU_SOURCE_DIR="${WORKSPACE}/icu"
12391250
LIBCXX_SOURCE_DIR="${WORKSPACE}/llvm-project/runtimes"
12401251
EXPERIMENTAL_STRING_PROCESSING_SOURCE_DIR="${WORKSPACE}/swift-experimental-string-processing"
1252+
SWIFTSYNTAX_SOURCE_DIR="${WORKSPACE}/swift-syntax"
12411253
LIBXML2_SOURCE_DIR="${WORKSPACE}/libxml2"
12421254
SWIFT_SYNTAX_SOURCE_DIR="${WORKSPACE}/swift-syntax"
12431255

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,9 @@ def create_argument_parser():
662662
option(['--swiftsyntax'], toggle_true('build_swiftsyntax'),
663663
help='build swiftSyntax')
664664

665-
option(['--early-swiftsyntax'], toggle_true('build_early_swiftsyntax'),
666-
help='build early SwiftSyntax')
665+
option(['--skip-early-swiftsyntax'],
666+
toggle_false('build_early_swiftsyntax'),
667+
help='skip building early SwiftSyntax')
667668

668669
option(['--skstresstester'], toggle_true('build_skstresstester'),
669670
help='build the SourceKit stress tester')

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
'build_swiftpm': False,
9191
'build_swift_driver': False,
9292
'build_early_swift_driver': True,
93-
'build_early_swiftsyntax': False,
93+
'build_early_swiftsyntax': True,
9494
'build_swiftsyntax': False,
9595
'build_libparser_only': False,
9696
'build_skstresstester': False,
@@ -519,7 +519,6 @@ class BuildScriptImplOption(_BaseOption):
519519
SetTrueOption('--skip-build'),
520520
SetTrueOption('--swiftpm', dest='build_swiftpm'),
521521
SetTrueOption('--swift-driver', dest='build_swift_driver'),
522-
SetTrueOption('--early-swiftsyntax', dest='build_early_swiftsyntax'),
523522
SetTrueOption('--swiftsyntax', dest='build_swiftsyntax'),
524523
SetTrueOption('--build-libparser-only', dest='build_libparser_only'),
525524
SetTrueOption('--skstresstester', dest='build_skstresstester'),
@@ -637,6 +636,7 @@ class BuildScriptImplOption(_BaseOption):
637636
DisableOption('--skip-clean-xctest', dest='clean_xctest'),
638637
DisableOption('--skip-clean-llbuild', dest='clean_llbuild'),
639638
DisableOption('--skip-early-swift-driver', dest='build_early_swift_driver'),
639+
DisableOption('--skip-early-swiftsyntax', dest='build_early_swiftsyntax'),
640640
DisableOption('--skip-clean-swiftpm', dest='clean_swiftpm'),
641641
DisableOption('--skip-clean-swift-driver', dest='clean_swift_driver'),
642642
DisableOption('--skip-test-android', dest='test_android'),

utils/swift_build_support/swift_build_support/build_script_invocation.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,7 @@ def convert_to_impl_arguments(self):
252252
'-DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE:PATH={}'.format(swift_syntax_src))
253253

254254
if args.build_early_swiftsyntax:
255-
early_swiftsyntax_build_dir = os.path.join(
256-
self.workspace.build_root,
257-
'%s-%s' % ('earlyswiftsyntax', self.args.host_target))
258-
args.extra_cmake_options.append(
259-
'-DSWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR:PATH={}'
260-
.format(early_swiftsyntax_build_dir))
255+
impl_args += ["--swift-earlyswiftsyntax"]
261256

262257
# Then add subproject install flags that either skip building them /or/
263258
# if we are going to build them and install_all is set, we also install

utils/swift_build_support/swift_build_support/products/swift.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#
1111
# ----------------------------------------------------------------------------
1212

13-
import os
14-
1513
from . import cmark
1614
from . import earlyswiftdriver
1715
from . import libcxx
@@ -57,9 +55,6 @@ def __init__(self, args, toolchain, source_dir, build_dir):
5755
# Add experimental distributed flag.
5856
self.cmake_options.extend(self._enable_experimental_distributed)
5957

60-
# Add path for the early SwiftSyntax build.
61-
self.cmake_options.extend(self._early_swiftsyntax_flags)
62-
6358
# Add static vprintf flag
6459
self.cmake_options.extend(self._enable_stdlib_static_vprintf)
6560

@@ -180,18 +175,6 @@ def _enable_experimental_distributed(self):
180175
return [('SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL',
181176
self.args.enable_experimental_distributed)]
182177

183-
@property
184-
def _early_swiftsyntax_flags(self):
185-
result = []
186-
if self.args.build_early_swiftsyntax:
187-
build_root = os.path.dirname(self.build_dir)
188-
early_swiftsyntax_build_dir = os.path.join(
189-
'..', build_root, '%s-%s' % ('earlyswiftsyntax',
190-
self.args.host_target))
191-
result.append(('SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR:PATH',
192-
early_swiftsyntax_build_dir))
193-
return result
194-
195178
@property
196179
def _enable_stdlib_static_vprintf(self):
197180
return [('SWIFT_STDLIB_STATIC_PRINT',

0 commit comments

Comments
 (0)