Skip to content

Commit 6336b88

Browse files
authored
Merge pull request #1111 from swiftwasm/master
[pull] swiftwasm from master
2 parents 18324fe + b78bd2e commit 6336b88

File tree

60 files changed

+1263
-231
lines changed

Some content is hidden

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

60 files changed

+1263
-231
lines changed

docs/Lexicon.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ and *zero* protocols; the latter is the `Any` type).
167167
Describes a type or function where making changes will break binary
168168
compatibility. See [LibraryEvolution.rst](LibraryEvolution.rst).
169169

170+
## gardening
171+
172+
Describes contributions which fix code that is not executed
173+
(such as in a manifesto or README) and written text
174+
(correcting typos and grammatical errors).
175+
170176
## generic environment
171177

172178
Provides context for interpreting a type that may have generic parameters

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ WARNING(tbd_only_supported_in_whole_module,none,
230230
"TBD generation is only supported when the whole module can be seen",
231231
())
232232

233+
ERROR(tbd_not_supported_with_cmo,none,
234+
"Test-Based InstallAPI (TBD) is not support with cross-module-optimization",
235+
())
236+
233237
WARNING(linker_directives_choice_confusion,none,
234238
"only one of -emit-ldadd-cfile-path and -module-installname-map-file can be specified;"
235239
"the c file won't be generated",

include/swift/AST/SemanticAttrs.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ SEMANTICS_ATTR(ARRAY_GET_ELEMENT_ADDRESS, "array.get_element_address")
5151
SEMANTICS_ATTR(ARRAY_INIT, "array.init")
5252
SEMANTICS_ATTR(ARRAY_INIT_EMPTY, "array.init.empty")
5353
SEMANTICS_ATTR(ARRAY_MAKE_MUTABLE, "array.make_mutable")
54+
SEMANTICS_ATTR(ARRAY_END_MUTATION, "array.end_mutation")
5455
SEMANTICS_ATTR(ARRAY_MUTATE_UNKNOWN, "array.mutate_unknown")
5556
SEMANTICS_ATTR(ARRAY_PROPS_IS_NATIVE_TYPE_CHECKED, "array.props.isNativeTypeChecked")
5657
SEMANTICS_ATTR(ARRAY_RESERVE_CAPACITY_FOR_APPEND, "array.reserve_capacity_for_append")
@@ -67,6 +68,8 @@ SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_GENERIC_PARTIAL_NEVER,
6768
"optimize.sil.specialize.generic.partial.never")
6869
SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_GENERIC_SIZE_NEVER,
6970
"optimize.sil.specialize.generic.size.never")
71+
SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_OWNED2GUARANTEE_NEVER,
72+
"optimize.sil.specialize.owned2guarantee.never")
7073

7174
SEMANTICS_ATTR(OSLOG_MESSAGE_INIT_INTERPOLATION, "oslog.message.init_interpolation")
7275
SEMANTICS_ATTR(OSLOG_MESSAGE_INIT_STRING_LITERAL, "oslog.message.init_stringliteral")

