Skip to content

Commit e3aa457

Browse files
committed
[AST] Add bit to VarDecl for isPlaceholderVar
This allows the query to be consistent both during type-checking and after.
2 parents 2f0dee4 + f8a31c6 commit e3aa457

File tree

176 files changed

+2438
-1145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+2438
-1145
lines changed

Runtimes/Core/cmake/modules/PlatformInfo.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
1515
if(CMAKE_Swift_COMPILER_TARGET)
1616
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
1717
endif()
18-
execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
18+
execute_process(COMMAND ${module_triple_command}
19+
OUTPUT_VARIABLE target_info_json
20+
ERROR_VARIABLE stderr
21+
RESULT_VARIABLE ec)
22+
if(ec)
23+
message(FATAL_ERROR "'${module_triple_command}' returned non-zero exit code ${ec}")
24+
message(CONFIGURE_LOG "Error Output: ${stderr}")
25+
endif()
1926
message(CONFIGURE_LOG "Swift target info: ${module_triple_command}\n"
2027
"${target_info_json}")
2128

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LoopInvariantCodeMotion.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -999,19 +999,6 @@ private extension Instruction {
999999
move(before: terminator, context)
10001000
}
10011001
}
1002-
1003-
if let singleValueInst = self as? SingleValueInstruction,
1004-
!(self is ScopedInstruction || self is AllocStackInst),
1005-
let identicalInst = (loop.preheader!.instructions.first { otherInst in
1006-
return singleValueInst != otherInst && singleValueInst.isIdenticalTo(otherInst)
1007-
}) {
1008-
guard let identicalSingleValueInst = identicalInst as? SingleValueInstruction else {
1009-
return true
1010-
}
1011-
1012-
singleValueInst.replace(with: identicalSingleValueInst, context)
1013-
}
1014-
10151002
return true
10161003
}
10171004

