Skip to content

Commit ca53527

Browse files
authored
Merge pull request #2585 from swiftwasm/main
[pull] swiftwasm from main
2 parents 9b0da27 + 43293ea commit ca53527

File tree

84 files changed

+1521
-1167
lines changed

Some content is hidden

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

84 files changed

+1521
-1167
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -719,11 +719,10 @@ ERROR(sema_opening_import,Fatal,
719719
ERROR(serialization_load_failed,Fatal,
720720
"failed to load module '%0'", (StringRef))
721721
ERROR(module_interface_build_failed,Fatal,
722-
"failed to %select{build module '%1' from its module interface|verify "
723-
"module interface of '%1'}0; %select{the compiler that produced it, "
724-
"'%3', may have used features that aren't supported by this compiler, "
725-
"'%4'|it may have been damaged or it may have triggered a bug in the "
726-
"Swift compiler when it was produced}2",
722+
"failed to %select{build module '%1' for importation|"
723+
"verify module interface of '%1'}0 due to the errors above; "
724+
"the textual interface may be broken by project issues"
725+
"%select{, differences between compilers (the producer '%3' and this compiler '%4')|}2 or a compiler bug",
727726
(bool, StringRef, bool, StringRef, StringRef))
728727
ERROR(serialization_malformed_module,Fatal,
729728
"malformed compiled module: %0", (StringRef))

include/swift/AST/PrintOptions.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,8 @@ struct PrintOptions {
504504
}
505505

506506
/// Retrieve the set of options suitable for diagnostics printing.
507-
static PrintOptions printForDiagnostics(AccessLevel accessFilter) {
507+
static PrintOptions printForDiagnostics(AccessLevel accessFilter,
508+
bool printFullConvention) {
508509
PrintOptions result = printVerbose();
509510
result.PrintAccess = true;
510511
result.Indent = 4;
@@ -523,12 +524,16 @@ struct PrintOptions {
523524
QualifyNestedDeclarations::TypesOnly;
524525
result.PrintDocumentationComments = false;
525526
result.PrintCurrentMembersOnly = true;
527+
if (printFullConvention)
528+
result.PrintFunctionRepresentationAttrs =
529+
PrintOptions::FunctionRepresentationMode::Full;
526530
return result;
527531
}
528532

529533
/// Retrieve the set of options suitable for interface generation.
530-
static PrintOptions printInterface() {
531-
PrintOptions result = printForDiagnostics(AccessLevel::Public);
534+
static PrintOptions printInterface(bool printFullConvention) {
535+
PrintOptions result =
536+
printForDiagnostics(AccessLevel::Public, printFullConvention);
532537
result.SkipUnavailable = true;
533538
result.SkipImplicit = true;
534539
result.SkipSwiftPrivateClangDecls = true;
@@ -565,8 +570,8 @@ struct PrintOptions {
565570
/// Retrieve the set of options suitable for "Generated Interfaces", which
566571
/// are a prettified representation of the public API of a module, to be
567572
/// displayed to users in an editor.
568-
static PrintOptions printModuleInterface();
569-
static PrintOptions printTypeInterface(Type T);
573+
static PrintOptions printModuleInterface(bool printFullConvention);
574+
static PrintOptions printTypeInterface(Type T, bool printFullConvention);
570575

571576
void setBaseType(Type T);
572577

@@ -582,16 +587,16 @@ struct PrintOptions {
582587
}
583588

584589
/// Retrieve the print options that are suitable to print the testable interface.
585-
static PrintOptions printTestableInterface() {
586-
PrintOptions result = printInterface();
590+
static PrintOptions printTestableInterface(bool printFullConvention) {
591+
PrintOptions result = printInterface(printFullConvention);
587592
result.AccessFilter = AccessLevel::Internal;
588593
return result;
589594
}
590595

591596
/// Retrieve the print options that are suitable to print interface for a
592597
/// swift file.
593-
static PrintOptions printSwiftFileInterface() {
594-
PrintOptions result = printInterface();
598+
static PrintOptions printSwiftFileInterface(bool printFullConvention) {
599+
PrintOptions result = printInterface(printFullConvention);
595600
result.AccessFilter = AccessLevel::Internal;
596601
result.EmptyLineBetweenMembers = true;
597602
return result;

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,9 @@ namespace swift {
547547
/// Enable experimental support for one-way constraints for the
548548
/// parameters of closures.
549549
bool EnableOneWayClosureParameters = false;
550+
551+
/// See \ref FrontendOptions.PrintFullConvention
552+
bool PrintFullConvention = false;
550553
};
551554

552555
/// Options for controlling the behavior of the Clang importer.

include/swift/SIL/ApplySite.h

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,30 +90,28 @@ class ApplySite {
9090

9191
SILModule &getModule() const { return Inst->getModule(); }
9292

93-
static ApplySite isa(SILInstruction *inst) {
94-
auto kind = ApplySiteKind::fromNodeKind(inst->getKind());
93+
static ApplySite isa(SILNode *node) {
94+
auto *i = dyn_cast<SILInstruction>(node);
95+
if (!i)
96+
return ApplySite();
97+
98+
auto kind = ApplySiteKind::fromNodeKind(i->getKind());
9599
if (!kind)
96100
return ApplySite();
97101

98102
switch (kind.getValue()) {
99103
case ApplySiteKind::ApplyInst:
100-
return ApplySite(cast<ApplyInst>(inst));
104+
return ApplySite(cast<ApplyInst>(node));
101105
case ApplySiteKind::BeginApplyInst:
102-
return ApplySite(cast<BeginApplyInst>(inst));
106+
return ApplySite(cast<BeginApplyInst>(node));
103107
case ApplySiteKind::TryApplyInst:
104-
return ApplySite(cast<TryApplyInst>(inst));
108+
return ApplySite(cast<TryApplyInst>(node));
105109
case ApplySiteKind::PartialApplyInst:
106-
return ApplySite(cast<PartialApplyInst>(inst));
110+
return ApplySite(cast<PartialApplyInst>(node));
107111
}
108112
llvm_unreachable("covered switch");
109113
}
110114

111-
static ApplySite isa(SILValue value) {
112-
if (auto *inst = value->getDefiningInstruction())
113-
return ApplySite::isa(inst);
114-
return ApplySite();
115-
}
116-
117115
ApplySiteKind getKind() const { return ApplySiteKind(Inst->getKind()); }
118116

119117
explicit operator bool() const { return Inst != nullptr; }
@@ -183,8 +181,8 @@ class ApplySite {
183181
/// Calls to (previous_)dynamic_function_ref have a dynamic target function so
184182
/// we should not optimize them.
185183
bool canOptimize() const {
186-
return !swift::isa<DynamicFunctionRefInst>(getCallee()) &&
187-
!swift::isa<PreviousDynamicFunctionRefInst>(getCallee());
184+
return !DynamicFunctionRefInst::classof(getCallee()) &&
185+
!PreviousDynamicFunctionRefInst::classof(getCallee());
188186
}
189187

190188
/// Return the type.
@@ -495,27 +493,24 @@ class FullApplySite : public ApplySite {
495493
FullApplySite(BeginApplyInst *inst) : ApplySite(inst) {}
496494
FullApplySite(TryApplyInst *inst) : ApplySite(inst) {}
497495

498-
static FullApplySite isa(SILInstruction *inst) {
499-
auto kind = FullApplySiteKind::fromNodeKind(inst->getKind());
496+
static FullApplySite isa(SILNode *node) {
497+
auto *i = dyn_cast<SILInstruction>(node);
498+
if (!i)
499+
return FullApplySite();
500+
auto kind = FullApplySiteKind::fromNodeKind(i->getKind());
500501
if (!kind)
501502
return FullApplySite();
502503
switch (kind.getValue()) {
503504
case FullApplySiteKind::ApplyInst:
504-
return FullApplySite(cast<ApplyInst>(inst));
505+
return FullApplySite(cast<ApplyInst>(node));
505506
case FullApplySiteKind::BeginApplyInst:
506-
return FullApplySite(cast<BeginApplyInst>(inst));
507+
return FullApplySite(cast<BeginApplyInst>(node));
507508
case FullApplySiteKind::TryApplyInst:
508-
return FullApplySite(cast<TryApplyInst>(inst));
509+
return FullApplySite(cast<TryApplyInst>(node));
509510
}
510511
llvm_unreachable("covered switch");
511512
}
512513

513-
static FullApplySite isa(SILValue value) {
514-
if (auto *inst = value->getDefiningInstruction())
515-
return FullApplySite::isa(inst);
516-
return FullApplySite();
517-
}
518-
519514
FullApplySiteKind getKind() const {
520515
return FullApplySiteKind(getInstruction()->getKind());
521516
}

include/swift/SIL/DynamicCasts.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,17 @@ struct SILDynamicCastInst {
158158
SILDynamicCastInst(ID *i) : inst(i) {}
159159
#include "swift/SIL/SILNodes.def"
160160

161-
static SILDynamicCastInst getAs(SILInstruction *inst) {
162-
auto kind = SILDynamicCastKind::fromNodeKind(inst->getKind());
161+
static SILDynamicCastInst getAs(SILNode *node) {
162+
auto *i = dyn_cast<SILInstruction>(node);
163+
if (!i)
164+
return SILDynamicCastInst();
165+
auto kind = SILDynamicCastKind::fromNodeKind(i->getKind());
163166
if (!kind)
164167
return SILDynamicCastInst();
165168
switch (kind.getValue()) {
166169
#define DYNAMICCAST_INST(ID, PARENT) \
167170
case SILDynamicCastKind::ID: \
168-
return SILDynamicCastInst(cast<ID>(inst));
171+
return SILDynamicCastInst(cast<ID>(node));
169172
#include "swift/SIL/SILNodes.def"
170173
}
171174
}

include/swift/SIL/PrettyStackTrace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
#define SWIFT_SIL_PRETTYSTACKTRACE_H
2020

2121
#include "swift/SIL/SILLocation.h"
22-
#include "swift/SIL/SILNode.h"
2322
#include "llvm/Support/PrettyStackTrace.h"
2423

2524
namespace swift {
2625
class ASTContext;
2726
class SILFunction;
27+
class SILNode;
2828

2929
void printSILLocationDescription(llvm::raw_ostream &out, SILLocation loc,
3030
ASTContext &ctx);
@@ -74,7 +74,7 @@ class PrettyStackTraceSILNode : public llvm::PrettyStackTraceEntry {
7474
const char *Action;
7575

7676
public:
77-
PrettyStackTraceSILNode(const char *action, SILNodePointer node)
77+
PrettyStackTraceSILNode(const char *action, const SILNode *node)
7878
: Node(node), Action(action) {}
7979

8080
virtual void print(llvm::raw_ostream &OS) const override;

include/swift/SIL/SILArgument.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class SILArgument : public ValueBase {
7878
explicit SILArgument(ValueKind subClassKind, SILType type,
7979
ValueOwnershipKind ownershipKind,
8080
const ValueDecl *inputDecl = nullptr)
81-
: ValueBase(subClassKind, type),
81+
: ValueBase(subClassKind, type, IsRepresentative::Yes),
8282
parentBlock(nullptr), decl(inputDecl) {
8383
Bits.SILArgument.VOKind = static_cast<unsigned>(ownershipKind);
8484
}
@@ -106,7 +106,7 @@ class SILArgument : public ValueBase {
106106

107107
static bool classof(const SILInstruction *) = delete;
108108
static bool classof(const SILUndef *) = delete;
109-
static bool classof(SILNodePointer node) {
109+
static bool classof(const SILNode *node) {
110110
return node->getKind() >= SILNodeKind::First_SILArgument &&
111111
node->getKind() <= SILNodeKind::Last_SILArgument;
112112
}
@@ -279,7 +279,7 @@ class SILPhiArgument : public SILArgument {
279279

280280
static bool classof(const SILInstruction *) = delete;
281281
static bool classof(const SILUndef *) = delete;
282-
static bool classof(SILNodePointer node) {
282+
static bool classof(const SILNode *node) {
283283
return node->getKind() == SILNodeKind::SILPhiArgument;
284284
}
285285
};
@@ -322,7 +322,7 @@ class SILFunctionArgument : public SILArgument {
322322

323323
static bool classof(const SILInstruction *) = delete;
324324
static bool classof(const SILUndef *) = delete;
325-
static bool classof(SILNodePointer node) {
325+
static bool classof(const SILNode *node) {
326326
return node->getKind() == SILNodeKind::SILFunctionArgument;
327327
}
328328
};

0 commit comments

Comments
 (0)