Skip to content

Commit 1c3bd3e

Browse files
authored
Merge pull request #70158 from eeckstein/fix-sil-linker
SIL linker: delay function verification to end of linking
2 parents 10ff55b + 4d2fe96 commit 1c3bd3e

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

lib/SIL/IR/Linker.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void SILLinkerVisitor::deserializeAndPushToWorklist(SILFunction *F) {
9191
"the de-serializer did set the wrong serialized flag");
9292

9393
F->setBare(IsBare);
94-
F->verify();
94+
toVerify.push_back(F);
9595
Worklist.push_back(F);
9696
Changed = true;
9797
++NumFuncLinked;
@@ -463,4 +463,9 @@ void SILLinkerVisitor::process() {
463463
}
464464
}
465465
}
466+
467+
while (!toVerify.empty()) {
468+
auto *fn = toVerify.pop_back_val();
469+
fn->verify();
470+
}
466471
}

lib/SIL/IR/Linker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ class SILLinkerVisitor : public SILInstructionVisitor<SILLinkerVisitor, void> {
8383
/// Worklist of SILFunctions we are processing.
8484
llvm::SmallVector<SILFunction *, 128> Worklist;
8585

86+
llvm::SmallVector<SILFunction *, 32> toVerify;
87+
8688
/// The current linking mode.
8789
LinkingMode Mode;
8890

test/embedded/fragile-reference.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %target-swift-frontend -target armv7-apple-none-macho -module-name main -parse-as-library -Xcc -D__MACH__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
2+
// RUN: %target-swift-frontend -target arm64-apple-none-macho -module-name main -parse-as-library -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
3+
// REQUIRES: swift_in_compiler
4+
// REQUIRES: OS=macosx || OS=linux-gnu
5+
@main
6+
public struct Application {
7+
public static func main() {
8+
var x: UInt64 = 0
9+
x <<= 8
10+
}
11+
}
12+
13+
enum MyEnum: UInt8 {
14+
case a = 0
15+
}
16+
17+
// CHECK: define {{.*}}@main(
18+

0 commit comments

Comments
 (0)