include/swift/SILOptimizer/Analysis/ArraySemantic.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ enum class ArrayCallKind {
3131
kGetElement,
3232
kGetElementAddress,
3333
kMakeMutable,
34+
kEndMutation,
3435
kMutateUnknown,
3536
kReserveCapacityForAppend,
3637
kWithUnsafeMutableBufferPointer,
@@ -42,7 +43,8 @@ enum class ArrayCallKind {
4243
// before this comment.
4344
kArrayInit,
4445
kArrayUninitialized,
45-
kArrayUninitializedIntrinsic
46+
kArrayUninitializedIntrinsic,
47+
kArrayFinalizeIntrinsic
4648
};
4749

4850
/// Return true is the given function is an array semantics call.
@@ -78,6 +80,8 @@ class ArraySemanticsCall {
7880
ArraySemanticsCall(SILValue V, StringRef semanticName,
7981
bool matchPartialName);
8082

83+
ArraySemanticsCall() : SemanticsCall(nullptr) {}
84+
8185
/// Can we hoist this call.
8286
bool canHoist(SILInstruction *To, DominanceInfo *DT) const;
8387

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ PASS(CopyForwarding, "copy-forwarding",
120120
"Copy Forwarding to Remove Redundant Copies")
121121
PASS(CopyPropagation, "copy-propagation",
122122
"Copy propagation to Remove Redundant SSA Copies")
123+
PASS(COWOpts, "cow-opts",
124+
"Optimize COW operations")
123125
PASS(Differentiation, "differentiation",
124126
"Automatic Differentiation")
125127
PASS(EpilogueARCMatcherDumper, "sil-epilogue-arc-dumper",

lib/ClangImporter/ImportName.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "clang/AST/ASTContext.h"
3535
#include "clang/Basic/IdentifierTable.h"
3636
#include "clang/Basic/Module.h"
37+
#include "clang/Basic/OperatorKinds.h"
3738
#include "clang/Lex/Preprocessor.h"
3839
#include "clang/Parse/Parser.h"
3940
#include "clang/Sema/Lookup.h"
@@ -1410,12 +1411,35 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
14101411
case clang::DeclarationName::CXXConversionFunctionName:
14111412
case clang::DeclarationName::CXXDestructorName:
14121413
case clang::DeclarationName::CXXLiteralOperatorName:
1413-
case clang::DeclarationName::CXXOperatorName:
14141414
case clang::DeclarationName::CXXUsingDirective:
14151415
case clang::DeclarationName::CXXDeductionGuideName:
14161416
// TODO: Handling these is part of C++ interoperability.
14171417
return ImportedName();
14181418

1419+
case clang::DeclarationName::CXXOperatorName: {
1420+
auto op = D->getDeclName().getCXXOverloadedOperator();
1421+
switch (op) {
1422+
case clang::OverloadedOperatorKind::OO_Plus:
1423+
case clang::OverloadedOperatorKind::OO_Minus:
1424+
case clang::OverloadedOperatorKind::OO_Star:
1425+
case clang::OverloadedOperatorKind::OO_Slash:
1426+
if (auto FD = dyn_cast<clang::FunctionDecl>(D)) {
1427+
baseName = clang::getOperatorSpelling(op);
1428+
isFunction = true;
1429+
argumentNames.resize(FD->param_size());
1430+
} else {
1431+
// This can happen for example for templated operators functions.
1432+
// We don't support those, yet.
1433+
return ImportedName();
1434+
}
1435+
break;
1436+
default:
1437+
// We don't import these yet.
1438+
return ImportedName();
1439+
}
1440+
break;
1441+
}
1442+
14191443
case clang::DeclarationName::Identifier:
14201444
// Map the identifier.
14211445
baseName = D->getDeclName().getAsIdentifierInfo()->getName();

lib/Frontend/ModuleInterfaceBuilder.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "swift/AST/DiagnosticsSema.h"
2020
#include "swift/AST/FileSystem.h"
2121
#include "swift/AST/Module.h"
22-
#include "llvm/ADT/StringSet.h"
2322
#include "swift/Basic/Defer.h"
2423
#include "swift/Frontend/Frontend.h"
2524
#include "swift/Frontend/ModuleInterfaceSupport.h"
@@ -28,7 +27,6 @@
2827
#include "clang/Frontend/CompilerInstance.h"
2928
#include "clang/Lex/PreprocessorOptions.h"
3029
#include "llvm/ADT/Hashing.h"
31-
#include "llvm/ADT/StringSet.h"
3230
#include "llvm/Support/xxhash.h"
3331
#include "llvm/Support/Debug.h"
3432
#include "llvm/Support/CommandLine.h"
@@ -85,7 +83,6 @@ bool ModuleInterfaceBuilder::collectDepsForSerialization(
8583
InitialDepNames.push_back(interfacePath);
8684
InitialDepNames.insert(InitialDepNames.end(),
8785
extraDependencies.begin(), extraDependencies.end());
88-
llvm::StringSet<> AllDepNames;
8986
SmallString<128> Scratch;
9087

9188
for (const auto &InitialDepName : InitialDepNames) {
@@ -104,7 +101,7 @@ bool ModuleInterfaceBuilder::collectDepsForSerialization(
104101
if (!prebuiltCachePath.empty() && DepName.startswith(prebuiltCachePath))
105102
continue;
106103

107-
if (AllDepNames.insert(DepName).second && dependencyTracker) {
104+
if (dependencyTracker) {
108105
dependencyTracker->addDependency(DepName, /*isSystem*/IsSDKRelative);
109106
}
110107

lib/FrontendTool/FrontendTool.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,12 @@ static bool writeTBDIfNeeded(CompilerInstance &Instance) {
10041004
return false;
10051005
}
10061006

1007+
if (Invocation.getSILOptions().CrossModuleOptimization) {
1008+
Instance.getDiags().diagnose(SourceLoc(),
1009+
diag::tbd_not_supported_with_cmo);
1010+
return false;
1011+
}
1012+
10071013
const std::string &TBDPath = Invocation.getTBDPathForWholeModule();
10081014

10091015
return writeTBD(Instance.getMainModule(), TBDPath, tbdOpts);
@@ -1404,7 +1410,7 @@ static bool validateTBDIfNeeded(const CompilerInvocation &Invocation,
14041410
return false;
14051411
}
14061412

1407-
// Cross-module optimization does not yet support TBD validation.
1413+
// Cross-module optimization does not support TBD.
14081414
if (Invocation.getSILOptions().CrossModuleOptimization) {
14091415
return false;
14101416
}

lib/SIL/Utils/InstructionUtils.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ SILValue swift::stripCastsWithoutMarkDependence(SILValue V) {
128128

129129
auto K = V->getKind();
130130
if (isRCIdentityPreservingCast(K) ||
131-
K == ValueKind::UncheckedTrivialBitCastInst) {
131+
K == ValueKind::UncheckedTrivialBitCastInst ||
132+
K == ValueKind::EndCOWMutationInst) {
132133
V = cast<SingleValueInstruction>(V)->getOperand(0);
133134
continue;
134135
}
@@ -308,7 +309,8 @@ bool swift::onlyAffectsRefCount(SILInstruction *user) {
308309
}
309310

310311
bool swift::mayCheckRefCount(SILInstruction *User) {
311-
return isa<IsUniqueInst>(User) || isa<IsEscapingClosureInst>(User);
312+
return isa<IsUniqueInst>(User) || isa<IsEscapingClosureInst>(User) ||
313+
isa<BeginCOWMutationInst>(User);
312314
}
313315

314316
bool swift::isSanitizerInstrumentation(SILInstruction *Instruction) {

lib/SIL/Utils/Projection.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,13 @@ Optional<ProjectionPath> ProjectionPath::getProjectionPath(SILValue Start,
371371

372372
auto Iter = End;
373373
while (Start != Iter) {
374-
Projection AP(Iter);
375-
if (!AP.isValid())
376-
break;
377-
P.Path.push_back(AP);
374+
// end_cow_mutation is not a projection, but we want to "see through" it.
375+
if (!isa<EndCOWMutationInst>(Iter)) {
376+
Projection AP(Iter);
377+
if (!AP.isValid())
378+
break;
379+
P.Path.push_back(AP);
380+
}
378381
Iter = cast<SingleValueInstruction>(*Iter).getOperand(0);
379382
}
380383

0 commit comments

Comments
 (0)