docs/DebuggingTheCompiler.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ benefit of all Swift developers.
5252
- [Viewing allocation history, references, and page-level info](#viewing-allocation-history-references-and-page-level-info)
5353
- [Printing memory contents](#printing-memory-contents)
5454
- [Windows Error Codes](#windows-error-codes)
55+
- [Debugging Simulator Apps](#working-simulator-apps)
5556
- [Debugging LLDB failures](#debugging-lldb-failures)
5657
- ["Types" Log](#types-log)
5758
- ["Expression" Log](#expression-log)
@@ -1201,6 +1202,15 @@ Some relevant Microsoft documentation:
12011202
* https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a
12021203
* https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
12031204

1205+
## Debugging Simulator Apps
1206+
1207+
Sometimes one has to debug apps compiled for one of the simulators (e.x.: iOS
1208+
simulator). To manipulate the simulator from the command line, one uses the tool
1209+
called `simctl`. This lets one perform actions such as installing apps,
1210+
uninstalling apps, and of course launching apps. To pass through environment
1211+
variables to launched apps, one sets them in the calling environment using the
1212+
environment variable prefix `SIMCTL_CHILD_$ACTUAL_ENV_VAR_NAME`.
1213+
12041214
# Debugging LLDB failures
12051215

12061216
Sometimes one needs to be able to while debugging actually debug LLDB and its

docs/ExternalResources.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ https://medium.com/kinandcartacreated/contributing-to-swift-part-2-efebcf7b6c93
116116
efficiency and correctness challenges with automatic reference counting and
117117
how including ownership semantics in the compiler's intermediate representation
118118
helps tackles those challenges.
119-
- [How to talk to your kids about SIL type use][] by Slava Pestov (blog post,
120-
Jul 2016): This blog post describes several important SIL concepts: object
121-
vs address types, AST -> SIL type lowering, trivial vs loadable vs
122-
address-only SIL types, abstraction patterns and more.
123119
- [Swift's High-Level IR][] by Joe Groff and Chris Lattner (talk, Oct 2015):
124120
This talk describes the goals and design of SIL. It covers the following:
125121
- Some commonly used SIL instructions and how they are motivated by language

docs/README.md

Lines changed: 124 additions & 294 deletions
Large diffs are not rendered by default.

include/swift/ABI/Task.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
#include "bitset"
3030
#include "queue" // TODO: remove and replace with our own mpsc
3131

32+
// Does the runtime integrate with libdispatch?
33+
#if defined(SWIFT_CONCURRENCY_USES_DISPATCH)
34+
#define SWIFT_CONCURRENCY_ENABLE_DISPATCH SWIFT_CONCURRENCY_USES_DISPATCH
35+
#else
36+
#define SWIFT_CONCURRENCY_ENABLE_DISPATCH 0
37+
#endif
38+
3239
// Does the runtime provide priority escalation support?
3340
#ifndef SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION
3441
#if SWIFT_CONCURRENCY_ENABLE_DISPATCH && \
@@ -422,7 +429,22 @@ class AsyncTask : public Job {
422429
///
423430
/// Generally this should be done immediately after updating
424431
/// ActiveTask.
425-
void flagAsRunning();
432+
///
433+
/// When Dispatch is used for the default executor:
434+
/// * If the return value is non-zero, it must be passed
435+
/// to swift_dispatch_thread_reset_override_self
436+
/// before returning to the executor.
437+
/// * If the return value is zero, it may be ignored or passed to
438+
/// the aforementioned function (which will ignore values of zero).
439+
/// The current implementation will always return zero
440+
/// if you call flagAsRunning again before calling
441+
/// swift_dispatch_thread_reset_override_self with the
442+
/// initial value. This supports suspending and immediately
443+
/// resuming a Task without returning up the callstack.
444+
///
445+
/// For all other default executors, flagAsRunning
446+
/// will return zero which may be ignored.
447+
uint32_t flagAsRunning();
426448

427449
/// Flag that this task is now suspended with information about what it is
428450
/// waiting on.

include/swift/AST/Decl.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl>, public Swi
493493
IsStatic : 1
494494
);
495495

496-
SWIFT_INLINE_BITFIELD(VarDecl, AbstractStorageDecl, 2+1+1+1+1+1+1+1,
496+
SWIFT_INLINE_BITFIELD(VarDecl, AbstractStorageDecl, 2+1+1+1+1+1+1+1+1,
497497
/// Encodes whether this is a 'let' binding.
498498
Introducer : 2,
499499

@@ -517,7 +517,11 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl>, public Swi
517517
NoAttachedPropertyWrappers : 1,
518518

519519
/// Whether this variable has no property wrapper auxiliary variables.
520-
NoPropertyWrapperAuxiliaryVariables : 1
520+
NoPropertyWrapperAuxiliaryVariables : 1,
521+
522+
/// Whether this variable is a placeholder that is introducing during
523+
/// type-checking that has its type inferred from its use.
524+
IsPlaceholderVar : 1
521525
);
522526

523527
SWIFT_INLINE_BITFIELD(ParamDecl, VarDecl, 1+2+NumDefaultArgumentKindBits,
@@ -6767,6 +6771,15 @@ class VarDecl : public AbstractStorageDecl {
67676771
Bits.VarDecl.IsLazyStorageProperty = IsLazyStorage;
67686772
}
67696773

6774+
/// Whether this variable is a placeholder that is introducing during
6775+
/// type-checking that has its type inferred from its use.
6776+
bool isPlaceholderVar() const {
6777+
return Bits.VarDecl.IsPlaceholderVar;
6778+
}
6779+
void setIsPlaceholderVar() {
6780+
Bits.VarDecl.IsPlaceholderVar = true;
6781+
}
6782+
67706783
/// Retrieve the backing storage property for a lazy property.
67716784
VarDecl *getLazyStorageProperty() const;
67726785

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,8 @@ ERROR(const_unsupported_type_expr,none,
832832
"type expressions not supported in a constant expression", ())
833833
ERROR(const_unsupported_closure,none,
834834
"closures not supported in a constant expression", ())
835+
ERROR(const_unsupported_closure_with_captures,none,
836+
"closures with captures not supported in a constant expression", ())
835837
ERROR(const_unsupported_keypath,none,
836838
"keypaths not supported in a constant expression", ())
837839
ERROR(const_opaque_decl_ref,none,

include/swift/AST/IRGenRequests.h

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ class SILOptions;
3333
struct TBDGenOptions;
3434
class TBDGenDescriptor;
3535

36+
namespace cas {
37+
class SwiftCASOutputBackend;
38+
}
39+
3640
namespace irgen {
3741
class IRGenModule;
3842
}
@@ -149,12 +153,15 @@ struct IRGenDescriptor {
149153

150154
StringRef ModuleName;
151155
const PrimarySpecificPaths &PSPs;
156+
std::shared_ptr<llvm::cas::ObjectStore> CAS;
152157
StringRef PrivateDiscriminator;
153158
ArrayRef<std::string> parallelOutputFilenames;
154159
ArrayRef<std::string> parallelIROutputFilenames;
155160
llvm::GlobalVariable **outModuleHash;
161+
swift::cas::SwiftCASOutputBackend *casBackend = nullptr;
156162
llvm::raw_pwrite_stream *out = nullptr;
157163

164+
158165
friend llvm::hash_code hash_value(const IRGenDescriptor &owner) {
159166
return llvm::hash_combine(owner.Ctx, owner.SymbolsToEmit, owner.SILMod);
160167
}
@@ -176,8 +183,10 @@ struct IRGenDescriptor {
176183
const TBDGenOptions &TBDOpts, const SILOptions &SILOpts,
177184
Lowering::TypeConverter &Conv, std::unique_ptr<SILModule> &&SILMod,
178185
StringRef ModuleName, const PrimarySpecificPaths &PSPs,
186+
std::shared_ptr<llvm::cas::ObjectStore> CAS,
179187
StringRef PrivateDiscriminator, SymsToEmit symsToEmit = std::nullopt,
180-
llvm::GlobalVariable **outModuleHash = nullptr) {
188+
llvm::GlobalVariable **outModuleHash = nullptr,
189+
cas::SwiftCASOutputBackend *casBackend = nullptr) {
181190
return IRGenDescriptor{file,
182191
symsToEmit,
183192
Opts,
@@ -187,20 +196,26 @@ struct IRGenDescriptor {
187196
SILMod.release(),
188197
ModuleName,
189198
PSPs,
199+
std::move(CAS),
190200
PrivateDiscriminator,
191201
{},
192202
{},
193-
outModuleHash};
203+
outModuleHash,
204+
casBackend};
194205
}
195206

196-
static IRGenDescriptor forWholeModule(
197-
ModuleDecl *M, const IRGenOptions &Opts, const TBDGenOptions &TBDOpts,
198-
const SILOptions &SILOpts, Lowering::TypeConverter &Conv,
199-
std::unique_ptr<SILModule> &&SILMod, StringRef ModuleName,
200-
const PrimarySpecificPaths &PSPs, SymsToEmit symsToEmit = std::nullopt,
201-
ArrayRef<std::string> parallelOutputFilenames = {},
202-
ArrayRef<std::string> parallelIROutputFilenames = {},
203-
llvm::GlobalVariable **outModuleHash = nullptr) {
207+
static IRGenDescriptor
208+
forWholeModule(ModuleDecl *M, const IRGenOptions &Opts,
209+
const TBDGenOptions &TBDOpts, const SILOptions &SILOpts,
210+
Lowering::TypeConverter &Conv,
211+
std::unique_ptr<SILModule> &&SILMod, StringRef ModuleName,
212+
const PrimarySpecificPaths &PSPs,
213+
std::shared_ptr<llvm::cas::ObjectStore> CAS,
214+
SymsToEmit symsToEmit = std::nullopt,
215+
ArrayRef<std::string> parallelOutputFilenames = {},
216+
ArrayRef<std::string> parallelIROutputFilenames = {},
217+
llvm::GlobalVariable **outModuleHash = nullptr,
218+
cas::SwiftCASOutputBackend *casBackend = nullptr) {
204219
return IRGenDescriptor{M,
205220
symsToEmit,
206221
Opts,
@@ -210,10 +225,12 @@ struct IRGenDescriptor {
210225
SILMod.release(),
211226
ModuleName,
212227
PSPs,
228+
std::move(CAS),
213229
"",
214230
parallelOutputFilenames,
215231
parallelIROutputFilenames,
216-
outModuleHash};
232+
outModuleHash,
233+
casBackend};
217234
}
218235

219236
/// Retrieves the files to perform IR generation for. If the descriptor is

include/swift/AST/KnownIdentifiers.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ IDENTIFIER(Any)
3535
IDENTIFIER(ArrayLiteralElement)
3636
IDENTIFIER(asLocalActor)
3737
IDENTIFIER(atIndexedSubscript)
38-
IDENTIFIER(basic_string)
3938
IDENTIFIER_(bridgeToObjectiveC)
4039
IDENTIFIER(buildArray)
4140
IDENTIFIER(buildBlock)

0 commit comments

Comments
 (0)