Skip to content

Commit 2d692f7

Browse files
authored
Merge pull request #643 from swiftwasm/master
[pull] swiftwasm from master
2 parents f71af6c + 0c9c901 commit 2d692f7

File tree

5 files changed

+43
-15
lines changed

5 files changed

+43
-15
lines changed

lib/SILOptimizer/IPO/CrossModuleSerializationSetup.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#define DEBUG_TYPE "cross-module-serialization-setup"
18-
#include "swift/SILOptimizer/PassManager/Passes.h"
19-
#include "swift/SILOptimizer/PassManager/Transforms.h"
20-
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
18+
#include "swift/AST/Module.h"
2119
#include "swift/SIL/ApplySite.h"
20+
#include "swift/SIL/SILCloner.h"
2221
#include "swift/SIL/SILFunction.h"
2322
#include "swift/SIL/SILModule.h"
24-
#include "swift/SIL/SILCloner.h"
25-
#include "swift/AST/Module.h"
23+
#include "swift/SILOptimizer/PassManager/Passes.h"
24+
#include "swift/SILOptimizer/PassManager/Transforms.h"
25+
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
26+
#include "llvm/Support/CommandLine.h"
2627
#include "llvm/Support/Debug.h"
2728

2829
using namespace swift;
@@ -181,12 +182,19 @@ makeSubstUsableFromInline(const SubstitutionMap &substs) {
181182
}
182183
}
183184
}
185+
static llvm::cl::opt<bool> SerializeEverything(
186+
"sil-cross-module-serialize-all", llvm::cl::init(false),
187+
llvm::cl::desc(
188+
"Serialize everything when performing cross module optimization in "
189+
"order to investigate performance differences caused by different "
190+
"@inlinable, @usableFromInline choices."),
191+
llvm::cl::Hidden);
184192

185193
/// Decide whether to serialize a function.
186194
static bool shouldSerialize(SILFunction *F) {
187195
// The basic heursitic: serialize all generic functions, because it makes a
188196
// huge difference if generic functions can be specialized or not.
189-
if (!F->getLoweredFunctionType()->isPolymorphic())
197+
if (!F->getLoweredFunctionType()->isPolymorphic() && !SerializeEverything)
190198
return false;
191199

192200
// Check if we already handled this function before.

test/Inputs/clang-importer-sdk/usr/include/cfuncs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ double pow(double x, double y);
1414
long double powl(long double x, long double y);
1515

1616
void f16ptrfunc(__fp16 *);
17-
#if defined __arm__ || defined __arm64__
17+
#if defined __arm__ || defined __arm64__ || defined __aarch64__
1818
_Float16 f16func(_Float16);
1919
#endif
2020

test/api-digester/Inputs/cake_current/cake.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,7 @@ open class AddingNewDesignatedInit {
241241
print(foo)
242242
}
243243
}
244+
245+
public extension Float {
246+
func floatHigher() {}
247+
}

test/api-digester/Outputs/Cake-abi.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ cake: Func C1.foo1() is now not static
6767
cake: Func C5.dy_foo() is now with dynamic
6868
cake: Func FinalFuncContainer.NewFinalFunc() is now with final
6969
cake: Func FinalFuncContainer.NoLongerFinalFunc() is now without final
70+
cake: Func Float.floatHigher() is a new API without @available attribute
7071
cake: Func HasMutatingMethodClone.foo() has self access kind changing from Mutating to NonMutating
7172
cake: Func RequiementChanges.addedFunc() is a new API without @available attribute
7273
cake: Func S1.foo1() has self access kind changing from NonMutating to Mutating

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,28 @@ class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
11121112
UpdateMap(Ctx.getNodeUpdateMap()),
11131113
ProtocolReqWhitelist(std::move(prWhitelist)) {}
11141114

1115+
void diagnoseMissingAvailable(SDKNodeDecl *D) {
1116+
// For extensions of external types, we diagnose individual member's missing
1117+
// available attribute instead of the extension itself.
1118+
// The reason is we may merge several extensions into a single one; some
1119+
// attributes are missing.
1120+
if (auto *DT = dyn_cast<SDKNodeDeclType>(D)) {
1121+
if (DT->isExtension()) {
1122+
for(auto MD: DT->getChildren()) {
1123+
diagnoseMissingAvailable(cast<SDKNodeDecl>(MD));
1124+
}
1125+
return;
1126+
}
1127+
}
1128+
// Diagnose the missing of @available attributes.
1129+
// Decls with @_alwaysEmitIntoClient aren't required to have an
1130+
// @available attribute.
1131+
if (!Ctx.getOpts().SkipOSCheck &&
1132+
!D->getIntroducingVersion().hasOSAvailability() &&
1133+
!D->hasDeclAttribute(DeclAttrKind::DAK_AlwaysEmitIntoClient)) {
1134+
D->emitDiag(D->getLoc(), diag::new_decl_without_intro);
1135+
}
1136+
}
11151137
void foundMatch(NodePtr Left, NodePtr Right, NodeMatchReason Reason) override {
11161138
if (options::DebugMapping)
11171139
debugMatch(Left, Right, Reason, llvm::errs());
@@ -1125,14 +1147,7 @@ class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
11251147
if (D->hasFixedBinaryOrder()) {
11261148
D->emitDiag(D->getLoc(), diag::decl_added);
11271149
}
1128-
// Diagnose the missing of @available attributes.
1129-
// Decls with @_alwaysEmitIntoClient aren't required to have an
1130-
// @available attribute.
1131-
if (!Ctx.getOpts().SkipOSCheck &&
1132-
!D->getIntroducingVersion().hasOSAvailability() &&
1133-
!D->hasDeclAttribute(DeclAttrKind::DAK_AlwaysEmitIntoClient)) {
1134-
D->emitDiag(D->getLoc(), diag::new_decl_without_intro);
1135-
}
1150+
diagnoseMissingAvailable(D);
11361151
}
11371152
}
11381153
// Complain about added protocol requirements

0 commit comments

Comments
 (0)