-
Couldn't load subscription status.
- Fork 10.6k
[wasm][IRGen] Stop attaching COMDATs to dead stub methods #85106
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
Open
kateinoigakukun
wants to merge
1
commit into
swiftlang:main
Choose a base branch
from
kateinoigakukun:yt/fix-dead-stub-comdat-wasm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+55
−5
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // RUN: %empty-directory(%t) | ||
| // RUN: split-file --leading-lines %s %t | ||
|
|
||
| // Note: Windows uses internal linkage for dead stub methods, which doesn't | ||
| // use linkonce_odr or COMDAT groups. | ||
| // UNSUPPORTED: OS=windows-msvc | ||
|
|
||
| // Ensure that swift_dead_method_stub is emitted without comdat linkage | ||
| // RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -parse-as-library -O -module-name A -c -primary-file %t/A.swift %t/B.swift -emit-ir -o - | %FileCheck %s -check-prefix CHECK | ||
| // RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -parse-as-library -O -module-name A -c %t/A.swift -primary-file %t/B.swift -emit-ir -o - | %FileCheck %s -check-prefix CHECK | ||
|
|
||
| // CHECK-LABEL: define {{(linkonce_odr )?}}hidden void @_swift_dead_method_stub( | ||
| // CHECK-NOT: comdat | ||
| // CHECK: { | ||
|
|
||
|
|
||
| // Ensure that link-time deduplication for swift_dead_method_stub works correctly | ||
| // RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -parse-as-library -O -module-name A -c -primary-file %t/A.swift %t/B.swift -o %t/A.swift.o | ||
| // RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -parse-as-library -O -module-name A -c %t/A.swift -primary-file %t/B.swift -o %t/B.swift.o | ||
| // RUN: %target-build-swift -target %target-swift-5.1-abi-triple %t/B.swift.o %t/A.swift.o -o %t/a.out | ||
|
|
||
| //--- A.swift | ||
|
|
||
| // Define an open class with a dead vtable entry | ||
| class C1 { | ||
| private func dead() {} | ||
| } | ||
|
|
||
| //--- B.swift | ||
|
|
||
| class C2: C1 { | ||
| // Define another dead vtable entry to ensure that this object file | ||
| // also should have dead vtable stub definition | ||
| private func beef() {} | ||
| } | ||
|
|
||
| @main | ||
| struct Entry { | ||
| static func main() { | ||
| _ = C2() | ||
| } | ||
| } | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this a bit? Windows definitely uses COMDATs rather aggressively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I wasn’t clear, in this case, IRGenModule::emitVTableStubs uses internal linkage instead of linkonce_odr only for COFF, so we don’t attach COMDATs in ApplyIRLinkage::to in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please update the comment to reflect that please? Yes, LinkOnce ODR doesn't really work on PE/COFF due to the weak linking behaviour.