-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix SynthesizedFileUnit serialization and TBDGen issues. #30912
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
dan-zheng
merged 2 commits into
swiftlang:master
from
dan-zheng:fix-synthesized-file-unit
Apr 9, 2020
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...er_crashers_fixed/Inputs/tf1202-differentiability-witness-dead-function-elimination.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import _Differentiation | ||
|
||
@inlinable | ||
@differentiable(where T: Differentiable) | ||
public func identity<T>(_ x: T) -> T { x } | ||
|
||
public func foo<T: Differentiable>(_ f: @differentiable (T) -> T = identity) -> T { | ||
fatalError() | ||
} |
17 changes: 17 additions & 0 deletions
17
.../compiler_crashers_fixed/tf1202-differentiability-witness-dead-function-elimination.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: %target-build-swift -emit-module -module-name tf1202 -emit-module-path %t/tf1202.swiftmodule %S/Inputs/tf1202-differentiability-witness-dead-function-elimination.swift | ||
// RUN: %target-build-swift -I%t -emit-module -O %s | ||
|
||
// TF-1202: test bug where DeadFunctionElimination eliminated the | ||
// SILFunction for `func identity<T>` even though a differentiability witness for it | ||
// exists. This causes deserialization of this module to crash when | ||
// trying to deserialize the differentiability witness because it can't find | ||
// the original function `func identity<T>`. | ||
|
||
// TF-1239: Test `SynthesizedFileUnit` serialization. | ||
|
||
import tf1202 | ||
|
||
func callit() -> Float { | ||
return foo() | ||
} |
14 changes: 14 additions & 0 deletions
14
test/AutoDiff/validation-test/Inputs/cross_module_differentiation_other.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import _Differentiation | ||
|
||
@differentiable | ||
public func defaultArgument(_ x: Float) -> Float { | ||
return x | ||
} | ||
|
||
@differentiable | ||
public func applyArgument( | ||
_ x: Float, | ||
_ f: @differentiable (Float) -> Float = defaultArgument | ||
) -> Float { | ||
return f(x) | ||
} |
28 changes: 28 additions & 0 deletions
28
test/AutoDiff/validation-test/cross_module_differentiation.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: %target-build-swift -working-directory %t -parse-as-library -emit-module -module-name cross_module_differentiation_other -emit-module-path %t/cross_module_differentiation_other.swiftmodule -emit-library -static %S/Inputs/cross_module_differentiation_other.swift | ||
// RUN: %target-build-swift -I%t -L%t %s -o %t/a.out -lcross_module_differentiation_other | ||
// RUN: %target-run %t/a.out | ||
// REQUIRES: executable_test | ||
|
||
// TF-1025: Test differentiability witness linkage for `PublicNonABI` original functions. | ||
// TF-1239: Test `SynthesizedFileUnit` TBDGen. | ||
|
||
import cross_module_differentiation_other | ||
import _Differentiation | ||
import StdlibUnittest | ||
|
||
var CrossModuleTests = TestSuite("E2ECrossModule") | ||
|
||
CrossModuleTests.test("differentiable function default argument") { | ||
let actualGrad = gradient(at: 0) { applyArgument($0) } | ||
let expectedGrad: Float = 1 | ||
expectEqual(actualGrad, expectedGrad) | ||
} | ||
|
||
CrossModuleTests.test("differentiable function specified default argument") { | ||
let actualGrad = gradient(at: 0) { applyArgument($0, { $0 }) } | ||
let expectedGrad: Float = 1 | ||
expectEqual(actualGrad, expectedGrad) | ||
} | ||
|
||
runAllTests() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.