Skip to content

Emit default arg for a package func during silgen #69414

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 2 commits into from
Oct 27, 2023
Merged

Emit default arg for a package func during silgen #69414

merged 2 commits into from
Oct 27, 2023

Conversation

elsh
Copy link
Contributor

@elsh elsh commented Oct 25, 2023

If a package func has a default arg, its symbol is not generated
in TBD, causing a linker error. This is because the default arg
is not generated during silgen. This PR adds a check to make sure
it's represented by SILDeclRef and its linkage emitted.

Resolves rdar://116184295

Copy link
Contributor

@tshortli tshortli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test to test/TBD that exercises this and uses -validate-tbd-against-ir?


// RUN: %target-build-swift -I %t -L %t -lUtils %s -o %t/main %target-rpath(%t) -package-name mypkg

// RUN: %target-run %t/main %t/%target-library-name(Utils) > %t/run-result.output
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this test may need a REQUIRES: executable_test. I would also organize it under test/Interpreter rather than test/Sema.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the test really need to be executable? I think test/TBD/ is the best place for it and it should not be executable, just check that the symbol appears in the TBD.

Copy link
Contributor

@tshortli tshortli Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't even need to write any CHECK: lines in a TBD test for this, the -validate-tbd-against-ir infrastructure does all the validation automatically by matching up the tbd contents and LLVM IR.

Copy link
Contributor Author

@elsh elsh Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right we don't need an executable; removed, added the flag, and moved to test/tbd.

@elsh elsh changed the title Make sure to call SIL default arg generator for a package func Emit default arg for a package func during silgen Oct 26, 2023
@elsh elsh requested a review from xymus October 26, 2023 00:11
in TBD, causing a linker error. This is because the default arg
is not generated during silgen. This PR adds a check to make sure
it's represented by SILDeclRef and its linkage emitted.

Resolves rdar://116184295
@elsh
Copy link
Contributor Author

elsh commented Oct 26, 2023

@swift-ci smoke test

@elsh
Copy link
Contributor Author

elsh commented Oct 26, 2023

@swift-ci smoke test

@elsh elsh merged commit cbc050a into main Oct 27, 2023
@elsh elsh deleted the es-tbd branch October 27, 2023 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants