Skip to content

Commit d0492c2

Browse files
[Wasm] Revert swift_once body workarounds in SILGen
1 parent 846d5ec commit d0492c2

File tree

2 files changed

+1
-26
lines changed

2 files changed

+1
-26
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,19 +1651,7 @@ SILFunction *SILGenModule::emitLazyGlobalInitializer(StringRef funcName,
16511651
cast<FuncDecl>(getBuiltinValueDecl(C, C.getIdentifier("once")));
16521652
auto blockParam = onceBuiltin->getParameters()->get(1);
16531653
auto *type = blockParam->getType()->castTo<FunctionType>();
1654-
SmallVector<AnyFunctionType::Param, 1> params;
1655-
// wasm: Lazy global init is used with swift_once which passes a context
1656-
// pointer parameter. If lazy global init doesn't take a context argument,
1657-
// caller and callee signatures are mismatched and it causes runtime
1658-
// exception on WebAssembly runtime. So we need to add dummy argument
1659-
// to consume the context pointer.
1660-
// See also: emitLazyGlobalInitializer
1661-
if (C.LangOpts.Target.isOSBinFormatWasm()) {
1662-
auto dummyParam = AnyFunctionType::Param(C.getUnsafeRawPointerDecl()->getDeclaredInterfaceType()
1663-
->getCanonicalType());
1664-
params.push_back(dummyParam);
1665-
}
1666-
Type initType = FunctionType::get(params, TupleType::getEmpty(C),
1654+
Type initType = FunctionType::get({}, TupleType::getEmpty(C),
16671655
type->getExtInfo());
16681656
auto initSILType = cast<SILFunctionType>(
16691657
Types.getLoweredRValueType(TypeExpansionContext::minimal(), initType));

lib/SILGen/SILGenGlobalVariable.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,6 @@ void SILGenFunction::emitLazyGlobalInitializer(PatternBindingDecl *binding,
228228
unsigned pbdEntry) {
229229
MagicFunctionName = SILGenModule::getMagicFunctionName(binding->getDeclContext());
230230

231-
ASTContext &C = getASTContext();
232-
// wasm: Lazy global init is used with swift_once which passes a context
233-
// pointer parameter. If lazy global init doesn't take a context argument,
234-
// caller and callee signatures are mismatched and it causes runtime
235-
// exception on WebAssembly runtime. So we need to add dummy argument
236-
// to consume the context pointer.
237-
// See also: emitLazyGlobalInitializer
238-
if (C.LangOpts.Target.isOSBinFormatWasm()) {
239-
auto UnsafeRawPointer = C.getUnsafeRawPointerDecl();
240-
auto UnsafeRawPtrTy = getLoweredType(UnsafeRawPointer->getDeclaredInterfaceType());
241-
F.front().createFunctionArgument(UnsafeRawPtrTy);
242-
}
243-
244231
{
245232
Scope scope(Cleanups, binding);
246233

0 commit comments

Comments
 (0)