Only mangle borrowing/consuming when they would change ABI.

`__shared` and `__owned` would always get mangled, even when they don't have any effect
on ABI, making it unnecessarily ABI-breaking to apply them to existing API to make
calling conventions explicit. Avoid this issue by only mangling them in cases where they
change the ABI from the default.
This commit is contained in:
Joe Groff
2023-03-02 20:41:40 -08:00
parent f3a6ce144c
commit 5345e982e9
16 changed files with 281 additions and 138 deletions

View File

@@ -4785,18 +4785,6 @@ getRawStableReferenceOwnership(swift::ReferenceOwnership ownership) {
}
llvm_unreachable("bad ownership kind");
}
/// Translate from the AST ownership enum to the Serialization enum
/// values, which are guaranteed to be stable.
static uint8_t getRawStableValueOwnership(swift::ValueOwnership ownership) {
switch (ownership) {
SIMPLE_CASE(ValueOwnership, Default)
SIMPLE_CASE(ValueOwnership, InOut)
SIMPLE_CASE(ValueOwnership, Shared)
SIMPLE_CASE(ValueOwnership, Owned)
}
llvm_unreachable("bad ownership kind");
}
/// Translate from the AST ParameterConvention enum to the
/// Serialization enum values, which are guaranteed to be stable.
static uint8_t getRawStableParameterConvention(swift::ParameterConvention pc) {
@@ -5153,7 +5141,7 @@ public:
for (auto &param : fnTy->getParams()) {
auto paramFlags = param.getParameterFlags();
auto rawOwnership =
getRawStableValueOwnership(paramFlags.getValueOwnership());
getRawStableParamDeclSpecifier(paramFlags.getOwnershipSpecifier());
FunctionParamLayout::emitRecord(
S.Out, S.ScratchRecord, abbrCode,
S.addDeclBaseNameRef(param.getLabel()),