Skip to content

Commit d850aff

Browse files
authored
Merge pull request #4097 from swiftwasm/main
[pull] swiftwasm from main
2 parents 1411973 + da1750b commit d850aff

30 files changed

+1882
-378
lines changed

SwiftCompilerSources/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ No yet implemented instruction classes are mapped to a "placeholder" instruction
135135

136136
Similar to SIL, the optimizer also uses a small bridging layer (`OptimizerBridging.h`).
137137
Passes are registered in `registerSwiftPasses()`, called from `initializeSwiftModules()`.
138-
The C++ PassManager can then call a Swift pass like any other `SILFunctionTransform` pass.
138+
The C++ `PassManager` can then call a Swift pass like any other `SILFunctionTransform` pass.
139139

140140
To add a new function pass:
141141

@@ -160,7 +160,7 @@ To add a new instruction pass:
160160
* create a new Swift file in `SwiftCompilerSources/Optimizer/InstructionPasses`
161161
* add an `InstructionPass` global
162162
* register the pass in `registerSwiftPasses()`
163-
* if this passes replaces an existing `SILCombiner` visit function, remove the old visit function
163+
* if this pass replaces an existing `SILCombiner` visit function, remove the old visit function
164164

165165
## Performance
166166

SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import SIL
1515

1616
struct AliasAnalysis {
1717
let bridged: BridgedAliasAnalysis
18-
18+
1919
func mayRead(_ inst: Instruction, fromAddress: Value) -> Bool {
2020
switch AliasAnalysis_getMemBehavior(bridged, inst.bridged, fromAddress.bridged) {
2121
case MayReadBehavior, MayReadWriteBehavior, MayHaveSideEffectsBehavior:

SwiftCompilerSources/Sources/Optimizer/Analysis/CalleeAnalysis.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public struct CalleeAnalysis {
2323

2424
public struct FunctionArray : RandomAccessCollection, CustomReflectable {
2525
fileprivate let bridged: BridgedCalleeList
26-
26+
2727
public var startIndex: Int { 0 }
2828
public var endIndex: Int { BridgedFunctionArray_size(bridged) }
2929

SwiftCompilerSources/Sources/Optimizer/InstructionPasses/SimplifyGlobalValue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ let simplifyGlobalValuePass = InstructionPass<GlobalValueInst>(
3131
users.removeAll()
3232
}
3333
})
34-
34+
3535
/// Returns true if reference counting and debug_value users of a global_value
3636
/// can be deleted.
3737
private func checkUsers(of val: Value, users: inout StackList<Instruction>) -> Bool {

SwiftCompilerSources/Sources/Optimizer/InstructionPasses/SimplifyStrongRetainRelease.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ let simplifyStrongRetainPass = InstructionPass<StrongRetainInst>(
4444
}
4545
}
4646
})
47-
47+
4848
let simplifyStrongReleasePass = InstructionPass<StrongReleaseInst>(
4949
name: "simplify-strong_release", {
5050
(release: StrongReleaseInst, context: PassContext) in
@@ -65,7 +65,7 @@ let simplifyStrongReleasePass = InstructionPass<StrongReleaseInst>(
6565
}
6666
}
6767
})
68-
68+
6969
/// Returns true if \p value is something where reference counting instructions
7070
/// don't have any effect.
7171
private func isNotReferenceCounted(value: Value, context: PassContext) -> Bool {

SwiftCompilerSources/Sources/Optimizer/PassManager/PassUtils.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ public typealias BridgedInstructionPassCtxt =
2121
struct PassContext {
2222

2323
fileprivate let passContext: BridgedPassContext
24-
24+
2525
var isSwift51RuntimeAvailable: Bool {
2626
PassContext_isSwift51RuntimeAvailable(passContext) != 0
2727
}
28-
28+
2929
var aliasAnalysis: AliasAnalysis {
3030
let bridgedAA = PassContext_getAliasAnalysis(passContext)
3131
return AliasAnalysis(bridged: bridgedAA)
3232
}
33-
33+
3434
var calleeAnalysis: CalleeAnalysis {
3535
let bridgeCA = PassContext_getCalleeAnalysis(passContext)
3636
return CalleeAnalysis(bridged: bridgeCA)
@@ -52,7 +52,7 @@ struct PassContext {
5252
}
5353
}
5454
}
55-
55+
5656
if instruction is FullApplySite {
5757
PassContext_notifyChanges(passContext, callsChanged)
5858
}

SwiftCompilerSources/Sources/SIL/BasicBlock.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ final public class BasicBlock : ListNode, CustomStringConvertible {
3131
public var reverseInstructions: ReverseList<Instruction> {
3232
ReverseList(startAt: SILBasicBlock_lastInst(bridged).instruction)
3333
}
34-
34+
3535
public var terminator: TermInst {
3636
SILBasicBlock_lastInst(bridged).instruction as! TermInst
3737
}
3838

3939
public var successors: SuccessorArray { terminator.successors }
40-
40+
4141
public var predecessors: PredecessorList {
4242
PredecessorList(startAt: SILBasicBlock_getFirstPred(bridged))
4343
}
@@ -60,7 +60,7 @@ final public class BasicBlock : ListNode, CustomStringConvertible {
6060
}
6161
fatalError()
6262
}
63-
63+
6464
public var label: String { "bb\(index)" }
6565

6666
var bridged: BridgedBasicBlock { BridgedBasicBlock(obj: SwiftObject(self)) }
@@ -82,20 +82,20 @@ public struct ArgumentArray : RandomAccessCollection {
8282

8383
public struct SuccessorArray : RandomAccessCollection, CustomReflectable {
8484
private let succArray: BridgedArrayRef
85-
85+
8686
init(succArray: BridgedArrayRef) {
8787
self.succArray = succArray
8888
}
89-
89+
9090
public var startIndex: Int { return 0 }
9191
public var endIndex: Int { return Int(succArray.numElements) }
92-
92+
9393
public subscript(_ index: Int) -> BasicBlock {
9494
precondition(index >= 0 && index < endIndex)
9595
let s = BridgedSuccessor(succ: succArray.data + index &* BridgedSuccessorSize);
9696
return SILSuccessor_getTargetBlock(s).block
9797
}
98-
98+
9999
public var customMirror: Mirror {
100100
let c: [Mirror.Child] = map { (label: nil, value: $0.label) }
101101
return Mirror(self, children: c)
@@ -104,7 +104,7 @@ public struct SuccessorArray : RandomAccessCollection, CustomReflectable {
104104

105105
public struct PredecessorList : Sequence, IteratorProtocol, CustomReflectable {
106106
private var currentSucc: OptionalBridgedSuccessor
107-
107+
108108
public init(startAt: OptionalBridgedSuccessor) { currentSucc = startAt }
109109

110110
public mutating func next() -> BasicBlock? {

SwiftCompilerSources/Sources/SIL/Builder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public struct Builder {
6060
return cf.getAs(CondFailInst.self)
6161
}
6262
}
63-
63+
6464
public func createIntegerLiteral(_ value: Int, type: Type) -> IntegerLiteralInst {
6565
notifyInstructionsChanged()
6666
let literal = SILBuilder_createIntegerLiteral(

include/swift/AST/KnownIdentifiers.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ IDENTIFIER(using)
266266
IDENTIFIER(assignID)
267267
IDENTIFIER(resignID)
268268
IDENTIFIER(resolve)
269+
IDENTIFIER(remoteCall)
270+
IDENTIFIER(makeInvocation)
269271
IDENTIFIER(system)
270272
IDENTIFIER(ID)
271273
IDENTIFIER(id)

include/swift/Demangling/Demangle.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ class Node {
258258
// Reverses the order of children.
259259
void reverseChildren(size_t StartingAt = 0);
260260

261+
// Find a node by its kind, traversing the node depth-first,
262+
// and bailing out early if not found at the 'maxDepth'.
263+
NodePointer findByKind(Node::Kind kind, int maxDepth);
264+
261265
/// Prints the whole node tree in readable form to stderr.
262266
///
263267
/// Useful to be called from the debugger.

include/swift/Demangling/TypeDecoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,7 @@ return {}; // Not Implemented!
12621262
// TODO: Handle OpaqueReturnType, when we're in the middle of reconstructing
12631263
// the defining decl
12641264
default:
1265+
12651266
return MAKE_NODE_TYPE_ERROR0(Node, "unexpected kind");
12661267
}
12671268
}

lib/Demangling/Demangler.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,20 @@ void Node::reverseChildren(size_t StartingAt) {
417417
}
418418
}
419419

420+
Node* Node::findByKind(Node::Kind kind, int maxDepth) {
421+
if (getKind() == kind)
422+
return this;
423+
424+
if (maxDepth <= 0)
425+
return nullptr;
426+
427+
for (auto node : *this)
428+
if (auto matchingChild = node->findByKind(kind, maxDepth - 1))
429+
return matchingChild;
430+
431+
return nullptr;
432+
}
433+
420434
//////////////////////////////////
421435
// NodeFactory member functions //
422436
//////////////////////////////////

lib/IRGen/Callee.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ namespace irgen {
176176
AsyncLetGetThrowing,
177177
AsyncLetFinish,
178178
TaskGroupWaitNext,
179+
DistributedExecuteTarget,
179180
};
180181

181182
class Kind {
@@ -221,6 +222,7 @@ namespace irgen {
221222
case SpecialKind::AsyncLetWait:
222223
case SpecialKind::AsyncLetWaitThrowing:
223224
case SpecialKind::TaskGroupWaitNext:
225+
case SpecialKind::DistributedExecuteTarget:
224226
return false;
225227
}
226228

@@ -243,6 +245,7 @@ namespace irgen {
243245
case SpecialKind::AsyncLetGetThrowing:
244246
case SpecialKind::AsyncLetFinish:
245247
case SpecialKind::TaskGroupWaitNext:
248+
case SpecialKind::DistributedExecuteTarget:
246249
return true;
247250
}
248251
llvm_unreachable("covered switch");

lib/IRGen/GenDistributed.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void DistributedAccessor::computeArguments(llvm::Value *argumentBuffer,
210210
Address(currentOffset, IGM.getPointerAlignment()),
211211
IGM.getStoragePointerType(paramTy));
212212

213-
// 3. Adjust typed pointer to the alignement of the type.
213+
// 3. Adjust typed pointer to the alignment of the type.
214214
auto alignedOffset = typeInfo.roundUpToTypeAlignment(IGF, eltPtr, paramTy);
215215

216216
if (paramTy.isObject()) {

lib/IRGen/IRGenModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class IRGenerator {
401401
/// Emit type metadata records for types without explicit protocol conformance.
402402
void emitTypeMetadataRecords();
403403

404-
/// Emit type metadata recrods for functions that can be looked up by name at
404+
/// Emit type metadata records for functions that can be looked up by name at
405405
/// runtime.
406406
void emitAccessibleFunctions();
407407

lib/IRGen/IRGenSIL.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2573,6 +2573,9 @@ FunctionPointer::Kind irgen::classifyFunctionPointerKind(SILFunction *fn) {
25732573

25742574
if (name.equals("swift_taskGroup_wait_next_throwing"))
25752575
return SpecialKind::TaskGroupWaitNext;
2576+
2577+
if (name.equals("swift_distributed_execute_target"))
2578+
return SpecialKind::DistributedExecuteTarget;
25762579
}
25772580

25782581
return fn->getLoweredFunctionType();

0 commit comments

Comments
 (0)