Skip to content

[4.2] IRGen: don't emit metadata lazily in JIT mode. #16613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ bool IRGenerator::tryEnableLazyTypeMetadata(NominalTypeDecl *Nominal) {
// is not used by the program itself.
if (!Opts.shouldOptimize())
return false;
if (Opts.UseJIT)
return false;

switch (Nominal->getKind()) {
case DeclKind::Enum:
Expand Down
17 changes: 17 additions & 0 deletions test/Interpreter/unused-type.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: %target-jit-run -O %s | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: swift_interpreter

// Check that when running the jit with -O we don't crash with an unresolved
// metadata symbol.

protocol Foo {
func foo() -> Int
}

struct Dummy: Foo {
func foo() -> Int { return 42 }
}

// CHECK: ok
print("ok")