Skip to content

Commit 3594f8e

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
Conflicts: test/IRGen/opaque-pointer-llvm.swift
2 parents 1edd3e9 + 7e9013d commit 3594f8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1225
-419
lines changed

docs/HowToGuides/FirstPullRequest.md

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,26 @@ make changes, run tests and debug issues.
9898

9999
## Submitting a pull request
100100

101-
### Tidying up
102-
103101
Alright! You've implemented a change and would like to submit it.
104-
Double-check that you've tidied your Git history, such as squashing
105-
work-in-progress commits, and that your commit messages provide context.
106-
For example, if a commit fixes a bug, then include a "Fixes SR-NNNNN" with the
107-
bug number in the commit message.
108102

109-
Next, [format your changes](/docs/HowToGuides/FAQ.md#how-do-i-format-my-changes)
110-
using `clang-format`.
103+
### Tidying up
104+
105+
> **Note**
106+
> If you intend to create a [draft pull request][draft-pr], you can tidy up
107+
> later *before* marking it as ready for review.
108+
109+
1. [Tidy up your commit history](FAQ.md#how-do-i-clean-up-my-git-history):
110+
* Squash work-in-progress commits.
111+
* Break up your changes into as many self-sufficient, meaningful commits as
112+
you can, rather than cramming everything into a single commit.
113+
For example, a patch that renames a function (1) and modifies an algorithm
114+
(2) can be split into two commits.
115+
A self-sufficient commit must compile, pass all tests, and contain
116+
any associated test changes.
117+
This practice is key to efficient and rigorous code review processes,
118+
as well as a neat, transparent, and actionable commit history.
119+
* [Top off your commit messages](https://swift.org/contributing/#commit-messages).
120+
1. Tidy up and [format your code changes](FAQ.md#how-do-i-format-my-changes).
111121

112122
### Pushing and creating a pull request
113123

@@ -120,21 +130,29 @@ show a helpful "Compare & Pull Request" button.
120130

121131
![Compare & Pull Request button in GitHub UI](/docs/GitHubCreatePRScreenshot.png)
122132

133+
[draft-pr]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests
123134
[create a pull request]: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request#creating-the-pull-request
124135

125136
## Asking for code review
126137

127-
If you had an active discussion with someone on how to implement your change,
128-
you can `@` mention them in the PR description and ask for code review.
129-
If you directly implemented the change without any guidance from anyone else,
130-
`@` mention someone from GitHub's suggested reviewers. If GitHub doesn't
131-
make any suggestions, ask the [Code Owner](https://github.com/apple/swift/blob/main/CODE_OWNERS.TXT) based on the
132-
component for your change. Please ask someone though! We don't want you to get
133-
stuck because you were not sure who to ask for code review.
134-
135-
At the beginning, contributors are not able to run the continuous integration
136-
(CI) bot, which builds the project and runs tests. Please ask your code
137-
reviewer(s) to invoke the bot for you.
138+
Collaborators and code owners are automatically requested for review per the
139+
[CODEOWNERS](/.github/CODEOWNERS) file. If no one is automatically requested for
140+
review, @mention and ask a suggested person under **Reviewers** to review your
141+
changes. If no reviewer suggestions are shown either, please
142+
[message][contributor-experience] the Contributor Experience Workgroup on the
143+
Swift forums to sort out review requests for you.
144+
145+
You are welcome to invite other people for review as well — say, someone you
146+
had an active discussion with on how to implement your change.
147+
Anyone with a GitHub account can review or comment on changes proposed to
148+
this repository!
149+
150+
Contributors without
151+
[write access](https://swift.org/contributing/#commit-access) are not able to
152+
run the continuous integration (CI) bot, which builds the project and runs
153+
tests. Please ask a code reviewer with write access to invoke the bot for you.
154+
155+
[contributor-experience]: https://forums.swift.org/g/contributor-experience-workgroup
138156

139157
## Responding to code review comments
140158

include/swift/AST/Attr.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ TYPE_ATTR(dynamic_self)
6767
#define REF_STORAGE(Name, name, ...) TYPE_ATTR(sil_##name)
6868
#include "swift/AST/ReferenceStorage.def"
6969
TYPE_ATTR(error)
70+
TYPE_ATTR(error_indirect)
71+
TYPE_ATTR(error_unowned)
7072
TYPE_ATTR(out)
7173
TYPE_ATTR(direct)
7274
TYPE_ATTR(in)

include/swift/AST/CASTBridging.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ typedef enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedTypeAttrKind : size_t {
165165
BridgedTypeAttrKind_sil_unowned,
166166
BridgedTypeAttrKind_sil_unmanaged,
167167
BridgedTypeAttrKind_error,
168+
BridgedTypeAttrKind_error_indirect,
169+
BridgedTypeAttrKind_error_unowned,
168170
BridgedTypeAttrKind_out,
169171
BridgedTypeAttrKind_direct,
170172
BridgedTypeAttrKind_in,

include/swift/AST/DiagnosticsSIL.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ ERROR(global_must_be_compile_time_const,none,
352352
"global variable must be a compile-time constant", ())
353353
ERROR(non_final_generic_class_function,none,
354354
"classes cannot have non-final generic fuctions in embedded Swift", ())
355+
ERROR(embedded_swift_existential_type,none,
356+
"cannot use a value of protocol type %0 in embedded Swift", (Type))
357+
ERROR(embedded_swift_existential,none,
358+
"cannot use a value of protocol type in embedded Swift", ())
355359
NOTE(performance_called_from,none,
356360
"called from here", ())
357361

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ namespace swift {
177177
llvm::VersionTuple MinimumInliningTargetVersion;
178178

179179
/// The alternate name to use for the entry point instead of main.
180-
std::string entryPointFunctionName = "main";
180+
std::optional<std::string> entryPointFunctionName;
181181

182182
///
183183
/// Language features

include/swift/SIL/ApplySite.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,17 @@ class FullApplySite : public ApplySite {
679679
return getSubstCalleeConv().getNumIndirectSILResults();
680680
}
681681

682+
unsigned getNumIndirectSILErrorResults() const {
683+
return getSubstCalleeConv().getNumIndirectSILErrorResults();
684+
}
685+
682686
OperandValueArrayRef getIndirectSILResults() const {
683687
return getArguments().slice(0, getNumIndirectSILResults());
684688
}
685689

686690
OperandValueArrayRef getArgumentsWithoutIndirectResults() const {
687-
return getArguments().slice(getNumIndirectSILResults());
691+
return getArguments().slice(getNumIndirectSILResults() +
692+
getNumIndirectSILErrorResults());
688693
}
689694

690695
InoutArgumentRange getInoutArguments() const {

include/swift/SIL/SILFunctionConventions.h

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,20 @@ class SILFunctionConventions {
232232
: funcTy->getNumPackResults();
233233
}
234234

235+
/// Get the number of SIL error results passed as address-typed arguments.
236+
unsigned getNumIndirectSILErrorResults() const {
237+
if (!silConv.loweredAddresses)
238+
return 0;
239+
if (auto errorResultInfo = funcTy->getOptionalErrorResult()) {
240+
return errorResultInfo->getConvention() == ResultConvention::Indirect ? 1 : 0;
241+
}
242+
243+
return 0;
244+
}
245+
235246
/// Are any SIL results passed as address-typed arguments?
236247
bool hasIndirectSILResults() const { return getNumIndirectSILResults() != 0; }
248+
bool hasIndirectSILErrorResults() const { return getNumIndirectSILErrorResults() != 0; }
237249

238250
struct IndirectSILResultFilter {
239251
bool loweredAddresses;
@@ -381,7 +393,7 @@ class SILFunctionConventions {
381393
unsigned getSILArgIndexOfFirstIndirectResult() const { return 0; }
382394

383395
unsigned getSILArgIndexOfFirstParam() const {
384-
return getNumIndirectSILResults();
396+
return getNumIndirectSILResults() + getNumIndirectSILErrorResults();
385397
}
386398

387399
/// Returns the index of self.
@@ -410,13 +422,15 @@ class SILFunctionConventions {
410422
/// this function type. This is also the total number of SILArguments
411423
/// in the entry block.
412424
unsigned getNumSILArguments() const {
413-
return getNumIndirectSILResults() + funcTy->getNumParameters();
425+
return getNumIndirectSILResults() + getNumIndirectSILErrorResults() +
426+
funcTy->getNumParameters();
414427
}
415428

416429
SILParameterInfo getParamInfoForSILArg(unsigned index) const {
417-
assert(index >= getNumIndirectSILResults()
430+
assert(index >= (getNumIndirectSILResults() + getNumIndirectSILErrorResults())
418431
&& index <= getNumSILArguments());
419-
return funcTy->getParameters()[index - getNumIndirectSILResults()];
432+
return funcTy->getParameters()[index - getNumIndirectSILResults()
433+
- getNumIndirectSILErrorResults()];
420434
}
421435

422436
/// Return the SIL argument convention of apply/entry argument at
@@ -518,11 +532,20 @@ inline SILType
518532
SILFunctionConventions::getSILArgumentType(unsigned index,
519533
TypeExpansionContext context) const {
520534
assert(index <= getNumSILArguments());
521-
if (index < getNumIndirectSILResults()) {
535+
auto numIndirectSILResults = getNumIndirectSILResults();
536+
if (index < numIndirectSILResults) {
522537
return *std::next(getIndirectSILResultTypes(context).begin(), index);
523538
}
539+
540+
auto numIndirectSILErrorResults = getNumIndirectSILErrorResults();
541+
if (numIndirectSILErrorResults &&
542+
(index < (numIndirectSILResults + numIndirectSILErrorResults))) {
543+
return getSILType(funcTy->getErrorResult(), context);
544+
}
545+
524546
return getSILType(
525-
funcTy->getParameters()[index - getNumIndirectSILResults()], context);
547+
funcTy->getParameters()[index - numIndirectSILResults -
548+
numIndirectSILErrorResults], context);
526549
}
527550

528551
inline bool

include/swift/Serialization/SerializationOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ namespace swift {
158158
bool EmbeddedSwiftModule = false;
159159
bool IsOSSA = false;
160160
bool SkipNonExportableDecls = false;
161+
bool ExplicitModuleBuild = false;
161162
};
162163

163164
} // end namespace swift

lib/AST/ASTContext.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5906,7 +5906,14 @@ ASTContext::SILTransformCtors ASTContext::getIRGenSILTransforms() const {
59065906
}
59075907

59085908
std::string ASTContext::getEntryPointFunctionName() const {
5909-
return LangOpts.entryPointFunctionName;
5909+
// Set default entry point name
5910+
//
5911+
// Usually the main entrypoint is "main" but WebAssembly's C ABI uses
5912+
// "__main_argc_argv" for `int (int, char **)` signature and Swift's
5913+
// main entrypoint always takes argc/argv.
5914+
// See https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md
5915+
std::string defaultName = LangOpts.Target.isWasm() ? "__main_argc_argv" : "main";
5916+
return LangOpts.entryPointFunctionName.value_or(defaultName);
59105917
}
59115918

59125919
SILLayout *SILLayout::get(ASTContext &C,

lib/AST/ASTPrinter.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6952,10 +6952,18 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
69526952
}
69536953

69546954
if (T->hasErrorResult()) {
6955-
// The error result is implicitly @owned; don't print that.
6956-
assert(T->getErrorResult().getConvention() == ResultConvention::Owned);
69576955
sub->Printer.printSeparator(first, ", ");
6958-
sub->Printer << "@error ";
6956+
if (T->getErrorResult().getConvention() == ResultConvention::Owned)
6957+
sub->Printer << "@error ";
6958+
else if (T->getErrorResult().getConvention() == ResultConvention::Indirect)
6959+
sub->Printer << "@error_indirect ";
6960+
else if (T->getErrorResult().getConvention() == ResultConvention::Unowned)
6961+
sub->Printer << "@error_unowned ";
6962+
else {
6963+
assert(false && "Should have error, error_indirect, or error_unowned");
6964+
}
6965+
6966+
69596967
T->getErrorResult().getInterfaceType().print(sub->Printer, subOptions);
69606968
}
69616969

0 commit comments

Comments
 (0)