From f267f62f652f9f89dce7c4d02663c692d1e69c35 Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Sat, 25 Oct 2025 16:32:01 -0700 Subject: [PATCH 1/8] [SILGen] Consistently use SIL asmname for foreign function/variable references Whenever we have a reference to a foreign function/variable in SIL, use a mangled name at the SIL level with the C name in the asmname attribute. The expands the use of asmname to three kinds of cases that it hadn't been used in yet: * Declarations imported from C headers/modules * @_cdecl @implementation of C headers/modules * @_cdecl functions in general Some code within the SIL pipeline makes assumptions that the C names of various runtime functions are reflected at the SIL level. For example, the linking of Embedded Swift runtime functions is done by-name, and some of those names refer to C functions (like `swift_retain`) and others refer to Swift functions that use `@_silgen_name` (like `swift_getDefaultExecutor`). Extend the serialized module format to include a table that maps from the asmname of functions/variables over to their mangled names, so we can look up functions by asmname if we want. These tables could also be used for checking for declarations that conflict on their asmname in the future. Right now, we leave it up to LLVM or the linker to do the checking. `@_silgen_name` is not affected by these changes, nor should it be: that hidden feature is specifically meant to affect the name at the SIL level. The vast majority of test changes are SIL tests where we had expected to see the C/C++/Objective-C names in the tests for references to foreign entities, and now we see Swift mangled names (ending in To). The SIL declarations themselves will have a corresponding asmname. Notably, the IRGen tests have *not* changed, because we generally the same IR as before. It's only the modeling at the SIL lever that has changed. Another part of rdar://137014448. --- include/swift/AST/Attr.h | 4 +- include/swift/SIL/SILDeclRef.h | 2 +- include/swift/SIL/SILFunction.h | 2 +- include/swift/SIL/SILGlobalVariable.h | 2 +- include/swift/SIL/SILModule.h | 17 ++- .../swift/Serialization/SerializedSILLoader.h | 6 +- lib/AST/Attr.cpp | 4 +- lib/SIL/IR/SILDeclRef.cpp | 63 +++++----- lib/SIL/IR/SILFunction.cpp | 13 ++- lib/SIL/IR/SILFunctionBuilder.cpp | 12 +- lib/SIL/IR/SILGlobalVariable.cpp | 10 ++ lib/SIL/IR/SILModule.cpp | 14 +++ lib/SILOptimizer/UtilityPasses/Link.cpp | 48 +++++--- lib/Serialization/DeserializeSIL.cpp | 110 ++++++++++++++++-- lib/Serialization/DeserializeSIL.h | 22 +++- lib/Serialization/ModuleFormat.h | 2 +- lib/Serialization/SILFormat.h | 1 + lib/Serialization/Serialization.cpp | 1 + lib/Serialization/SerializeSIL.cpp | 85 +++++++++++++- lib/Serialization/SerializedSILLoader.cpp | 11 +- test/ClangImporter/const_and_pure.swift | 6 +- .../indirect_field_codegen.swift | 12 +- test/ClangImporter/static_inline.swift | 2 +- .../static_inline_serialize.swift | 2 +- test/Concurrency/async_main.swift | 4 +- .../Cxx/class/closure-thunk-macosx-sil.swift | 2 +- .../Cxx/class/closure-thunk-macosx.swift | 2 +- test/Interop/Cxx/class/closure-thunk.swift | 6 +- .../Cxx/class/constructors-objc-silgen.swift | 2 +- .../Cxx/class/constructors-silgen.swift | 12 +- .../Cxx/class/function-call-macosx.swift | 8 +- test/Interop/Cxx/class/function-call.swift | 14 +-- .../Cxx/class/method/methods-silgen.swift | 4 +- .../inherited-field-access-silgen.swift | 4 +- .../class/nonescapable-lifetimebound.swift | 32 ++--- ...pe-classification-non-trivial-silgen.swift | 15 +-- .../frt-reference-returns-sil.swift | 31 +++-- .../foreign-reference/move-only-silgen.swift | 8 +- .../Cxx/foreign-reference/pod-silgen.swift | 8 +- .../foreign-reference/singleton-silgen.swift | 12 +- ...call-to-generated-init-with-nsstring.swift | 8 +- .../Cxx/operators/member-inline-silgen.swift | 58 ++++----- .../operators/member-out-of-line-silgen.swift | 8 +- .../non-member-out-of-line-silgen.swift | 4 +- .../Cxx/reference/const-ref-parameter.swift | 8 +- ...reference-silgen-cxx-objc-ctors+init.swift | 2 +- .../Cxx/reference/reference-silgen.swift | 16 +-- .../static/static-member-func-silgen.swift | 8 +- .../templates/function-template-silgen.swift | 8 +- .../templates/member-templates-silgen.swift | 30 ++--- ...ly-pre-defined-class-template-silgen.swift | 8 +- .../import-swift-class-back-to-swift.swift | 4 +- ...ilability_query_custom_domains_clang.swift | 26 ++--- test/SILGen/cdecl.swift | 10 +- test/SILGen/cf.swift | 14 +-- test/SILGen/cf_curried_init.swift | 2 +- test/SILGen/cf_members.swift | 64 +++++----- .../SILGen/diagnose_duplicate_functions.swift | 4 +- test/SILGen/dynamically_replaceable.swift | 2 +- test/SILGen/external_definitions.swift | 6 +- .../SILGen/foreign_to_native_inout_self.swift | 2 +- test/SILGen/has_symbol.swift | 2 +- test/SILGen/import_as_member.swift | 9 +- test/SILGen/keypaths_import_as_member.swift | 2 +- test/SILGen/objc_blocks_bridging.swift | 10 +- test/SILGen/objc_bridging.swift | 44 +++---- test/SILGen/objc_bridging_peephole.swift | 2 +- test/SILGen/objc_direct.swift | 44 ++++--- test/SILGen/objc_error.swift | 4 +- test/SILGen/objc_factory_init.swift | 2 +- test/SILGen/opaque_values_cxx.swift | 2 +- test/SILGen/pointer_conversion.swift | 12 +- .../closure_lifetime_fixup_objc.swift | 2 +- .../closure_specialize_block.swift | 4 +- .../definite-init-convert-to-escape.swift | 7 +- test/SILOptimizer/objc_bridging_opt.swift | 12 +- .../Recovery/error-sil-function.swift | 4 +- .../inlined-shadowed-clang-vs-swift.swift | 2 +- .../inlined-shadowed-layered-modules.swift | 2 +- test/embedded/modules-used2.swift | 4 +- .../batch_mode_external_definitions.swift | 36 +++--- 81 files changed, 674 insertions(+), 439 deletions(-) diff --git a/include/swift/AST/Attr.h b/include/swift/AST/Attr.h index 3c3b3593c8010..e3e6e458503da 100644 --- a/include/swift/AST/Attr.h +++ b/include/swift/AST/Attr.h @@ -3126,8 +3126,8 @@ class ExternAttr : public DeclAttribute { } /// Returns the C name of the given declaration. - /// \p forDecl is the func decl that the attribute belongs to. - StringRef getCName(const FuncDecl *forDecl) const; + /// \p forDecl is the decl that the attribute belongs to. + StringRef getCName(const ValueDecl *forDecl) const; /// Find an ExternAttr with the given kind in the given DeclAttributes. static const ExternAttr *find(const DeclAttributes &attrs, ExternKind kind); diff --git a/include/swift/SIL/SILDeclRef.h b/include/swift/SIL/SILDeclRef.h index 84c1d5b3d9e10..955fb7043f8f0 100644 --- a/include/swift/SIL/SILDeclRef.h +++ b/include/swift/SIL/SILDeclRef.h @@ -335,7 +335,7 @@ struct SILDeclRef { /// If the symbol has a specific name for use at the LLVM IR level, /// produce that name. This may be different than the mangled name in SIL. - std::optional getAsmName() const; + std::optional getAsmName() const; /// True if the SILDeclRef references a function. bool isFunc() const { diff --git a/include/swift/SIL/SILFunction.h b/include/swift/SIL/SILFunction.h index 6f250c6aee0bc..980cf767bac8a 100644 --- a/include/swift/SIL/SILFunction.h +++ b/include/swift/SIL/SILFunction.h @@ -1430,7 +1430,7 @@ class SILFunction /// Return custom assembler name, otherwise empty. StringRef asmName() const { return AsmName; } - void setAsmName(StringRef value) { AsmName = value; } + void setAsmName(StringRef value); /// Return custom section name if @section was used, otherwise empty StringRef section() const { return Section; } diff --git a/include/swift/SIL/SILGlobalVariable.h b/include/swift/SIL/SILGlobalVariable.h index 9f3f6fd548ecf..acc01dda5a650 100644 --- a/include/swift/SIL/SILGlobalVariable.h +++ b/include/swift/SIL/SILGlobalVariable.h @@ -160,7 +160,7 @@ class SILGlobalVariable /// Return custom assembler name, otherwise empty. StringRef asmName() const { return AsmName; } - void setAsmName(StringRef value) { AsmName = value; } + void setAsmName(StringRef value); /// Return custom section name if @section was used, otherwise empty StringRef section() const { return Section; } diff --git a/include/swift/SIL/SILModule.h b/include/swift/SIL/SILModule.h index bc329987b79c8..4f1dfbe55b192 100644 --- a/include/swift/SIL/SILModule.h +++ b/include/swift/SIL/SILModule.h @@ -235,6 +235,10 @@ class SILModule { llvm::StringMap FunctionTable; llvm::StringMap ZombieFunctionTable; + /// Lookup table for SIL functions by their asmnames, for those that + /// have them. + llvm::StringMap FunctionByAsmNameTable; + /// The list of SILFunctions in the module. FunctionListType functions; @@ -310,6 +314,9 @@ class SILModule { /// Lookup table for SIL Global Variables. llvm::StringMap GlobalVariableMap; + /// Lookup table for SIL Global Variables, indexed by their asmnames. + llvm::StringMap GlobalVariableByAsmNameMap; + /// The list of SILGlobalVariables in the module. GlobalListType silGlobals; @@ -822,14 +829,20 @@ class SILModule { /// Look for a global variable by name. /// /// \return null if this module has no such global variable - SILGlobalVariable *lookUpGlobalVariable(StringRef name) const { + SILGlobalVariable *lookUpGlobalVariable(StringRef name, + bool byAsmName = false) const { + if (byAsmName) + return GlobalVariableByAsmNameMap.lookup(name); + return GlobalVariableMap.lookup(name); } /// Look for a function by name. /// /// \return null if this module has no such function - SILFunction *lookUpFunction(StringRef name) const { + SILFunction *lookUpFunction(StringRef name, bool byAsmName = false) const { + if (byAsmName) + return FunctionByAsmNameTable.lookup(name); return FunctionTable.lookup(name); } diff --git a/include/swift/Serialization/SerializedSILLoader.h b/include/swift/Serialization/SerializedSILLoader.h index e82e52bed7f1f..01ea88a593fb8 100644 --- a/include/swift/Serialization/SerializedSILLoader.h +++ b/include/swift/Serialization/SerializedSILLoader.h @@ -62,8 +62,10 @@ class SerializedSILLoader { SILFunction *lookupSILFunction(SILFunction *Callee, bool onlyUpdateLinkage); SILFunction *lookupSILFunction(StringRef Name, - std::optional linkage); - SILGlobalVariable *lookupSILGlobalVariable(StringRef Name); + std::optional linkage, + bool byAsmName = false); + SILGlobalVariable *lookupSILGlobalVariable(StringRef Name, + bool byAsmName = false); bool hasSILFunction(StringRef Name, std::optional linkage = std::nullopt); SILVTable *lookupVTable(const ClassDecl *C); diff --git a/lib/AST/Attr.cpp b/lib/AST/Attr.cpp index e9b7986842c15..ade306cc16a5c 100644 --- a/lib/AST/Attr.cpp +++ b/lib/AST/Attr.cpp @@ -3273,11 +3273,11 @@ bool MacroRoleAttr::hasNameKind(MacroIntroducedDeclNameKind kind) const { }) != getNames().end(); } -StringRef ExternAttr::getCName(const FuncDecl *D) const { +StringRef ExternAttr::getCName(const ValueDecl *D) const { if (auto cName = this->Name) return cName.value(); // If no name was specified, fall back on the Swift base name without mangling. - // Base name is always available and non-empty for FuncDecl. + // Base name is always available and non-empty for functions and variables. return D->getBaseIdentifier().str(); } diff --git a/lib/SIL/IR/SILDeclRef.cpp b/lib/SIL/IR/SILDeclRef.cpp index fc04a558564f9..f09fd457fe5a4 100644 --- a/lib/SIL/IR/SILDeclRef.cpp +++ b/lib/SIL/IR/SILDeclRef.cpp @@ -1386,18 +1386,6 @@ std::string SILDeclRef::mangle(ManglingKind MKind) const { silConfig); } - // As a special case, Clang functions and globals don't get mangled at all - // - except \c objc_direct decls. - if (hasDecl() && !isDefaultArgGenerator()) { - if (getDecl()->getClangDecl()) { - if (!isForeignToNativeThunk() && !isNativeToForeignThunk()) { - auto clangMangling = mangleClangDecl(getDecl(), isForeign); - if (!clangMangling.empty()) - return clangMangling; - } - } - } - // Mangle prespecializations. if (getSpecializedSignature()) { SILDeclRef nonSpecializedDeclRef = *this; @@ -1443,23 +1431,6 @@ std::string SILDeclRef::mangle(ManglingKind MKind) const { return NameA->Name.str(); } - // Use a given cdecl name for native-to-foreign thunks. Don't do this - // for functions that only have a C entrypoint. - if (getDecl()->getAttrs().hasAttribute() && - !(getDecl()->hasOnlyCEntryPoint() && - !getDecl()->getImplementedObjCDecl())) { - if (isNativeToForeignThunk() || isForeign) { - // If this is an @implementation @_cdecl, mangle it like the clang - // function it implements. - if (auto objcInterface = getDecl()->getImplementedObjCDecl()) { - auto clangMangling = mangleClangDecl(objcInterface, isForeign); - if (!clangMangling.empty()) - return clangMangling; - } - return getDecl()->getCDeclName().str(); - } - } - if (SKind == ASTMangler::SymbolKind::DistributedThunk) { return mangler.mangleDistributedThunk(cast(getDecl())); } @@ -1547,13 +1518,33 @@ std::string SILDeclRef::mangle(ManglingKind MKind) const { llvm_unreachable("bad entity kind!"); } -std::optional SILDeclRef::getAsmName() const { - if (isForeign && isFunc()) { - auto func = getFuncDecl(); - if (auto *EA = ExternAttr::find(func->getAttrs(), ExternKind::C)) - return EA->getCName(func); - if (func->hasOnlyCEntryPoint() && !func->getImplementedObjCDecl()) - return func->getCDeclName(); +std::optional SILDeclRef::getAsmName() const { + if (isAutoDiffDerivativeFunction()) + return std::nullopt; + + if (hasDecl() && !isDefaultArgGenerator() && + (getDecl()->getClangDecl() || getDecl()->getImplementedObjCDecl())) { + // If there is a Clang declaration, use its mangled name. + if (isNativeToForeignThunk() || isForeign) { + auto decl = getDecl(); + auto hasClangDecl = decl->getClangDecl() + ? decl : decl->getImplementedObjCDecl(); + auto clangMangling = mangleClangDecl(hasClangDecl, isForeign); + if (!clangMangling.empty()) + return clangMangling; + } + } + + if (isForeign && hasDecl()) { + // @_extern(c) + auto decl = getDecl(); + if (auto *EA = ExternAttr::find(decl->getAttrs(), ExternKind::C)) + if (auto VD = dyn_cast(decl)) + return std::string(EA->getCName(VD)); + + // @c/@_cdecl + if (decl->getAttrs().hasAttribute()) + return std::string(decl->getCDeclName()); } return std::nullopt; diff --git a/lib/SIL/IR/SILFunction.cpp b/lib/SIL/IR/SILFunction.cpp index bf1d41eaf903a..538af167ee190 100644 --- a/lib/SIL/IR/SILFunction.cpp +++ b/lib/SIL/IR/SILFunction.cpp @@ -442,6 +442,16 @@ bool SILFunction::hasForeignBody() const { return SILDeclRef::isClangGenerated(getClangNode()); } +void SILFunction::setAsmName(StringRef value) { + assert((AsmName.empty() || value == AsmName) && "Cannot change asmname"); + AsmName = value; + + if (!value.empty()) { + // Update the function-by-asm-name-table. + getModule().FunctionByAsmNameTable.insert({AsmName, this}); + } +} + const SILFunction *SILFunction::getOriginOfSpecialization() const { if (!isSpecialization()) return nullptr; @@ -1049,7 +1059,8 @@ bool SILFunction::isSwiftRuntimeFunction( } bool SILFunction::isSwiftRuntimeFunction() const { - return isSwiftRuntimeFunction(getName(), getParentModule()); + return isSwiftRuntimeFunction(asmName(), getParentModule()) || + isSwiftRuntimeFunction(getName(), getParentModule()); } bool diff --git a/lib/SIL/IR/SILFunctionBuilder.cpp b/lib/SIL/IR/SILFunctionBuilder.cpp index 64b23a9e47523..f261d44280406 100644 --- a/lib/SIL/IR/SILFunctionBuilder.cpp +++ b/lib/SIL/IR/SILFunctionBuilder.cpp @@ -128,7 +128,7 @@ void SILFunctionBuilder::addFunctionAttributes( } if (auto asmName = constant.getAsmName()) { - F->setAsmName(*asmName); + F->setAsmName(M.getASTContext().AllocateCopy(*asmName)); } } @@ -177,16 +177,18 @@ void SILFunctionBuilder::addFunctionAttributes( if (Attrs.hasAttribute()) { // If the function is marked with @c, expose only C compatible // thunk function. - shouldExportDecl = constant.isNativeToForeignThunk(); + shouldExportDecl = constant.isNativeToForeignThunk() || constant.isForeign; } if (EA->getExposureKind() == ExposureKind::Wasm && shouldExportDecl) { // A wasm-level exported function must be retained if it appears in a // compilation unit. F->setMarkedAsUsed(true); - if (EA->Name.empty()) - F->setWasmExportName(F->getName()); - else + if (!EA->Name.empty()) F->setWasmExportName(EA->Name); + else if (!F->asmName().empty()) + F->setWasmExportName(F->asmName()); + else + F->setWasmExportName(F->getName()); } } diff --git a/lib/SIL/IR/SILGlobalVariable.cpp b/lib/SIL/IR/SILGlobalVariable.cpp index 903c61f88ab4a..9467e89f0a71b 100644 --- a/lib/SIL/IR/SILGlobalVariable.cpp +++ b/lib/SIL/IR/SILGlobalVariable.cpp @@ -84,6 +84,16 @@ SILGlobalVariable::~SILGlobalVariable() { clear(); } +void SILGlobalVariable::setAsmName(StringRef value) { + assert((AsmName.empty() || value == AsmName) && "Cannot change asmname"); + AsmName = value; + + if (!value.empty()) { + // Update the variable-by-asm-name-table. + getModule().GlobalVariableByAsmNameMap.insert({AsmName, this}); + } +} + bool SILGlobalVariable::isPossiblyUsedExternally() const { if (shouldBePreservedForDebugger()) return true; diff --git a/lib/SIL/IR/SILModule.cpp b/lib/SIL/IR/SILModule.cpp index 4d68535f6574a..e3d75c7cc4ec3 100644 --- a/lib/SIL/IR/SILModule.cpp +++ b/lib/SIL/IR/SILModule.cpp @@ -477,6 +477,13 @@ void SILModule::eraseFunction(SILFunction *F) { FunctionTable.erase(F->getName()); F->setName(zombieName); + // Remove from the asmname table. + if (!F->asmName().empty()) { + auto known = FunctionByAsmNameTable.find(F->asmName()); + if (known != FunctionByAsmNameTable.end() && known->second == F) + FunctionByAsmNameTable.erase(known); + } + // The function is dead, but we need it later (at IRGen) for debug info // or vtable stub generation. So we move it into the zombie list. getFunctionList().remove(F); @@ -501,6 +508,13 @@ void SILModule::invalidateFunctionInSILCache(SILFunction *F) { void SILModule::eraseGlobalVariable(SILGlobalVariable *gv) { getSILLoader()->invalidateGlobalVariable(gv); GlobalVariableMap.erase(gv->getName()); + + if (gv->asmName().empty()) { + auto known = GlobalVariableByAsmNameMap.find(gv->asmName()); + if (known != GlobalVariableByAsmNameMap.end() && known->second == gv) + GlobalVariableByAsmNameMap.erase(known); + } + getSILGlobalList().erase(gv); } diff --git a/lib/SILOptimizer/UtilityPasses/Link.cpp b/lib/SILOptimizer/UtilityPasses/Link.cpp index e3666ee9e9d00..b899595d56d55 100644 --- a/lib/SILOptimizer/UtilityPasses/Link.cpp +++ b/lib/SILOptimizer/UtilityPasses/Link.cpp @@ -63,7 +63,7 @@ class SILLinker : public SILModuleTransform { using namespace RuntimeConstants; #define FUNCTION(ID, MODULE, NAME, CC, AVAILABILITY, RETURNS, ARGS, ATTRS, \ EFFECT, MEMORY_EFFECTS) \ - linkEmbeddedRuntimeFunctionByName(#NAME, EFFECT); \ +linkEmbeddedRuntimeFunctionByName(#NAME, EFFECT, StringRef(#CC) == "C_CC"); \ if (getModule()->getASTContext().hadError()) \ return; @@ -79,7 +79,8 @@ class SILLinker : public SILModuleTransform { #include "swift/Runtime/RuntimeFunctions.def" // swift_retainCount is not part of private contract between the compiler and runtime, but we still need to link it - linkEmbeddedRuntimeFunctionByName("swift_retainCount", { RefCounting }); + linkEmbeddedRuntimeFunctionByName("swift_retainCount", { RefCounting }, + /*byAsmName=*/true); } void linkEmbeddedConcurrency() { @@ -95,25 +96,28 @@ class SILLinker : public SILModuleTransform { // runtime functions, which are public. #define SWIFT_CONCURRENCY_HOOK(RETURNS, NAME, ...) \ - linkUsedFunctionByName(#NAME "Impl", SILLinkage::HiddenExternal) + linkUsedFunctionByName(#NAME "Impl", SILLinkage::HiddenExternal, \ + /*byAsmName=*/false) #define SWIFT_CONCURRENCY_HOOK0(RETURNS, NAME) \ - linkUsedFunctionByName(#NAME "Impl", SILLinkage::HiddenExternal) + linkUsedFunctionByName(#NAME "Impl", SILLinkage::HiddenExternal, \ + /*byAsmName=*/false) #include "swift/Runtime/ConcurrencyHooks.def" linkUsedFunctionByName("swift_task_asyncMainDrainQueueImpl", - SILLinkage::HiddenExternal); + SILLinkage::HiddenExternal, /*byAsmName=*/false); linkUsedFunctionByName("_swift_task_enqueueOnExecutor", - SILLinkage::HiddenExternal); + SILLinkage::HiddenExternal, /*byAsmName=*/false); linkUsedFunctionByName("swift_createDefaultExecutors", - SILLinkage::HiddenExternal); + SILLinkage::HiddenExternal, /*byAsmName=*/false); linkUsedFunctionByName("swift_getDefaultExecutor", - SILLinkage::HiddenExternal); + SILLinkage::HiddenExternal, /*byAsmName=*/false); linkEmbeddedRuntimeWitnessTables(); } void linkEmbeddedRuntimeFunctionByName(StringRef name, - ArrayRef effects) { + ArrayRef effects, + bool byAsmName) { SILModule &M = *getModule(); bool allocating = false; @@ -125,7 +129,7 @@ class SILLinker : public SILModuleTransform { if (M.getOptions().NoAllocations && allocating) return; // Swift Runtime functions are all expected to be SILLinkage::PublicExternal - linkUsedFunctionByName(name, SILLinkage::PublicExternal); + linkUsedFunctionByName(name, SILLinkage::PublicExternal, byAsmName); } void linkEmbeddedRuntimeWitnessTables() { @@ -146,13 +150,15 @@ class SILLinker : public SILModuleTransform { } SILFunction *linkUsedFunctionByName(StringRef name, - std::optional Linkage) { + std::optional Linkage, + bool byAsmName) { SILModule &M = *getModule(); // Bail if function is already loaded. - if (auto *Fn = M.lookUpFunction(name)) return Fn; + if (auto *Fn = M.lookUpFunction(name, byAsmName)) return Fn; - SILFunction *Fn = M.getSILLoader()->lookupSILFunction(name, Linkage); + SILFunction *Fn = + M.getSILLoader()->lookupSILFunction(name, Linkage, byAsmName); if (!Fn) return nullptr; if (M.linkFunction(Fn, LinkMode)) @@ -170,13 +176,15 @@ class SILLinker : public SILModuleTransform { return Fn; } - SILGlobalVariable *linkUsedGlobalVariableByName(StringRef name) { + SILGlobalVariable *linkUsedGlobalVariableByName(StringRef name, + bool byAsmName) { SILModule &M = *getModule(); // Bail if runtime function is already loaded. - if (auto *GV = M.lookUpGlobalVariable(name)) return GV; + if (auto *GV = M.lookUpGlobalVariable(name, byAsmName)) return GV; - SILGlobalVariable *GV = M.getSILLoader()->lookupSILGlobalVariable(name); + SILGlobalVariable *GV = + M.getSILLoader()->lookupSILGlobalVariable(name, byAsmName); if (!GV) return nullptr; // Make sure that dead-function-elimination doesn't remove the explicitly @@ -194,17 +202,19 @@ class SILLinker : public SILModuleTransform { for (auto *G : Globals) { auto declRef = SILDeclRef(G, SILDeclRef::Kind::Func); - linkUsedGlobalVariableByName(declRef.mangle()); + linkUsedGlobalVariableByName(declRef.mangle(), /*byAsmName=*/false); } for (auto *F : Functions) { auto declRef = SILDeclRef(F, SILDeclRef::Kind::Func); - auto *Fn = linkUsedFunctionByName(declRef.mangle(), /*Linkage*/{}); + auto *Fn = linkUsedFunctionByName(declRef.mangle(), /*Linkage*/{}, + /*byAsmName=*/false); // If we have @_cdecl or @_silgen_name, also link the foreign thunk if (Fn->hasCReferences()) { auto declRef = SILDeclRef(F, SILDeclRef::Kind::Func, /*isForeign*/true); - linkUsedFunctionByName(declRef.mangle(), /*Linkage*/{}); + linkUsedFunctionByName(declRef.mangle(), /*Linkage*/{}, + /*byAsmName=*/false); } } } diff --git a/lib/Serialization/DeserializeSIL.cpp b/lib/Serialization/DeserializeSIL.cpp index db4874b8d16a8..edc5f84683958 100644 --- a/lib/Serialization/DeserializeSIL.cpp +++ b/lib/Serialization/DeserializeSIL.cpp @@ -156,6 +156,48 @@ class SILDeserializer::FuncTableInfo { } }; +/// Used to deserialize string -> string mappings in on-disk hash tables. +class SILDeserializer::StringTableInfo { +public: + using internal_key_type = StringRef; + using external_key_type = internal_key_type; + using data_type = StringRef; + using hash_value_type = uint32_t; + using offset_type = uint32_t; + + internal_key_type GetInternalKey(external_key_type ID) { return ID; } + + external_key_type GetExternalKey(internal_key_type ID) { return ID; } + + hash_value_type ComputeHash(internal_key_type key) { + return llvm::djbHash(key, SWIFTMODULE_HASH_SEED); + } + + static bool EqualKey(internal_key_type lhs, internal_key_type rhs) { + return lhs == rhs; + } + + static std::pair ReadKeyDataLength(const uint8_t *&data) { + offset_type keyLength = + llvm::support::endian::readNext(data); + offset_type dataLength = + llvm::support::endian::readNext(data); + + return { keyLength, dataLength }; + } + + internal_key_type ReadKey(const uint8_t *data, unsigned length) { + return internal_key_type((const char *)data, length); + } + + static data_type ReadData(internal_key_type key, const uint8_t *data, + unsigned length) { + return data_type((const char *)data, length); + } +}; + SILDeserializer::SILDeserializer( ModuleFile *MF, SILModule &M, DeserializationNotificationHandlerSet *callback) @@ -195,10 +237,11 @@ SILDeserializer::SILDeserializer( kind == sil_index_block::SIL_DEFAULT_WITNESS_TABLE_NAMES || kind == sil_index_block::SIL_DEFAULT_OVERRIDE_TABLE_NAMES || kind == sil_index_block::SIL_PROPERTY_OFFSETS || - kind == sil_index_block::SIL_DIFFERENTIABILITY_WITNESS_NAMES)) && + kind == sil_index_block::SIL_DIFFERENTIABILITY_WITNESS_NAMES || + kind == sil_index_block::SIL_ASM_NAMES)) && "Expect SIL_FUNC_NAMES, SIL_VTABLE_NAMES, SIL_GLOBALVAR_NAMES, \ SIL_WITNESS_TABLE_NAMES, SIL_DEFAULT_WITNESS_TABLE_NAMES, \ - SIL_PROPERTY_OFFSETS, SIL_MOVEONLYDEINIT_NAMES, or SIL_DIFFERENTIABILITY_WITNESS_NAMES."); + SIL_PROPERTY_OFFSETS, SIL_MOVEONLYDEINIT_NAMES, SIL_DIFFERENTIABILITY_WITNESS_NAMES, or SIL_ASM_NAMES."); (void)prevKind; if (kind == sil_index_block::SIL_FUNC_NAMES) @@ -217,10 +260,14 @@ SILDeserializer::SILDeserializer( DefaultOverrideTableList = readFuncTable(scratch, blobData); else if (kind == sil_index_block::SIL_DIFFERENTIABILITY_WITNESS_NAMES) DifferentiabilityWitnessList = readFuncTable(scratch, blobData); - else if (kind == sil_index_block::SIL_PROPERTY_OFFSETS) { + else if (kind == sil_index_block::SIL_ASM_NAMES) { + // No matching offset block. + AsmNameTable = readStringTable(scratch, blobData); + continue; + } else if (kind == sil_index_block::SIL_PROPERTY_OFFSETS) { // No matching 'names' block for property descriptors needed yet. MF->allocateBuffer(Properties, scratch); - return; + continue; } // Read SIL_FUNC|VTABLE|GLOBALVAR_OFFSETS record. @@ -286,6 +333,19 @@ SILDeserializer::readFuncTable(ArrayRef fields, StringRef blobData) { FuncTableInfo(*MF))); } +std::unique_ptr +SILDeserializer::readStringTable(ArrayRef fields, StringRef blobData){ + uint32_t tableOffset; + sil_index_block::ListLayout::readRecord(fields, tableOffset); + auto base = reinterpret_cast(blobData.data()); + + using OwnedTable = std::unique_ptr; + return OwnedTable(SerializedStringTable::Create(base + tableOffset, + base + sizeof(uint32_t), base, + StringTableInfo())); +} + + /// A high-level overview of how forward references work in serializer and /// deserializer: /// In the serializer, we pre-assign a value ID in order, to each basic block @@ -625,9 +685,10 @@ SILFunction *SILDeserializer::getFuncForReference(StringRef name, /// Helper function to find a SILGlobalVariable given its name. It first checks /// in the module. If we cannot find it in the module, we attempt to /// deserialize it. -SILGlobalVariable *SILDeserializer::getGlobalForReference(StringRef name) { +SILGlobalVariable * +SILDeserializer::getGlobalForReference(StringRef name, bool byAsmName) { // Check to see if we have a global by this name already. - if (SILGlobalVariable *g = SILMod.lookUpGlobalVariable(name)) + if (SILGlobalVariable *g = SILMod.lookUpGlobalVariable(name, byAsmName)) return g; // Otherwise, look for a global with this name in the module. @@ -4042,7 +4103,21 @@ bool SILDeserializer::hasSILFunction(StringRef Name, } SILFunction *SILDeserializer::lookupSILFunction(StringRef name, - bool declarationOnly) { + bool declarationOnly, + bool byAsmName) { + // If we're looking up the function by its AsmName, check that table. + if (byAsmName) { + if (!AsmNameTable) + return nullptr; + + auto iter = AsmNameTable->find(name); + if (iter == AsmNameTable->end()) + return nullptr; + + // Now look for this name in the function table. + name = *iter; + } + if (!FuncTable) return nullptr; auto iter = FuncTable->find(name); @@ -4066,11 +4141,26 @@ SILFunction *SILDeserializer::lookupSILFunction(StringRef name, return maybeFunc.get(); } -SILGlobalVariable *SILDeserializer::lookupSILGlobalVariable(StringRef name) { - return getGlobalForReference(name); +SILGlobalVariable *SILDeserializer::lookupSILGlobalVariable(StringRef name, + bool byAsmName) { + return getGlobalForReference(name, byAsmName); } -SILGlobalVariable *SILDeserializer::readGlobalVar(StringRef Name) { +SILGlobalVariable *SILDeserializer::readGlobalVar(StringRef Name, + bool byAsmName) { + // If we're looking up the function by its AsmName, check that table. + if (byAsmName) { + if (!AsmNameTable) + return nullptr; + + auto iter = AsmNameTable->find(Name); + if (iter == AsmNameTable->end()) + return nullptr; + + // Now look for this name in the global variable table. + Name = *iter; + } + if (!GlobalVarList) return nullptr; diff --git a/lib/Serialization/DeserializeSIL.h b/lib/Serialization/DeserializeSIL.h index 21edb3f60b548..34f1a1b5cf17d 100644 --- a/lib/Serialization/DeserializeSIL.h +++ b/lib/Serialization/DeserializeSIL.h @@ -40,6 +40,10 @@ namespace swift { using SerializedFuncTable = llvm::OnDiskIterableChainedHashTable; + class StringTableInfo; + using SerializedStringTable = + llvm::OnDiskIterableChainedHashTable; + //----- // Deserialization Caches // @@ -83,6 +87,9 @@ namespace swift { ModuleFile::PartiallySerialized> DifferentiabilityWitnesses; + /// asmname -> SIL entity name + std::unique_ptr AsmNameTable; + //----- // End Deserialization Caches // @@ -133,6 +140,10 @@ namespace swift { std::unique_ptr readFuncTable(ArrayRef fields, StringRef blobData); + /// Read a string -> string mapping table. + std::unique_ptr + readStringTable(ArrayRef fields, StringRef blobData); + /// When an instruction or block argument is defined, this method is used to /// register it and update our symbol table. void setLocalValue(ValueBase *Value, serialization::ValueID Id); @@ -163,8 +174,9 @@ namespace swift { SILFunction *getFuncForReference(StringRef Name, bool forDebugScope = false); SILVTable *readVTable(serialization::DeclID); SILMoveOnlyDeinit *readMoveOnlyDeinit(serialization::DeclID); - SILGlobalVariable *getGlobalForReference(StringRef Name); - SILGlobalVariable *readGlobalVar(StringRef Name); + SILGlobalVariable *getGlobalForReference(StringRef Name, + bool byAsmName = false); + SILGlobalVariable *readGlobalVar(StringRef Name, bool byAsmName = false); /// Read and return the witness table identified with \p WId. SILWitnessTable *readWitnessTable(serialization::DeclID WId, @@ -205,8 +217,10 @@ namespace swift { } SILFunction *lookupSILFunction(SILFunction *InFunc, bool onlyUpdateLinkage); SILFunction *lookupSILFunction(StringRef Name, - bool declarationOnly = false); - SILGlobalVariable *lookupSILGlobalVariable(StringRef Name); + bool declarationOnly = false, + bool byAsmName = false); + SILGlobalVariable *lookupSILGlobalVariable(StringRef Name, + bool byAsmName = false); bool hasSILFunction(StringRef Name, std::optional Linkage = std::nullopt); SILVTable *lookupVTable(StringRef MangledClassName); diff --git a/lib/Serialization/ModuleFormat.h b/lib/Serialization/ModuleFormat.h index 846e2c99fbbb4..2e10089b6b0c3 100644 --- a/lib/Serialization/ModuleFormat.h +++ b/lib/Serialization/ModuleFormat.h @@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0; /// describe what change you made. The content of this comment isn't important; /// it just ensures a conflict if two people change the module format. /// Don't worry about adhering to the 80-column limit for this line. -const uint16_t SWIFTMODULE_VERSION_MINOR = 971; // new platform kinds +const uint16_t SWIFTMODULE_VERSION_MINOR = 972; // SIL asmname string table /// A standard hash seed used for all string hashes in a serialized module. /// diff --git a/lib/Serialization/SILFormat.h b/lib/Serialization/SILFormat.h index 0722b16e45756..3cafe4e785a27 100644 --- a/lib/Serialization/SILFormat.h +++ b/lib/Serialization/SILFormat.h @@ -114,6 +114,7 @@ namespace sil_index_block { SIL_PROPERTY_OFFSETS, SIL_DIFFERENTIABILITY_WITNESS_NAMES, SIL_DIFFERENTIABILITY_WITNESS_OFFSETS, + SIL_ASM_NAMES, }; using ListLayout = BCGenericRecordLayout< diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp index 38014b2d139e0..d520e7602e6a4 100644 --- a/lib/Serialization/Serialization.cpp +++ b/lib/Serialization/Serialization.cpp @@ -996,6 +996,7 @@ void Serializer::writeBlockInfoBlock() { BLOCK_RECORD(sil_index_block, SIL_DIFFERENTIABILITY_WITNESS_OFFSETS); BLOCK_RECORD(sil_index_block, SIL_DEFAULT_OVERRIDE_TABLE_NAMES); BLOCK_RECORD(sil_index_block, SIL_DEFAULT_OVERRIDE_TABLE_OFFSETS); + BLOCK_RECORD(sil_index_block, SIL_ASM_NAMES); BLOCK(INCREMENTAL_INFORMATION_BLOCK); BLOCK_RECORD(fine_grained_dependencies::record_block, METADATA); diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp index f728cfb934481..2c8bda1286aa5 100644 --- a/lib/Serialization/SerializeSIL.cpp +++ b/lib/Serialization/SerializeSIL.cpp @@ -157,6 +157,42 @@ namespace { } }; + class StringTableInfo { + public: + using key_type = StringRef; + using key_type_ref = key_type; + using data_type = StringRef; + using data_type_ref = const data_type &; + using hash_value_type = uint32_t; + using offset_type = uint32_t; + + hash_value_type ComputeHash(key_type_ref key) { + assert(!key.empty()); + return llvm::djbHash(key, SWIFTMODULE_HASH_SEED); + } + + std::pair EmitKeyDataLength(raw_ostream &out, + key_type_ref key, + data_type_ref data) { + offset_type keyLength = static_cast(key.size()); + llvm::support::endian::write(out, keyLength, + llvm::endianness::little); + offset_type dataLength = static_cast(data.size()); + llvm::support::endian::write(out, dataLength, + llvm::endianness::little); + return {keyLength, dataLength}; + } + + void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { + out << key; + } + + void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, + unsigned len) { + out << data; + } + }; + class SILSerializer { using TypeID = serialization::TypeID; using DebugScopeID = DeclID; @@ -181,6 +217,7 @@ namespace { public: using TableData = FuncTableInfo::data_type; using Table = llvm::MapVector; + using StringMapTable = llvm::MapVector; private: /// FuncTable maps function name to an ID. Table FuncTable; @@ -233,6 +270,10 @@ namespace { std::vector DifferentiabilityWitnessOffset; uint32_t /*DeclID*/ NextDifferentiabilityWitnessID = 1; + /// Maps asmname of SIL functions and global variables to their SIL names, + /// which will generally be mangled names. + StringMapTable AsmNameTable; + llvm::DenseMap, DeclID> DebugScopeMap; llvm::DenseMap SourceLocMap; @@ -559,8 +600,14 @@ void SILSerializer::writeSILFunction(const SILFunction &F, bool DeclOnly) { // Each extra string emitted below needs to update the trailing record // count here. - if (!F.asmName().empty()) + if (!F.asmName().empty()) { ++numTrailingRecords; + + // Record asmname mapping. + if (F.asmName() != F.getName()) { + AsmNameTable[F.asmName()] = F.getName(); + } + } if (!F.section().empty()) ++numTrailingRecords; @@ -3086,8 +3133,31 @@ static void writeIndexTable(Serializer &S, List.emit(scratch, kind, tableOffset, hashTableBlob); } +static void writeStringTable(Serializer &S, + const sil_index_block::ListLayout &List, + sil_index_block::RecordKind kind, + const SILSerializer::StringMapTable &table) { + assert((kind == sil_index_block::SIL_ASM_NAMES) && + "Only SIL asm names table is supported"); + llvm::SmallString<4096> hashTableBlob; + uint32_t tableOffset; + { + llvm::OnDiskChainedHashTableGenerator generator; + StringTableInfo tableInfo; + for (auto &entry : table) + generator.insert(entry.first, entry.second, tableInfo); + + llvm::raw_svector_ostream blobStream(hashTableBlob); + // Make sure that no bucket is at offset 0. + endian::write(blobStream, 0, llvm::endianness::little); + tableOffset = generator.Emit(blobStream, tableInfo); + } + SmallVector scratch; + List.emit(scratch, kind, tableOffset, hashTableBlob); +} + void SILSerializer::writeIndexTables() { - BCBlockRAII restoreBlock(Out, SIL_INDEX_BLOCK_ID, 4); + BCBlockRAII restoreBlock(Out, SIL_INDEX_BLOCK_ID, 5); sil_index_block::ListLayout List(Out); sil_index_block::OffsetLayout Offset(Out); @@ -3153,6 +3223,9 @@ void SILSerializer::writeIndexTables() { DifferentiabilityWitnessOffset); } + if (!AsmNameTable.empty()) { + writeStringTable(S, List, sil_index_block::SIL_ASM_NAMES, AsmNameTable); + } } void SILSerializer::writeSILGlobalVar(const SILGlobalVariable &g) { @@ -3169,8 +3242,14 @@ void SILSerializer::writeSILGlobalVar(const SILGlobalVariable &g) { // Each extra string emitted below needs to update the trailing record // count here. - if (!g.asmName().empty()) + if (!g.asmName().empty()) { ++numTrailingRecords; + + // Record asmname mapping. + if (g.asmName() != g.getName()) { + AsmNameTable[g.asmName()] = g.getName(); + } + } if (!g.section().empty()) ++numTrailingRecords; diff --git a/lib/Serialization/SerializedSILLoader.cpp b/lib/Serialization/SerializedSILLoader.cpp index 0c21ad5203fd0..581d722dc81bf 100644 --- a/lib/Serialization/SerializedSILLoader.cpp +++ b/lib/Serialization/SerializedSILLoader.cpp @@ -62,9 +62,11 @@ SILFunction *SerializedSILLoader::lookupSILFunction(SILFunction *Callee, SILFunction * SerializedSILLoader::lookupSILFunction(StringRef Name, - std::optional Linkage) { + std::optional Linkage, + bool byAsmName) { for (auto &Des : LoadedSILSections) { - if (auto *Func = Des->lookupSILFunction(Name, /*declarationOnly*/ true)) { + if (auto *Func = Des->lookupSILFunction(Name, /*declarationOnly*/ true, + byAsmName)) { LLVM_DEBUG(llvm::dbgs() << "Deserialized " << Func->getName() << " from " << Des->getModuleIdentifier().str() << "\n"); if (Linkage) { @@ -85,9 +87,10 @@ SerializedSILLoader::lookupSILFunction(StringRef Name, return nullptr; } -SILGlobalVariable *SerializedSILLoader::lookupSILGlobalVariable(StringRef Name) { +SILGlobalVariable * +SerializedSILLoader::lookupSILGlobalVariable(StringRef Name, bool byAsmName) { for (auto &Des : LoadedSILSections) { - if (auto *G = Des->lookupSILGlobalVariable(Name)) { + if (auto *G = Des->lookupSILGlobalVariable(Name, byAsmName)) { return G; } } diff --git a/test/ClangImporter/const_and_pure.swift b/test/ClangImporter/const_and_pure.swift index a6fbe1d6c0834..1093f1473d514 100644 --- a/test/ClangImporter/const_and_pure.swift +++ b/test/ClangImporter/const_and_pure.swift @@ -8,8 +8,8 @@ func testit() { _ = normal_function() } -// CHECK: sil [readnone] [clang const_function] @const_function : $@convention(c) () -> Int32 -// CHECK: sil [readonly] [clang pure_function] @pure_function : $@convention(c) () -> Int32 -// CHECK: sil [clang normal_function] @normal_function : $@convention(c) () -> Int32 +// CHECK: sil [readnone] [asmname "const_function"] [clang const_function] @$sSo14const_functions5Int32VyFTo : $@convention(c) () -> Int32 +// CHECK: sil [readonly] [asmname "pure_function"] [clang pure_function] @$sSo13pure_functions5Int32VyFTo : $@convention(c) () -> Int32 +// CHECK: sil [asmname "normal_function"] [clang normal_function] @$sSo15normal_functions5Int32VyFTo : $@convention(c) () -> Int32 diff --git a/test/ClangImporter/indirect_field_codegen.swift b/test/ClangImporter/indirect_field_codegen.swift index 31928543756ea..2e70288e5042f 100644 --- a/test/ClangImporter/indirect_field_codegen.swift +++ b/test/ClangImporter/indirect_field_codegen.swift @@ -17,17 +17,17 @@ extension StructWithIndirectField2Copy { // The names look complex because we assign names to unnamed unions/structs // using a mangling scheme which the Swift demangler doesn't understand. -// CHECK-DAG: sil shared @$So24StructWithIndirectField2V34__Unnamed_union___Anonymous_field0V02__e10_struct___G7_field1V$x$getter : $@convention(c) (StructWithIndirectField2.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1) -> UInt32 +// CHECK-DAG: sil shared {{.*}}@$sSo24StructWithIndirectField2V34__Unnamed_union___Anonymous_field0V02__e10_struct___G7_field1V1xs6UInt32VvgTo : $@convention(c) (StructWithIndirectField2.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1) -> UInt32 -// CHECK-DAG: sil shared @$So24StructWithIndirectField2V34__Unnamed_union___Anonymous_field0V02__e10_struct___G7_field1V$y$getter : $@convention(c) (StructWithIndirectField2.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1) -> UInt32 +// CHECK-DAG: sil shared {{.*}}@$sSo24StructWithIndirectField2V34__Unnamed_union___Anonymous_field0V02__e10_struct___G7_field1V1ys6UInt32VvgTo : $@convention(c) (StructWithIndirectField2.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1) -> UInt32 -// CHECK-DAG: sil shared @$So28StructWithIndirectField2CopyV34__Unnamed_union___Anonymous_field0V02__f10_struct___H7_field1V$x$getter : $@convention(c) (StructWithIndirectField2Copy.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1) -> UInt32 +// CHECK-DAG: sil shared {{.*}}@$sSo28StructWithIndirectField2CopyV34__Unnamed_union___Anonymous_field0V02__f10_struct___H7_field1V1xs6UInt32VvgTo : $@convention(c) (StructWithIndirectField2Copy.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1) -> UInt32 -// CHECK-DAG: sil shared @$So28StructWithIndirectField2CopyV34__Unnamed_union___Anonymous_field0V02__f10_struct___H7_field1V$x$setter : $@convention(c) (UInt32, @inout StructWithIndirectField2Copy.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1) -> () +// CHECK-DAG: sil shared {{.*}}@$sSo28StructWithIndirectField2CopyV34__Unnamed_union___Anonymous_field0V02__f10_struct___H7_field1V1xs6UInt32VvsTo : $@convention(c) (UInt32, @inout StructWithIndirectField2Copy.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1) -> () -// CHECK-DAG: sil shared @$So28StructWithIndirectField2CopyV34__Unnamed_union___Anonymous_field0V02__f10_struct___H7_field1V$y$getter : $@convention(c) (StructWithIndirectField2Copy.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1) -> UInt32 +// CHECK-DAG: sil shared {{.*}}@$sSo28StructWithIndirectField2CopyV34__Unnamed_union___Anonymous_field0V02__f10_struct___H7_field1V1ys6UInt32VvgTo : $@convention(c) (StructWithIndirectField2Copy.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1) -> UInt32 -// CHECK-DAG: sil shared @$So28StructWithIndirectField2CopyV34__Unnamed_union___Anonymous_field0V02__f10_struct___H7_field1V$y$setter : $@convention(c) (UInt32, @inout StructWithIndirectField2Copy.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1) -> () +// CHECK-DAG: sil shared {{.*}}@$sSo28StructWithIndirectField2CopyV34__Unnamed_union___Anonymous_field0V02__f10_struct___H7_field1V1ys6UInt32VvsTo : $@convention(c) (UInt32, @inout StructWithIndirectField2Copy.__Unnamed_union___Anonymous_field0.__Unnamed_struct___Anonymous_field1) -> () func test() -> UInt32 { var s = StructWithIndirectField2Copy(x: 1, y: 2) diff --git a/test/ClangImporter/static_inline.swift b/test/ClangImporter/static_inline.swift index 5309df9617dce..f6d921e1068ad 100644 --- a/test/ClangImporter/static_inline.swift +++ b/test/ClangImporter/static_inline.swift @@ -6,7 +6,7 @@ // RUN: %FileCheck < %t/static_inline.sil %s // RUN: %target-swift-frontend -parse-as-library -module-name=static_inline -O -emit-ir %t/static_inline.sil -enable-objc-interop -import-objc-header %S/Inputs/static_inline.h | %FileCheck --check-prefix=CHECK-IR %s -// CHECK: sil shared [clang c_inline_func] @c_inline_func : $@convention(c) (Int32) -> Int32 +// CHECK: sil shared [asmname "c_inline_func"] [clang c_inline_func] @$sSo13c_inline_funcys5Int32VACFTo : $@convention(c) (Int32) -> Int32 // CHECK-IR-LABEL: define{{.*}} i32 @"$s13static_inline6testit1xs5Int32VAE_tF"(i32 %0) // CHECK-IR: = add {{.*}}, 27 diff --git a/test/ClangImporter/static_inline_serialize.swift b/test/ClangImporter/static_inline_serialize.swift index 139c4e4bbee0f..e8bf826297cdc 100644 --- a/test/ClangImporter/static_inline_serialize.swift +++ b/test/ClangImporter/static_inline_serialize.swift @@ -6,7 +6,7 @@ // RUN: %target-swift-frontend -module-name test -O -emit-sil %s -I %t -enable-objc-interop | %FileCheck %s // RUN: %target-swift-frontend -module-name test -O -emit-ir %s -I %t -enable-objc-interop | %FileCheck --check-prefix=CHECK-IR %s -// CHECK: sil shared [clang c_inline_func] @c_inline_func : $@convention(c) (Int32) -> Int32 +// CHECK: sil shared [asmname "c_inline_func"] [clang c_inline_func] @$sSo13c_inline_funcys5Int32VACFTo : $@convention(c) (Int32) -> Int32 // CHECK-IR-LABEL: define{{.*}} i32 @"$s4test6mytest1xs5Int32VAE_tF"(i32 %0) // CHECK-IR: = add {{.*}}, 27 diff --git a/test/Concurrency/async_main.swift b/test/Concurrency/async_main.swift index 9fd02723d1f2f..8a892a39f04df 100644 --- a/test/Concurrency/async_main.swift +++ b/test/Concurrency/async_main.swift @@ -51,8 +51,8 @@ func asyncFunc() async { // CHECK-SIL: bb1(%3 : $()): // CHECK-SIL-NEXT: %4 = integer_literal $Builtin.Int32, 0 // CHECK-SIL-NEXT: %5 = struct $Int32 (%4 : $Builtin.Int32) -// CHECK-SIL-NEXT: // function_ref exit -// CHECK-SIL-NEXT: %6 = function_ref @exit : $@convention(c) (Int32) -> Never +// CHECK-SIL-NEXT: // function_ref @objc exit(_:) +// CHECK-SIL-NEXT: %6 = function_ref @$sSo4exitys5NeverOs5Int32VFTo : $@convention(c) (Int32) -> Never // CHECK-SIL-NEXT: %7 = apply %6(%5) : $@convention(c) (Int32) -> Never // CHECK-SIL-NEXT: unreachable diff --git a/test/Interop/Cxx/class/closure-thunk-macosx-sil.swift b/test/Interop/Cxx/class/closure-thunk-macosx-sil.swift index 66919dc6ad262..f5d8493ba2988 100644 --- a/test/Interop/Cxx/class/closure-thunk-macosx-sil.swift +++ b/test/Interop/Cxx/class/closure-thunk-macosx-sil.swift @@ -14,7 +14,7 @@ import Closure // CHECK: %[[V6:.*]] = init_block_storage_header %[[V2]] : $*@block_storage @callee_guaranteed (@in_guaranteed ARCWeak) -> (), invoke %[[V7]] : $@convention(c) (@inout_aliasable @block_storage @callee_guaranteed (@in_guaranteed ARCWeak) -> (), @in ARCWeak) -> (), type $@convention(block) (@in ARCWeak) -> () // CHECK: %[[V8:.*]] = copy_block %[[V6]] : $@convention(block) (@in ARCWeak) -> () // CHECK: dealloc_stack %[[V2]] : $*@block_storage @callee_guaranteed (@in_guaranteed ARCWeak) -> () -// CHECK: %[[V11:.*]] = function_ref @_Z12cfuncARCWeakU13block_pointerFv7ARCWeakE : $@convention(c) (@convention(block) (@in ARCWeak) -> ()) -> () +// CHECK: %[[V11:.*]] = function_ref @$sSo12cfuncARCWeakyyySo0B0VcFTo : $@convention(c) (@convention(block) (@in ARCWeak) -> ()) -> () // CHECK: apply %[[V11]](%[[V8]]) : $@convention(c) (@convention(block) (@in ARCWeak) -> ()) -> () // CHECK: strong_release %[[V8]] : $@convention(block) (@in ARCWeak) -> () // CHECK: %[[V12:.*]] = tuple () diff --git a/test/Interop/Cxx/class/closure-thunk-macosx.swift b/test/Interop/Cxx/class/closure-thunk-macosx.swift index 9c84201602da2..ecb0e34a4f0bc 100644 --- a/test/Interop/Cxx/class/closure-thunk-macosx.swift +++ b/test/Interop/Cxx/class/closure-thunk-macosx.swift @@ -6,7 +6,7 @@ import Closure // CHECK: sil [ossa] @$s4main20testClosureToFuncPtryyF : $@convention(thin) () -> () { // CHECK: %[[V0:.*]] = function_ref @$s4main20testClosureToFuncPtryyFySo9ARCStrongVcfU_To : $@convention(c) (@owned ARCStrong) -> () -// CHECK: %[[V1:.*]] = function_ref @_Z14cfuncARCStrongPFv9ARCStrongE : $@convention(c) (@convention(c) (@owned ARCStrong) -> ()) -> () +// CHECK: %[[V1:.*]] = function_ref @$sSo14cfuncARCStrongyyySo0B0VXCFTo : $@convention(c) (@convention(c) (@owned ARCStrong) -> ()) -> () // CHECK: apply %[[V1]](%[[V0]]) : $@convention(c) (@convention(c) (@owned ARCStrong) -> ()) -> () // CHECK: sil private [thunk] [ossa] @$s4main20testClosureToFuncPtryyFySo9ARCStrongVcfU_To : $@convention(c) (@owned ARCStrong) -> () { diff --git a/test/Interop/Cxx/class/closure-thunk.swift b/test/Interop/Cxx/class/closure-thunk.swift index 463855ddde9ff..c925cdcc61e15 100644 --- a/test/Interop/Cxx/class/closure-thunk.swift +++ b/test/Interop/Cxx/class/closure-thunk.swift @@ -14,7 +14,7 @@ import Closure // CHECK: %[[V6:.*]] = init_block_storage_header %[[V2]] : $*@block_storage @callee_guaranteed (@in_guaranteed NonTrivial) -> (), invoke %[[V7]] : $@convention(c) (@inout_aliasable @block_storage @callee_guaranteed (@in_guaranteed NonTrivial) -> (), @in_cxx NonTrivial) -> (), type $@convention(block) (@in_cxx NonTrivial) -> () // CHECK: %[[V8:.*]] = copy_block %[[V6]] : $@convention(block) (@in_cxx NonTrivial) -> () // CHECK: dealloc_stack %[[V2]] : $*@block_storage @callee_guaranteed (@in_guaranteed NonTrivial) -> () -// CHECK: %[[V11:.*]] = function_ref @_Z5cfuncU13block_pointerFv10NonTrivialE : $@convention(c) (@convention(block) (@in_cxx NonTrivial) -> ()) -> () +// CHECK: %[[V11:.*]] = function_ref @$sSo5cfuncyyySo10NonTrivialVcFTo : $@convention(c) (@convention(block) (@in_cxx NonTrivial) -> ()) -> () // CHECK: apply %[[V11]](%[[V8]]) : $@convention(c) (@convention(block) (@in_cxx NonTrivial) -> ()) -> () // CHECK: strong_release %[[V8]] : $@convention(block) (@in_cxx NonTrivial) -> () // CHECK: %[[V12:.*]] = tuple () @@ -37,7 +37,7 @@ public func testClosureToBlock() { // CHECK: sil @$s4main20testClosureToFuncPtryyF : $@convention(thin) () -> () { // CHECK: %[[V0:.*]] = function_ref @$s4main20testClosureToFuncPtryyFySo10NonTrivialVcfU_To : $@convention(c) (@in_cxx NonTrivial) -> () -// CHECK: %[[V1:.*]] = function_ref @_Z6cfunc2PFv10NonTrivialE : $@convention(c) (@convention(c) (@in_cxx NonTrivial) -> ()) -> () +// CHECK: %[[V1:.*]] = function_ref @$sSo6cfunc2yyySo10NonTrivialVXCFTo : $@convention(c) (@convention(c) (@in_cxx NonTrivial) -> ()) -> () // CHECK: apply %[[V1]](%[[V0]]) : $@convention(c) (@convention(c) (@in_cxx NonTrivial) -> ()) -> () // CHECK: %[[V3:.*]] = tuple () // CHECK: return %[[V3]] : $() @@ -53,7 +53,7 @@ public func testClosureToFuncPtr() { } // CHECK: sil @$s4main13returnFuncPtrySo10NonTrivialVcyF : $@convention(thin) () -> @owned @callee_guaranteed (@in_guaranteed NonTrivial) -> () { -// CHECK: %[[V0:.*]] = function_ref @_Z8getFnPtrv : $@convention(c) () -> @convention(c) (@in_cxx NonTrivial) -> () +// CHECK: %[[V0:.*]] = function_ref @$sSo8getFnPtrySo10NonTrivialVXCyFTo : $@convention(c) () -> @convention(c) (@in_cxx NonTrivial) -> () // CHECK: %[[V1:.*]] = apply %[[V0]]() : $@convention(c) () -> @convention(c) (@in_cxx NonTrivial) -> () // CHECK: %[[V2:.*]] = function_ref @$sSo10NonTrivialVIetCX_ABIegn_TR : $@convention(thin) (@in_guaranteed NonTrivial, @convention(c) (@in_cxx NonTrivial) -> ()) -> () // CHECK: %[[V3:.*]] = partial_apply [callee_guaranteed] %[[V2]](%[[V1]]) : $@convention(thin) (@in_guaranteed NonTrivial, @convention(c) (@in_cxx NonTrivial) -> ()) -> () diff --git a/test/Interop/Cxx/class/constructors-objc-silgen.swift b/test/Interop/Cxx/class/constructors-objc-silgen.swift index 4c70166f70b64..179ab491c8233 100644 --- a/test/Interop/Cxx/class/constructors-objc-silgen.swift +++ b/test/Interop/Cxx/class/constructors-objc-silgen.swift @@ -6,6 +6,6 @@ import ConstructorsObjC // CHECK: [[VAR:%[0-9]+]] = alloc_stack $ConstructorWithNSArrayParam // CHECK: [[OPT_ARRAY:%[0-9]+]] = enum $Optional, #Optional.some!enumelt, %{{[0-9]+}} : $NSArray -// CHECK: [[FUNC:%[0-9]+]] = function_ref @_ZN27ConstructorWithNSArrayParamC1EP7NSArray : $@convention(c) (Optional) -> @out ConstructorWithNSArrayParam +// CHECK: [[FUNC:%[0-9]+]] = function_ref @$sSo27ConstructorWithNSArrayParamVyABSayypGSgcfCTo : $@convention(c) (Optional) -> @out ConstructorWithNSArrayParam // CHECK: %{{[0-9]+}} = apply [[FUNC]]([[VAR]], [[OPT_ARRAY]]) : $@convention(c) (Optional) -> @out ConstructorWithNSArrayParam let _ = ConstructorWithNSArrayParam([]) diff --git a/test/Interop/Cxx/class/constructors-silgen.swift b/test/Interop/Cxx/class/constructors-silgen.swift index 79cbdf170de9c..c2b515c062e44 100644 --- a/test/Interop/Cxx/class/constructors-silgen.swift +++ b/test/Interop/Cxx/class/constructors-silgen.swift @@ -9,33 +9,30 @@ import Constructors // CHECK: [[VAR:%[0-9]+]] = alloc_stack $ConstructorWithParam // CHECK: [[LITERAL:%[0-9]+]] = integer_literal $Builtin.IntLiteral, 42 // CHECK: [[INT:%[0-9]+]] = apply %{{[0-9]+}}([[LITERAL]], %{{[0-9]+}}) -// CHECK: [[FUNC:%[0-9]+]] = function_ref @{{_ZN20ConstructorWithParamC1Ei|\?\?0ConstructorWithParam@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out ConstructorWithParam +// CHECK: [[FUNC:%[0-9]+]] = function_ref @$sSo20ConstructorWithParamVyABs5Int32VcfCTo : $@convention(c) (Int32) -> @out ConstructorWithParam // CHECK: %{{[0-9]+}} = apply [[FUNC]]([[VAR]], [[INT]]) : $@convention(c) (Int32) -> @out ConstructorWithParam // CHECK-LABEL: end sil function '$s4main24testConstructorWithParamyyF' -// CHECK-LABEL: sil [clang ConstructorWithParam.init] @{{_ZN20ConstructorWithParamC1Ei|\?\?0ConstructorWithParam@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out ConstructorWithParam public func testConstructorWithParam() { let c = ConstructorWithParam(42) } // CHECK-LABEL: sil [ossa] @$s4main18emptyTypeNoArgInityyF : $@convention(thin) () -> () // CHECK: [[AS:%.*]] = alloc_stack $EmptyStruct -// CHECK: [[FN:%.*]] = function_ref @{{_ZN11EmptyStructC1Ev|\?\?0EmptyStruct@@QEAA@XZ}} : $@convention(c) () -> @out EmptyStruct +// CHECK: [[FN:%.*]] = function_ref @$sSo11EmptyStructVABycfCTo : $@convention(c) () -> @out EmptyStruct // CHECK: apply [[FN]]([[AS]]) : $@convention(c) () -> @out EmptyStruct // CHECK-LABEL: end sil function '$s4main18emptyTypeNoArgInityyF' -// CHECK-LABEL: sil [clang EmptyStruct.init] @{{_ZN11EmptyStructC1Ev|\?\?0EmptyStruct@@QEAA@XZ}} : $@convention(c) () -> @out EmptyStruct public func emptyTypeNoArgInit() { let e = EmptyStruct() } // CHECK-LABEL: sil [ossa] @$s4main25singleMemberTypeNoArgInityyF : $@convention(thin) () -> () // CHECK: [[AS:%.*]] = alloc_stack $IntWrapper -// CHECK: [[FN:%.*]] = function_ref @{{_ZN10IntWrapperC1Ev|\?\?0IntWrapper@@QEAA@XZ}} : $@convention(c) () -> @out IntWrapper +// CHECK: [[FN:%.*]] = function_ref @$sSo10IntWrapperVABycfCTo : $@convention(c) () -> @out IntWrapper // CHECK: apply [[FN]]([[AS]]) : $@convention(c) () -> @out IntWrapper // CHECK-LABEL: end sil function '$s4main25singleMemberTypeNoArgInityyF' -//CHECK-LABEL: sil [clang IntWrapper.init] @{{_ZN10IntWrapperC1Ev|\?\?0IntWrapper@@QEAA@XZ}} : $@convention(c) () -> @out IntWrapper public func singleMemberTypeNoArgInit() { let i = IntWrapper() } @@ -62,11 +59,10 @@ public func deletedConstructor(a: UnsafeMutablePointer) { // CHECK: [[TEMPL:%.*]] = alloc_stack $TemplatedConstructor // CHECK: [[ARG:%.*]] = alloc_stack $ArgType // CHECK: [[ARG_VAL:%.*]] = load [trivial] [[ARG]] : $*ArgType -// CHECK: [[FN:%.*]] = function_ref @{{_ZN20TemplatedConstructorC1I7ArgTypeEET_|\?\?\$\?0UArgType@@@TemplatedConstructor@@QEAA@UArgType@@@Z}} : $@convention(c) (ArgType) -> @out TemplatedConstructor +// CHECK: [[FN:%.*]] = function_ref @$sSo20TemplatedConstructorVyABSo7ArgTypeVcfCTo : $@convention(c) (ArgType) -> @out TemplatedConstructor // CHECK: apply [[FN]]([[TEMPL]], [[ARG_VAL]]) : $@convention(c) (ArgType) -> @out TemplatedConstructor // CHECK-LABEL: end sil function '$s4main20templatedConstructoryyF' -// CHECK-LABEL: sil [clang TemplatedConstructor.init] @{{_ZN20TemplatedConstructorC1I7ArgTypeEET_|\?\?\$\?0UArgType@@@TemplatedConstructor@@QEAA@UArgType@@@Z}} : $@convention(c) (ArgType) -> @out TemplatedConstructor public func templatedConstructor() { let templated = TemplatedConstructor(ArgType()) } diff --git a/test/Interop/Cxx/class/function-call-macosx.swift b/test/Interop/Cxx/class/function-call-macosx.swift index 02a6a479bd386..e113a4463744b 100644 --- a/test/Interop/Cxx/class/function-call-macosx.swift +++ b/test/Interop/Cxx/class/function-call-macosx.swift @@ -6,9 +6,9 @@ import Closure // CHECK: sil [ossa] @$s4main11testARCWeakyyF : $@convention(thin) () -> () { // CHECK: %[[V0:.*]] = alloc_stack $ARCWeak -// CHECK: %[[V2:.*]] = function_ref @_ZN7ARCWeakC1Ev : $@convention(c) () -> @out ARCWeak +// CHECK: %[[V2:.*]] = function_ref @$sSo7ARCWeakVABycfCTo : $@convention(c) () -> @out ARCWeak // CHECK: %[[V3:.*]] = apply %[[V2]](%[[V0]]) : $@convention(c) () -> @out ARCWeak -// CHECK: %[[V4:.*]] = function_ref @_Z12cfuncARCWeak7ARCWeak : $@convention(c) (@in ARCWeak) -> () +// CHECK: %[[V4:.*]] = function_ref @$sSo12cfuncARCWeakyySo0B0VFTo : $@convention(c) (@in ARCWeak) -> () // CHECK: %[[V7:.*]] = apply %[[V4]](%[[V0]]) : $@convention(c) (@in ARCWeak) -> () // CHECK-NOT: destroy_addr // CHECK: dealloc_stack %[[V0]] : $*ARCWeak @@ -18,11 +18,11 @@ public func testARCWeak() { } // CHECK: sil [ossa] @$s4main26testARCWeakFunctionPointeryyF : $@convention(thin) () -> () { -// CHECK: %[[V0:.*]] = function_ref @_Z9getFnPtr2v : $@convention(c) () -> @convention(c) (@in ARCWeak) -> () +// CHECK: %[[V0:.*]] = function_ref @$sSo9getFnPtr2ySo7ARCWeakVXCyFTo : $@convention(c) () -> @convention(c) (@in ARCWeak) -> () // CHECK: %[[V1:.*]] = apply %[[V0]]() : $@convention(c) () -> @convention(c) (@in ARCWeak) -> () // CHECK: %[[MV1:.*]] = move_value [var_decl] %[[V1]] : $@convention(c) (@in ARCWeak) -> () // CHECK: %[[V3:.*]] = alloc_stack $ARCWeak -// CHECK: %[[V6:.*]] = function_ref @_ZN7ARCWeakC1Ev : $@convention(c) () -> @out ARCWeak +// CHECK: %[[V6:.*]] = function_ref @$sSo7ARCWeakVABycfCTo : $@convention(c) () -> @out ARCWeak // CHECK: apply %[[V6]](%[[V3]]) : $@convention(c) () -> @out ARCWeak // CHECK: apply %[[MV1]](%[[V3]]) : $@convention(c) (@in ARCWeak) -> () // CHECK-NEXT: dealloc_stack %[[V3]] : $*ARCWeak diff --git a/test/Interop/Cxx/class/function-call.swift b/test/Interop/Cxx/class/function-call.swift index 34206ac3da200..4b92d6d8a803e 100644 --- a/test/Interop/Cxx/class/function-call.swift +++ b/test/Interop/Cxx/class/function-call.swift @@ -6,9 +6,9 @@ import Closure // CHECK: sil @$s4main14testNonTrivialyyF : $@convention(thin) () -> () { // CHECK: %[[V0:.*]] = alloc_stack $NonTrivial -// CHECK: %[[V2:.*]] = function_ref @_ZN10NonTrivialC1Ev : $@convention(c) () -> @out NonTrivial +// CHECK: %[[V2:.*]] = function_ref @$sSo10NonTrivialVABycfCTo : $@convention(c) () -> @out NonTrivial // CHECK: %[[V3:.*]] = apply %[[V2]](%[[V0]]) : $@convention(c) () -> @out NonTrivial -// CHECK: %[[V4:.*]] = function_ref @_Z5cfunc10NonTrivial : $@convention(c) (@in_cxx NonTrivial) -> () +// CHECK: %[[V4:.*]] = function_ref @$sSo5cfuncyySo10NonTrivialVFTo : $@convention(c) (@in_cxx NonTrivial) -> () // CHECK: %[[V7:.*]] = apply %[[V4]](%[[V0]]) : $@convention(c) (@in_cxx NonTrivial) -> () // CHECK: destroy_addr %[[V0]] : $*NonTrivial // CHECK: dealloc_stack %[[V0]] : $*NonTrivial @@ -20,14 +20,14 @@ public func testNonTrivial() { // CHECK: sil @$s4main15testDestroyAddryyF : $@convention(thin) () -> () { // CHECK: %[[V0:.*]] = alloc_stack [lexical] [var_decl] $NonTrivial, var, name "a" // CHECK-NEXT: %[[V1:.*]] = alloc_stack $NonTrivial -// CHECK: %[[V2:.*]] = function_ref @_ZN10NonTrivialC1Ev : $@convention(c) () -> @out NonTrivial +// CHECK: %[[V2:.*]] = function_ref @$sSo10NonTrivialVABycfCTo : $@convention(c) () -> @out NonTrivial // CHECK-NEXT: apply %[[V2]](%[[V1]]) : $@convention(c) () -> @out NonTrivial // CHECK-NEXT: %[[V4:.*]] = integer_literal $Builtin.Int32, 1 // CHECK-NEXT: %[[V5:.*]] = struct $Int32 (%[[V4]] : $Builtin.Int32) // CHECK-NEXT: %[[V6:.*]] = alloc_stack $NonTrivial -// CHECK: %[[V7:.*]] = function_ref @_ZN10NonTrivialC1Ev : $@convention(c) () -> @out NonTrivial +// CHECK: %[[V7:.*]] = function_ref @$sSo10NonTrivialVABycfCTo : $@convention(c) () -> @out NonTrivial // CHECK-NEXT: apply %[[V7]](%[[V6]]) : $@convention(c) () -> @out NonTrivial -// CHECK: %[[V16:.*]] = function_ref @_Z6cfunc310NonTrivialiS_ : $@convention(c) (@in_cxx NonTrivial, Int32, @in_cxx NonTrivial) -> @out NonTrivial +// CHECK: %[[V16:.*]] = function_ref @$sSo6cfunc3ySo10NonTrivialVAC_s5Int32VACtFTo : $@convention(c) (@in_cxx NonTrivial, Int32, @in_cxx NonTrivial) -> @out NonTrivial // CHECK-NEXT: apply %[[V16]](%[[V0]], %[[V1]], %[[V5]], %[[V6]]) : $@convention(c) (@in_cxx NonTrivial, Int32, @in_cxx NonTrivial) -> @out NonTrivial // CHECK-NEXT: destroy_addr %[[V6]] : $*NonTrivial // CHECK-NEXT: destroy_addr %[[V1]] : $*NonTrivial @@ -44,10 +44,10 @@ public func testDestroyAddr() { } // CHECK: sil @$s4main29testNonTrivialFunctionPointeryyF : $@convention(thin) () -> () { -// CHECK: %[[V0:.*]] = function_ref @_Z8getFnPtrv : $@convention(c) () -> @convention(c) (@in_cxx NonTrivial) -> () +// CHECK: %[[V0:.*]] = function_ref @$sSo8getFnPtrySo10NonTrivialVXCyFTo : $@convention(c) () -> @convention(c) (@in_cxx NonTrivial) -> () // CHECK: %[[V1:.*]] = apply %[[V0]]() : $@convention(c) () -> @convention(c) (@in_cxx NonTrivial) -> () // CHECK: %[[V3:.*]] = alloc_stack $NonTrivial -// CHECK: %[[V7:.*]] = function_ref @_ZN10NonTrivialC1Ev : $@convention(c) () -> @out NonTrivial +// CHECK: %[[V7:.*]] = function_ref @$sSo10NonTrivialVABycfCTo : $@convention(c) () -> @out NonTrivial // CHECK: apply %[[V7]](%[[V3]]) : $@convention(c) () -> @out NonTrivial // CHECK: apply %[[V1]](%[[V3]]) : $@convention(c) (@in_cxx NonTrivial) -> () // CHECK: destroy_addr %[[V3]] : $*NonTrivial diff --git a/test/Interop/Cxx/class/method/methods-silgen.swift b/test/Interop/Cxx/class/method/methods-silgen.swift index 4fda8491985b1..c684429b23457 100644 --- a/test/Interop/Cxx/class/method/methods-silgen.swift +++ b/test/Interop/Cxx/class/method/methods-silgen.swift @@ -3,10 +3,10 @@ import Methods // clang name: ReferenceParams::ReferenceParams -// CHECK: sil [clang ReferenceParams.init] @{{_ZN15ReferenceParamsC1ERKiS1_|\?\?0ReferenceParams@@QEAA@AEBH0@Z}} : $@convention(c) (@in_guaranteed Int32, @in_guaranteed Int32) -> @out ReferenceParams +// CHECK: sil [asmname "_ZN15ReferenceParamsC1ERKiS1_"] [clang ReferenceParams.init] @$sSo15ReferenceParamsVyABs5Int32V_ADtcfCTo : $@convention(c) (@in_guaranteed Int32, @in_guaranteed Int32) -> @out ReferenceParams // clang name: ReferenceParams::staticMethod -// CHECK: sil [clang ReferenceParams.staticMethod] @{{_ZN15ReferenceParams12staticMethodERKiS1_|\?staticMethod@ReferenceParams@@SAXAEBH0@Z}} : $@convention(c) (@in_guaranteed Int32, @in_guaranteed Int32) -> () +// CHECK: sil [asmname "_ZN15ReferenceParams12staticMethodERKiS1_"] [clang ReferenceParams.staticMethod] @$sSo15ReferenceParamsV12staticMethodyys5Int32V_AEtFZTo : $@convention(c) (@in_guaranteed Int32, @in_guaranteed Int32) -> () public func use() { let a = CInt(42) diff --git a/test/Interop/Cxx/class/move-only/inherited-field-access-silgen.swift b/test/Interop/Cxx/class/move-only/inherited-field-access-silgen.swift index 5539e89b16777..648aba286074f 100644 --- a/test/Interop/Cxx/class/move-only/inherited-field-access-silgen.swift +++ b/test/Interop/Cxx/class/move-only/inherited-field-access-silgen.swift @@ -26,8 +26,8 @@ testSetX(2) // CHECK: sil shared [transparent] @$sSo024NonCopyableHolderDerivedD0V1xSo0aB0Vvlu : $@convention(method) (@{{(in_)?}}guaranteed NonCopyableHolderDerivedDerived) -> UnsafePointer // CHECK: {{.*}}(%[[SELF_VAL:.*]] : ${{(\*)?}}NonCopyableHolderDerivedDerived): -// CHECK: function_ref @{{(.*)(31NonCopyableHolderDerivedDerived33__synthesizedBaseGetterAccessor_x|__synthesizedBaseGetterAccessor_x@NonCopyableHolderDerivedDerived)(.*)}} : $@convention(cxx_method) (@in_guaranteed NonCopyableHolderDerivedDerived) -> UnsafePointer +// CHECK: function_ref @$sSo024NonCopyableHolderDerivedD0V41____synthesizedBaseGetterAccessor_xUnsafeSPySo0aB0VGyFTo : $@convention(cxx_method) (@in_guaranteed NonCopyableHolderDerivedDerived) -> UnsafePointer // CHECK-NEXT: apply %{{.*}} // CHECK: sil shared [transparent] @$sSo024NonCopyableHolderDerivedD0V1xSo0aB0Vvau : $@convention(method) (@inout NonCopyableHolderDerivedDerived) -> UnsafeMutablePointer -// CHECK: function_ref @{{(.*)(31NonCopyableHolderDerivedDerived33__synthesizedBaseSetterAccessor_x|__synthesizedBaseSetterAccessor_x@NonCopyableHolderDerivedDerived)(.*)}} : $@convention(cxx_method) (@inout NonCopyableHolderDerivedDerived) -> UnsafeMutablePointer +// CHECK: function_ref @$sSo024NonCopyableHolderDerivedD0V41____synthesizedBaseSetterAccessor_xUnsafeSpySo0aB0VGyFTo : $@convention(cxx_method) (@inout NonCopyableHolderDerivedDerived) -> UnsafeMutablePointer diff --git a/test/Interop/Cxx/class/nonescapable-lifetimebound.swift b/test/Interop/Cxx/class/nonescapable-lifetimebound.swift index e15f9bfa48779..fe83cc1018354 100644 --- a/test/Interop/Cxx/class/nonescapable-lifetimebound.swift +++ b/test/Interop/Cxx/class/nonescapable-lifetimebound.swift @@ -166,22 +166,22 @@ using ReadonlyBytes = ReadonlySpan; using Bytes = Span; } // namespace rdar153081347 -// CHECK: sil [clang makeOwner] {{.*}}: $@convention(c) () -> Owner -// CHECK: sil [clang getView] {{.*}} : $@convention(c) (@in_guaranteed Owner) -> @lifetime(borrow address 0) @owned View -// CHECK: sil [clang getViewFromFirst] {{.*}} : $@convention(c) (@in_guaranteed Owner, @in_guaranteed Owner) -> @lifetime(borrow address 0) @owned View -// CHECK: sil [clang getViewFromEither] {{.*}} : $@convention(c) (@in_guaranteed Owner, @in_guaranteed Owner) -> @lifetime(borrow address 0, borrow address 1) @owned View -// CHECK: sil [clang Owner.handOutView] {{.*}} : $@convention(cxx_method) (@in_guaranteed Owner) -> @lifetime(borrow 0) @owned View -// CHECK: sil [clang Owner.handOutView2] {{.*}} : $@convention(cxx_method) (View, @in_guaranteed Owner) -> @lifetime(borrow 1) @owned View -// CHECK: sil [clang getViewFromEither] {{.*}} : $@convention(c) (View, View) -> @lifetime(copy 0, copy 1) @owned View -// CHECK: sil [clang View.init] {{.*}} : $@convention(c) () -> @lifetime(immortal) @out View -// CHECK: sil [clang OtherView.init] {{.*}} : $@convention(c) (View) -> @lifetime(copy 0) @out OtherView -// CHECK: sil [clang returnsImmortal] {{.*}} : $@convention(c) () -> @lifetime(immortal) @owned View -// CHECK: sil [clang copyView] {{.*}} : $@convention(c) (View, @lifetime(copy 0) @inout View) -> () -// CHECK: sil [clang getCaptureView] {{.*}} : $@convention(c) (@in_guaranteed Owner) -> @lifetime(borrow address 0) @owned CaptureView -// CHECK: sil [clang CaptureView.captureView] {{.*}} : $@convention(cxx_method) (View, @lifetime(copy 0) @inout CaptureView) -> () -// CHECK: sil [clang CaptureView.handOut] {{.*}} : $@convention(cxx_method) (@lifetime(copy 1) @inout View, @in_guaranteed CaptureView) -> () -// CHECK: sil [clang NS.getView] {{.*}} : $@convention(c) (@in_guaranteed Owner) -> @lifetime(borrow address 0) @owned View -// CHECK: sil [clang moveOnlyId] {{.*}} : $@convention(c) (@in_guaranteed MoveOnly) -> @lifetime(borrow {{.*}}0) @out MoveOnly +// CHECK: sil {{.*}}[clang makeOwner] {{.*}}: $@convention(c) () -> Owner +// CHECK: sil {{.*}}[clang getView] {{.*}} : $@convention(c) (@in_guaranteed Owner) -> @lifetime(borrow address 0) @owned View +// CHECK: sil {{.*}}[clang getViewFromFirst] {{.*}} : $@convention(c) (@in_guaranteed Owner, @in_guaranteed Owner) -> @lifetime(borrow address 0) @owned View +// CHECK: sil {{.*}}[clang getViewFromEither] {{.*}} : $@convention(c) (@in_guaranteed Owner, @in_guaranteed Owner) -> @lifetime(borrow address 0, borrow address 1) @owned View +// CHECK: sil {{.*}}[clang Owner.handOutView] {{.*}} : $@convention(cxx_method) (@in_guaranteed Owner) -> @lifetime(borrow 0) @owned View +// CHECK: sil {{.*}}[clang Owner.handOutView2] {{.*}} : $@convention(cxx_method) (View, @in_guaranteed Owner) -> @lifetime(borrow 1) @owned View +// CHECK: sil {{.*}}[clang getViewFromEither] {{.*}} : $@convention(c) (View, View) -> @lifetime(copy 0, copy 1) @owned View +// CHECK: sil {{.*}}[clang View.init] {{.*}} : $@convention(c) () -> @lifetime(immortal) @out View +// CHECK: sil {{.*}}[clang OtherView.init] {{.*}} : $@convention(c) (View) -> @lifetime(copy 0) @out OtherView +// CHECK: sil {{.*}}[clang returnsImmortal] {{.*}} : $@convention(c) () -> @lifetime(immortal) @owned View +// CHECK: sil {{.*}}[clang copyView] {{.*}} : $@convention(c) (View, @lifetime(copy 0) @inout View) -> () +// CHECK: sil {{.*}}[clang getCaptureView] {{.*}} : $@convention(c) (@in_guaranteed Owner) -> @lifetime(borrow address 0) @owned CaptureView +// CHECK: sil {{.*}}[clang CaptureView.captureView] {{.*}} : $@convention(cxx_method) (View, @lifetime(copy 0) @inout CaptureView) -> () +// CHECK: sil {{.*}}[clang CaptureView.handOut] {{.*}} : $@convention(cxx_method) (@lifetime(copy 1) @inout View, @in_guaranteed CaptureView) -> () +// CHECK: sil {{.*}}[clang NS.getView] {{.*}} : $@convention(c) (@in_guaranteed Owner) -> @lifetime(borrow address 0) @owned View +// CHECK: sil {{.*}}[clang moveOnlyId] {{.*}} : $@convention(c) (@in_guaranteed MoveOnly) -> @lifetime(borrow {{.*}}0) @out MoveOnly //--- test.swift diff --git a/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift b/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift index 60d766a307f9d..e2a7c6ae2f77f 100644 --- a/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift +++ b/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift @@ -8,13 +8,12 @@ import TypeClassification // "destroy_addr". // CHECK-LABEL: sil [ossa] @$s4main24testStructWithDestructoryyF // CHECK: [[AS:%.*]] = alloc_stack [lexical] [var_decl] $StructWithDestructor -// CHECK: [[FN:%.*]] = function_ref @{{_ZN20StructWithDestructorC1Ev|\?\?0StructWithDestructor@@QEAA@XZ}} : $@convention(c) () -> @out StructWithDestructor +// CHECK: [[FN:%.*]] = function_ref @$sSo20StructWithDestructorVABycfCTo : $@convention(c) () -> @out StructWithDestructor // CHECK: apply [[FN]]([[AS]]) : $@convention(c) () -> @out StructWithDestructor // CHECK: destroy_addr [[AS]] // CHECK: dealloc_stack %0 : $*StructWithDestructor // CHECK-LABEL: end sil function '$s4main24testStructWithDestructoryyF' -// CHECK-LABEL: sil [clang StructWithDestructor.init] @{{_ZN20StructWithDestructorC1Ev|\?\?0StructWithDestructor@@QEAA@XZ}} : $@convention(c) () -> @out StructWithDestructor public func testStructWithDestructor() { let d = StructWithDestructor() } @@ -23,19 +22,18 @@ public func testStructWithDestructor() { // for a "destroy_addr". // CHECK-LABEL: sil [ossa] @$s4main33testStructWithSubobjectDestructoryyF : $@convention(thin) () -> () // CHECK: [[AS:%.*]] = alloc_stack [lexical] [var_decl] $StructWithSubobjectDestructor -// CHECK: [[FN:%.*]] = function_ref @{{_ZN29StructWithSubobjectDestructorC1Ev|\?\?0StructWithSubobjectDestructor@@QEAA@XZ}} : $@convention(c) () -> @out StructWithSubobjectDestructor +// CHECK: [[FN:%.*]] = function_ref @$sSo29StructWithSubobjectDestructorVABycfCTo : $@convention(c) () -> @out StructWithSubobjectDestructor // CHECK: apply [[FN]]([[AS]]) : $@convention(c) () -> @out StructWithSubobjectDestructor // CHECK: destroy_addr [[AS]] // CHECK-LABEL: end sil function '$s4main33testStructWithSubobjectDestructoryyF' -// CHECK-LABEL: sil [clang StructWithSubobjectDestructor.init] @{{_ZN29StructWithSubobjectDestructorC1Ev|\?\?0StructWithSubobjectDestructor@@QEAA@XZ}} : $@convention(c) () -> @out StructWithSubobjectDestructor public func testStructWithSubobjectDestructor() { let d = StructWithSubobjectDestructor() } // CHECK-LABEL: sil [ossa] @$s4main37testStructWithCopyConstructorAndValueSbyF // CHECK: [[AS:%.*]] = alloc_stack [lexical] [var_decl] $StructWithCopyConstructorAndValue -// CHECK: [[FN:%.*]] = function_ref @{{_ZN33StructWithCopyConstructorAndValueC1Ei|\?\?0StructWithCopyConstructorAndValue@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue +// CHECK: [[FN:%.*]] = function_ref @$sSo33StructWithCopyConstructorAndValueVyABs5Int32VcfCTo : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue // CHECK: apply [[FN]]([[AS]], %{{.*}}) : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue // CHECK: [[OBJ_VAL_ADDR:%.*]] = struct_element_addr [[AS]] : $*StructWithCopyConstructorAndValue, #StructWithCopyConstructorAndValue.value // CHECK: [[OBJ_VAL:%.*]] = load [trivial] [[OBJ_VAL_ADDR]] : $*Int32 @@ -48,7 +46,6 @@ public func testStructWithSubobjectDestructor() { // CHECK: return [[OUT]] : $Bool // CHECK-LABEL: end sil function '$s4main37testStructWithCopyConstructorAndValueSbyF' -// CHECK-LABEL: sil [clang StructWithCopyConstructorAndValue.init] @{{_ZN33StructWithCopyConstructorAndValueC1Ei|\?\?0StructWithCopyConstructorAndValue@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue public func testStructWithCopyConstructorAndValue() -> Bool { let obj = StructWithCopyConstructorAndValue(42) return obj.value == 42 @@ -56,7 +53,7 @@ public func testStructWithCopyConstructorAndValue() -> Bool { // CHECK-LABEL: sil [ossa] @$s4main46testStructWithSubobjectCopyConstructorAndValueSbyF : $@convention(thin) () -> Bool // CHECK: [[MEMBER_0:%.*]] = alloc_stack [lexical] [var_decl] $StructWithCopyConstructorAndValue -// CHECK: [[MAKE_MEMBER_FN:%.*]] = function_ref @{{_ZN33StructWithCopyConstructorAndValueC1Ei|\?\?0StructWithCopyConstructorAndValue@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue +// CHECK: [[MAKE_MEMBER_FN:%.*]] = function_ref @$sSo33StructWithCopyConstructorAndValueVyABs5Int32VcfCTo : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue // CHECK: apply [[MAKE_MEMBER_FN]]([[MEMBER_0]], %{{.*}}) : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue // CHECK: [[AS:%.*]] = alloc_stack [lexical] [var_decl] $StructWithSubobjectCopyConstructorAndValue // CHECK: [[META:%.*]] = metatype $@thin StructWithSubobjectCopyConstructorAndValue.Type @@ -90,12 +87,12 @@ public func testStructWithSubobjectCopyConstructorAndValue() -> Bool { // testStructWithCopyConstructorAndSubobjectCopyConstructorAndValue() // CHECK-LABEL: sil [ossa] @$s4main041testStructWithCopyConstructorAndSubobjectefG5ValueSbyF : $@convention(thin) () -> Bool // CHECK: [[MEMBER_0:%.*]] = alloc_stack [lexical] [var_decl] $StructWithCopyConstructorAndValue -// CHECK: [[CREATE_MEMBER_FN:%.*]] = function_ref @{{_ZN33StructWithCopyConstructorAndValueC1Ei|\?\?0StructWithCopyConstructorAndValue@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue +// CHECK: [[CREATE_MEMBER_FN:%.*]] = function_ref @$sSo33StructWithCopyConstructorAndValueVyABs5Int32VcfCTo : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue // CHECK: apply [[CREATE_MEMBER_FN]]([[MEMBER_0]], %{{.*}}) : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue // CHECK: [[AS:%.*]] = alloc_stack [lexical] [var_decl] $StructWithCopyConstructorAndSubobjectCopyConstructorAndValue // CHECK: [[MEMBER_1:%.*]] = alloc_stack $StructWithCopyConstructorAndValue // CHECK: copy_addr [[MEMBER_0]] to [init] [[MEMBER_1]] : $*StructWithCopyConstructorAndValue -// CHECK: [[FN:%.*]] = function_ref @{{_ZN60StructWithCopyConstructorAndSubobjectCopyConstructorAndValueC1E33StructWithCopyConstructorAndValue|\?\?0StructWithCopyConstructorAndSubobjectCopyConstructorAndValue@@QEAA@UStructWithCopyConstructorAndValue@@@Z}} : $@convention(c) (@in_cxx StructWithCopyConstructorAndValue) -> @out StructWithCopyConstructorAndSubobjectCopyConstructorAndValue +// CHECK: [[FN:%.*]] = function_ref @$sSo037StructWithCopyConstructorAndSubobjectcdE5ValueVyABSo0abcdeG0VcfCTo : $@convention(c) (@in_cxx StructWithCopyConstructorAndValue) -> @out StructWithCopyConstructorAndSubobjectCopyConstructorAndValue // CHECK: apply [[FN]]([[AS]], [[MEMBER_1]]) : $@convention(c) (@in_cxx StructWithCopyConstructorAndValue) -> @out StructWithCopyConstructorAndSubobjectCopyConstructorAndValue // CHECK: [[OBJ_MEMBER_ADDR:%.*]] = struct_element_addr [[AS]] : $*StructWithCopyConstructorAndSubobjectCopyConstructorAndValue, #StructWithCopyConstructorAndSubobjectCopyConstructorAndValue.member // CHECK: [[MEMBER_2:%.*]] = alloc_stack $StructWithCopyConstructorAndValue diff --git a/test/Interop/Cxx/foreign-reference/frt-reference-returns-sil.swift b/test/Interop/Cxx/foreign-reference/frt-reference-returns-sil.swift index fb02159e5fb18..ae369ca7b18e0 100644 --- a/test/Interop/Cxx/foreign-reference/frt-reference-returns-sil.swift +++ b/test/Interop/Cxx/foreign-reference/frt-reference-returns-sil.swift @@ -6,30 +6,41 @@ import FRTReferenceReturns func useAll() { let _ = NoAnnotations.getRefCountedByRef() - // CHECK: sil [clang NoAnnotations.getRefCountedByRef] @{{.*}} : $@convention(c) () -> NoAnnotations.RefCountedType + // CHECK: function_ref @{{.*}} : $@convention(c) () -> NoAnnotations.RefCountedType // Note: create/copy rule (default without ownership annotations) does not apply if return type is & to frt let _ = NoAnnotations.createRefCountedByRef() - // CHECK: sil [clang NoAnnotations.createRefCountedByRef] @{{.*}} : $@convention(c) () -> NoAnnotations.RefCountedType + // CHECK: function_ref @{{.*}} : $@convention(c) () -> NoAnnotations.RefCountedType let _ = NoAnnotations.copyRefCountedByRef() - // CHECK: sil [clang NoAnnotations.copyRefCountedByRef] @{{.*}} : $@convention(c) () -> NoAnnotations.RefCountedType + // CHECK: function_ref @{{.*}} : $@convention(c) () -> NoAnnotations.RefCountedType // APIAnnotations - explicit ownership let _ = APIAnnotations.createByRef() - // CHECK: sil [clang APIAnnotations.createByRef] @{{.*}} : $@convention(c) () -> @owned APIAnnotations.RefCountedType + // CHECK: function_ref @{{.*}} : $@convention(c) () -> @owned APIAnnotations.RefCountedType let _ = APIAnnotations.getByRef() - // CHECK: sil [clang APIAnnotations.getByRef] @{{.*}} : $@convention(c) () -> APIAnnotations.RefCountedType + // CHECK: function_ref @{{.*}} : $@convention(c) () -> APIAnnotations.RefCountedType // TypeAnnotation - all unretained due to type default let _ = TypeAnnotation.getByRef() - // CHECK: sil [clang TypeAnnotation.getByRef] @{{.*}} : $@convention(c) () -> TypeAnnotation.RefCountedType + // CHECK: function_ref @{{.*}} : $@convention(c) () -> TypeAnnotation.RefCountedType let _ = TypeAnnotation.createByRef() - // CHECK: sil [clang TypeAnnotation.createByRef] @{{.*}} : $@convention(c) () -> TypeAnnotation.RefCountedType + // CHECK: function_ref @{{.*}} : $@convention(c) () -> TypeAnnotation.RefCountedType let _ = TypeAnnotation.copyByRef() - // CHECK: sil [clang TypeAnnotation.copyByRef] @{{.*}} : $@convention(c) () -> TypeAnnotation.RefCountedType + // CHECK: function_ref @{{.*}} : $@convention(c) () -> TypeAnnotation.RefCountedType // BothAnnotations - API overrides type let _ = BothAnnotations.createByRef() - // CHECK: sil [clang BothAnnotations.createByRef] @{{.*}} : $@convention(c) () -> @owned BothAnnotations.RefCountedType + // CHECK: function_ref @{{.*}} : $@convention(c) () -> @owned BothAnnotations.RefCountedType let _ = BothAnnotations.getByRef() - // CHECK: sil [clang BothAnnotations.getByRef] @{{.*}} : $@convention(c) () -> BothAnnotations.RefCountedType + // CHECK: function_ref @{{.*}} : $@convention(c) () -> BothAnnotations.RefCountedType } + +// CHECK: sil {{.*}}[clang NoAnnotations.getRefCountedByRef] @{{.*}} : $@convention(c) () -> NoAnnotations.RefCountedType +// CHECK: sil {{.*}}[clang NoAnnotations.createRefCountedByRef] @{{.*}} : $@convention(c) () -> NoAnnotations.RefCountedType +// CHECK: sil {{.*}}[clang NoAnnotations.copyRefCountedByRef] @{{.*}} : $@convention(c) () -> NoAnnotations.RefCountedType +// CHECK: sil {{.*}}[clang APIAnnotations.createByRef] @{{.*}} : $@convention(c) () -> @owned APIAnnotations.RefCountedType +// CHECK: sil {{.*}}[clang APIAnnotations.getByRef] @{{.*}} : $@convention(c) () -> APIAnnotations.RefCountedType +// CHECK: sil {{.*}}[clang TypeAnnotation.getByRef] @{{.*}} : $@convention(c) () -> TypeAnnotation.RefCountedType +// CHECK: sil {{.*}}[clang TypeAnnotation.createByRef] @{{.*}} : $@convention(c) () -> TypeAnnotation.RefCountedType +// CHECK: sil {{.*}}[clang TypeAnnotation.copyByRef] @{{.*}} : $@convention(c) () -> TypeAnnotation.RefCountedType +// CHECK: sil {{.*}}[clang BothAnnotations.createByRef] @{{.*}} : $@convention(c) () -> @owned BothAnnotations.RefCountedType +// CHECK: sil {{.*}}[clang BothAnnotations.getByRef] @{{.*}} : $@convention(c) () -> BothAnnotations.RefCountedType diff --git a/test/Interop/Cxx/foreign-reference/move-only-silgen.swift b/test/Interop/Cxx/foreign-reference/move-only-silgen.swift index e4ecd2948b906..f88b8f9d30919 100644 --- a/test/Interop/Cxx/foreign-reference/move-only-silgen.swift +++ b/test/Interop/Cxx/foreign-reference/move-only-silgen.swift @@ -9,13 +9,13 @@ import MoveOnly // CHECK: [[BOX:%.*]] = project_box {{.*}} : ${ var MoveOnly }, 0 -// CHECK: [[CREATE_FN:%.*]] = function_ref @{{_ZN8MoveOnly6createEv|\?create\@MoveOnly\@\@SAPEAU1\@XZ}} : $@convention(c) () -> MoveOnly +// CHECK: [[CREATE_FN:%.*]] = function_ref @$sSo8MoveOnlyV6createAByFZTo : $@convention(c) () -> MoveOnly // CHECK: [[CREATED_PTR:%.*]] = apply [[CREATE_FN]]() : $@convention(c) () -> MoveOnly // CHECK: store [[CREATED_PTR]] to [trivial] [[BOX]] : $*MoveOnly // CHECK: [[ACCESS_1:%.*]] = begin_access [read] [unknown] [[BOX]] : $*MoveOnly // CHECK: [[X_1:%.*]] = load [trivial] [[ACCESS_1]] : $*MoveOnly -// CHECK: [[TEST_FN:%.*]] = function_ref @{{_ZNK8MoveOnly4testEv|\?test\@MoveOnly\@\@QEBAHXZ}} : $@convention(cxx_method) (MoveOnly) -> Int32 +// CHECK: [[TEST_FN:%.*]] = function_ref @$sSo8MoveOnlyV4tests5Int32VyFTo : $@convention(cxx_method) (MoveOnly) -> Int32 // CHECK: apply [[TEST_FN]]([[X_1]]) : $@convention(cxx_method) (MoveOnly) -> Int32 // CHECK: return @@ -25,6 +25,4 @@ public func test() { _ = x.test() } -// CHECK-LABEL: sil{{ \[available .*\] | }}[clang MoveOnly.create] @{{_ZN8MoveOnly6createEv|\?create\@MoveOnly\@\@SAPEAU1\@XZ}} : $@convention(c) () -> MoveOnly - -// CHECK-LABEL: sil{{ \[available .*\] | }}[clang MoveOnly.test] @{{_ZNK8MoveOnly4testEv|\?test\@MoveOnly\@\@QEBAHXZ}} : $@convention(cxx_method) (MoveOnly) -> Int32 +// CHECK-LABEL: sil [available 13.3.0] [asmname "_ZN8MoveOnly6createEv"] [clang MoveOnly.create] @$sSo8MoveOnlyV6createAByFZTo : $@convention(c) () -> MoveOnly diff --git a/test/Interop/Cxx/foreign-reference/pod-silgen.swift b/test/Interop/Cxx/foreign-reference/pod-silgen.swift index c017d4b5dd590..096887c4b62ef 100644 --- a/test/Interop/Cxx/foreign-reference/pod-silgen.swift +++ b/test/Interop/Cxx/foreign-reference/pod-silgen.swift @@ -9,7 +9,7 @@ import POD // CHECK: [[BOX:%.*]] = project_box {{.*}} : ${ var IntPair }, 0 -// CHECK: [[CREATE_FN:%.*]] = function_ref @{{_ZN7IntPair6createEv|\?create\@IntPair\@\@SAPEAU1\@XZ}} : $@convention(c) () -> IntPair +// CHECK: [[CREATE_FN:%.*]] = function_ref @$sSo7IntPairV6createAByFZTo : $@convention(c) () -> IntPair // CHECK: [[CREATED_PTR:%.*]] = apply [[CREATE_FN]]() : $@convention(c) () -> IntPair // CHECK: store [[CREATED_PTR]] to [trivial] [[BOX]] : $*IntPair // CHECK: [[ACCESS_1:%.*]] = begin_access [read] [unknown] [[BOX]] : $*IntPair @@ -21,7 +21,7 @@ import POD // CHECK: [[ACCESS_3:%.*]] = begin_access [read] [unknown] [[BOX]] : $*IntPair // CHECK: [[X_2:%.*]] = load [trivial] [[ACCESS_3]] : $*IntPair -// CHECK: [[TEST_FN:%.*]] = function_ref @{{_ZNK7IntPair4testEv|\?test\@IntPair\@\@QEBAHXZ}} : $@convention(cxx_method) (IntPair) -> Int32 +// CHECK: [[TEST_FN:%.*]] = function_ref @$sSo7IntPairV4tests5Int32VyFTo : $@convention(cxx_method) (IntPair) -> Int32 // CHECK: apply [[TEST_FN]]([[X_2]]) : $@convention(cxx_method) (IntPair) -> Int32 // CHECK: return @@ -32,6 +32,4 @@ public func test() { _ = x.test() } -// CHECK-LABEL: sil{{ \[available .*\] | }}[clang IntPair.create] @{{_ZN7IntPair6createEv|\?create\@IntPair\@\@SAPEAU1\@XZ}} : $@convention(c) () -> IntPair - -// CHECK-LABEL: sil{{ \[available .*\] | }}[clang IntPair.test] @{{_ZNK7IntPair4testEv|\?test\@IntPair\@\@QEBAHXZ}} : $@convention(cxx_method) (IntPair) -> Int32 +// CHECK-LABEL: sil [available 13.3.0] [asmname "_ZN7IntPair6createEv"] [clang IntPair.create] @$sSo7IntPairV6createAByFZTo : $@convention(c) () -> IntPair diff --git a/test/Interop/Cxx/foreign-reference/singleton-silgen.swift b/test/Interop/Cxx/foreign-reference/singleton-silgen.swift index 85a224d38b898..b14f38699ccec 100644 --- a/test/Interop/Cxx/foreign-reference/singleton-silgen.swift +++ b/test/Interop/Cxx/foreign-reference/singleton-silgen.swift @@ -9,18 +9,18 @@ import Singleton // CHECK: [[BOX:%.*]] = project_box {{.*}} : ${ var DeletedSpecialMembers }, 0 -// CHECK: [[CREATE_FN:%.*]] = function_ref @{{_ZN21DeletedSpecialMembers6createEv|\?create\@DeletedSpecialMembers\@\@SAPEAU1\@XZ}} : $@convention(c) () -> DeletedSpecialMembers +// CHECK: [[CREATE_FN:%.*]] = function_ref @$sSo21DeletedSpecialMembersV6createAByFZTo : $@convention(c) () -> DeletedSpecialMembers // CHECK: [[CREATED_PTR:%.*]] = apply [[CREATE_FN]]() : $@convention(c) () -> DeletedSpecialMembers // CHECK: store [[CREATED_PTR]] to [trivial] [[BOX]] : $*DeletedSpecialMembers // CHECK: [[ACCESS_1:%.*]] = begin_access [read] [unknown] [[BOX]] : $*DeletedSpecialMembers // CHECK: [[X_1:%.*]] = load [trivial] [[ACCESS_1]] : $*DeletedSpecialMembers -// CHECK: [[TEST_FN:%.*]] = function_ref @{{_ZNK21DeletedSpecialMembers4testEv|\?test\@DeletedSpecialMembers\@\@QEBAHXZ}} : $@convention(cxx_method) (DeletedSpecialMembers) -> Int32 +// CHECK: [[TEST_FN:%.*]] = function_ref @$sSo21DeletedSpecialMembersV4tests5Int32VyFTo : $@convention(cxx_method) (DeletedSpecialMembers) -> Int32 // CHECK: apply [[TEST_FN]]([[X_1]]) : $@convention(cxx_method) (DeletedSpecialMembers) -> Int32 // CHECK: [[ACCESS_2:%.*]] = begin_access [read] [unknown] [[BOX]] : $*DeletedSpecialMembers // CHECK: [[X_2:%.*]] = load [trivial] [[ACCESS_2]] : $*DeletedSpecialMembers -// CHECK: [[MOVE_IN_RES_FN:%.*]] = function_ref @{{_Z8mutateItR21DeletedSpecialMembers|\?mutateIt\@\@YAXAEAUDeletedSpecialMembers\@\@\@Z}} : $@convention(c) (DeletedSpecialMembers) -> () +// CHECK: [[MOVE_IN_RES_FN:%.*]] = function_ref @$sSo8mutateItyySo21DeletedSpecialMembersVFTo : $@convention(c) (DeletedSpecialMembers) -> () // CHECK: apply [[MOVE_IN_RES_FN]]([[X_2]]) : $@convention(c) (DeletedSpecialMembers) -> () // CHECK: return @@ -31,8 +31,8 @@ public func test() { mutateIt(x) } -// CHECK-LABEL: sil{{ \[available .*\] | }}[clang DeletedSpecialMembers.create] @{{_ZN21DeletedSpecialMembers6createEv|\?create\@DeletedSpecialMembers\@\@SAPEAU1\@XZ}} : $@convention(c) () -> DeletedSpecialMembers +// CHECK-LABEL: sil [available 13.3.0] [asmname "_ZN21DeletedSpecialMembers6createEv"] [clang DeletedSpecialMembers.create] @$sSo21DeletedSpecialMembersV6createAByFZTo : $@convention(c) () -> DeletedSpecialMembers -// CHECK-LABEL: sil{{ \[available .*\] | }}[clang DeletedSpecialMembers.test] @{{_ZNK21DeletedSpecialMembers4testEv|\?test\@DeletedSpecialMembers\@\@QEBAHXZ}} : $@convention(cxx_method) (DeletedSpecialMembers) -> Int32 +// CHECK-LABEL: sil [available 13.3.0] [asmname "_ZNK21DeletedSpecialMembers4testEv"] [clang DeletedSpecialMembers.test] @$sSo21DeletedSpecialMembersV4tests5Int32VyFTo : $@convention(cxx_method) (DeletedSpecialMembers) -> Int32 -// CHECK-LABEL: sil{{ \[available .*\] | }}[serialized] [clang mutateIt] @{{_Z8mutateItR21DeletedSpecialMembers|\?mutateIt\@\@YAXAEAUDeletedSpecialMembers\@\@\@Z}} : $@convention(c) (DeletedSpecialMembers) -> () +// CHECK-LABEL: sil [serialized] [asmname "_Z8mutateItR21DeletedSpecialMembers"] [clang mutateIt] @$sSo8mutateItyySo21DeletedSpecialMembersVFTo : $@convention(c) (DeletedSpecialMembers) -> () diff --git a/test/Interop/Cxx/objc-correctness/call-to-generated-init-with-nsstring.swift b/test/Interop/Cxx/objc-correctness/call-to-generated-init-with-nsstring.swift index ad8ee601a2331..d9fb22a770911 100644 --- a/test/Interop/Cxx/objc-correctness/call-to-generated-init-with-nsstring.swift +++ b/test/Interop/Cxx/objc-correctness/call-to-generated-init-with-nsstring.swift @@ -29,18 +29,18 @@ func testSdump() { testSdump() -// SIL-TRIVIAL: function_ref @_ZNK1S4dumpEv : $@convention(cxx_method) (@in_guaranteed S) -> () +// SIL-TRIVIAL: function_ref @$sSo1SV4dumpyyFTo : $@convention(cxx_method) (@in_guaranteed S) -> () // SIL-TRIVIAL-NEXT: apply %{{.*}}(%{{.*}}) : $@convention(cxx_method) (@in_guaranteed S) -> () // SIL-TRIVIAL: $@convention(objc_method) (@owned S, ClassWithNonTrivialDestructorIvar) -> () // SIL-TRIVIAL-NEXT: apply %{{.*}}(%{{.*}}) : $@convention(objc_method) (@owned S, ClassWithNonTrivialDestructorIvar) -> () -// SIL-TRIVIAL: function_ref @_Z9takeSFunc1S : $@convention(c) (@owned S) -> () +// SIL-TRIVIAL: function_ref @$sSo9takeSFuncyySo1SVFTo : $@convention(c) (@owned S) -> () // SIL-TRIVIAL-NEXT: apply %{{.*}}(%{{.*}}) : $@convention(c) (@owned S) -> () -// SIL-NONTRIVIAL: function_ref @_ZNK1S4dumpEv : $@convention(cxx_method) (@in_guaranteed S) -> () +// SIL-NONTRIVIAL: function_ref @$sSo1SV4dumpyyFTo : $@convention(cxx_method) (@in_guaranteed S) -> () // SIL-NONTRIVIAL-NEXT: apply %{{.*}}(%{{.*}}) : $@convention(cxx_method) (@in_guaranteed S) -> () // SIL-NONTRIVIAL: $@convention(objc_method) (@in_cxx S, ClassWithNonTrivialDestructorIvar) -> () // SIL-NONTRIVIAL-NEXT: apply %{{.*}}(%{{.*}}) : $@convention(objc_method) (@in_cxx S, ClassWithNonTrivialDestructorIvar) -> () -// SIL-NONTRIVIAL: function_ref @_Z9takeSFunc1S : $@convention(c) (@in_cxx S) -> () +// SIL-NONTRIVIAL: function_ref @$sSo9takeSFuncyySo1SVFTo : $@convention(c) (@in_cxx S) -> () // SIL-NONTRIVIAL-NEXT: apply %{{.*}}(%{{.*}}) : $@convention(c) (@in_cxx S) -> () diff --git a/test/Interop/Cxx/operators/member-inline-silgen.swift b/test/Interop/Cxx/operators/member-inline-silgen.swift index 4f8fd1a9cec17..af789b6ca8ad3 100644 --- a/test/Interop/Cxx/operators/member-inline-silgen.swift +++ b/test/Interop/Cxx/operators/member-inline-silgen.swift @@ -24,33 +24,33 @@ public func call(_ wrapper: inout LoadableIntWrapper, _ arg: Int32) -> Int32 { w // CHECK: bb0([[SELF:%.*]] : $*LoadableIntWrapper, [[RHS:%.*]] : $Int32): // CHECK: [[SELFACCESS:%.*]] = begin_access [modify] [static] [[SELF]] : $*LoadableIntWrapper -// CHECK: [[OP:%.*]] = function_ref [[NAME:@(_ZN18LoadableIntWrapperclEi|\?\?RLoadableIntWrapper@@QEAAHH@Z)]] : $@convention(cxx_method) (Int32, @inout LoadableIntWrapper) -> Int32 +// CHECK: [[OP:%.*]] = function_ref @$sSo18LoadableIntWrapperV14callAsFunctionys5Int32VAEFTo : $@convention(cxx_method) (Int32, @inout LoadableIntWrapper) -> Int32 // CHECK: apply [[OP]]([[RHS]], [[SELFACCESS]]) : $@convention(cxx_method) (Int32, @inout LoadableIntWrapper) -> Int32 // CHECK: end_access [[SELFACCESS]] : $*LoadableIntWrapper -// CHECK: sil [clang LoadableIntWrapper.callAsFunction] [[NAME]] : $@convention(cxx_method) (Int32, @inout LoadableIntWrapper) -> Int32 +// CHECK: sil [asmname "_ZN18LoadableIntWrapperclEi"] [clang LoadableIntWrapper.callAsFunction] @$sSo18LoadableIntWrapperV14callAsFunctionys5Int32VAEFTo : $@convention(cxx_method) (Int32, @inout LoadableIntWrapper) -> Int32 public func call(_ wrapper: inout AddressOnlyIntWrapper) -> Int32 { wrapper() } // CHECK: bb0([[SELF:%.*]] : $*AddressOnlyIntWrapper): // CHECK: [[SELFACCESS:%.*]] = begin_access [modify] [static] [[SELF]] : $*AddressOnlyIntWrapper -// CHECK: [[OP:%.*]] = function_ref [[NAME:@(_ZN21AddressOnlyIntWrapperclEv|\?\?RAddressOnlyIntWrapper@@QEAAHXZ)]] : $@convention(cxx_method) (@inout AddressOnlyIntWrapper) -> Int32 +// CHECK: [[OP:%.*]] = function_ref @$sSo21AddressOnlyIntWrapperV14callAsFunctions5Int32VyFTo : $@convention(cxx_method) (@inout AddressOnlyIntWrapper) -> Int32 // CHECK: apply [[OP]]([[SELFACCESS]]) : $@convention(cxx_method) (@inout AddressOnlyIntWrapper) -> Int32 // CHECK: end_access [[SELFACCESS]] : $*AddressOnlyIntWrapper -// CHECK: sil [clang AddressOnlyIntWrapper.callAsFunction] [[NAME]] : $@convention(cxx_method) (@inout AddressOnlyIntWrapper) -> Int32 +// CHECK: sil [asmname "_ZN21AddressOnlyIntWrapperclEv"] [clang AddressOnlyIntWrapper.callAsFunction] @$sSo21AddressOnlyIntWrapperV14callAsFunctions5Int32VyFTo : $@convention(cxx_method) (@inout AddressOnlyIntWrapper) -> Int32 public func index(_ arr: ReadOnlyIntArray, _ arg: Int32) -> Int32 { arr[arg] } // CHECK: sil @$s4main5indexys5Int32VSo16ReadOnlyIntArrayV_ADtF : $@convention(thin) (@in_guaranteed ReadOnlyIntArray, Int32) -> Int32 { // CHECK: bb0([[ARR:%.*]] : $*ReadOnlyIntArray, [[INDEX:%.*]] : $Int32): -// CHECK: [[OP:%.*]] = function_ref [[READCLASSNAME:@(_ZNK16ReadOnlyIntArrayixEi|\?\?AReadOnlyIntArray@@QEBAAEBHH@Z)]] : $@convention(cxx_method) (Int32, @in_guaranteed ReadOnlyIntArray) -> UnsafePointer +// CHECK: [[OP:%.*]] = function_ref @$sSo16ReadOnlyIntArrayV24__operatorSubscriptConstySPys5Int32VGAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed ReadOnlyIntArray) -> UnsafePointer // CHECK: [[PTR:%.*]] = apply [[OP]]([[INDEX]], [[ARRACCESS:%.*]]) : $@convention(cxx_method) (Int32, @in_guaranteed ReadOnlyIntArray) -> UnsafePointer // CHECK: } // end sil function '$s4main5indexys5Int32VSo16ReadOnlyIntArrayV_ADtF' // CHECK: sil shared [transparent] @$sSo16ReadOnlyIntArrayVys5Int32VADcig : $@convention(method) (Int32, @in_guaranteed ReadOnlyIntArray) -> Int32 { // CHECK: bb0([[INDEX:%.*]] : $Int32, [[SELF:%.*]] : $*ReadOnlyIntArray): -// CHECK: [[OP:%.*]] = function_ref [[READCLASSNAME]] : $@convention(cxx_method) (Int32, @in_guaranteed ReadOnlyIntArray) -> UnsafePointer +// CHECK: [[OP:%.*]] = function_ref @$sSo16ReadOnlyIntArrayV24__operatorSubscriptConstySPys5Int32VGAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed ReadOnlyIntArray) -> UnsafePointer // CHECK: [[PTR:%.*]] = apply [[OP]]([[INDEX]], [[SELFACCESS:%.*]]) : $@convention(cxx_method) (Int32, @in_guaranteed ReadOnlyIntArray) -> UnsafePointer // CHECK: [[PTR2:%.*]] = struct_extract [[PTR]] : $UnsafePointer, #UnsafePointer._rawValue // CHECK: pointer_to_address [[PTR2]] : $Builtin.RawPointer to [strict] $*Int32 @@ -62,14 +62,14 @@ public func index(_ arr: inout ReadWriteIntArray, _ arg: Int32, _ val: Int32) { // CHECK: bb0([[ARR:%.*]] : $*ReadWriteIntArray, [[INDEX:%.*]] : $Int32, [[NEWVALUE:%.*]] : $Int32): // CHECK: [[ARRACCESS:%.*]] = begin_access [modify] [static] [[ARR]] : $*ReadWriteIntArray // CHECK: [[ARRACCESS2:%.*]] = begin_access [modify] [static] [[ARRACCESS]] : $*ReadWriteIntArray -// CHECK: [[OP:%.*]] = function_ref [[READWRITECLASSNAME:@(_ZN17ReadWriteIntArrayixEi|\?\?AReadWriteIntArray@@QEAAAEAHH@Z)]] : $@convention(cxx_method) (Int32, @inout ReadWriteIntArray) -> UnsafeMutablePointer +// CHECK: [[OP:%.*]] = function_ref @$sSo17ReadWriteIntArrayV19__operatorSubscriptySpys5Int32VGAEFTo : $@convention(cxx_method) (Int32, @inout ReadWriteIntArray) -> UnsafeMutablePointer // CHECK: [[PTR:%.*]] = apply [[OP]]([[INDEX]], [[ARRACCESS2]]) : $@convention(cxx_method) (Int32, @inout ReadWriteIntArray) -> UnsafeMutablePointer // CHECK: } // end sil function '$s4main5indexyySo17ReadWriteIntArrayVz_s5Int32VAFtF' // CHECK: sil shared [transparent] @$sSo17ReadWriteIntArrayVys5Int32VADcis : $@convention(method) (Int32, Int32, @inout ReadWriteIntArray) -> () { // CHECK: bb0([[NEWVALUE:%.*]] : $Int32, [[INDEX:%.*]] : $Int32, [[SELF:%.*]] : $*ReadWriteIntArray): // CHECK: [[SELFACCESS:%.*]] = begin_access [modify] [static] [[SELF]] : $*ReadWriteIntArray -// CHECK: [[OP:%.*]] = function_ref [[READWRITECLASSNAME]] : $@convention(cxx_method) (Int32, @inout ReadWriteIntArray) -> UnsafeMutablePointer +// CHECK: [[OP:%.*]] = function_ref @$sSo17ReadWriteIntArrayV19__operatorSubscriptySpys5Int32VGAEFTo : $@convention(cxx_method) (Int32, @inout ReadWriteIntArray) -> UnsafeMutablePointer // CHECK: [[PTR:%.*]] = apply [[OP]]([[INDEX]], [[SELFACCESS]]) : $@convention(cxx_method) (Int32, @inout ReadWriteIntArray) -> UnsafeMutablePointer // CHECK: end_access [[SELFACCESS]] : $*ReadWriteIntArray // CHECK: [[PTR2:%.*]] = struct_extract [[PTR]] : $UnsafeMutablePointer, #UnsafeMutablePointer._rawValue @@ -80,13 +80,13 @@ public func index(_ arr: inout NonTrivialIntArrayByVal, _ arg: Int32, _ val: Int // CHECK: sil @$s4main5indexys5Int32VSo23NonTrivialIntArrayByValVz_A2DtF : $@convention(thin) (@inout NonTrivialIntArrayByVal, Int32, Int32) -> Int32 { // CHECK: bb0([[ARR:%.*]] : $*NonTrivialIntArrayByVal, [[INDEX:%.*]] : $Int32, [[NEWVALUE:%.*]] : $Int32): -// CHECK: [[OP:%.*]] = function_ref [[READWRITECLASSNAMEBYVAL:@(_ZNK23NonTrivialIntArrayByValixEi|\?\?ANonTrivialIntArrayByVal@@QEBAHH@Z)]] : $@convention(cxx_method) (Int32, @in_guaranteed NonTrivialIntArrayByVal) -> Int32 +// CHECK: [[OP:%.*]] = function_ref @$sSo23NonTrivialIntArrayByValV24__operatorSubscriptConstys5Int32VAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed NonTrivialIntArrayByVal) -> Int32 // CHECK: [[PTR:%.*]] = apply [[OP]]([[INDEX]], [[ARRACCESS:%.*]]) : $@convention(cxx_method) (Int32, @in_guaranteed NonTrivialIntArrayByVal) -> Int32 // CHECK: } // end sil function '$s4main5indexys5Int32VSo23NonTrivialIntArrayByValVz_A2DtF' // CHECK: sil shared [transparent] @$sSo23NonTrivialIntArrayByValVys5Int32VADcig : $@convention(method) (Int32, @in_guaranteed NonTrivialIntArrayByVal) -> Int32 { // CHECK: bb0([[NEWVALUE:%.*]] : $Int32, [[INDEX:%.*]] : $*NonTrivialIntArrayByVal): -// CHECK: [[OP:%.*]] = function_ref [[READWRITECLASSNAMEBYVAL]] : $@convention(cxx_method) (Int32, @in_guaranteed NonTrivialIntArrayByVal) -> Int32 +// CHECK: [[OP:%.*]] = function_ref @$sSo23NonTrivialIntArrayByValV24__operatorSubscriptConstys5Int32VAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed NonTrivialIntArrayByVal) -> Int32 // CHECK: [[PTR:%.*]] = apply [[OP]]([[NEWVALUE]], [[SELFACCESS:%.*]]) : $@convention(cxx_method) (Int32, @in_guaranteed NonTrivialIntArrayByVal) -> Int32 // CHECK: } // end sil function '$sSo23NonTrivialIntArrayByValVys5Int32VADcig @@ -95,14 +95,14 @@ public func index(_ arr: inout PtrByVal, _ arg: Int32, _ val: Int32) -> Int32 { // CHECK: bb0([[ARR:%.*]] : $*PtrByVal, [[INDEX:%.*]] : $Int32, [[NEWVALUE:%.*]] : $Int32): // CHECK: [[ARRACCESS:%.*]] = begin_access [modify] [static] [[ARR]] : $*PtrByVal // CHECK: [[ARRACCESS2:%.*]] = begin_access [modify] [static] [[ARRACCESS]] : $*PtrByVal -// CHECK: [[OP:%.*]] = function_ref [[PTRBYVAL:@(_ZN8PtrByValixEi|\?\?APtrByVal@@QEAAPEAHH@Z)]] : $@convention(cxx_method) (Int32, @inout PtrByVal) -> Optional> +// CHECK: [[OP:%.*]] = function_ref @$sSo8PtrByValV19__operatorSubscriptySpys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @inout PtrByVal) -> Optional> // CHECK: [[PTR:%.*]] = apply [[OP]]([[INDEX]], [[ARRACCESS2]]) : $@convention(cxx_method) (Int32, @inout PtrByVal) -> Optional> // CHECK: } // end sil function '$s4main5indexys5Int32VSo8PtrByValVz_A2DtF' // CHECK: sil shared [transparent] @$sSo8PtrByValVySpys5Int32VGSgADcig : $@convention(method) (Int32, @inout PtrByVal) -> Optional> { // CHECK: bb0([[NEWVALUE:%.*]] : $Int32, [[INDEX:%.*]] : $*PtrByVal): // CHECK: [[SELFACCESS:%.*]] = begin_access [modify] [static] [[INDEX]] : $*PtrByVal -// CHECK: [[OP:%.*]] = function_ref [[PTRBYVAL]] : $@convention(cxx_method) (Int32, @inout PtrByVal) -> Optional> +// CHECK: [[OP:%.*]] = function_ref @$sSo8PtrByValV19__operatorSubscriptySpys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @inout PtrByVal) -> Optional> // CHECK: [[PTR:%.*]] = apply [[OP]]([[NEWVALUE]], [[SELFACCESS]]) : $@convention(cxx_method) (Int32, @inout PtrByVal) -> Optional> // CHECK: end_access [[SELFACCESS]] : $*PtrByVal // CHECK: } // end sil function '$sSo8PtrByValVySpys5Int32VGSgADcig @@ -112,14 +112,14 @@ public func index(_ arr: inout RefToPtr, _ arg: Int32, _ val: Int32) -> Int32 { // CHECK: bb0([[ARR:%.*]] : $*RefToPtr, [[INDEX:%.*]] : $Int32, [[NEWVALUE:%.*]] : $Int32): // CHECK: [[ARRACCESS:%.*]] = begin_access [modify] [static] [[ARR]] : $*RefToPtr // CHECK: [[ARRACCESS2:%.*]] = begin_access [modify] [static] [[ARRACCESS]] : $*RefToPtr -// CHECK: [[OP:%.*]] = function_ref [[REFTOPTR:@(_ZN8RefToPtrixEi|\?\?ARefToPtr@@QEAAAEAPEAHH@Z)]] : $@convention(cxx_method) (Int32, @inout RefToPtr) -> UnsafeMutablePointer>> +// CHECK: [[OP:%.*]] = function_ref @$sSo8RefToPtrV19__operatorSubscriptySpySpys5Int32VGSgGAEFTo : $@convention(cxx_method) (Int32, @inout RefToPtr) -> UnsafeMutablePointer>> // CHECK: [[PTR:%.*]] = apply [[OP]]([[INDEX]], [[ARRACCESS2]]) : $@convention(cxx_method) (Int32, @inout RefToPtr) -> UnsafeMutablePointer>> // CHECK: } // end sil function '$s4main5indexys5Int32VSo8RefToPtrVz_A2DtF' // CHECK: sil shared [transparent] @$sSo8RefToPtrVySpys5Int32VGSgADcig : $@convention(method) (Int32, @inout RefToPtr) -> Optional> { // CHECK: bb0([[NEWVALUE:%.*]] : $Int32, [[INDEX:%.*]] : $*RefToPtr): // CHECK: [[SELFACCESS:%.*]] = begin_access [modify] [static] [[INDEX]] : $*RefToPtr -// CHECK: [[OP:%.*]] = function_ref [[REFTOPTR]] : $@convention(cxx_method) (Int32, @inout RefToPtr) -> UnsafeMutablePointer>> +// CHECK: [[OP:%.*]] = function_ref @$sSo8RefToPtrV19__operatorSubscriptySpySpys5Int32VGSgGAEFTo : $@convention(cxx_method) (Int32, @inout RefToPtr) -> UnsafeMutablePointer>> // CHECK: [[PTR:%.*]] = apply [[OP]]([[NEWVALUE]], [[SELFACCESS]]) : $@convention(cxx_method) (Int32, @inout RefToPtr) -> UnsafeMutablePointer>> // CHECK: end_access [[SELFACCESS]] : $*RefToPtr // CHECK: } // end sil function '$sSo8RefToPtrVySpys5Int32VGSgADcig @@ -129,14 +129,14 @@ public func index(_ arr: inout PtrToPtr, _ arg: Int32, _ val: Int32) -> Int32 { // CHECK: bb0([[ARR:%.*]] : $*PtrToPtr, [[INDEX:%.*]] : $Int32, [[NEWVALUE:%.*]] : $Int32): // CHECK: [[ARRACCESS:%.*]] = begin_access [modify] [static] [[ARR]] : $*PtrToPtr // CHECK: [[ARRACCESS2:%.*]] = begin_access [modify] [static] [[ARRACCESS]] : $*PtrToPtr -// CHECK: [[OP:%.*]] = function_ref [[PTRTOPTR:@(_ZN8PtrToPtrixEi|\?\?APtrToPtr@@QEAAPEAPEAHH@Z)]] : $@convention(cxx_method) (Int32, @inout PtrToPtr) -> Optional>>> +// CHECK: [[OP:%.*]] = function_ref @$sSo05PtrToA0V19__operatorSubscriptySpySpys5Int32VGSgGSgAEFTo : $@convention(cxx_method) (Int32, @inout PtrToPtr) -> Optional>>> // CHECK: [[PTR:%.*]] = apply [[OP]]([[INDEX]], [[ARRACCESS2]]) : $@convention(cxx_method) (Int32, @inout PtrToPtr) -> Optional>>> // CHECK: } // end sil function '$s4main5indexys5Int32VSo05PtrToD0Vz_A2DtF' // CHECK: sil shared [transparent] @$sSo05PtrToA0VySpySpys5Int32VGSgGSgADcig : $@convention(method) (Int32, @inout PtrToPtr) -> Optional>>> { // CHECK: bb0([[NEWVALUE:%.*]] : $Int32, [[INDEX:%.*]] : $*PtrToPtr): // CHECK: [[SELFACCESS:%.*]] = begin_access [modify] [static] [[INDEX]] : $*PtrToPtr -// CHECK: [[OP:%.*]] = function_ref [[PTRTOPTR]] : $@convention(cxx_method) (Int32, @inout PtrToPtr) -> Optional>>> +// CHECK: [[OP:%.*]] = function_ref @$sSo05PtrToA0V19__operatorSubscriptySpySpys5Int32VGSgGSgAEFTo : $@convention(cxx_method) (Int32, @inout PtrToPtr) -> Optional>>> // CHECK: [[PTR:%.*]] = apply [[OP]]([[NEWVALUE]], [[SELFACCESS]]) : $@convention(cxx_method) (Int32, @inout PtrToPtr) -> Optional>>> // CHECK: end_access [[SELFACCESS]] : $*PtrToPtr // CHECK: } // end sil function '$sSo05PtrToA0VySpySpys5Int32VGSgGSgADcig @@ -144,13 +144,13 @@ public func index(_ arr: inout PtrToPtr, _ arg: Int32, _ val: Int32) -> Int32 { public func index(_ arr: ConstOpPtrByVal, _ arg: Int32, _ val: Int32) -> Int32 { arr[arg]![0] } // CHECK: sil @$s4main5indexys5Int32VSo15ConstOpPtrByValV_A2DtF : $@convention(thin) (ConstOpPtrByVal, Int32, Int32) -> Int32 { // CHECK: bb0([[ARR:%.*]] : $ConstOpPtrByVal, [[INDEX:%.*]] : $Int32, [[NEWVALUE:%.*]] : $Int32): -// CHECK: [[OP:%.*]] = function_ref [[CONSTOPPTRBYVAL:@(_ZNK15ConstOpPtrByValixEi|\?\?AConstOpPtrByVal@@QEBAPEBHH@Z)]] : $@convention(cxx_method) (Int32, @in_guaranteed ConstOpPtrByVal) -> Optional> +// CHECK: [[OP:%.*]] = function_ref @$sSo15ConstOpPtrByValV019__operatorSubscriptA0ySPys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed ConstOpPtrByVal) -> Optional> // CHECK: [[PTR:%.*]] = apply [[OP]]([[INDEX]], [[ARRACCESS2:%.*]]) : $@convention(cxx_method) (Int32, @in_guaranteed ConstOpPtrByVal) -> Optional> // CHECK: } // end sil function '$s4main5indexys5Int32VSo15ConstOpPtrByValV_A2DtF' // CHECK: sil shared [transparent] @$sSo15ConstOpPtrByValVySPys5Int32VGSgADcig : $@convention(method) (Int32, ConstOpPtrByVal) -> Optional> { // CHECK: bb0([[NEWVALUE:%.*]] : $Int32, [[INDEX:%.*]] : $ConstOpPtrByVal): -// CHECK: [[OP:%.*]] = function_ref [[CONSTOPPTRBYVAL]] : $@convention(cxx_method) (Int32, @in_guaranteed ConstOpPtrByVal) -> Optional> +// CHECK: [[OP:%.*]] = function_ref @$sSo15ConstOpPtrByValV019__operatorSubscriptA0ySPys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed ConstOpPtrByVal) -> Optional> // CHECK: [[PTR:%.*]] = apply [[OP]]([[NEWVALUE]], [[SELFACCESS:%.*]]) : $@convention(cxx_method) (Int32, @in_guaranteed ConstOpPtrByVal) -> Optional> // CHECK: } // end sil function '$sSo15ConstOpPtrByValVySPys5Int32VGSgADcig @@ -159,14 +159,14 @@ public func index(_ arr: inout ConstPtrByVal, _ arg: Int32, _ val: Int32) -> Int // CHECK: bb0([[ARR:%.*]] : $*ConstPtrByVal, [[INDEX:%.*]] : $Int32, [[NEWVALUE:%.*]] : $Int32): // CHECK: [[ARRACCESS:%.*]] = begin_access [modify] [static] [[ARR]] : $*ConstPtrByVal // CHECK: [[ARRACCESS2:%.*]] = begin_access [modify] [static] [[ARRACCESS]] : $*ConstPtrByVal -// CHECK: [[OP:%.*]] = function_ref [[CONSTPTRBYVAL:@(_ZN13ConstPtrByValixEi|\?\?AConstPtrByVal@@QEAAPEBHH@Z)]] : $@convention(cxx_method) (Int32, @inout ConstPtrByVal) -> Optional> +// CHECK: [[OP:%.*]] = function_ref @$sSo13ConstPtrByValV019__operatorSubscriptA0ySPys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @inout ConstPtrByVal) -> Optional> // CHECK: [[PTR:%.*]] = apply [[OP]]([[INDEX]], [[ARRACCESS2]]) : $@convention(cxx_method) (Int32, @inout ConstPtrByVal) -> Optional> // CHECK: } // end sil function '$s4main5indexys5Int32VSo13ConstPtrByValVz_A2DtF' // CHECK: sil shared [transparent] @$sSo13ConstPtrByValVySPys5Int32VGSgADcig : $@convention(method) (Int32, @inout ConstPtrByVal) -> Optional> { // CHECK: bb0([[NEWVALUE:%.*]] : $Int32, [[INDEX:%.*]] : $*ConstPtrByVal): // CHECK: [[SELFACCESS:%.*]] = begin_access [modify] [static] [[INDEX]] : $*ConstPtrByVal -// CHECK: [[OP:%.*]] = function_ref [[CONSTPTRBYVAL]] : $@convention(cxx_method) (Int32, @inout ConstPtrByVal) -> Optional> +// CHECK: [[OP:%.*]] = function_ref @$sSo13ConstPtrByValV019__operatorSubscriptA0ySPys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @inout ConstPtrByVal) -> Optional> // CHECK: [[PTR:%.*]] = apply [[OP]]([[NEWVALUE]], [[SELFACCESS]]) : $@convention(cxx_method) (Int32, @inout ConstPtrByVal) -> Optional> // CHECK: end_access [[SELFACCESS]] : $*ConstPtrByVal // CHECK: } // end sil function '$sSo13ConstPtrByValVySPys5Int32VGSgADcig @@ -175,17 +175,17 @@ public func subscriptUnnamed(_ unnamed: SubscriptUnnamedParameter, _ arg: Int32) // CHECK: sil shared [transparent] @$sSo25SubscriptUnnamedParameterVys5Int32VADcig : $@convention(method) (Int32, SubscriptUnnamedParameter) -> Int32 { // CHECK: bb0([[INDEX:%.*]] : $Int32, [[SELF:%.*]] : $SubscriptUnnamedParameter): // CHECK: [[SELFACCESS:%.*]] = alloc_stack $SubscriptUnnamedParameter -// CHECK: [[OP:%.*]] = function_ref [[OPERATORNAME:@(_ZNK25SubscriptUnnamedParameterixEi|\?\?ASubscriptUnnamedParameter@@QEBAHH@Z)]] : $@convention(cxx_method) (Int32, @in_guaranteed SubscriptUnnamedParameter) -> Int32 +// CHECK: [[OP:%.*]] = function_ref @$sSo25SubscriptUnnamedParameterV010__operatorA5Constys5Int32VAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed SubscriptUnnamedParameter) -> Int32 // CHECK: [[PTR:%.*]] = apply [[OP]]([[INDEX]], [[SELFACCESS]]) : $@convention(cxx_method) (Int32, @in_guaranteed SubscriptUnnamedParameter) -> Int32 // CHECK: dealloc_stack [[SELFACCESS]] // CHECK: } // end sil function '$sSo25SubscriptUnnamedParameterVys5Int32VADcig' -// CHECK: sil [clang ReadOnlyIntArray.__operatorSubscriptConst] [[READCLASSNAME]] : $@convention(cxx_method) (Int32, @in_guaranteed ReadOnlyIntArray) -> UnsafePointer -// CHECK: sil [clang ReadWriteIntArray.__operatorSubscript] [[READWRITECLASSNAME]] : $@convention(cxx_method) (Int32, @inout ReadWriteIntArray) -> UnsafeMutablePointer -// CHECK: sil [clang NonTrivialIntArrayByVal.__operatorSubscriptConst] [[READWRITECLASSNAMEBYVAL]] : $@convention(cxx_method) (Int32, @in_guaranteed NonTrivialIntArrayByVal) -> Int32 +// CHECK: sil [asmname "_ZNK16ReadOnlyIntArrayixEi"] [clang ReadOnlyIntArray.__operatorSubscriptConst] @$sSo16ReadOnlyIntArrayV24__operatorSubscriptConstySPys5Int32VGAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed ReadOnlyIntArray) -> UnsafePointer +// CHECK: sil [asmname "_ZN17ReadWriteIntArrayixEi"] [clang ReadWriteIntArray.__operatorSubscript] @$sSo17ReadWriteIntArrayV19__operatorSubscriptySpys5Int32VGAEFTo : $@convention(cxx_method) (Int32, @inout ReadWriteIntArray) -> UnsafeMutablePointer +// CHECK: sil [asmname "_ZNK23NonTrivialIntArrayByValixEi"] [clang NonTrivialIntArrayByVal.__operatorSubscriptConst] @$sSo23NonTrivialIntArrayByValV24__operatorSubscriptConstys5Int32VAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed NonTrivialIntArrayByVal) -> Int32 -// CHECK: sil [clang PtrByVal.__operatorSubscript] [[PTRBYVAL]] : $@convention(cxx_method) (Int32, @inout PtrByVal) -> Optional> -// CHECK: sil [clang RefToPtr.__operatorSubscript] [[REFTOPTR]] : $@convention(cxx_method) (Int32, @inout RefToPtr) -> UnsafeMutablePointer>> -// CHECK: sil [clang PtrToPtr.__operatorSubscript] [[PTRTOPTR]] : $@convention(cxx_method) (Int32, @inout PtrToPtr) -> Optional>>> -// CHECK: sil [clang ConstOpPtrByVal.__operatorSubscriptConst] [[CONSTOPPTRBYVAL]] : $@convention(cxx_method) (Int32, @in_guaranteed ConstOpPtrByVal) -> Optional> -// CHECK: sil [clang ConstPtrByVal.__operatorSubscriptConst] [[CONSTPTRBYVAL]] : $@convention(cxx_method) (Int32, @inout ConstPtrByVal) -> Optional> +// CHECK: sil [asmname "_ZN8PtrByValixEi"] [clang PtrByVal.__operatorSubscript] @$sSo8PtrByValV19__operatorSubscriptySpys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @inout PtrByVal) -> Optional> +// CHECK: sil [asmname "_ZN8RefToPtrixEi"] [clang RefToPtr.__operatorSubscript] @$sSo8RefToPtrV19__operatorSubscriptySpySpys5Int32VGSgGAEFTo : $@convention(cxx_method) (Int32, @inout RefToPtr) -> UnsafeMutablePointer>> +// CHECK: sil [asmname "_ZN8PtrToPtrixEi"] [clang PtrToPtr.__operatorSubscript] @$sSo05PtrToA0V19__operatorSubscriptySpySpys5Int32VGSgGSgAEFTo : $@convention(cxx_method) (Int32, @inout PtrToPtr) -> Optional>>> +// CHECK: sil [asmname "_ZNK15ConstOpPtrByValixEi"] [clang ConstOpPtrByVal.__operatorSubscriptConst] @$sSo15ConstOpPtrByValV019__operatorSubscriptA0ySPys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed ConstOpPtrByVal) -> Optional> +// CHECK: sil [asmname "_ZN13ConstPtrByValixEi"] [clang ConstPtrByVal.__operatorSubscriptConst] @$sSo13ConstPtrByValV019__operatorSubscriptA0ySPys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @inout ConstPtrByVal) -> Optional> diff --git a/test/Interop/Cxx/operators/member-out-of-line-silgen.swift b/test/Interop/Cxx/operators/member-out-of-line-silgen.swift index 81c4d5071099f..8a7ca5496a889 100644 --- a/test/Interop/Cxx/operators/member-out-of-line-silgen.swift +++ b/test/Interop/Cxx/operators/member-out-of-line-silgen.swift @@ -6,14 +6,14 @@ public func add(_ lhs: LoadableIntWrapper, _ rhs: LoadableIntWrapper) -> Loadabl // CHECK-SYSV: bb0([[LHS:%.*]] : $LoadableIntWrapper, [[RHS:%.*]] : $LoadableIntWrapper): // CHECK-SYSV: store [[LHS]] to [[STORE_LOC:%.*]] : $*LoadableIntWrapper -// CHECK-SYSV: [[FUNC:%.*]] = function_ref [[NAME:@_ZNK18LoadableIntWrapperplES_]] : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper +// CHECK-SYSV: [[FUNC:%.*]] = function_ref @$sSo18LoadableIntWrapperV14__operatorPlusyA2BFTo : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper // CHECK-SYSV: apply [[FUNC]]([[ACCESS:%.*]], [[STORE_LOC]]) : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper -// CHECK-SYSV: sil [clang LoadableIntWrapper.__operatorPlus] [[NAME]] : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper +// CHECK-SYSV: sil [asmname "_ZNK18LoadableIntWrapperplES_"] [clang LoadableIntWrapper.__operatorPlus] @$sSo18LoadableIntWrapperV14__operatorPlusyA2BFTo : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper // CHECK-WIN: bb0([[LHS:%.*]] : $LoadableIntWrapper, [[RHS:%.*]] : $LoadableIntWrapper): // CHECK-WIN: store [[LHS]] to [[STORE_LOC:%.*]] : $*LoadableIntWrapper -// CHECK-WIN: [[FUNC:%.*]] = function_ref [[NAME:@\?\?HLoadableIntWrapper@@QEBA\?AU0@U0@@Z]] : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper +// CHECK-WIN: [[FUNC:%.*]] = function_ref @$sSo18LoadableIntWrapperV14__operatorPlusyA2BFTo : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper // CHECK-WIN: apply [[FUNC]]([[ACCESS:%.*]], [[STORE_LOC]]) : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper -// CHECK-WIN: sil [clang LoadableIntWrapper.__operatorPlus] [[NAME]] : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper +// CHECK-WIN: sil [asmname "_ZNK18LoadableIntWrapperplES_"] [clang LoadableIntWrapper.__operatorPlus] @$sSo18LoadableIntWrapperV14__operatorPlusyA2BFTo : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper diff --git a/test/Interop/Cxx/operators/non-member-out-of-line-silgen.swift b/test/Interop/Cxx/operators/non-member-out-of-line-silgen.swift index 196c6619a8750..2246668a11acd 100644 --- a/test/Interop/Cxx/operators/non-member-out-of-line-silgen.swift +++ b/test/Interop/Cxx/operators/non-member-out-of-line-silgen.swift @@ -4,7 +4,7 @@ import NonMemberOutOfLine public func add(_ lhs: LoadableIntWrapper, _ rhs: LoadableIntWrapper) -> LoadableIntWrapper { lhs + rhs } -// CHECK: [[COUNTER:%.*]] = function_ref [[NAME:@(_Zpl18LoadableIntWrapperS_|\?\?H@YA\?AULoadableIntWrapper@@U0@0@Z)]] : $@convention(c) (LoadableIntWrapper, LoadableIntWrapper) -> LoadableIntWrapper +// CHECK: [[COUNTER:%.*]] = function_ref @$sSo1poiySo18LoadableIntWrapperVAC_ACtFTo : $@convention(c) (LoadableIntWrapper, LoadableIntWrapper) -> LoadableIntWrapper // CHECK: apply [[COUNTER]](%0, %1) : $@convention(c) (LoadableIntWrapper, LoadableIntWrapper) -> LoadableIntWrapper -// CHECK: sil [clang "+"] [[NAME]] : $@convention(c) (LoadableIntWrapper, LoadableIntWrapper) -> LoadableIntWrapper +// CHECK: sil [asmname "{{(_Zpl18LoadableIntWrapperS_|\?\?H@YA\?AULoadableIntWrapper@@U0@0@Z)}}"] [clang "+"] @$sSo1poiySo18LoadableIntWrapperVAC_ACtFTo : $@convention(c) (LoadableIntWrapper, LoadableIntWrapper) -> LoadableIntWrapper diff --git a/test/Interop/Cxx/reference/const-ref-parameter.swift b/test/Interop/Cxx/reference/const-ref-parameter.swift index 390cbf827fa4d..d9d07bc4ed98d 100644 --- a/test/Interop/Cxx/reference/const-ref-parameter.swift +++ b/test/Interop/Cxx/reference/const-ref-parameter.swift @@ -52,18 +52,18 @@ func testFunction() { // CHECK-NEXT: apply [[FN4]] // CHECK-SAME: : $@convention(objc_method) (@in_guaranteed OptionsStruct, @objc_metatype OptionsConsumerObjC.Type) -> Int32 -// CHECK: [[FN5:%[0-9]+]] = function_ref @_ZN18OptionsConsumerCxxC1ERK13OptionsStruct : $@convention(c) (@in_guaranteed OptionsStruct) -> @out OptionsConsumerCxx +// CHECK: [[FN5:%[0-9]+]] = function_ref @$sSo18OptionsConsumerCxxVyABSo0A6StructVcfCTo : $@convention(c) (@in_guaranteed OptionsStruct) -> @out OptionsConsumerCxx // CHECK-NEXT: apply [[FN5]] // CHECK-SAME: : $@convention(c) (@in_guaranteed OptionsStruct) -> @out OptionsConsumerCxx -// CHECK: [[FN6:%[0-9]+]] = function_ref @_ZN18OptionsConsumerCxx12doOtherThingERK13OptionsStruct : $@convention(cxx_method) (@in_guaranteed OptionsStruct, @inout OptionsConsumerCxx) -> Float +// CHECK: [[FN6:%[0-9]+]] = function_ref @$sSo18OptionsConsumerCxxV12doOtherThingySfSo0A6StructVFTo : $@convention(cxx_method) (@in_guaranteed OptionsStruct, @inout OptionsConsumerCxx) -> Float // CHECK-NEXT: apply [[FN6]] // CHECK-SAME: : $@convention(cxx_method) (@in_guaranteed OptionsStruct, @inout OptionsConsumerCxx) -> Float -// CHECK: [[FN6:%[0-9]+]] = function_ref @_ZN18OptionsConsumerCxx5buildERK13OptionsStruct : $@convention(c) (@in_guaranteed OptionsStruct) -> OptionsConsumerCxx +// CHECK: [[FN6:%[0-9]+]] = function_ref @$sSo18OptionsConsumerCxxV5buildyABSo0A6StructVFZTo : $@convention(c) (@in_guaranteed OptionsStruct) -> OptionsConsumerCxx // CHECK-NEXT: apply [[FN6]] // CHECK-SAME: : $@convention(c) (@in_guaranteed OptionsStruct) -> OptionsConsumerCxx -// CHECK: [[FN7:%[0-9]+]] = function_ref @_ZN18OptionsConsumerCxx7doThingERK13OptionsStruct : $@convention(c) (@in_guaranteed OptionsStruct) -> Int32 +// CHECK: [[FN7:%[0-9]+]] = function_ref @$sSo18OptionsConsumerCxxV7doThingys5Int32VSo0A6StructVFZTo : $@convention(c) (@in_guaranteed OptionsStruct) -> Int32 // CHECK-NEXT: apply [[FN7]] // CHECK-SAME: : $@convention(c) (@in_guaranteed OptionsStruct) -> Int32 diff --git a/test/Interop/Cxx/reference/reference-silgen-cxx-objc-ctors+init.swift b/test/Interop/Cxx/reference/reference-silgen-cxx-objc-ctors+init.swift index 28502b8e4e06a..dc89b1e3f4b5f 100644 --- a/test/Interop/Cxx/reference/reference-silgen-cxx-objc-ctors+init.swift +++ b/test/Interop/Cxx/reference/reference-silgen-cxx-objc-ctors+init.swift @@ -8,7 +8,7 @@ var b = IntWrapper(a) var c = ObjCSwiftBridge(embedded: b) // FIXME: the const-ref C++ Constructor here is not getting an @in_guaranteed or even an @in convention here. -// CHECK: {{%[0-9]+}} = function_ref @_ZN10IntWrapperC1ERKi : $@convention(c) (@in_guaranteed Int32) -> @out IntWrapper +// CHECK: {{%[0-9]+}} = function_ref @$sSo10IntWrapperVyABs5Int32VcfCTo : $@convention(c) (@in_guaranteed Int32) -> @out IntWrapper // CHECK: {{%[0-9]+}} = apply {{%[0-9]+}}({{%[0-9]+}}, {{%[0-9]+}}) : $@convention(c) (@in_guaranteed Int32) -> @out IntWrapper // CHECK: alloc_global @$s4main1cSo15ObjCSwiftBridgeCSgvp // CHECK: {{%[0-9]+}} = global_addr @$s4main1cSo15ObjCSwiftBridgeCSgvp : $*Optional diff --git a/test/Interop/Cxx/reference/reference-silgen.swift b/test/Interop/Cxx/reference/reference-silgen.swift index 5fbb50158a41d..df21d41067d5e 100644 --- a/test/Interop/Cxx/reference/reference-silgen.swift +++ b/test/Interop/Cxx/reference/reference-silgen.swift @@ -7,7 +7,7 @@ func getCxxRef() -> UnsafeMutablePointer { } // CHECK: sil hidden @$s4main9getCxxRefSpys5Int32VGyF : $@convention(thin) () -> UnsafeMutablePointer -// CHECK: [[REF:%.*]] = function_ref @{{_Z15getStaticIntRefv|\?getStaticIntRef@@YAAEAHXZ}} : $@convention(c) () -> UnsafeMutablePointer +// CHECK: [[REF:%.*]] = function_ref @$sSo15getStaticIntRefSpys5Int32VGyFTo : $@convention(c) () -> UnsafeMutablePointer // CHECK: apply [[REF]]() : $@convention(c) () -> UnsafeMutablePointer func getConstCxxRef() -> UnsafePointer { @@ -15,7 +15,7 @@ func getConstCxxRef() -> UnsafePointer { } // CHECK: sil hidden @$s4main14getConstCxxRefSPys5Int32VGyF : $@convention(thin) () -> UnsafePointer -// CHECK: [[REF:%.*]] = function_ref @{{_Z20getConstStaticIntRefv|\?getConstStaticIntRef@@YAAEBHXZ}} : $@convention(c) () -> UnsafePointer +// CHECK: [[REF:%.*]] = function_ref @$sSo20getConstStaticIntRefSPys5Int32VGyFTo : $@convention(c) () -> UnsafePointer // CHECK: apply [[REF]]() : $@convention(c) () -> UnsafePointer func getCxxRvalueRef() -> UnsafeMutablePointer { @@ -23,7 +23,7 @@ func getCxxRvalueRef() -> UnsafeMutablePointer { } // CHECK: sil hidden @$s4main15getCxxRvalueRefSpys5Int32VGyF : $@convention(thin) () -> UnsafeMutablePointer -// CHECK: [[REF:%.*]] = function_ref @{{_Z21getStaticIntRvalueRefv|\?getStaticIntRvalueRef@@YA\$\$QEAHXZ}} : $@convention(c) () -> UnsafeMutablePointer +// CHECK: [[REF:%.*]] = function_ref @$sSo21getStaticIntRvalueRefSpys5Int32VGyFTo : $@convention(c) () -> UnsafeMutablePointer // CHECK: apply [[REF]]() : $@convention(c) () -> UnsafeMutablePointer func getConstCxxRvalueRef() -> UnsafePointer { @@ -31,7 +31,7 @@ func getConstCxxRvalueRef() -> UnsafePointer { } // CHECK: sil hidden @$s4main20getConstCxxRvalueRefSPys5Int32VGyF : $@convention(thin) () -> UnsafePointer -// CHECK: [[REF:%.*]] = function_ref @{{_Z26getConstStaticIntRvalueRefv|\?getConstStaticIntRvalueRef@@YA\$\$QEBHXZ}} : $@convention(c) () -> UnsafePointer +// CHECK: [[REF:%.*]] = function_ref @$sSo26getConstStaticIntRvalueRefSPys5Int32VGyFTo : $@convention(c) () -> UnsafePointer // CHECK: apply [[REF]]() : $@convention(c) () -> UnsafePointer func setCxxRef() { @@ -40,7 +40,7 @@ func setCxxRef() { } // CHECK: sil hidden @$s4main9setCxxRefyyF : $@convention(thin) () -> () -// CHECK: [[REF:%.*]] = function_ref @{{_Z15setStaticIntRefRi|\?setStaticIntRef@@YAXAEAH@Z}} : $@convention(c) (@inout Int32) -> () +// CHECK: [[REF:%.*]] = function_ref @$sSo15setStaticIntRefyys5Int32VzFTo : $@convention(c) (@inout Int32) -> () // CHECK: apply [[REF]](%{{[0-9]+}}) : $@convention(c) (@inout Int32) -> () func setCxxConstRef() { @@ -49,7 +49,7 @@ func setCxxConstRef() { } // CHECK: sil hidden @$s4main14setCxxConstRefyyF : $@convention(thin) () -> () -// CHECK: [[REF:%.*]] = function_ref @{{_Z20setConstStaticIntRefRKi|\?setConstStaticIntRef@@YAXAEBH@Z}} : $@convention(c) (@in_guaranteed Int32) -> () +// CHECK: [[REF:%.*]] = function_ref @$sSo20setConstStaticIntRefyys5Int32VFTo : $@convention(c) (@in_guaranteed Int32) -> () // CHECK: apply [[REF]](%{{[0-9]+}}) : $@convention(c) (@in_guaranteed Int32) -> () func setCxxConstRefTypealias() { @@ -58,7 +58,7 @@ func setCxxConstRefTypealias() { } // CHECK: sil hidden @$s4main23setCxxConstRefTypealiasyyF : $@convention(thin) () -> () -// CHECK: [[REF:%.*]] = function_ref @{{_Z29setConstStaticIntRefTypealiasRKi|\?setConstStaticIntRefTypealias@@YAXAEBH@Z}} : $@convention(c) (@in_guaranteed Int32) -> () +// CHECK: [[REF:%.*]] = function_ref @$sSo29setConstStaticIntRefTypealiasyys5Int32VFTo : $@convention(c) (@in_guaranteed Int32) -> () // CHECK: apply [[REF]](%{{[0-9]+}}) : $@convention(c) (@in_guaranteed Int32) -> () func setStaticIntRefTypealias() { @@ -67,5 +67,5 @@ func setStaticIntRefTypealias() { } // CHECK: sil hidden @$s4main24setStaticIntRefTypealiasyyF : $@convention(thin) () -> () -// CHECK: [[REF:%.*]] = function_ref @{{_Z24setStaticIntRefTypealiasRi|\?setStaticIntRefTypealias@@YAXAEAH@Z}} : $@convention(c) (@inout Int32) -> () +// CHECK: [[REF:%.*]] = function_ref @$sSo24setStaticIntRefTypealiasyys5Int32VzFTo : $@convention(c) (@inout Int32) -> () // CHECK: apply [[REF]](%{{[0-9]+}}) : $@convention(c) (@inout Int32) -> () diff --git a/test/Interop/Cxx/static/static-member-func-silgen.swift b/test/Interop/Cxx/static/static-member-func-silgen.swift index 46accdf00e2db..785db8c87b097 100644 --- a/test/Interop/Cxx/static/static-member-func-silgen.swift +++ b/test/Interop/Cxx/static/static-member-func-silgen.swift @@ -7,20 +7,20 @@ func callStaticMemberFunc() -> CInt { } // CHECK: sil hidden @$s4main20callStaticMemberFuncs5Int32VyF : $@convention(thin) () -> Int32 { -// CHECK: [[FUNC:%.*]] = function_ref @{{_ZN20WithStaticMemberFunc16staticMemberFuncEv|\?staticMemberFunc@WithStaticMemberFunc@@SAHXZ}} : $@convention(c) () -> Int32 +// CHECK: [[FUNC:%.*]] = function_ref @$sSo20WithStaticMemberFuncV06staticcD0s5Int32VyFZTo : $@convention(c) () -> Int32 // CHECK: [[VALUE:%.*]] = apply [[FUNC]]() : $@convention(c) () -> Int32 // CHECK: return [[VALUE]] : $Int32 // CHECK: // clang name: WithStaticMemberFunc::staticMemberFunc -// CHECK: sil [clang WithStaticMemberFunc.staticMemberFunc] @{{_ZN20WithStaticMemberFunc16staticMemberFuncEv|\?staticMemberFunc@WithStaticMemberFunc@@SAHXZ}} : $@convention(c) () -> Int32 +// CHECK: sil [asmname "_ZN20WithStaticMemberFunc16staticMemberFuncEv"] [clang WithStaticMemberFunc.staticMemberFunc] @$sSo20WithStaticMemberFuncV06staticcD0s5Int32VyFZTo : $@convention(c) () -> Int32 func callStaticMemberFuncAddr() -> CInt { return WithStaticMemberFunc.getStaticMemberFuncAddress()!() } // CHECK: sil hidden @$s4main24callStaticMemberFuncAddrs5Int32VyF : $@convention(thin) () -> Int32 -// CHECK: [[FUNC:%.*]] = function_ref @{{_ZN20WithStaticMemberFunc26getStaticMemberFuncAddressEv|\?getStaticMemberFuncAddress@WithStaticMemberFunc@@SAP6AHXZXZ}} : $@convention(c) () -> Optional<@convention(c) () -> Int32> +// CHECK: [[FUNC:%.*]] = function_ref @$sSo20WithStaticMemberFuncV03getbcD7Addresss5Int32VyXCSgyFZTo : $@convention(c) () -> Optional<@convention(c) () -> Int32> // CHECK: [[VALUE:%.*]] = apply [[FUNC]]() : $@convention(c) () -> Optional<@convention(c) () -> Int32> // CHECK: // clang name: WithStaticMemberFunc::getStaticMemberFuncAddress -// CHECK: sil [clang WithStaticMemberFunc.getStaticMemberFuncAddress] @{{_ZN20WithStaticMemberFunc26getStaticMemberFuncAddressEv|\?getStaticMemberFuncAddress@WithStaticMemberFunc@@SAP6AHXZXZ}} : $@convention(c) () -> Optional<@convention(c) () -> Int32> +// CHECK: sil [asmname "_ZN20WithStaticMemberFunc26getStaticMemberFuncAddressEv"] [clang WithStaticMemberFunc.getStaticMemberFuncAddress] @$sSo20WithStaticMemberFuncV03getbcD7Addresss5Int32VyXCSgyFZTo : $@convention(c) () -> Optional<@convention(c) () -> Int32> diff --git a/test/Interop/Cxx/templates/function-template-silgen.swift b/test/Interop/Cxx/templates/function-template-silgen.swift index 5a0a93f63b6a8..b4e1f330505ca 100644 --- a/test/Interop/Cxx/templates/function-template-silgen.swift +++ b/test/Interop/Cxx/templates/function-template-silgen.swift @@ -7,16 +7,16 @@ import FunctionTemplates // CHECK: bb0(%0 : $Int32): // CHECK: [[IL_ZERO:%.*]] = integer_literal $Builtin.Int32, 0 // CHECK: [[ZERO:%.*]] = struct $Int32 ([[IL_ZERO]] : $Builtin.Int32) -// CHECK: [[PASS_THROUGH_CONST_FN:%.*]] = function_ref @{{_Z16passThroughConstIiEKT_S0_|\?\?\$passThroughConst@H@@YA\?BHH@Z}} : $@convention(c) (Int32) -> Int32 +// CHECK: [[PASS_THROUGH_CONST_FN:%.*]] = function_ref @$sSo16passThroughConstys5Int32VACFTo : $@convention(c) (Int32) -> Int32 // CHECK: [[A:%.*]] = apply [[PASS_THROUGH_CONST_FN]]([[ZERO]]) : $@convention(c) (Int32) -> Int32 -// CHECK: [[PASS_THROUGH_FN:%.*]] = function_ref @{{_Z11passThroughIiET_S0_|\?\?\$passThrough@H@@YAHH@Z}} : $@convention(c) (Int32) -> Int32 +// CHECK: [[PASS_THROUGH_FN:%.*]] = function_ref @$sSo11passThroughys5Int32VACFTo : $@convention(c) (Int32) -> Int32 // CHECK: [[B:%.*]] = apply [[PASS_THROUGH_FN]](%0) : $@convention(c) (Int32) -> Int32 -// CHECK: [[ADD_TWO_FN:%.*]] = function_ref @{{_Z18addMixedTypeParamsIiiET_S0_T0_|\?\?\$addMixedTypeParams@HH@@YAHHH@Z}} : $@convention(c) (Int32, Int32) -> Int32 +// CHECK: [[ADD_TWO_FN:%.*]] = function_ref @$sSo18addMixedTypeParamsys5Int32VAC_ACtFTo : $@convention(c) (Int32, Int32) -> Int32 // CHECK: [[C:%.*]] = apply [[ADD_TWO_FN]]([[A]], [[B]]) : $@convention(c) (Int32, Int32) -> Int32 -// CHECK: [[ADD_FN:%.*]] = function_ref @{{_Z17addSameTypeParamsIiET_S0_S0_|\?\?\$addSameTypeParams@H@@YAHHH@Z}} : $@convention(c) (Int32, Int32) -> Int32 +// CHECK: [[ADD_FN:%.*]] = function_ref @$sSo17addSameTypeParamsys5Int32VAC_ACtFTo : $@convention(c) (Int32, Int32) -> Int32 // CHECK: [[OUT:%.*]] = apply [[ADD_FN]]([[B]], [[C_32:%.*]]) : $@convention(c) (Int32, Int32) -> Int32 // CHECK: return [[OUT]] : $Int32 diff --git a/test/Interop/Cxx/templates/member-templates-silgen.swift b/test/Interop/Cxx/templates/member-templates-silgen.swift index cbcea5ec3f174..036c5424ff7ab 100644 --- a/test/Interop/Cxx/templates/member-templates-silgen.swift +++ b/test/Interop/Cxx/templates/member-templates-silgen.swift @@ -4,16 +4,16 @@ import MemberTemplates // CHECK-LABEL: sil hidden @$s4main9basicTestyyF : $@convention(thin) () -> () -// CHECK: [[ADD:%.*]] = function_ref @{{_ZN18HasMemberTemplates17addSameTypeParamsIiEET_S1_S1_|\?\?\$addSameTypeParams@H@HasMemberTemplates@@QEAAHHH@Z}} : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 +// CHECK: [[ADD:%.*]] = function_ref @$sSo18HasMemberTemplatesV17addSameTypeParamsys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 // CHECK: apply [[ADD]]({{.*}}) : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 -// CHECK: [[ADD_TWO_TEMPLATES:%.*]] = function_ref @{{_ZN18HasMemberTemplates18addMixedTypeParamsIiiEET_S1_T0_|\?\?\$addMixedTypeParams@HH@HasMemberTemplates@@QEAAHHH@Z}} : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 +// CHECK: [[ADD_TWO_TEMPLATES:%.*]] = function_ref @$sSo18HasMemberTemplatesV18addMixedTypeParamsys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 // CHECK: apply [[ADD_TWO_TEMPLATES]]({{.*}}) : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 -// CHECK: [[ADD_ALL:%.*]] = function_ref @{{_ZN18HasMemberTemplates6addAllIiiEEiiT_T0_|\?\?\$addAll@HH@HasMemberTemplates@@QEAAHHHH@Z}} : $@convention(cxx_method) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32 +// CHECK: [[ADD_ALL:%.*]] = function_ref @$sSo18HasMemberTemplatesV6addAllys5Int32VAE_A2EtFTo : $@convention(cxx_method) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32 // CHECK: apply [[ADD_ALL]]({{.*}}) : $@convention(cxx_method) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32 -// CHECK: [[DO_NOTHING:%.*]] = function_ref @{{_ZN18HasMemberTemplates17doNothingConstRefIiEEvRKT_|\?\?\$doNothingConstRef@H@HasMemberTemplates@@QEAAXAEBH@Z}} : $@convention(cxx_method) (@in_guaranteed Int32, @inout HasMemberTemplates) -> () +// CHECK: [[DO_NOTHING:%.*]] = function_ref @$sSo18HasMemberTemplatesV17doNothingConstRefyys5Int32VFTo : $@convention(cxx_method) (@in_guaranteed Int32, @inout HasMemberTemplates) -> () // CHECK: apply [[DO_NOTHING]]({{.*}}) : $@convention(cxx_method) (@in_guaranteed Int32, @inout HasMemberTemplates) -> () // CHECK-LABEL: end sil function '$s4main9basicTestyyF' @@ -26,17 +26,17 @@ func basicTest() { obj.doNothingConstRef(i) } -// CHECK-LABEL: sil [clang HasMemberTemplates.addSameTypeParams] @{{_ZN18HasMemberTemplates17addSameTypeParamsIiEET_S1_S1_|\?\?\$addSameTypeParams@H@HasMemberTemplates@@QEAAHHH@Z}} : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 +// CHECK-LABEL: sil [asmname "_ZN18HasMemberTemplates17addSameTypeParamsIiEET_S1_S1_"] [clang HasMemberTemplates.addSameTypeParams] @$sSo18HasMemberTemplatesV17addSameTypeParamsys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 -// CHECK-LABEL: sil [clang HasMemberTemplates.addMixedTypeParams] @{{_ZN18HasMemberTemplates18addMixedTypeParamsIiiEET_S1_T0_|\?\?\$addMixedTypeParams@HH@HasMemberTemplates@@QEAAHHH@Z}} : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 +// CHECK-LABEL: sil [asmname "_ZN18HasMemberTemplates18addMixedTypeParamsIiiEET_S1_T0_"] [clang HasMemberTemplates.addMixedTypeParams] @$sSo18HasMemberTemplatesV18addMixedTypeParamsys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 -// CHECK-LABEL: sil [clang HasMemberTemplates.addAll] @{{_ZN18HasMemberTemplates6addAllIiiEEiiT_T0_|\?\?\$addAll@HH@HasMemberTemplates@@QEAAHHHH@Z}} : $@convention(cxx_method) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32 +// CHECK-LABEL: sil [asmname "_ZN18HasMemberTemplates6addAllIiiEEiiT_T0_"] [clang HasMemberTemplates.addAll] @$sSo18HasMemberTemplatesV6addAllys5Int32VAE_A2EtFTo : $@convention(cxx_method) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32 -// CHECK-LABEL: sil [clang HasMemberTemplates.doNothingConstRef] @{{_ZN18HasMemberTemplates17doNothingConstRefIiEEvRKT_|\?\?\$doNothingConstRef@H@HasMemberTemplates@@QEAAXAEBH@Z}} : $@convention(cxx_method) (@in_guaranteed Int32, @inout HasMemberTemplates) -> () +// CHECK-LABEL: sil [asmname "_ZN18HasMemberTemplates17doNothingConstRefIiEEvRKT_"] [clang HasMemberTemplates.doNothingConstRef] @$sSo18HasMemberTemplatesV17doNothingConstRefyys5Int32VFTo : $@convention(cxx_method) (@in_guaranteed Int32, @inout HasMemberTemplates) -> () // CHECK-LABEL: sil hidden @$s4main12testSetValueyyF : $@convention(thin) () -> () -// CHECK: [[SET_VALUE:%.*]] = function_ref @{{_ZN32TemplateClassWithMemberTemplatesIiE8setValueIlEEvT_|\?\?\$setValue@_J@\?\$TemplateClassWithMemberTemplates@H@@QEAAX_J@Z}} : $@convention(cxx_method) (Int, @inout TemplateClassWithMemberTemplates) -> () +// CHECK: [[SET_VALUE:%.*]] = function_ref @$sSo0044TemplateClassWithMemberTemplatesCInt_CeCInkcV8setValueyySiFTo : $@convention(cxx_method) (Int, @inout TemplateClassWithMemberTemplates) -> () // CHECK: apply [[SET_VALUE]]({{.*}}) : $@convention(cxx_method) (Int, @inout TemplateClassWithMemberTemplates) -> () // CHECK-LABEL: end sil function '$s4main12testSetValueyyF' @@ -47,13 +47,13 @@ func testSetValue() { // CHECK-LABEL: sil hidden @$s4main17testStaticMembersyyF : $@convention(thin) () -> () -// CHECK: [[ADD_FN:%.*]] = function_ref @{{_ZN24HasStaticMemberTemplates3addIlEET_S1_S1_|\?\?\$add@_J@HasStaticMemberTemplates@@SA_J_J0@Z}} : $@convention(c) (Int, Int) -> Int +// CHECK: [[ADD_FN:%.*]] = function_ref @$sSo24HasStaticMemberTemplatesV3addyS2i_SitFZTo : $@convention(c) (Int, Int) -> Int // CHECK: apply [[ADD_FN]]({{.*}}) : $@convention(c) (Int, Int) -> Int -// CHECK: [[ADD_TWO_TEMPLATES_FN:%.*]] = function_ref @{{_ZN24HasStaticMemberTemplates15addTwoTemplatesIlcEET_S1_T0_|\?\?\$addTwoTemplates@_JD@HasStaticMemberTemplates@@SA_J_JD@Z}} : $@convention(c) (Int, Int8) -> Int +// CHECK: [[ADD_TWO_TEMPLATES_FN:%.*]] = function_ref @$sSo24HasStaticMemberTemplatesV06addTwoD0yS2i_s4Int8VtFZTo : $@convention(c) (Int, Int8) -> Int // CHECK: apply [[ADD_TWO_TEMPLATES_FN]]({{.*}}) : $@convention(c) (Int, Int8) -> Int -// CHECK: [[REMOVE_REFERENCE_FN:%.*]] = function_ref @{{_ZN24HasStaticMemberTemplates15removeReferenceIlEET_RS1_|\?\?\$removeReference@_J@HasStaticMemberTemplates@@SA_JAEA_J@Z}} : $@convention(c) (@inout Int) -> Int +// CHECK: [[REMOVE_REFERENCE_FN:%.*]] = function_ref @$sSo24HasStaticMemberTemplatesV15removeReferenceyS2izFZTo : $@convention(c) (@inout Int) -> Int // CHECK: apply [[REMOVE_REFERENCE_FN]]({{.*}}) : $@convention(c) (@inout Int) -> Int // CHECK-LABEL: end sil function '$s4main17testStaticMembersyyF' @@ -65,8 +65,8 @@ func testStaticMembers() { HasStaticMemberTemplates.removeReference(&x) } -// CHECK: sil hidden_external [clang HasStaticMemberTemplates.add] @{{_ZN24HasStaticMemberTemplates3addIlEET_S1_S1_|\?\?\$add@_J@HasStaticMemberTemplates@@SA_J_J0@Z}} : $@convention(c) (Int, Int) -> Int +// CHECK: sil hidden_external [asmname "_ZN24HasStaticMemberTemplates3addIlEET_S1_S1_"] [clang HasStaticMemberTemplates.add] @$sSo24HasStaticMemberTemplatesV3addyS2i_SitFZTo : $@convention(c) (Int, Int) -> Int -// CHECK: sil hidden_external [clang HasStaticMemberTemplates.addTwoTemplates] @{{_ZN24HasStaticMemberTemplates15addTwoTemplatesIlcEET_S1_T0_|\?\?\$addTwoTemplates@_JD@HasStaticMemberTemplates@@SA_J_JD@Z}} : $@convention(c) (Int, Int8) -> Int +// CHECK: sil hidden_external [asmname "_ZN24HasStaticMemberTemplates15addTwoTemplatesIlcEET_S1_T0_"] [clang HasStaticMemberTemplates.addTwoTemplates] @$sSo24HasStaticMemberTemplatesV06addTwoD0yS2i_s4Int8VtFZTo : $@convention(c) (Int, Int8) -> Int -// CHECK: sil hidden_external [clang HasStaticMemberTemplates.removeReference] @{{_ZN24HasStaticMemberTemplates15removeReferenceIlEET_RS1_|\?\?\$removeReference@_J@HasStaticMemberTemplates@@SA_JAEA_J@Z}} : $@convention(c) (@inout Int) -> Int +// CHECK: sil hidden_external [asmname "_ZN24HasStaticMemberTemplates15removeReferenceIlEET_RS1_"] [clang HasStaticMemberTemplates.removeReference] @$sSo24HasStaticMemberTemplatesV15removeReferenceyS2izFZTo : $@convention(c) (@inout Int) -> Int diff --git a/test/Interop/Cxx/templates/partially-pre-defined-class-template-silgen.swift b/test/Interop/Cxx/templates/partially-pre-defined-class-template-silgen.swift index 67c2b496fc175..de636c3032eef 100644 --- a/test/Interop/Cxx/templates/partially-pre-defined-class-template-silgen.swift +++ b/test/Interop/Cxx/templates/partially-pre-defined-class-template-silgen.swift @@ -12,10 +12,6 @@ public func getWrappedMagicInt() -> CInt { // CHECK: sil @$s4main18getWrappedMagicInts5Int32VyF : $@convention(thin) () -> Int32 { // CHECK: [[INT_WRAPPER:%.*]] = struct $IntWrapper ([[_:%.*]] : $Int32) // CHECK: [[_:%.*]] = struct $MagicWrapper ([[INT_WRAPPER]] : $IntWrapper) -// CHECK: // function_ref {{_ZNK12MagicWrapperI10IntWrapperE15getValuePlusArgEi|\?getValuePlusArg@\?\$MagicWrapper@UIntWrapper@@@@QEBAHH@Z}} -// CHECK: [[_:%.*]] = function_ref @{{_ZNK12MagicWrapperI10IntWrapperE15getValuePlusArgEi|\?getValuePlusArg@\?\$MagicWrapper@UIntWrapper@@@@QEBAHH@Z}} : $@convention(cxx_method) (Int32, @in_guaranteed MagicWrapper) -> Int32 +// CHECK: [[_:%.*]] = function_ref @$sSo0030MagicWrapperIntWrapper_bHAFhxbV15getValuePlusArgys5Int32VAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed MagicWrapper) -> Int32 -// CHECK: // {{_ZNK12MagicWrapperI10IntWrapperE15getValuePlusArgEi|\?getValuePlusArg@\?\$MagicWrapper@UIntWrapper@@@@QEBAHH@Z}} -// CHECK: MagicWrapper::getValuePlusArg - -// CHECK: sil [clang MagicWrapper.getValuePlusArg] @{{_ZNK12MagicWrapperI10IntWrapperE15getValuePlusArgEi|\?getValuePlusArg@\?\$MagicWrapper@UIntWrapper@@@@QEBAHH@Z}} : $@convention(cxx_method) (Int32, @in_guaranteed MagicWrapper) -> Int32 +// CHECK: sil {{.*}}[clang MagicWrapper.getValuePlusArg] @$sSo0030MagicWrapperIntWrapper_bHAFhxbV15getValuePlusArgys5Int32VAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed MagicWrapper) -> Int32 diff --git a/test/Interop/SwiftToCxxToSwift/import-swift-class-back-to-swift.swift b/test/Interop/SwiftToCxxToSwift/import-swift-class-back-to-swift.swift index f2d8c9f044723..0bd9df0311d1d 100644 --- a/test/Interop/SwiftToCxxToSwift/import-swift-class-back-to-swift.swift +++ b/test/Interop/SwiftToCxxToSwift/import-swift-class-back-to-swift.swift @@ -90,9 +90,9 @@ testSwiftClassInClass() #endif // SIL-LABEL: @$s8SwiftMod04testa14ClassFromCxxInA0yyF : $@convention(thin) () -> () -// SIL: function_ref @{{_Z21createSwiftClassInCxxv|"\?createSwiftClassInCxx@@YA?AVExposedToCxx@SwiftMod@@XZ"}} : $@convention(c) () -> @owned ExposedToCxx +// SIL: function_ref @$sSo21createSwiftClassInCxx0B3Mod09ExposedToE0CyFTo : $@convention(c) () -> @owned ExposedToCxx // SIL: apply {{.*}} : $@convention(c) () -> @owned ExposedToCxx -// SIL: function_ref @{{_Z19passSwiftClassToCxxN8SwiftMod12ExposedToCxxE|"\?passSwiftClassToCxx@@YAXVExposedToCxx@SwiftMod@@@Z"}} : $@convention(c) (@in_guaranteed ExposedToCxx) -> () +// SIL: function_ref @$sSo19passSwiftClassToCxxyy0B3Mod07ExposeddE0CFTo : $@convention(c) (@in_guaranteed ExposedToCxx) -> () // SIL: apply {{.*}} : $@convention(c) (@in_guaranteed ExposedToCxx) -> () // SIL-LABEL: @$s8SwiftMod04testa7ClassInD0yyF : $@convention(thin) () -> () { diff --git a/test/SILGen/availability_query_custom_domains_clang.swift b/test/SILGen/availability_query_custom_domains_clang.swift index 71beb7399605a..b3272fa000166 100644 --- a/test/SILGen/availability_query_custom_domains_clang.swift +++ b/test/SILGen/availability_query_custom_domains_clang.swift @@ -12,10 +12,10 @@ public func testIfAvailableEnabledDomain() { // CHECK: cond_br [[PRED]], [[TRUE_BB:bb[0-9]+]], [[FALSE_BB:bb[0-9]+]] // CHECK: [[TRUE_BB]]: - // CHECK: function_ref @available_in_enabled_domain + // CHECK: function_ref @$sSo27available_in_enabled_domainyyFTo // CHECK: [[FALSE_BB]]: - // CHECK: function_ref @unavailable_in_enabled_domain + // CHECK: function_ref @$sSo29unavailable_in_enabled_domainyyFTo if #available(EnabledDomain) { available_in_enabled_domain() } else { @@ -31,10 +31,10 @@ public func testIfUnavailableEnabledDomain() { // CHECK: cond_br [[PRED]], [[TRUE_BB:bb[0-9]+]], [[FALSE_BB:bb[0-9]+]] // CHECK: [[TRUE_BB]]: - // CHECK: function_ref @unavailable_in_enabled_domain + // CHECK: function_ref @$sSo29unavailable_in_enabled_domainyyFTo // CHECK: [[FALSE_BB]]: - // CHECK: function_ref @available_in_enabled_domain + // CHECK: function_ref @$sSo27available_in_enabled_domainyyFTo if #unavailable(EnabledDomain) { unavailable_in_enabled_domain() } else { @@ -50,10 +50,10 @@ public func testIfAvailableDisabledDomain() { // CHECK: cond_br [[PRED]], [[TRUE_BB:bb[0-9]+]], [[FALSE_BB:bb[0-9]+]] // CHECK: [[TRUE_BB]]: - // CHECK: function_ref @available_in_disabled_domain + // CHECK: function_ref @$sSo28available_in_disabled_domainyyFTo // CHECK: [[FALSE_BB]]: - // CHECK: function_ref @unavailable_in_disabled_domain + // CHECK: function_ref @$sSo30unavailable_in_disabled_domainyyFTo if #available(DisabledDomain) { available_in_disabled_domain() } else { @@ -69,10 +69,10 @@ public func testIfUnavailableDisabledDomain() { // CHECK: cond_br [[PRED]], [[TRUE_BB:bb[0-9]+]], [[FALSE_BB:bb[0-9]+]] // CHECK: [[TRUE_BB]]: - // CHECK: function_ref @unavailable_in_disabled_domain + // CHECK: function_ref @$sSo30unavailable_in_disabled_domainyyFTo // CHECK: [[FALSE_BB]]: - // CHECK: function_ref @available_in_disabled_domain + // CHECK: function_ref @$sSo28available_in_disabled_domainyyFTo if #unavailable(DisabledDomain) { unavailable_in_disabled_domain() } else { @@ -89,10 +89,10 @@ public func testIfAvailableDynamicDomain() { // CHECK: cond_br [[QUERY_RESULT]], [[TRUE_BB:bb[0-9]+]], [[FALSE_BB:bb[0-9]+]] // CHECK: [[TRUE_BB]]: - // CHECK: function_ref @available_in_dynamic_domain + // CHECK: function_ref @$sSo27available_in_dynamic_domainyyFTo // CHECK: [[FALSE_BB]]: - // CHECK: function_ref @unavailable_in_dynamic_domain + // CHECK: function_ref @$sSo29unavailable_in_dynamic_domainyyFTo if #available(DynamicDomain) { available_in_dynamic_domain() } else { @@ -103,7 +103,7 @@ public func testIfAvailableDynamicDomain() { // CHECK-LABEL: sil non_abi [serialized] [ossa] @$sSC33__swift_DynamicDomain_isAvailableBi1_yF : $@convention(thin) () -> Builtin.Int1 // CHECK: bb0: -// CHECK: [[QUERY_FUNC:%.*]] = function_ref @__DynamicDomain_isAvailable : $@convention(c) () -> Bool +// CHECK: [[QUERY_FUNC:%.*]] = function_ref @$sSo27__DynamicDomain_isAvailableSbyFTo : $@convention(c) () -> Bool // CHECK: [[QUERY_RESULT:%.*]] = apply [[QUERY_FUNC]]() : $@convention(c) () -> Bool // CHECK: [[RESULT:%.*]] = struct_extract [[QUERY_RESULT]], #Bool._value // CHECK: return [[RESULT]] @@ -119,10 +119,10 @@ public func testIfUnavailableDynamicDomain() { // CHECK: cond_br [[QUERY_INVERSION]], [[TRUE_BB:bb[0-9]+]], [[FALSE_BB:bb[0-9]+]] // CHECK: [[TRUE_BB]]: - // CHECK: function_ref @unavailable_in_dynamic_domain + // CHECK: function_ref @$sSo29unavailable_in_dynamic_domainyyFTo // CHECK: [[FALSE_BB]]: - // CHECK: function_ref @available_in_dynamic_domain + // CHECK: function_ref @$sSo27available_in_dynamic_domainyyFTo if #unavailable(DynamicDomain) { unavailable_in_dynamic_domain() } else { diff --git a/test/SILGen/cdecl.swift b/test/SILGen/cdecl.swift index a42de840936b5..5c60a392537f0 100644 --- a/test/SILGen/cdecl.swift +++ b/test/SILGen/cdecl.swift @@ -1,6 +1,6 @@ // RUN: %target-swift-emit-silgen %s | %FileCheck %s -// CHECK-LABEL: sil hidden [thunk] [ossa] @pear : $@convention(c) +// CHECK-LABEL: sil hidden [thunk] [asmname "pear"] [ossa] @$s5cdecl5apple{{[_0-9a-zA-Z]*}}FTo : $@convention(c) // CHECK: function_ref @$s5cdecl5apple{{[_0-9a-zA-Z]*}}F // CHECK-LABEL: sil hidden [ossa] @$s5cdecl5apple{{[_0-9a-zA-Z]*}}F @_cdecl("pear") @@ -8,12 +8,12 @@ func apple(_ f: @convention(c) (Int) -> Int) { } // CHECK-LABEL: sil hidden [ossa] @$s5cdecl16forceCEntryPoint{{[_0-9a-zA-Z]*}}F -// CHECK: function_ref @grapefruit +// CHECK: function_ref @$s5cdecl6orange{{[_0-9a-zA-Z]*}}FTo func forceCEntryPoint() { apple(orange) } -// CHECK-LABEL: sil hidden [thunk] [ossa] @grapefruit : $@convention(c) +// CHECK-LABEL: sil hidden [thunk] [asmname "grapefruit"] [ossa] @$s5cdecl6orange{{[_0-9a-zA-Z]*}}FTo : $@convention(c) // CHECK: function_ref @$s5cdecl6orange{{[_0-9a-zA-Z]*}}F // CHECK-LABEL: sil hidden [ossa] @$s5cdecl6orange{{[_0-9a-zA-Z]*}}F @_cdecl("grapefruit") @@ -21,7 +21,7 @@ func orange(_ x: Int) -> Int { return x } -// CHECK-LABEL: sil [serialized] [thunk] [ossa] @cauliflower : $@convention(c) +// CHECK-LABEL: sil [serialized] [thunk] [asmname "cauliflower"] [ossa] @$s5cdecl8broccoli{{[_0-9a-zA-Z]*}}FTo : $@convention(c) // CHECK: function_ref @$s5cdecl8broccoli{{[_0-9a-zA-Z]*}}F // CHECK-LABEL: sil [ossa] @$s5cdecl8broccoli{{[_0-9a-zA-Z]*}}F @_cdecl("cauliflower") @@ -29,7 +29,7 @@ public func broccoli(_ x: Int) -> Int { return x } -// CHECK-LABEL: sil private [thunk] [ossa] @collard_greens : $@convention(c) +// CHECK-LABEL: sil private [thunk] [asmname "collard_greens"] [ossa] @$s5cdecl4kale{{.*}}FTo : $@convention(c) // CHECK: function_ref @$s5cdecl4kale[[PRIVATE:.*]] // CHECK: sil private [ossa] @$s5cdecl4kale[[PRIVATE:.*]] @_cdecl("collard_greens") diff --git a/test/SILGen/cf.swift b/test/SILGen/cf.swift index 5553ac19376c7..fb81c7994ffa0 100644 --- a/test/SILGen/cf.swift +++ b/test/SILGen/cf.swift @@ -5,25 +5,25 @@ import CoreCooling // CHECK: sil hidden [ossa] @$s2cf8useEmAllyySo16CCMagnetismModelCF : // CHECK: bb0([[ARG:%.*]] : @guaranteed $CCMagnetismModel): func useEmAll(_ model: CCMagnetismModel) { -// CHECK: function_ref @CCPowerSupplyGetDefault : $@convention(c) () -> @autoreleased Optional +// CHECK: function_ref @$sSo23CCPowerSupplyGetDefaultSo0aB3RefaSgyFTo : $@convention(c) () -> @autoreleased Optional let power = CCPowerSupplyGetDefault() -// CHECK: function_ref @CCRefrigeratorCreate : $@convention(c) (Optional) -> Optional> +// CHECK: function_ref @$sSo20CCRefrigeratorCreateys9UnmanagedVySo0A3RefaGSgSo013CCPowerSupplyD0aSgFTo : $@convention(c) (Optional) -> Optional> let unmanagedFridge = CCRefrigeratorCreate(power) -// CHECK: function_ref @CCRefrigeratorSpawn : $@convention(c) (Optional) -> @owned Optional +// CHECK: function_ref @$sSo19CCRefrigeratorSpawnySo0A3RefaSgSo013CCPowerSupplyC0aSgFTo : $@convention(c) (Optional) -> @owned Optional let managedFridge = CCRefrigeratorSpawn(power) -// CHECK: function_ref @CCRefrigeratorOpen : $@convention(c) (Optional) -> () +// CHECK: function_ref @$sSo18CCRefrigeratorOpenyySo0A3RefaSgFTo : $@convention(c) (Optional) -> () CCRefrigeratorOpen(managedFridge) -// CHECK: function_ref @CCRefrigeratorCopy : $@convention(c) (Optional) -> @owned Optional +// CHECK: function_ref @$sSo18CCRefrigeratorCopyySo0A3RefaSgADFTo : $@convention(c) (Optional) -> @owned Optional let copy = CCRefrigeratorCopy(managedFridge) -// CHECK: function_ref @CCRefrigeratorClone : $@convention(c) (Optional) -> @autoreleased Optional +// CHECK: function_ref @$sSo19CCRefrigeratorCloneySo0A3RefaSgADFTo : $@convention(c) (Optional) -> @autoreleased Optional let clone = CCRefrigeratorClone(managedFridge) -// CHECK: function_ref @CCRefrigeratorDestroy : $@convention(c) (@owned Optional) -> () +// CHECK: function_ref @$sSo21CCRefrigeratorDestroyyySo0A3RefaSgFTo : $@convention(c) (@owned Optional) -> () CCRefrigeratorDestroy(clone) // CHECK: objc_method [[ARG]] : $CCMagnetismModel, #CCMagnetismModel.refrigerator!foreign : (CCMagnetismModel) -> () -> Unmanaged?, $@convention(objc_method) (CCMagnetismModel) -> @unowned_inner_pointer Optional> diff --git a/test/SILGen/cf_curried_init.swift b/test/SILGen/cf_curried_init.swift index 15ed624be98f6..38b88662091fe 100644 --- a/test/SILGen/cf_curried_init.swift +++ b/test/SILGen/cf_curried_init.swift @@ -8,4 +8,4 @@ import CoreGraphics let _: (CFURL) -> CGDataProvider? = CGDataProvider.init // CHECK-LABEL: sil private [ossa] @$s15cf_curried_initSo17CGDataProviderRefaSgSo8CFURLRefacfu_ : $@convention(thin) (@guaranteed CFURL) -> @owned Optional -// CHECK-LABEL: sil {{.*}}[clang CGDataProvider.init] @CGDataProviderCreateWithURL : $@convention(c) (CFURL) -> @owned Optional +// CHECK-LABEL: sil {{.*}}[asmname "CGDataProviderCreateWithURL"] [clang CGDataProvider.init] @$sSo17CGDataProviderRefa3urlABSgSo8CFURLRefa_tcfCTo : $@convention(c) (CFURL) -> @owned Optional diff --git a/test/SILGen/cf_members.swift b/test/SILGen/cf_members.swift index 19b1ba52ad4a7..b5e59b2c1d29e 100644 --- a/test/SILGen/cf_members.swift +++ b/test/SILGen/cf_members.swift @@ -6,7 +6,7 @@ func makeMetatype() -> Struct1.Type { return Struct1.self } // CHECK-LABEL: sil [ossa] @$s10cf_members17importAsUnaryInityyF : public func importAsUnaryInit() { - // CHECK: function_ref @CCPowerSupplyCreateDangerous : $@convention(c) () -> @owned CCPowerSupply + // CHECK: function_ref @$sSo16CCPowerSupplyRefa9dangerousAByt_tcfCTo : $@convention(c) () -> @owned CCPowerSupply var a = CCPowerSupply(dangerous: ()) let f: (()) -> CCPowerSupply = CCPowerSupply.init(dangerous:) a = f(()) @@ -27,14 +27,14 @@ public func foo(_ x: Double) { // CHECK: [[Z:%.*]] = project_box - // CHECK: [[FN:%.*]] = function_ref @IAMStruct1CreateSimple + // CHECK: [[FN:%.*]] = function_ref @$sSo10IAMStruct1V5valueABSd_tcfCTo : $@convention(c) (Double) -> Struct1 // CHECK: apply [[FN]]([[X]]) var z = Struct1(value: x) // The metatype expression should still be evaluated even if it isn't // used. // CHECK: [[MAKE_METATYPE:%.*]] = function_ref @$s10cf_members12makeMetatype{{[_0-9a-zA-Z]*}}F // CHECK: apply [[MAKE_METATYPE]]() - // CHECK: [[FN:%.*]] = function_ref @IAMStruct1CreateSimple + // CHECK: [[FN:%.*]] = function_ref @$sSo10IAMStruct1V5valueABSd_tcfCTo : $@convention(c) (Double) -> Struct1 // CHECK: apply [[FN]]([[X]]) z = makeMetatype().init(value: x) @@ -57,14 +57,14 @@ public func foo(_ x: Double) { // z = b(x) // CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] [[Z]] : $*Struct1 - // CHECK: [[FN:%.*]] = function_ref @IAMStruct1InvertInPlace + // CHECK: [[FN:%.*]] = function_ref @$sSo10IAMStruct1V6invertyyFTo : $@convention(c) (@inout Struct1) -> () // CHECK: apply [[FN]]([[WRITE]]) z.invert() // CHECK: [[WRITE:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1 // CHECK: [[ZVAL:%.*]] = load [trivial] [[WRITE]] // CHECK: store [[ZVAL]] to [trivial] [[ZTMP:%.*]] : - // CHECK: [[FN:%.*]] = function_ref @IAMStruct1Rotate : $@convention(c) (@in Struct1, Double) -> Struct1 + // CHECK: [[FN:%.*]] = function_ref @$sSo10IAMStruct1V9translate7radiansABSd_tFTo : $@convention(c) (@in Struct1, Double) -> Struct1 // CHECK: apply [[FN]]([[ZTMP]], [[X]]) z = z.translate(radians: x) @@ -102,7 +102,7 @@ public func foo(_ x: Double) { // CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1 // CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]] - // CHECK: [[FN:%.*]] = function_ref @IAMStruct1Scale + // CHECK: [[FN:%.*]] = function_ref @$sSo10IAMStruct1V5scaleyABSdFTo : $@convention(c) (Struct1, Double) -> Struct1 // CHECK: apply [[FN]]([[ZVAL]], [[X]]) z = z.scale(x) @@ -133,32 +133,32 @@ public func foo(_ x: Double) { // CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1 // CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]] // CHECK: store [[ZVAL]] to [trivial] [[ZTMP:%.*]] : - // CHECK: [[GET:%.*]] = function_ref @IAMStruct1GetRadius : $@convention(c) (@in Struct1) -> Double + // CHECK: [[GET:%.*]] = function_ref @$sSo10IAMStruct1V6radiusSdvgTo : $@convention(c) (@in Struct1) -> Double // CHECK: apply [[GET]]([[ZTMP]]) _ = z.radius // CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1 // CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]] - // CHECK: [[SET:%.*]] = function_ref @IAMStruct1SetRadius : $@convention(c) (Struct1, Double) -> () + // CHECK: [[SET:%.*]] = function_ref @$sSo10IAMStruct1V6radiusSdvsTo : $@convention(c) (Struct1, Double) -> () // CHECK: apply [[SET]]([[ZVAL]], [[X]]) z.radius = x // CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1 // CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]] - // CHECK: [[GET:%.*]] = function_ref @IAMStruct1GetAltitude : $@convention(c) (Struct1) -> Double + // CHECK: [[GET:%.*]] = function_ref @$sSo10IAMStruct1V8altitudeSdvgTo : $@convention(c) (Struct1) -> Double // CHECK: apply [[GET]]([[ZVAL]]) _ = z.altitude // CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] [[Z]] : $*Struct1 - // CHECK: [[SET:%.*]] = function_ref @IAMStruct1SetAltitude : $@convention(c) (@inout Struct1, Double) -> () + // CHECK: [[SET:%.*]] = function_ref @$sSo10IAMStruct1V8altitudeSdvsTo : $@convention(c) (@inout Struct1, Double) -> () // CHECK: apply [[SET]]([[WRITE]], [[X]]) z.altitude = x // CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1 // CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]] - // CHECK: [[GET:%.*]] = function_ref @IAMStruct1GetMagnitude : $@convention(c) (Struct1) -> Double + // CHECK: [[GET:%.*]] = function_ref @$sSo10IAMStruct1V9magnitudeSdvgTo : $@convention(c) (Struct1) -> Double // CHECK: apply [[GET]]([[ZVAL]]) _ = z.magnitude - // CHECK: [[FN:%.*]] = function_ref @IAMStruct1StaticMethod + // CHECK: [[FN:%.*]] = function_ref @$sSo10IAMStruct1V12staticMethods5Int32VyFZTo : $@convention(c) () -> Int32 // CHECK: apply [[FN]]() var y = Struct1.staticMethod() // CHECK: [[THUNK:%.*]] = function_ref @$s10cf_members3fooyySdFs5Int32Vycfu8_ : $@convention(thin) () -> Int32 @@ -175,35 +175,35 @@ public func foo(_ x: Double) { // let j: @convention(c) () -> Int32 = Struct1.staticMethod // y = j() - // CHECK: [[GET:%.*]] = function_ref @IAMStruct1StaticGetProperty + // CHECK: [[GET:%.*]] = function_ref @$sSo10IAMStruct1V8propertys5Int32VvgZTo : $@convention(c) () -> Int32 // CHECK: apply [[GET]]() _ = Struct1.property - // CHECK: [[SET:%.*]] = function_ref @IAMStruct1StaticSetProperty + // CHECK: [[SET:%.*]] = function_ref @$sSo10IAMStruct1V8propertys5Int32VvsZTo : $@convention(c) (Int32) -> Int32 // CHECK: apply [[SET]](%{{[0-9]+}}) Struct1.property = y - // CHECK: [[GET:%.*]] = function_ref @IAMStruct1StaticGetOnlyProperty + // CHECK: [[GET:%.*]] = function_ref @$sSo10IAMStruct1V15getOnlyPropertys5Int32VvgZTo : $@convention(c) () -> Int32 // CHECK: apply [[GET]]() _ = Struct1.getOnlyProperty // CHECK: [[MAKE_METATYPE:%.*]] = function_ref @$s10cf_members12makeMetatype{{[_0-9a-zA-Z]*}}F // CHECK: apply [[MAKE_METATYPE]]() - // CHECK: [[GET:%.*]] = function_ref @IAMStruct1StaticGetProperty + // CHECK: [[GET:%.*]] = function_ref @$sSo10IAMStruct1V8propertys5Int32VvgZTo : $@convention(c) () -> Int32 // CHECK: apply [[GET]]() _ = makeMetatype().property // CHECK: [[MAKE_METATYPE:%.*]] = function_ref @$s10cf_members12makeMetatype{{[_0-9a-zA-Z]*}}F // CHECK: apply [[MAKE_METATYPE]]() - // CHECK: [[SET:%.*]] = function_ref @IAMStruct1StaticSetProperty + // CHECK: [[SET:%.*]] = function_ref @$sSo10IAMStruct1V8propertys5Int32VvsZTo : $@convention(c) (Int32) -> Int32 // CHECK: apply [[SET]](%{{[0-9]+}}) makeMetatype().property = y // CHECK: [[MAKE_METATYPE:%.*]] = function_ref @$s10cf_members12makeMetatype{{[_0-9a-zA-Z]*}}F // CHECK: apply [[MAKE_METATYPE]]() - // CHECK: [[GET:%.*]] = function_ref @IAMStruct1StaticGetOnlyProperty + // CHECK: [[GET:%.*]] = function_ref @$sSo10IAMStruct1V15getOnlyPropertys5Int32VvgZTo : $@convention(c) () -> Int32 // CHECK: apply [[GET]]() _ = makeMetatype().getOnlyProperty // CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1 // CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]] - // CHECK: [[FN:%.*]] = function_ref @IAMStruct1SelfComesLast : $@convention(c) (Double, Struct1) -> () + // CHECK: [[FN:%.*]] = function_ref @$sSo10IAMStruct1V13selfComesLast1xySd_tFTo : $@convention(c) (Double, Struct1) -> () // CHECK: apply [[FN]]([[X]], [[ZVAL]]) z.selfComesLast(x: x) // CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1 @@ -221,7 +221,7 @@ public func foo(_ x: Double) { // CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1 // CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]] - // CHECK: [[FN:%.*]] = function_ref @IAMStruct1SelfComesThird : $@convention(c) (Int32, Float, Struct1, Double) -> () + // CHECK: [[FN:%.*]] = function_ref @$sSo10IAMStruct1V14selfComesThird1a1b1xys5Int32V_SfSdtFTo : $@convention(c) (Int32, Float, Struct1, Double) -> () // CHECK: apply [[FN]]({{.*}}, {{.*}}, [[ZVAL]], [[X]]) z.selfComesThird(a: y, b: 0, x: x) let n: (Int32, Float, Double) -> () = z.selfComesThird(a:b:x:) @@ -239,50 +239,50 @@ public func foo(_ x: Double) { // CHECK-LABEL: sil private [ossa] @$s10cf_members3fooyySdFSo10IAMStruct1VSdcfu_ : $@convention(thin) (Double) -> Struct1 { // CHECK: bb0([[X:%.*]] : $Double): -// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1CreateSimple +// CHECK: [[CFUNC:%.*]] = function_ref @$sSo10IAMStruct1V5valueABSd_tcfCTo : $@convention(c) (Double) -> Struct1 // CHECK: [[RET:%.*]] = apply [[CFUNC]]([[X]]) // CHECK: return [[RET]] // CHECK-LABEL: sil private [ossa] @$s10cf_members3fooyySdFSo10IAMStruct1VSdcADcfu0_ADSdcfu1_ : $@convention(thin) (Double, Struct1) -> Struct1 { // CHECK: bb0([[X:%.*]] : $Double, [[SELF:%.*]] : @closureCapture $Struct1): // CHECK: store [[SELF]] to [trivial] [[TMP:%.*]] : -// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1Rotate +// CHECK: [[CFUNC:%.*]] = function_ref @$sSo10IAMStruct1V9translate7radiansABSd_tFTo : $@convention(c) (@in Struct1, Double) -> Struct1 // CHECK: [[RET:%.*]] = apply [[CFUNC]]([[TMP]], [[X]]) // CHECK: return [[RET]] // CHECK-LABEL: sil private [ossa] @$s10cf_members3fooyySdFSo10IAMStruct1VSdcADcfu4_ADSdcfu5_ : $@convention(thin) (Double, Struct1) -> Struct1 { // CHECK: bb0([[X:%.*]] : $Double, [[SELF:%.*]] : @closureCapture $Struct1): -// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1Scale +// CHECK: [[CFUNC:%.*]] = function_ref @$sSo10IAMStruct1V5scaleyABSdFTo : $@convention(c) (Struct1, Double) -> Struct1 // CHECK: [[RET:%.*]] = apply [[CFUNC]]([[SELF]], [[X]]) // CHECK: return [[RET]] -// CHECK-LABEL: sil private [ossa] @$s10cf_members3fooyySdFs5Int32Vycfu8_ : $@convention(thin) () -> Int32 +// CHECK-LABEL: sil private [ossa] @$s10cf_members3fooyySdFs5Int32Vycfu8_ : $@convention(thin) () -> Int32 // CHECK: bb0: -// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1StaticMethod +// CHECK: [[CFUNC:%.*]] = function_ref @$sSo10IAMStruct1V12staticMethods5Int32VyFZTo : $@convention(c) () -> Int32 // CHECK: [[RET:%.*]] = apply [[CFUNC]]() // CHECK: return [[RET]] // CHECK-LABEL:sil private [ossa] @$s10cf_members3fooyySdFySdcSo10IAMStruct1Vcfu11_ySdcfu12_ : $@convention(thin) (Double, Struct1) -> () { // CHECK: bb0([[X:%.*]] : $Double, [[SELF:%.*]] : @closureCapture $Struct1): -// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1SelfComesLast +// CHECK: [[CFUNC:%.*]] = function_ref @$sSo10IAMStruct1V13selfComesLast1xySd_tFTo : $@convention(c) (Double, Struct1) -> () // CHECK: apply [[CFUNC]]([[X]], [[SELF]]) // CHECK-LABEL: sil private [ossa] @$s10cf_members3fooyySdFys5Int32V_SfSdtcSo10IAMStruct1Vcfu13_yAD_SfSdtcfu14_ : $@convention(thin) (Int32, Float, Double, Struct1) -> () { // CHECK: bb0([[X:%.*]] : $Int32, [[Y:%.*]] : $Float, [[Z:%.*]] : $Double, [[SELF:%.*]] : @closureCapture $Struct1): -// CHECK: [[CFUNC:%.*]] = function_ref @IAMStruct1SelfComesThird +// CHECK: [[CFUNC:%.*]] = function_ref @$sSo10IAMStruct1V14selfComesThird1a1b1xys5Int32V_SfSdtFTo : $@convention(c) (Int32, Float, Struct1, Double) -> () // CHECK: apply [[CFUNC]]([[X]], [[Y]], [[SELF]], [[Z]]) // CHECK-LABEL: sil [ossa] @$s10cf_members3bar{{[_0-9a-zA-Z]*}}F public func bar(_ x: Double) { - // CHECK: function_ref @CCPowerSupplyCreate : $@convention(c) (Double) -> @owned CCPowerSupply + // CHECK: function_ref @$sSo16CCPowerSupplyRefa5wattsABSd_tcfCTo : $@convention(c) (Double) -> @owned CCPowerSupply let ps = CCPowerSupply(watts: x) - // CHECK: function_ref @CCRefrigeratorCreate : $@convention(c) (CCPowerSupply) -> @owned CCRefrigerator + // CHECK: function_ref @$sSo17CCRefrigeratorRefa11powerSupplyABSo07CCPowerdB0a_tcfCTo : $@convention(c) (CCPowerSupply) -> @owned CCRefrigerator let fridge = CCRefrigerator(powerSupply: ps) - // CHECK: function_ref @CCRefrigeratorOpen : $@convention(c) (CCRefrigerator) -> () + // CHECK: function_ref @$sSo17CCRefrigeratorRefa4openyyFTo : $@convention(c) (CCRefrigerator) -> () fridge.open() - // CHECK: function_ref @CCRefrigeratorGetPowerSupply : $@convention(c) (CCRefrigerator) -> @autoreleased CCPowerSupply + // CHECK: function_ref @$sSo17CCRefrigeratorRefa11powerSupplySo07CCPowerdB0avgTo : $@convention(c) (CCRefrigerator) -> @autoreleased CCPowerSupply let ps2 = fridge.powerSupply - // CHECK: function_ref @CCRefrigeratorSetPowerSupply : $@convention(c) (CCRefrigerator, CCPowerSupply) -> () + // CHECK: function_ref @$sSo17CCRefrigeratorRefa11powerSupplySo07CCPowerdB0avsTo : $@convention(c) (CCRefrigerator, CCPowerSupply) -> () fridge.powerSupply = ps2 let a: (Double) -> CCPowerSupply = CCPowerSupply.init(watts:) diff --git a/test/SILGen/diagnose_duplicate_functions.swift b/test/SILGen/diagnose_duplicate_functions.swift index bfa37ae6a2919..cb157bbc2b5fb 100644 --- a/test/SILGen/diagnose_duplicate_functions.swift +++ b/test/SILGen/diagnose_duplicate_functions.swift @@ -11,11 +11,11 @@ func b(_ x: Int) -> Int { // expected-error {{multiple definitions of symbol 'fo } @_cdecl("bar") -func c(_ x: Int) -> Int { // expected-note {{other definition here}} +func c(_ x: Int) -> Int { // duplication only detected at the LLVM IR level return x } @_cdecl("bar") -func d(_ x: Int) -> Int { // expected-error {{multiple definitions of symbol 'bar'}} +func d(_ x: Int) -> Int { // duplication only detected at the LLVM IR level return x } diff --git a/test/SILGen/dynamically_replaceable.swift b/test/SILGen/dynamically_replaceable.swift index e7c0f41d77072..a67583b665431 100644 --- a/test/SILGen/dynamically_replaceable.swift +++ b/test/SILGen/dynamically_replaceable.swift @@ -385,7 +385,7 @@ dynamic func funcWithDefaultArg(_ arg : String = String("hello")) { print("hello") } -// IMPLICIT-LABEL: sil hidden [thunk] [ossa] @barfoo +// IMPLICIT-LABEL: sil hidden [thunk] [asmname "barfoo"] [ossa] @$s23dynamically_replaceable6foobaryyFTo @_cdecl("barfoo") func foobar() { } diff --git a/test/SILGen/external_definitions.swift b/test/SILGen/external_definitions.swift index e7e1b12068d0d..c83d94cc26117 100644 --- a/test/SILGen/external_definitions.swift +++ b/test/SILGen/external_definitions.swift @@ -13,13 +13,13 @@ hasNoPrototype() // CHECK: [[NSOBJECT_CTOR:%.*]] = function_ref @$sSo8NSObjectC{{[_0-9a-zA-Z]*}}fC : $@convention(method) (@thick NSObject.Type) -> @owned NSObject // CHECK: [[ANSIBLE_CTOR:%.*]] = function_ref @$sSo7AnsibleC{{[_0-9a-zA-Z]*}}fC // CHECK: [[ANSIBLE:%.*]] = apply [[ANSIBLE_CTOR]] -// CHECK: [[NSANSE:%.*]] = function_ref @NSAnse : $@convention(c) (Optional) -> @autoreleased Optional +// CHECK: [[NSANSE:%.*]] = function_ref @$sSo6NSAnseySo7AnsibleCSgADFTo : $@convention(c) (Optional) -> @autoreleased Optional // CHECK: [[NSANSE_RESULT:%.*]] = apply [[NSANSE]]([[ANSIBLE]]) // CHECK: destroy_value [[ANSIBLE]] : $Optional // -- Referencing unapplied C function goes through a thunk // CHECK: [[NSANSE:%.*]] = function_ref @$sSo6NSAnseySo7AnsibleCSgADFTO : $@convention(thin) (@guaranteed Optional) -> @owned Optional // -- Referencing unprototyped C function passes no parameters -// CHECK: [[NOPROTO:%.*]] = function_ref @hasNoPrototype : $@convention(c) () -> () +// CHECK: [[NOPROTO:%.*]] = function_ref @$sSo14hasNoPrototypeyyFTo : $@convention(c) () -> () // CHECK: apply [[NOPROTO]]() // -- Constructors for imported NSObject @@ -32,7 +32,7 @@ hasNoPrototype() // CHECK: sil shared [serialized] [thunk] [ossa] @$sSo6NSAnseySo7AnsibleCSgADFTO : $@convention(thin) (@guaranteed Optional) -> @owned Optional { // CHECK: bb0([[ARG0:%.*]] : @guaranteed $Optional): // CHECK: [[ARG0_COPY:%.*]] = copy_value [[ARG0]] -// CHECK: [[FUNC:%.*]] = function_ref @NSAnse : $@convention(c) (Optional) -> @autoreleased Optional +// CHECK: [[FUNC:%.*]] = function_ref @$sSo6NSAnseySo7AnsibleCSgADFTo : $@convention(c) (Optional) -> @autoreleased Optional // CHECK: [[RESULT:%.*]] = apply [[FUNC]]([[ARG0_COPY]]) : $@convention(c) (Optional) -> @autoreleased Optional // CHECK: destroy_value [[ARG0_COPY]] : $Optional // CHECK: return [[RESULT]] : $Optional diff --git a/test/SILGen/foreign_to_native_inout_self.swift b/test/SILGen/foreign_to_native_inout_self.swift index 351d412cf7017..5ecdba723f504 100644 --- a/test/SILGen/foreign_to_native_inout_self.swift +++ b/test/SILGen/foreign_to_native_inout_self.swift @@ -8,7 +8,7 @@ extension MyIterator : FakeIterator {} // CHECK-LABEL: sil shared [serialized] [thunk] [ossa] @$sSo10MyIteratora4nextyyFTO : $@convention(method) (@inout MyIterator) -> () { // CHECK: bb0(%0 : $*MyIterator): -// CHECK: [[FN:%.*]] = function_ref @MyIteratorNext : $@convention(c) (@inout MyIterator) -> () +// CHECK: [[FN:%.*]] = function_ref @$sSo10MyIteratora4nextyyFTo : $@convention(c) (@inout MyIterator) -> () // CHECK: apply [[FN]](%0) : $@convention(c) (@inout MyIterator) -> () // CHECK: [[RESULT:%.*]] = tuple () // CHECK: return [[RESULT]] : $() diff --git a/test/SILGen/has_symbol.swift b/test/SILGen/has_symbol.swift index 6f3330e97dc9c..bafd5017402f0 100644 --- a/test/SILGen/has_symbol.swift +++ b/test/SILGen/has_symbol.swift @@ -30,7 +30,7 @@ func testGlobalFunctions() { // --- cdeclFunc() --- // CHECK: sil @$s17has_symbol_helper9cdeclFuncyyF : $@convention(thin) () -> () -// CHECK: sil [serialized] @cdecl_func : $@convention(c) () -> () +// CHECK: sil [serialized] [asmname "cdecl_func"] @$s17has_symbol_helper9cdeclFuncyyFTo : $@convention(c) () -> () // --- forwardDeclaredFunc() --- // CHECK: sil @forward_declared_func : $@convention(thin) () -> () diff --git a/test/SILGen/import_as_member.swift b/test/SILGen/import_as_member.swift index 335acd915ce3b..581627325da5e 100644 --- a/test/SILGen/import_as_member.swift +++ b/test/SILGen/import_as_member.swift @@ -42,24 +42,27 @@ public func returnNullableStringGlobalVar() -> String? { // CHECK-LABEL: sil {{.*}}useClass{{.*}} // CHECK: bb0([[D:%[0-9]+]] : $Double, [[OPTS:%[0-9]+]] : $SomeClass.Options): public func useClass(d: Double, opts: SomeClass.Options) { - // CHECK: [[CTOR:%[0-9]+]] = function_ref @MakeIAMSomeClass : $@convention(c) (Double) -> @autoreleased SomeClass + // CHECK: [[CTOR:%[0-9]+]] = function_ref @$sSo12IAMSomeClassC5valueABSd_tcfCTo : $@convention(c) (Double) -> @autoreleased SomeClass // CHECK: [[OBJ:%[0-9]+]] = apply [[CTOR]]([[D]]) let o = SomeClass(value: d) // CHECK: [[MOVED_OBJ:%.*]] = move_value [lexical] [var_decl] [[OBJ]] // CHECK: [[BORROWED_OBJ:%.*]] = begin_borrow [[MOVED_OBJ]] - // CHECK: [[APPLY_FN:%[0-9]+]] = function_ref @IAMSomeClassApplyOptions : $@convention(c) (SomeClass, SomeClass.Options) -> () + // CHECK: [[APPLY_FN:%[0-9]+]] = function_ref @$sSo12IAMSomeClassC12applyOptionsyySo0abD0VFTo : $@convention(c) (SomeClass, SomeClass.Options) -> () // CHECK: apply [[APPLY_FN]]([[BORROWED_OBJ]], [[OPTS]]) // CHECK: end_borrow [[BORROWED_OBJ]] // CHECK: destroy_value [[MOVED_OBJ]] o.applyOptions(opts) } +// CHECK: sil [asmname "MakeIAMSomeClass"] [clang SomeClass.init] @$sSo12IAMSomeClassC5valueABSd_tcfCTo : $@convention(c) (Double) -> @autoreleased SomeClass +// CHECK: sil [asmname "IAMSomeClassApplyOptions"] [clang SomeClass.applyOptions] @$sSo12IAMSomeClassC12applyOptionsyySo0abD0VFTo + extension SomeClass { // CHECK-LABEL: sil hidden [ossa] @$sSo12IAMSomeClassC16import_as_memberE6doubleABSd_tcfC // CHECK: bb0([[DOUBLE:%[0-9]+]] : $Double // CHECK-NOT: value_metatype - // CHECK: [[FNREF:%[0-9]+]] = function_ref @MakeIAMSomeClass + // CHECK: [[FNREF:%[0-9]+]] = function_ref @$sSo12IAMSomeClassC5valueABSd_tcfCTo // CHECK: apply [[FNREF]]([[DOUBLE]]) convenience init(double: Double) { self.init(value: double) diff --git a/test/SILGen/keypaths_import_as_member.swift b/test/SILGen/keypaths_import_as_member.swift index 204207d55e13d..0fda234de60ef 100644 --- a/test/SILGen/keypaths_import_as_member.swift +++ b/test/SILGen/keypaths_import_as_member.swift @@ -2,6 +2,6 @@ // CHECK-LABEL: sil {{.*}} @$s{{.*}}23keyPathToImportedMember func keyPathToImportedMember() { - // CHECK: keypath $KeyPath, (root $Butt; gettable_property $Int32, id @ButtSize + // CHECK: keypath $KeyPath, (root $Butt; gettable_property $Int32, id @$sSo4ButtV4sizes5Int32VvgTo _ = \Butt.size } diff --git a/test/SILGen/objc_blocks_bridging.swift b/test/SILGen/objc_blocks_bridging.swift index 32881dc70efb8..40dd00876c82a 100644 --- a/test/SILGen/objc_blocks_bridging.swift +++ b/test/SILGen/objc_blocks_bridging.swift @@ -195,7 +195,7 @@ func bridgeNoescapeBlock(fn: () -> (), optFn: (() -> ())?) { // CHECK: [[SOME_BLOCK:%.*]] = enum $Optional<@convention(block) @noescape () -> ()>, #Optional.some!enumelt, [[BLOCK]] // CHECK: dealloc_stack [[BLOCK_ALLOC]] - // CHECK: [[FN:%.*]] = function_ref @noescapeBlock : $@convention(c) (Optional<@convention(block) @noescape () -> ()>) -> () + // CHECK: [[FN:%.*]] = function_ref @$sSo13noescapeBlockyyyyXESgFTo : $@convention(c) (Optional<@convention(block) @noescape () -> ()>) -> () // CHECK: apply [[FN]]([[SOME_BLOCK]]) noescapeBlock { } // CHECK: destroy_value [[SOME_BLOCK]] @@ -217,13 +217,13 @@ func bridgeNoescapeBlock(fn: () -> (), optFn: (() -> ())?) { // CHECK: [[SOME_BLOCK:%.*]] = enum $Optional<@convention(block) @noescape () -> ()>, #Optional.some!enumelt, [[BLOCK]] // CHECK: dealloc_stack [[BLOCK_ALLOC]] - // CHECK: [[FN:%.*]] = function_ref @noescapeBlock : $@convention(c) (Optional<@convention(block) @noescape () -> ()>) -> () + // CHECK: [[FN:%.*]] = function_ref @$sSo13noescapeBlockyyyyXESgFTo : $@convention(c) (Optional<@convention(block) @noescape () -> ()>) -> () // CHECK: apply [[FN]]([[SOME_BLOCK]]) noescapeBlock(fn) // CHECK: destroy_value [[SOME_BLOCK]] // CHECK: [[NIL_BLOCK:%.*]] = enum $Optional<@convention(block) @noescape () -> ()>, #Optional.none!enumelt - // CHECK: [[FN:%.*]] = function_ref @noescapeBlock : $@convention(c) (Optional<@convention(block) @noescape () -> ()>) -> () + // CHECK: [[FN:%.*]] = function_ref @$sSo13noescapeBlockyyyyXESgFTo : $@convention(c) (Optional<@convention(block) @noescape () -> ()>) -> () // CHECK: apply [[FN]]([[NIL_BLOCK]]) noescapeBlock(nil) @@ -242,7 +242,7 @@ func bridgeNoescapeBlock(fn: () -> (), optFn: (() -> ())?) { // FIXME: We're passing the block as a no-escape -- so we don't have to copy it // CHECK: [[BLOCK:%.*]] = copy_block_without_escaping [[BLOCK_STACK]] - // CHECK: [[FN:%.*]] = function_ref @noescapeNonnullBlock : $@convention(c) (@convention(block) @noescape () -> ()) -> () + // CHECK: [[FN:%.*]] = function_ref @$sSo20noescapeNonnullBlockyyyyXEFTo : $@convention(c) (@convention(block) @noescape () -> ()) -> () // CHECK: apply [[FN]]([[BLOCK]]) noescapeNonnullBlock { } // CHECK: destroy_value [[BLOCK]] @@ -262,7 +262,7 @@ func bridgeNoescapeBlock(fn: () -> (), optFn: (() -> ())?) { // FIXME: We're passing the block as a no-escape -- so we don't have to copy it // CHECK: [[BLOCK:%.*]] = copy_block_without_escaping [[BLOCK_STACK]] - // CHECK: [[FN:%.*]] = function_ref @noescapeNonnullBlock : $@convention(c) (@convention(block) @noescape () -> ()) -> () + // CHECK: [[FN:%.*]] = function_ref @$sSo20noescapeNonnullBlockyyyyXEFTo : $@convention(c) (@convention(block) @noescape () -> ()) -> () // CHECK: apply [[FN]]([[BLOCK]]) noescapeNonnullBlock(fn) diff --git a/test/SILGen/objc_bridging.swift b/test/SILGen/objc_bridging.swift index 79605f7664880..a18cd2edc0d21 100644 --- a/test/SILGen/objc_bridging.swift +++ b/test/SILGen/objc_bridging.swift @@ -210,7 +210,7 @@ func callBar() -> String { } // CHECK-LABEL: sil hidden [ossa] @$s13objc_bridging7callBar{{.*}}F // CHECK: bb0: -// CHECK: [[BAR:%.*]] = function_ref @bar +// CHECK: [[BAR:%.*]] = function_ref @$sSo3barSSSgyFTo // CHECK: [[OPT_BRIDGED:%.*]] = apply [[BAR]]() : $@convention(c) () -> @autoreleased Optional // CHECK: switch_enum [[OPT_BRIDGED]] : $Optional, case #Optional.some!enumelt: [[SOME_BB:bb[0-9]+]], case #Optional.none!enumelt: [[NONE_BB:bb[0-9]+]] @@ -236,7 +236,7 @@ func callSetBar(_ s: String) { // CHECK: [[BRIDGED:%.*]] = apply [[STRING_TO_NSSTRING]]([[BORROWED_NATIVE]]) // CHECK: end_borrow [[BORROWED_NATIVE]] // CHECK: [[OPT_BRIDGED:%.*]] = enum $Optional, #Optional.some!enumelt, [[BRIDGED]] -// CHECK: [[SET_BAR:%.*]] = function_ref @setBar +// CHECK: [[SET_BAR:%.*]] = function_ref @$sSo6setBaryySSSgFTo // CHECK: apply [[SET_BAR]]([[OPT_BRIDGED]]) // CHECK: destroy_value [[OPT_BRIDGED]] // CHECK: } @@ -513,38 +513,38 @@ func forceNSArrayMembers() -> (NSArray, NSArray) { // imported C functions. // CHECK-ios-i386-LABEL: sil hidden [ossa] @$s13objc_bridging5boolsySb_SbtSbF -// CHECK-ios-i386: function_ref @useBOOL : $@convention(c) (ObjCBool) -> () -// CHECK-ios-i386: function_ref @useBool : $@convention(c) (Bool) -> () -// CHECK-ios-i386: function_ref @getBOOL : $@convention(c) () -> ObjCBool -// CHECK-ios-i386: function_ref @getBool : $@convention(c) () -> Bool +// CHECK-ios-i386: function_ref @$sSo7useBOOLyySo0B0VFTo : $@convention(c) (ObjCBool) -> () +// CHECK-ios-i386: function_ref @$sSo7useBoolyySbFTo : $@convention(c) (Bool) -> () +// CHECK-ios-i386: function_ref @$sSo7getBOOLSo0B0VyFTo : $@convention(c) () -> ObjCBool +// CHECK-ios-i386: function_ref @$sSo7getBoolSbyFTo : $@convention(c) () -> Bool // CHECK-macosx-x86_64-LABEL: sil hidden [ossa] @$s13objc_bridging5boolsySb_SbtSbF -// CHECK-macosx-x86_64: function_ref @useBOOL : $@convention(c) (ObjCBool) -> () -// CHECK-macosx-x86_64: function_ref @useBool : $@convention(c) (Bool) -> () -// CHECK-macosx-x86_64: function_ref @getBOOL : $@convention(c) () -> ObjCBool -// CHECK-macosx-x86_64: function_ref @getBool : $@convention(c) () -> Bool +// CHECK-macosx-x86_64: function_ref @$sSo7useBOOLyySo0B0VFTo : $@convention(c) (ObjCBool) -> () +// CHECK-macosx-x86_64: function_ref @$sSo7useBoolyySbFTo : $@convention(c) (Bool) -> () +// CHECK-macosx-x86_64: function_ref @$sSo7getBOOLSo0B0VyFTo : $@convention(c) () -> ObjCBool +// CHECK-macosx-x86_64: function_ref @$sSo7getBoolSbyFTo : $@convention(c) () -> Bool // FIXME: no distinction on x86_64, arm64 or watchos-i386, since SILGen looks // at the underlying Clang decl of the bridged decl to decide whether it needs // bridging. // // CHECK-watchos-i386-LABEL: sil hidden [ossa] @$s13objc_bridging5boolsySb_SbtSbF -// CHECK-watchos-i386: function_ref @useBOOL : $@convention(c) (Bool) -> () -// CHECK-watchos-i386: function_ref @useBool : $@convention(c) (Bool) -> () -// CHECK-watchos-i386: function_ref @getBOOL : $@convention(c) () -> Bool -// CHECK-watchos-i386: function_ref @getBool : $@convention(c) () -> Bool +// CHECK-watchos-i386: function_ref @$sSo7useBOOLyySbFTo : $@convention(c) (Bool) -> () +// CHECK-watchos-i386: function_ref @$sSo7useBoolyySbFTo : $@convention(c) (Bool) -> () +// CHECK-watchos-i386: function_ref @$sSo7getBOOLSbyFTo : $@convention(c) () -> Bool +// CHECK-watchos-i386: function_ref @$sSo7getBoolSbyFTo : $@convention(c) () -> Bool // CHECK-ios-x86_64-LABEL: sil hidden [ossa] @$s13objc_bridging5boolsySb_SbtSbF -// CHECK-ios-x86_64: function_ref @useBOOL : $@convention(c) (Bool) -> () -// CHECK-ios-x86_64: function_ref @useBool : $@convention(c) (Bool) -> () -// CHECK-ios-x86_64: function_ref @getBOOL : $@convention(c) () -> Bool -// CHECK-ios-x86_64: function_ref @getBool : $@convention(c) () -> Bool +// CHECK-ios-x86_64: function_ref @$sSo7useBOOLyySbFTo : $@convention(c) (Bool) -> () +// CHECK-ios-x86_64: function_ref @$sSo7useBoolyySbFTo : $@convention(c) (Bool) -> () +// CHECK-ios-x86_64: function_ref @$sSo7getBOOLSbyFTo : $@convention(c) () -> Bool +// CHECK-ios-x86_64: function_ref @$sSo7getBoolSbyFTo : $@convention(c) () -> Bool // CHECK-arm64-LABEL: sil hidden [ossa] @$s13objc_bridging5boolsySb_SbtSbF -// CHECK-arm64: function_ref @useBOOL : $@convention(c) (Bool) -> () -// CHECK-arm64: function_ref @useBool : $@convention(c) (Bool) -> () -// CHECK-arm64: function_ref @getBOOL : $@convention(c) () -> Bool -// CHECK-arm64: function_ref @getBool : $@convention(c) () -> Bool +// CHECK-arm64: function_ref @$sSo7useBOOLyySbFTo : $@convention(c) (Bool) -> () +// CHECK-arm64: function_ref @$sSo7useBoolyySbFTo : $@convention(c) (Bool) -> () +// CHECK-arm64: function_ref @$sSo7getBOOLSbyFTo : $@convention(c) () -> Bool +// CHECK-arm64: function_ref @$sSo7getBoolSbyFTo : $@convention(c) () -> Bool func bools(_ x: Bool) -> (Bool, Bool) { useBOOL(x) diff --git a/test/SILGen/objc_bridging_peephole.swift b/test/SILGen/objc_bridging_peephole.swift index 3b37947fea9a5..5be2869c8d8a9 100644 --- a/test/SILGen/objc_bridging_peephole.swift +++ b/test/SILGen/objc_bridging_peephole.swift @@ -586,7 +586,7 @@ func testBlockToOptionalAnyObjectBridge(block: @escaping @convention(block) () - // CHECK-NEXT: [[OPTREF:%.*]] = enum $Optional, #Optional.some!enumelt, [[REF]] : $AnyObject // CHECK-NEXT: end_borrow [[T0]] // CHECK-NEXT: // function_ref - // CHECK-NEXT: [[FN:%.*]] = function_ref @takeNullableId : $@convention(c) (Optional) -> () + // CHECK-NEXT: [[FN:%.*]] = function_ref @$sSo14takeNullableIdyyypSgFTo : $@convention(c) (Optional) -> () // CHECK-NEXT: apply [[FN]]([[OPTREF]]) // CHECK-NEXT: destroy_value [[OPTREF]] takeNullableId(block as Any) diff --git a/test/SILGen/objc_direct.swift b/test/SILGen/objc_direct.swift index 22cbbb08d076d..1156d9c346040 100644 --- a/test/SILGen/objc_direct.swift +++ b/test/SILGen/objc_direct.swift @@ -19,55 +19,53 @@ markUsed(Bar.init(value: 0)) // CHECK: function_ref @$sSo3BarC5valueABSgs5Int32V_tcfC bar.directProperty = 123 -// CHECK: function_ref @[[BYTE01:.]]-[Bar setDirectProperty:] +// CHECK: function_ref @$sSo3BarC14directPropertys5Int32VvsTo markUsed(bar.directProperty) -// CHECK: function_ref @[[BYTE01]]-[Bar directProperty] +// CHECK: function_ref @$sSo3BarC14directPropertys5Int32VvgTo bar.directProperty2 = 456 -// CHECK: function_ref @[[BYTE01]]-[Bar setDirectProperty2:] +// CHECK: function_ref @$sSo3BarC15directProperty2s5Int32VvsTo markUsed(bar.directProperty2) -// CHECK: function_ref @[[BYTE01]]-[Bar directProperty2] +// CHECK: function_ref @$sSo3BarC15directProperty2s5Int32VvgTo bar[0] = 789 -// CHECK: function_ref @[[BYTE01]]-[Bar setObject:atIndexedSubscript:] +// CHECK: function_ref @$sSo3BarCys5Int32VADcisTo markUsed(bar[0]) -// CHECK: function_ref @[[BYTE01]]-[Bar objectAtIndexedSubscript:] +// CHECK: function_ref @$sSo3BarCys5Int32VADcigTo markUsed(bar.directMethod()) -// CHECK: function_ref @[[BYTE01]]-[Bar directMethod] +// CHECK: function_ref @$sSo3BarC12directMethodSSSgyFTo markUsed(bar.directMethod2()) -// CHECK: function_ref @[[BYTE01]]-[Bar directMethod2] +// CHECK: function_ref @$sSo3BarC13directMethod2SSSgyFTo markUsed(Bar.directClassMethod()) -// CHECK: function_ref @[[BYTE01]]+[Bar directClassMethod] +// CHECK: function_ref @$sSo3BarC17directClassMethodSSSgyFZTo markUsed(Bar.directClassMethod2()) -// CHECK: function_ref @[[BYTE01]]+[Bar directClassMethod2] +// CHECK: function_ref @$sSo3BarC18directClassMethod2SSSgyFZTo markUsed(bar.directProtocolMethod()) -// CHECK: function_ref @[[BYTE01]]-[Bar directProtocolMethod] +// CHECK: function_ref @$sSo3BarC20directProtocolMethodSSSgyFTo // CHECK-LABEL: sil shared [serialized] [ossa] @$sSo3BarC5valueABSgs5Int32V_tcfC : $@convention(method) (Int32, @thick Bar.Type) -> @owned Optional { // CHECK: {{.*}} = function_ref @$sSo3BarC5valueABSgs5Int32V_tcfcTO : $@convention(method) // CHECK: } // end sil function '$sSo3BarC5valueABSgs5Int32V_tcfC' -// CHECK-DAG: sil @[[BYTE01]]-[Bar setDirectProperty:] : $@convention(objc_method) -// CHECK-DAG: sil @[[BYTE01]]-[Bar directProperty] : $@convention(objc_method) -// CHECK-DAG: sil @[[BYTE01]]-[Bar setDirectProperty2:] : $@convention(objc_method) -// CHECK-DAG: sil @[[BYTE01]]-[Bar directProperty2] : $@convention(objc_method) -// CHECK-DAG: sil @[[BYTE01]]-[Bar objectAtIndexedSubscript:] : $@convention(objc_method) -// CHECK-DAG: sil @[[BYTE01]]-[Bar setObject:atIndexedSubscript:] : $@convention(objc_method) -// CHECK-DAG: sil [clang Bar.directMethod] @[[BYTE01]]-[Bar directMethod] : $@convention(objc_method) -// CHECK-DAG: sil [clang Bar.directMethod2] @[[BYTE01]]-[Bar directMethod2] : $@convention(objc_method) -// CHECK-DAG: sil [clang Bar.directClassMethod] @[[BYTE01]]+[Bar directClassMethod] : $@convention(objc_method) -// CHECK-DAG: sil [clang Bar.directClassMethod2] @[[BYTE01]]+[Bar directClassMethod2] : $@convention(objc_method) +// CHECK: sil [asmname "[[BYTE01:.]]-[Bar setDirectProperty:]"] @$sSo3BarC14directPropertys5Int32VvsTo : $@convention(objc_method) +// CHECK: sil [asmname "[[BYTE01]]-[Bar directProperty]"] @$sSo3BarC14directPropertys5Int32VvgTo : $@convention(objc_method) +// CHECK: sil [asmname "[[BYTE01]]-[Bar setDirectProperty2:]"] @$sSo3BarC15directProperty2s5Int32VvsTo : $@convention(objc_method) +// CHECK: sil [asmname "[[BYTE01]]-[Bar directProperty2]"] @$sSo3BarC15directProperty2s5Int32VvgTo : $@convention(objc_method) +// CHECK: sil [asmname "[[BYTE01]]-[Bar directMethod]"] [clang Bar.directMethod] @$sSo3BarC12directMethodSSSgyFTo : $@convention(objc_method) +// CHECK: sil [asmname "[[BYTE01]]-[Bar directMethod2]"] [clang Bar.directMethod2] @$sSo3BarC13directMethod2SSSgyFTo : $@convention(objc_method) +// CHECK: sil [asmname "[[BYTE01]]+[Bar directClassMethod]"] [clang Bar.directClassMethod] @$sSo3BarC17directClassMethodSSSgyFZTo : $@convention(objc_method) +// CHECK-DAG: sil [asmname "[[BYTE01]]+[Bar directClassMethod2]"] [clang Bar.directClassMethod2] @$sSo3BarC18directClassMethod2SSSgyFZTo : $@convention(objc_method) -// CHECK: sil [clang Bar.directProtocolMethod] @[[BYTE01]]-[Bar directProtocolMethod] : $@convention(objc_method) +// CHECK: sil [asmname "[[BYTE01]]-[Bar directProtocolMethod]"] [clang Bar.directProtocolMethod] @$sSo3BarC20directProtocolMethodSSSgyFTo : $@convention(objc_method) // CHECK-LABEL: sil{{.*}}@$sSo3BarC5valueABSgs5Int32V_tcfcTO : $@convention(method) (Int32, @owned Bar) -> @owned Optional { -// CHECK: function_ref @[[BYTE01]]-[Bar initWithValue:] +// CHECK: function_ref @$sSo3BarC5valueABSgs5Int32V_tcfcTo : $@convention(objc_method) // CHECK: } // end sil function '$sSo3BarC5valueABSgs5Int32V_tcfcTO' diff --git a/test/SILGen/objc_error.swift b/test/SILGen/objc_error.swift index 2bea429434a89..add106c748dd7 100644 --- a/test/SILGen/objc_error.swift +++ b/test/SILGen/objc_error.swift @@ -90,14 +90,14 @@ func testAcceptError(error: Error) { // CHECK-LABEL: sil hidden [ossa] @$s10objc_error16testProduceError{{[_0-9a-zA-Z]*}}F func testProduceError() -> Error { - // CHECK: function_ref @produceError : $@convention(c) () -> @autoreleased NSError + // CHECK: function_ref @$sSo12produceErrors0B0_pyFTo : $@convention(c) () -> @autoreleased NSError // CHECK: init_existential_ref {{.*}} : $NSError : $NSError, $any Error return produceError() } // CHECK-LABEL: sil hidden [ossa] @$s10objc_error24testProduceOptionalError{{[_0-9a-zA-Z]*}}F func testProduceOptionalError() -> Error? { - // CHECK: function_ref @produceOptionalError + // CHECK: function_ref @$sSo20produceOptionalErrors0C0_pSgyFTo : $@convention(c) () -> @autoreleased Optional // CHECK: init_existential_ref {{.*}} : $NSError : $NSError, $any Error return produceOptionalError(); } diff --git a/test/SILGen/objc_factory_init.swift b/test/SILGen/objc_factory_init.swift index c50f8644b8813..5cf82c9c393dd 100644 --- a/test/SILGen/objc_factory_init.swift +++ b/test/SILGen/objc_factory_init.swift @@ -83,7 +83,7 @@ extension SomeClass { // CHECK-LABEL: sil hidden [ossa] @$sSo12IAMSomeClassC17objc_factory_initE6doubleABSd_tcfC // CHECK: bb0([[DOUBLE:%.*]] : $Double, // CHECK-NOT: value_metatype - // CHECK: [[FNREF:%[0-9]+]] = function_ref @MakeIAMSomeClass + // CHECK: [[FNREF:%[0-9]+]] = function_ref @$sSo12IAMSomeClassC5valueABSd_tcfCTo : $@convention(c) (Double) -> @autoreleased SomeClass // CHECK: apply [[FNREF]]([[DOUBLE]]) convenience init(double: Double) { self.init(value: double) diff --git a/test/SILGen/opaque_values_cxx.swift b/test/SILGen/opaque_values_cxx.swift index 641b66c11a6a8..f90b918636ffe 100644 --- a/test/SILGen/opaque_values_cxx.swift +++ b/test/SILGen/opaque_values_cxx.swift @@ -17,7 +17,7 @@ import Cxx // CHECK-LABEL: } // end sil function '$sSo3stdO3__1O0065vectorCUnsignedIntstd__1allocatorCUnsignedInt_dDGIrdqahddCJdFaAjaV3Cxx0B8SequenceSCAgHP13__beginUnsafe11RawIteratorQzyFTW' // CHECK-LABEL: sil {{.*}}[ossa] @$sSo3stdO{{(3__1O)?}}0047___wrap_iterUnsafePointerCUnsignedInt_heCInnaEgaVSQSCSQ2eeoiySbx_xtFZTW : {{.*}} { // CHECK: bb0([[LHS:%[^,]+]] : $std.__1.__wrap_iter>, [[RHS:%[^,]+]] : -// CHECK: [[CALLEE:%[^,]+]] = function_ref @_ZNSt3__1eqB8ne{{.*}}IPKjEEbRKNS_11__wrap_iterIT_EES7_ +// CHECK: [[CALLEE:%[^,]+]] = function_ref @$sSo2eeoiySbSo3stdO3__1O0047___wrap_iterUnsafePointerCUnsignedInt_heCInnaEgaV_AGtFTo // CHECK: [[EQUAL:%[^,]+]] = apply [[CALLEE]]([[LHS]], [[RHS]]) // CHECK: return [[EQUAL]] // CHECK-LABEL: } // end sil function '$sSo3stdO{{(3__1O)?}}0047___wrap_iterUnsafePointerCUnsignedInt_heCInnaEgaVSQSCSQ2eeoiySbx_xtFZTW' diff --git a/test/SILGen/pointer_conversion.swift b/test/SILGen/pointer_conversion.swift index 557a250e9597e..dcb4ea43aacf2 100644 --- a/test/SILGen/pointer_conversion.swift +++ b/test/SILGen/pointer_conversion.swift @@ -149,7 +149,7 @@ func arrayToPointer() { // CHECK: [[PTR:%[0-9]+]] = load [trivial] [[PTR_RESULT]] : $*UnsafePointer // CHECK: [[PTR_MD:%[0-9]+]] = mark_dependence [[PTR]] : $UnsafePointer on // CHECK: [[PTR_OPT:%[0-9]+]] = enum $Optional>, #Optional.some!enumelt, [[PTR_MD]] - // CHECK: [[READ_FN:%.*]] = function_ref @read_char : $@convention(c) (Optional>) -> () + // CHECK: [[READ_FN:%.*]] = function_ref @$sSo9read_charyySPys4Int8VGSgFTo : $@convention(c) (Optional>) -> () // CHECK: apply [[READ_FN]]([[PTR_OPT]]) : $@convention(c) (Optional>) -> () read_uchar(ints); // CHECK: [[CONVERT_FN:%.*]] = function_ref @$ss35_convertConstArrayToPointerArgumentyyXlSg_q_tSayxGs01_E0R_r0_lF @@ -157,7 +157,7 @@ func arrayToPointer() { // CHECK: [[PTR:%[0-9]+]] = load [trivial] [[PTR_RESULT]] : $*UnsafePointer // CHECK: [[PTR_MD:%[0-9]+]] = mark_dependence [[PTR]] : $UnsafePointer on // CHECK: [[PTR_OPT:%[0-9]+]] = enum $Optional>, #Optional.some!enumelt, [[PTR_MD]] - // CHECK: [[READ_FN:%.*]] = function_ref @read_uchar : $@convention(c) (Optional>) -> () + // CHECK: [[READ_FN:%.*]] = function_ref @$sSo10read_ucharyySPys5UInt8VGSgFTo : $@convention(c) (Optional>) -> () // CHECK: apply [[READ_FN]]([[PTR_OPT]]) : $@convention(c) (Optional>) -> () read_void(ints); // CHECK: [[CONVERT_FN:%.*]] = function_ref @$ss35_convertConstArrayToPointerArgumentyyXlSg_q_tSayxGs01_E0R_r0_lF @@ -165,7 +165,7 @@ func arrayToPointer() { // CHECK: [[PTR:%[0-9]+]] = load [trivial] [[PTR_RESULT]] : $*UnsafeRawPointer // CHECK: [[PTR_MD:%[0-9]+]] = mark_dependence [[PTR]] : $UnsafeRawPointer on // CHECK: [[PTR_OPT:%[0-9]+]] = enum $Optional, #Optional.some!enumelt, [[PTR_MD]] - // CHECK: [[READ_FN:%.*]] = function_ref @read_void : $@convention(c) (Optional) -> () + // CHECK: [[READ_FN:%.*]] = function_ref @$sSo9read_voidyySVSgFTo : $@convention(c) (Optional) -> () // CHECK: apply [[READ_FN]]([[PTR_OPT]]) : $@convention(c) (Optional) -> () write_char(&ints); // CHECK: [[CONVERT_FN:%.*]] = function_ref @$ss37_convertMutableArrayToPointerArgumentyyXlSg_q_tSayxGzs01_E0R_r0_lF @@ -173,7 +173,7 @@ func arrayToPointer() { // CHECK: [[PTR:%[0-9]+]] = load [trivial] [[PTR_RESULT]] : $*UnsafeMutablePointer // CHECK: [[PTR_MD:%[0-9]+]] = mark_dependence [[PTR]] : $UnsafeMutablePointer on // CHECK: [[PTR_OPT:%[0-9]+]] = enum $Optional>, #Optional.some!enumelt, [[PTR_MD]] - // CHECK: [[WRITE_FN:%.*]] = function_ref @write_char : $@convention(c) (Optional>) -> () + // CHECK: [[WRITE_FN:%.*]] = function_ref @$sSo10write_charyySpys4Int8VGSgFTo : $@convention(c) (Optional>) -> () // CHECK: apply [[WRITE_FN]]([[PTR_OPT]]) : $@convention(c) (Optional>) -> () write_uchar(&ints); // CHECK: [[CONVERT_FN:%.*]] = function_ref @$ss37_convertMutableArrayToPointerArgumentyyXlSg_q_tSayxGzs01_E0R_r0_lF @@ -181,7 +181,7 @@ func arrayToPointer() { // CHECK: [[PTR:%[0-9]+]] = load [trivial] [[PTR_RESULT]] : $*UnsafeMutablePointer // CHECK: [[PTR_MD:%[0-9]+]] = mark_dependence [[PTR]] : $UnsafeMutablePointer on // CHECK: [[PTR_OPT:%[0-9]+]] = enum $Optional>, #Optional.some!enumelt, [[PTR_MD]] - // CHECK: [[WRITE_FN:%.*]] = function_ref @write_uchar : $@convention(c) (Optional>) -> () + // CHECK: [[WRITE_FN:%.*]] = function_ref @$sSo11write_ucharyySpys5UInt8VGSgFTo : $@convention(c) (Optional>) -> () // CHECK: apply [[WRITE_FN]]([[PTR_OPT]]) : $@convention(c) (Optional>) -> () write_void(&ints); // CHECK: [[CONVERT_FN:%.*]] = function_ref @$ss37_convertMutableArrayToPointerArgumentyyXlSg_q_tSayxGzs01_E0R_r0_lF @@ -189,7 +189,7 @@ func arrayToPointer() { // CHECK: [[PTR:%[0-9]+]] = load [trivial] [[PTR_RESULT]] : $*UnsafeMutableRawPointer // CHECK: [[PTR_MD:%[0-9]+]] = mark_dependence [[PTR]] : $UnsafeMutableRawPointer on // CHECK: [[PTR_OPT:%[0-9]+]] = enum $Optional, #Optional.some!enumelt, [[PTR_MD]] - // CHECK: [[WRITE_FN:%.*]] = function_ref @write_void : $@convention(c) (Optional) -> () + // CHECK: [[WRITE_FN:%.*]] = function_ref @$sSo10write_voidyySvSgFTo : $@convention(c) (Optional) -> () // CHECK: apply [[WRITE_FN]]([[PTR_OPT]]) : $@convention(c) (Optional) -> () } diff --git a/test/SILOptimizer/closure_lifetime_fixup_objc.swift b/test/SILOptimizer/closure_lifetime_fixup_objc.swift index e97457e87e96a..0a05826a1044c 100644 --- a/test/SILOptimizer/closure_lifetime_fixup_objc.swift +++ b/test/SILOptimizer/closure_lifetime_fixup_objc.swift @@ -92,7 +92,7 @@ public func couldActuallyEscapeWithLoop(_ closure: @escaping () -> (), _ villain // CHECK: [[SOME:%.*]] = enum $Optional<{{.*}}>, #Optional.some!enumelt, [[MDI]] // CHECK: [[BLOCK_COPY:%.*]] = copy_block [[BLOCK]] // CHECK: destroy_addr [[BLOCK_PROJ]] -// CHECK: [[DISPATCH_SYNC_FUNC:%.*]] = function_ref @dispatch_sync : +// CHECK: [[DISPATCH_SYNC_FUNC:%.*]] = function_ref @$sSo17OS_dispatch_queueC4sync7executeyyyXE_tFTo : // CHECK: apply [[DISPATCH_SYNC_FUNC]]({{%.*}}, [[BLOCK_COPY]]) // CHECK: strong_release [[BLOCK_COPY]] // CHECK: destroy_not_escaped_closure [objc] [[SOME]] diff --git a/test/SILOptimizer/closure_specialize_block.swift b/test/SILOptimizer/closure_specialize_block.swift index 30e5b758b4931..c5dd27b82ff46 100644 --- a/test/SILOptimizer/closure_specialize_block.swift +++ b/test/SILOptimizer/closure_specialize_block.swift @@ -5,10 +5,10 @@ func callClosure(_ body: () -> R) -> R { } // Check that after removing a copy_block, no retains+releases are inserted for the block. -// CHECK-LABEL: sil {{.*}}@testit : +// CHECK-LABEL: sil {{.*}} [asmname "testit"] {{.*}} : // CHECK-NOT: retain // CHECK-NOT: release -// CHECK: } // end sil function 'testit' +// CHECK: } // end sil function @_cdecl("testit") public func testit(_ block: (_ index: Int) -> Int) -> Bool { @inline(never) diff --git a/test/SILOptimizer/definite-init-convert-to-escape.swift b/test/SILOptimizer/definite-init-convert-to-escape.swift index fccff212f67c2..df3984c3d20d4 100644 --- a/test/SILOptimizer/definite-init-convert-to-escape.swift +++ b/test/SILOptimizer/definite-init-convert-to-escape.swift @@ -24,7 +24,7 @@ import Foundation // CHECK: convert_escape_to_noescape % // CHECK: strong_release // CHECK: bb10 -// CHECK: [[F:%.*]] = function_ref @noescapeBlock3 +// CHECK: [[F:%.*]] = function_ref @$sSo14noescapeBlock3yyySSSgXESg_AcBtFTo // CHECK: apply [[F]] // CHECK: release_value {{.*}} : $Optional // CHECK: release_value %1 : $Optional<@callee_guaranteed (@guaranteed Optional) -> ()> @@ -77,7 +77,7 @@ public func returnOptionalEscape() -> (() ->())? // CHECK: br bb5([[NONE_BLOCK]] : {{.*}}, [[NONE]] : // // CHECK: bb5([[BLOCK_PHI:%.*]] : $Optional<{{.*}}>, [[SWIFT_CLOSURE_PHI:%.*]] : -// CHECK: [[F:%.*]] = function_ref @noescapeBlock +// CHECK: [[F:%.*]] = function_ref @$sSo13noescapeBlockyyyyXESgFTo // CHECK: apply [[F]]([[BLOCK_PHI]]) // CHECK: release_value [[BLOCK_PHI]] // CHECK: release_value [[SWIFT_CLOSURE_PHI]] @@ -110,8 +110,7 @@ public func returnOptionalEscape() -> (() ->())? // NOPEEPHOLE: br bb5 // // NOPEEPHOLE: bb5([[BLOCK_PHI:%.*]] : $Optional<{{.*}}>, [[SWIFT_CLOSURE_PHI:%.*]] : -// NOPEEPHOLE-NEXT: function_ref noescapeBlock -// NOPEEPHOLE-NEXT: [[F:%.*]] = function_ref @noescapeBlock : +// NOPEEPHOLE: [[F:%.*]] = function_ref @$sSo13noescapeBlockyyyyXESgFTo : // NOPEEPHOLE-NEXT: apply [[F]]([[BLOCK_PHI]]) // NOPEEPHOLE-NEXT: release_value [[BLOCK_PHI]] // NOPEEPHOLE-NEXT: tuple diff --git a/test/SILOptimizer/objc_bridging_opt.swift b/test/SILOptimizer/objc_bridging_opt.swift index 3d3b658b5a6e7..a0d365f786374 100644 --- a/test/SILOptimizer/objc_bridging_opt.swift +++ b/test/SILOptimizer/objc_bridging_opt.swift @@ -12,14 +12,14 @@ import Foundation // CHECK-SIL-LABEL: sil hidden [noinline] @$s4test0A17NonOptionalStringyyF -// CHECK-SIL: [[F1:%[0-9]+]] = function_ref @returnNSString +// CHECK-SIL: [[F1:%[0-9]+]] = function_ref @$sSo14returnNSStringSSyFTo // CHECK-SIL: apply [[F1]]() // CHECK-SIL-NOT: apply // CHECK-SIL: switch_enum // CHECK-SIL: [[F2:%[0-9]+]] = function_ref @$sSS10FoundationE19_bridgeToObjectiveCSo8NSStringCyF // CHECK-SIL: apply [[F2]] // CHECK-SIL-NOT: apply -// CHECK-SIL: [[F3:%[0-9]+]] = function_ref @useNSString +// CHECK-SIL: [[F3:%[0-9]+]] = function_ref @$sSo11useNSStringyySSFTo // CHECK-SIL: apply [[F3]] // CHECK-SIL: // end sil function '$s4test0A17NonOptionalStringyyF' @inline(never) @@ -36,14 +36,14 @@ func testOptionalString(_ some: Bool) { } // CHECK-SIL-LABEL: sil hidden [noinline] @$s4test0a13NonOptionalToC6StringyyF -// CHECK-SIL: [[F1:%[0-9]+]] = function_ref @returnNSString +// CHECK-SIL: [[F1:%[0-9]+]] = function_ref @$sSo14returnNSStringSSyFTo // CHECK-SIL: apply [[F1]]() // CHECK-SIL-NOT: apply // CHECK-SIL: switch_enum // CHECK-SIL: [[F2:%[0-9]+]] = function_ref @$sSS10FoundationE19_bridgeToObjectiveCSo8NSStringCyF // CHECK-SIL: apply [[F2]] // CHECK-SIL-NOT: apply -// CHECK-SIL: [[F3:%[0-9]+]] = function_ref @useOptNSString +// CHECK-SIL: [[F3:%[0-9]+]] = function_ref @$sSo14useOptNSStringyySSSgFTo // CHECK-SIL: apply [[F3]] // CHECK-SIL: // end sil function '$s4test0a13NonOptionalToC6StringyyF' @inline(never) @@ -62,14 +62,14 @@ func testOptionalToNonOptionalString(_ some: Bool) { } // CHECK-SIL-LABEL: sil hidden [noinline] @$s4test0A15NonOptionalLoopyySiF -// CHECK-SIL: [[F1:%[0-9]+]] = function_ref @returnNSString +// CHECK-SIL: [[F1:%[0-9]+]] = function_ref @$sSo14returnNSStringSSyFTo // CHECK-SIL: apply [[F1]]() // CHECK-SIL-NOT: apply // CHECK-SIL: switch_enum // CHECK-SIL: [[F2:%[0-9]+]] = function_ref @$sSS10FoundationE19_bridgeToObjectiveCSo8NSStringCyF // CHECK-SIL: apply [[F2]] // CHECK-SIL-NOT: apply -// CHECK-SIL: [[F3:%[0-9]+]] = function_ref @useNSString +// CHECK-SIL: [[F3:%[0-9]+]] = function_ref @$sSo11useNSStringyySSFTo // CHECK-SIL: apply [[F3]] // CHECK-SIL: // end sil function '$s4test0A15NonOptionalLoopyySiF' @inline(never) diff --git a/test/Serialization/Recovery/error-sil-function.swift b/test/Serialization/Recovery/error-sil-function.swift index f6f6eb1608f76..f4c9390967cb4 100644 --- a/test/Serialization/Recovery/error-sil-function.swift +++ b/test/Serialization/Recovery/error-sil-function.swift @@ -1,7 +1,5 @@ // RUN: %empty-directory(%t/cache) -// RUN: not --crash %target-swift-frontend -c %s -module-cache-path %t/cache 2>&1 | %FileCheck %s -// CHECK: *** DESERIALIZATION FAILURE *** -// CHECK: SILFunction type mismatch for 'asinf': '$@convention(thin) (Float) -> Float' != '$@convention(c) (Float) -> Float' +// RUN: %target-swift-frontend -c %s -module-cache-path %t/cache // REQUIRES: VENDOR=apple diff --git a/test/Serialization/inlined-shadowed-clang-vs-swift.swift b/test/Serialization/inlined-shadowed-clang-vs-swift.swift index 519ddc8ab64aa..bfd3a649c4f74 100644 --- a/test/Serialization/inlined-shadowed-clang-vs-swift.swift +++ b/test/Serialization/inlined-shadowed-clang-vs-swift.swift @@ -59,6 +59,6 @@ swiftUser() // CHECK-NOT: apply [[SWIFT_FUNC]]() : $@convention(thin) () -> () clangUser() -// CHECK: [[CLANG_FUNC:%.*]] = function_ref @ShadowedFunc : $@convention(c) () -> () +// CHECK: [[CLANG_FUNC:%.*]] = function_ref @$sSo12ShadowedFuncyyFTo : $@convention(c) () -> () // CHECK: apply [[CLANG_FUNC]]() : $@convention(c) () -> () // CHECK-NOT: apply [[CLANG_FUNC]]() : $@convention(c) () -> () diff --git a/test/Serialization/inlined-shadowed-layered-modules.swift b/test/Serialization/inlined-shadowed-layered-modules.swift index d2c6aef4d824f..42c9c80146dbd 100644 --- a/test/Serialization/inlined-shadowed-layered-modules.swift +++ b/test/Serialization/inlined-shadowed-layered-modules.swift @@ -120,7 +120,7 @@ userFromHigh() clangUserFromRoot() clangUserFromMiddle() clangUserFromHigh() -// CHECK: [[CLANG_FUNC:%.*]] = function_ref @ShadowedFuncClang : $@convention(c) () -> () +// CHECK: [[CLANG_FUNC:%.*]] = function_ref @$sSo17ShadowedFuncClangyyFTo : $@convention(c) () -> () // CHECK: apply [[CLANG_FUNC]]() : $@convention(c) () -> () // CHECK: apply [[CLANG_FUNC]]() : $@convention(c) () -> () // CHECK: apply [[CLANG_FUNC]]() : $@convention(c) () -> () diff --git a/test/embedded/modules-used2.swift b/test/embedded/modules-used2.swift index ff62698302725..4f0905313f6f5 100644 --- a/test/embedded/modules-used2.swift +++ b/test/embedded/modules-used2.swift @@ -30,8 +30,8 @@ import MyModule // CHECK-SIL: // main() // CHECK-SIL-NEXT: sil [used] @$e8MyModule4mains5Int32VyF : $@convention(thin) () -> Int32 { -// CHECK-SIL: // main -// CHECK-SIL-NEXT: sil [thunk] [used] @main : $@convention(c) () -> Int32 +// CHECK-SIL: // @objc main +// CHECK-SIL-NEXT: sil [thunk] [used] [asmname "main"] @$e8MyModule4mains5Int32VyFTo : $@convention(c) () -> Int32 // CHECK-SIL: // foo() // CHECK-SIL-NEXT: sil [used] @$e8MyModule3fooyyF : $@convention(thin) () -> () { diff --git a/test/multifile/batch_mode_external_definitions.swift b/test/multifile/batch_mode_external_definitions.swift index 0075a3523cba8..d3f76cbbd7cf4 100644 --- a/test/multifile/batch_mode_external_definitions.swift +++ b/test/multifile/batch_mode_external_definitions.swift @@ -19,51 +19,51 @@ // // CHECK-FIELD1-ONLY: sil_stage canonical // CHECK-FIELD1-ONLY: use_extern_struct_field_1 -// CHECK-FIELD1-ONLY: sil shared{{.*}}@$So13extern_structV$field$getter -// CHECK-FIELD1-ONLY-NOT: sil shared{{.*}}@$So13extern_structV$field$getter +// CHECK-FIELD1-ONLY: sil shared{{.*}}@$sSo13extern_structV5fields5Int32VvgTo +// CHECK-FIELD1-ONLY-NOT: sil shared{{.*}}@$sSo13extern_structV5fields5Int32VvgTo // CHECK-FIELD1-ONLY: sil_stage canonical // CHECK-FIELD1-ONLY-NOT: use_extern_struct_field_2 -// CHECK-FIELD1-ONLY-NOT: sil shared{{.*}}extern_struct$field$getter +// CHECK-FIELD1-ONLY-NOT: sil shared{{.*}}extern_struct{{.*}}vgTo // // CHECK-FIELD1-ONLY-REORDER: sil_stage canonical // CHECK-FIELD1-ONLY-REORDER-NOT: use_extern_struct_field_2 -// CHECK-FIELD1-ONLY-REORDER-NOT: sil shared{{.*}}extern_struct$field$getter +// CHECK-FIELD1-ONLY-REORDER-NOT: sil shared{{.*}}extern_struct{{.*}}vgTo // CHECK-FIELD1-ONLY-REORDER: sil_stage canonical // CHECK-FIELD1-ONLY-REORDER: use_extern_struct_field_1 -// CHECK-FIELD1-ONLY-REORDER: sil shared{{.*}}@$So13extern_structV$field$getter -// CHECK-FIELD1-ONLY-REORDER-NOT: sil shared{{.*}}@$So13extern_structV$field$getter +// CHECK-FIELD1-ONLY-REORDER: sil shared{{.*}}@$sSo13extern_structV5fields5Int32VvgTo +// CHECK-FIELD1-ONLY-REORDER-NOT: sil shared{{.*}}@$sSo13extern_structV5fields5Int32VvgTo // // CHECK-FIELD2-ONLY: sil_stage canonical // CHECK-FIELD2-ONLY-NOT: use_extern_struct_field_1 -// CHECK-FIELD2-ONLY-NOT: sil shared{{.*}}extern_struct$field$getter +// CHECK-FIELD2-ONLY-NOT: sil shared{{.*}}extern_struct{{.*}}vgTo // CHECK-FIELD2-ONLY: sil_stage canonical // CHECK-FIELD2-ONLY: use_extern_struct_field_2 -// CHECK-FIELD2-ONLY: sil shared{{.*}}@$So13extern_structV$field$getter -// CHECK-FIELD2-ONLY-NOT: sil shared{{.*}}@$So13extern_structV$field$getter +// CHECK-FIELD2-ONLY: sil shared{{.*}}@$sSo13extern_structV5fields5Int32VvgTo +// CHECK-FIELD2-ONLY-NOT: sil shared{{.*}}@$sSo13extern_structV5fields5Int32VvgTo // // CHECK-FIELD2-ONLY-REORDER: sil_stage canonical // CHECK-FIELD2-ONLY-REORDER: use_extern_struct_field_2 -// CHECK-FIELD2-ONLY-REORDER: sil shared{{.*}}@$So13extern_structV$field$getter -// CHECK-FIELD2-ONLY-REORDER-NOT: sil shared{{.*}}@$So13extern_structV$field$getter +// CHECK-FIELD2-ONLY-REORDER: sil shared{{.*}}@$sSo13extern_structV5fields5Int32VvgTo +// CHECK-FIELD2-ONLY-REORDER-NOT: sil shared{{.*}}@$sSo13extern_structV5fields5Int32VvgTo // CHECK-FIELD2-ONLY-REORDER: sil_stage canonical // CHECK-FIELD2-ONLY-REORDER-NOT: use_extern_struct_field_1 -// CHECK-FIELD2-ONLY-REORDER-NOT: sil shared{{.*}}extern_struct$field$getter +// CHECK-FIELD2-ONLY-REORDER-NOT: sil shared{{.*}}extern_struct{{.*}}vgTo // // CHECK-BOTH-FIELDS: sil_stage canonical // CHECK-BOTH-FIELDS: use_extern_struct_field_1 -// CHECK-BOTH-FIELDS: sil shared{{.*}}@$So13extern_structV$field$getter -// CHECK-BOTH-FIELDS-NOT: sil shared{{.*}}@$So13extern_structV$field$getter +// CHECK-BOTH-FIELDS: sil shared{{.*}}@$sSo13extern_structV5fields5Int32VvgTo +// CHECK-BOTH-FIELDS-NOT: sil shared{{.*}}@$sSo13extern_structV5fields5Int32VvgTo // CHECK-BOTH-FIELDS: sil_stage canonical // CHECK-BOTH-FIELDS: use_extern_struct_field_2 -// CHECK-BOTH-FIELDS: sil shared{{.*}}@$So13extern_structV$field$getter -// CHECK-BOTH-FIELDS-NOT: sil shared{{.*}}@$So13extern_structV$field$getter +// CHECK-BOTH-FIELDS: sil shared{{.*}}@$sSo13extern_structV5fields5Int32VvgTo +// CHECK-BOTH-FIELDS-NOT: sil shared{{.*}}@$sSo13extern_structV5fields5Int32VvgTo // // CHECK-NEITHER-FIELD: sil_stage canonical // CHECK-NEITHER-FIELD-NOT: use_extern_struct_field_1 -// CHECK-NEITHER-FIELD-NOT: sil shared{{.*}}extern_struct$field$getter +// CHECK-NEITHER-FIELD-NOT: sil shared{{.*}}extern_struct{{.*}}vgTo // CHECK-NEITHER-FIELD: sil_stage canonical // CHECK-NEITHER-FIELD-NOT: use_extern_struct_field_2 -// CHECK-NEITHER-FIELD-NOT: sil shared{{.*}}extern_struct$field$getter +// CHECK-NEITHER-FIELD-NOT: sil shared{{.*}}extern_struct{{.*}}vgTo // From 0ac8a830512258c7098152f5cc2baf30eea2fd10 Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Tue, 28 Oct 2025 06:18:36 -0700 Subject: [PATCH 2/8] Use correct IR name for AutoDiff mangling --- lib/AST/ASTMangler.cpp | 13 ++ .../Mandatory/Differentiation.cpp | 19 +- ...etained-unretained-attributes-silgen.swift | 190 +++++++++--------- 3 files changed, 121 insertions(+), 101 deletions(-) diff --git a/lib/AST/ASTMangler.cpp b/lib/AST/ASTMangler.cpp index f9a6ed9c7f1a6..6d88e666e7d2b 100644 --- a/lib/AST/ASTMangler.cpp +++ b/lib/AST/ASTMangler.cpp @@ -669,6 +669,19 @@ void ASTMangler::beginManglingWithAutoDiffOriginalFunction( beginManglingClangDecl(typedefType->getDecl()); return; } + + if (auto *EA = ExternAttr::find(afd->getAttrs(), ExternKind::C)) { + beginManglingWithoutPrefix(); + appendOperator(EA->getCName(afd)); + return; + } + + if (afd->getAttrs().hasAttribute()) { + beginManglingWithoutPrefix(); + appendOperator(afd->getCDeclName()); + return; + } + beginMangling(); if (auto *cd = dyn_cast(afd)) appendConstructorEntity(cd, /*isAllocating*/ !cd->isConvenienceInit()); diff --git a/lib/SILOptimizer/Mandatory/Differentiation.cpp b/lib/SILOptimizer/Mandatory/Differentiation.cpp index 50bf686400211..020d6f13ea5ab 100644 --- a/lib/SILOptimizer/Mandatory/Differentiation.cpp +++ b/lib/SILOptimizer/Mandatory/Differentiation.cpp @@ -983,6 +983,13 @@ DifferentiationTransformer::emitDerivativeFunctionReference( // `SILDifferentiabilityWitness` processing //===----------------------------------------------------------------------===// +static StringRef getIRName(SILFunction *F) { + if (!F->asmName().empty()) + return F->asmName(); + + return F->getName(); +} + static SILFunction *createEmptyVJP(ADContext &context, SILDifferentiabilityWitness *witness, SerializedKind_t isSerialized) { @@ -990,7 +997,7 @@ static SILFunction *createEmptyVJP(ADContext &context, auto config = witness->getConfig(); LLVM_DEBUG({ auto &s = getADDebugStream(); - s << "Creating VJP for " << original->getName() << ":\n\t"; + s << "Creating VJP for " << getIRName(original) << ":\n\t"; s << "Original type: " << original->getLoweredFunctionType() << "\n\t"; s << "Config: " << config << "\n\t"; }); @@ -1001,7 +1008,7 @@ static SILFunction *createEmptyVJP(ADContext &context, // === Create an empty VJP. === Mangle::DifferentiationMangler mangler(context.getASTContext()); auto vjpName = mangler.mangleDerivativeFunction( - original->getName(), AutoDiffDerivativeFunctionKind::VJP, config); + getIRName(original), AutoDiffDerivativeFunctionKind::VJP, config); auto vjpCanGenSig = witness->getDerivativeGenericSignature().getCanonicalSignature(); GenericEnvironment *vjpGenericEnv = nullptr; if (vjpCanGenSig && !vjpCanGenSig->areAllParamsConcrete()) @@ -1035,7 +1042,7 @@ static SILFunction *createEmptyJVP(ADContext &context, auto config = witness->getConfig(); LLVM_DEBUG({ auto &s = getADDebugStream(); - s << "Creating JVP for " << original->getName() << ":\n\t"; + s << "Creating JVP for " << getIRName(original) << ":\n\t"; s << "Original type: " << original->getLoweredFunctionType() << "\n\t"; s << "Config: " << config << "\n\t"; }); @@ -1045,7 +1052,7 @@ static SILFunction *createEmptyJVP(ADContext &context, Mangle::DifferentiationMangler mangler(context.getASTContext()); auto jvpName = mangler.mangleDerivativeFunction( - original->getName(), AutoDiffDerivativeFunctionKind::JVP, config); + getIRName(original), AutoDiffDerivativeFunctionKind::JVP, config); auto jvpCanGenSig = witness->getDerivativeGenericSignature().getCanonicalSignature(); GenericEnvironment *jvpGenericEnv = nullptr; if (jvpCanGenSig && !jvpCanGenSig->areAllParamsConcrete()) @@ -1174,7 +1181,7 @@ bool DifferentiationTransformer::canonicalizeDifferentiabilityWitness( "_fatalErrorForwardModeDifferentiationDisabled"); LLVM_DEBUG(getADDebugStream() << "Generated empty JVP for " - << orig->getName() << ":\n" + << getIRName(orig) << ":\n" << *jvp); } } @@ -1245,7 +1252,7 @@ static SILValue promoteCurryThunkApplicationToDifferentiableFunction( // Create a new curry thunk. AutoDiffConfig desiredConfig(parameterIndices, resultIndices); // TODO(TF-685): Use more principled mangling for thunks. - auto newThunkName = "AD__" + thunk->getName().str() + + auto newThunkName = "AD__" + getIRName(thunk).str() + "__differentiable_curry_thunk_" + desiredConfig.mangle(); // Construct new curry thunk type with `@differentiable` function diff --git a/test/Interop/Cxx/foreign-reference/frt-retained-unretained-attributes-silgen.swift b/test/Interop/Cxx/foreign-reference/frt-retained-unretained-attributes-silgen.swift index 00df0fa9a5a01..536853614b19b 100644 --- a/test/Interop/Cxx/foreign-reference/frt-retained-unretained-attributes-silgen.swift +++ b/test/Interop/Cxx/foreign-reference/frt-retained-unretained-attributes-silgen.swift @@ -4,231 +4,231 @@ import FunctionsAndMethodsReturningFRT func testFriendFunctionsReturningFRT() { let frtLocalVar1 = returnInstanceOfFRTStruct() - // CHECK: function_ref @{{.*}}returnInstanceOfFRTStruct{{.*}} : $@convention(c) () -> Optional + // CHECK: function_ref @$sSo25returnInstanceOfFRTStructSo0D0VSgyFTo : $@convention(c) () -> Optional let frtLocalVar2 = returnInstanceOfFRTStructWithAttrReturnsRetained() - // CHECK: function_ref @{{.*}}returnInstanceOfFRTStructWithAttrReturnsRetained{{.*}} : $@convention(c) () -> @owned Optional + // CHECK: function_ref @$sSo48returnInstanceOfFRTStructWithAttrReturnsRetainedSo0D0VSgyFTo : $@convention(c) () -> @owned Optional let frtLocalVar3 = returnInstanceOfFRTStructWithAttrReturnsUnretained() - // CHECK: function_ref @{{.*}}returnInstanceOfFRTStructWithAttrReturnsUnretained{{.*}} : $@convention(c) () -> Optional + // CHECK: function_ref @$sSo50returnInstanceOfFRTStructWithAttrReturnsUnretainedSo0D0VSgyFTo : $@convention(c) () -> Optional } func testFreeFunctionsWithoutAttrubutes() { let frtLocalVar1 = global_function_returning_FRT() - // CHECK: function_ref @{{.*}}global_function_returning_FRT{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo29global_function_returning_FRTSo9FRTStructVyFTo : $@convention(c) () -> FRTStruct // Free/global functions having copy/create in the function name are passed as owned by default let frtLocalVar2 = global_function_returning_copy() - // CHECK: function_ref @{{.*}}global_function_returning_copy{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo30global_function_returning_copySo9FRTStructVyFTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar3 = global_function_returning_create() - // CHECK: function_ref @{{.*}}global_function_returning_create{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo32global_function_returning_createSo9FRTStructVyFTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar4 = global_function_returning_init() - // CHECK: function_ref @{{.*}}global_function_returning_init{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo30global_function_returning_initSo9FRTStructVyFTo : $@convention(c) () -> FRTStruct let frtLocalVar5 = global_function_returning_clone() - // CHECK: function_ref @{{.*}}global_function_returning_clone{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo31global_function_returning_cloneSo9FRTStructVyFTo : $@convention(c) () -> FRTStruct } func testFreeFunctionsWithAttrubuteReturnsRetained() { let frtLocalVar1 = global_function_returning_FRT_with_attr_returns_retained() - // CHECK: function_ref @{{.*}}global_function_returning_FRT_with_attr_returns_retained{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo56global_function_returning_FRT_with_attr_returns_retainedSo9FRTStructVyFTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar2 = global_function_returning_copy_with_attr_returns_retained() - // CHECK: function_ref @{{.*}}global_function_returning_copy_with_attr_returns_retained{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo57global_function_returning_copy_with_attr_returns_retainedSo9FRTStructVyFTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar3 = global_function_returning_create_with_attr_returns_retained() - // CHECK: function_ref @{{.*}}global_function_returning_create_with_attr_returns_retained{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo59global_function_returning_create_with_attr_returns_retainedSo9FRTStructVyFTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar4 = global_function_returning_init_with_attr_returns_retained() - // CHECK: function_ref @{{.*}}global_function_returning_init_with_attr_returns_retained{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo57global_function_returning_init_with_attr_returns_retainedSo9FRTStructVyFTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar5 = global_function_returning_clone_with_attr_returns_retained() - // CHECK: function_ref @{{.*}}global_function_returning_clone_with_attr_returns_retained{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo58global_function_returning_clone_with_attr_returns_retainedSo9FRTStructVyFTo : $@convention(c) () -> @owned FRTStruct } func testFreeFunctionsWithAttrubuteReturnsUnretained() { let frtLocalVar1 = global_function_returning_FRT_with_attr_returns_unretained() - // CHECK: function_ref @{{.*}}global_function_returning_FRT_with_attr_returns_unretained{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo58global_function_returning_FRT_with_attr_returns_unretainedSo9FRTStructVyFTo : $@convention(c) () -> FRTStruct let frtLocalVar2 = global_function_returning_copy_with_attr_returns_unretained() - // CHECK: function_ref @{{.*}}global_function_returning_copy_with_attr_returns_unretained{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo59global_function_returning_copy_with_attr_returns_unretainedSo9FRTStructVyFTo : $@convention(c) () -> FRTStruct let frtLocalVar3 = global_function_returning_create_with_attr_returns_unretained() - // CHECK: function_ref @{{.*}}global_function_returning_create_with_attr_returns_unretained{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo61global_function_returning_create_with_attr_returns_unretainedSo9FRTStructVyFTo : $@convention(c) () -> FRTStruct let frtLocalVar4 = global_function_returning_init_with_attr_returns_unretained() - // CHECK: function_ref @{{.*}}global_function_returning_init_with_attr_returns_unretained{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo59global_function_returning_init_with_attr_returns_unretainedSo9FRTStructVyFTo : $@convention(c) () -> FRTStruct let frtLocalVar5 = global_function_returning_clone_with_attr_returns_unretained() - // CHECK: function_ref @{{.*}}global_function_returning_clone_with_attr_returns_unretained{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo60global_function_returning_clone_with_attr_returns_unretainedSo9FRTStructVyFTo : $@convention(c) () -> FRTStruct } func testStaticFreeFunctions() { let frtLocalVar1 = global_static_function_returning_FRT() - // CHECK: function_ref @{{.*}}global_static_function_returning_FRT{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo36global_static_function_returning_FRTSo9FRTStructVyFTo : $@convention(c) () -> FRTStruct let frtLocalVar2 = global_static_function_returning_FRT_with_attr_returns_retained() - // CHECK: function_ref @{{.*}}global_static_function_returning_FRT_with_attr_returns_retained{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo63global_static_function_returning_FRT_with_attr_returns_retainedSo9FRTStructVyFTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar3 = global_static_function_returning_FRT_with_attr_returns_unretained() - // CHECK: function_ref @{{.*}}global_static_function_returning_FRT_with_attr_returns_unretained{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo65global_static_function_returning_FRT_with_attr_returns_unretainedSo9FRTStructVyFTo : $@convention(c) () -> FRTStruct let frtLocalVar4 = global_static_function_returning_copy() - // CHECK: function_ref @{{.*}}global_static_function_returning_copy{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo37global_static_function_returning_copySo9FRTStructVyFTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar5 = global_static_function_returning_create() - // CHECK: function_ref @{{.*}}global_static_function_returning_create{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo39global_static_function_returning_createSo9FRTStructVyFTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar6 = global_static_function_returning_copy_with_attr_returns_retained() - // CHECK: function_ref @{{.*}}global_static_function_returning_copy_with_attr_returns_retained{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo64global_static_function_returning_copy_with_attr_returns_retainedSo9FRTStructVyFTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar7 = global_static_function_returning_copy_with_attr_returns_unretained() - // CHECK: function_ref @{{.*}}global_static_function_returning_copy_with_attr_returns_unretained{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo66global_static_function_returning_copy_with_attr_returns_unretainedSo9FRTStructVyFTo : $@convention(c) () -> FRTStruct } // Testing Global/free C++ functions without _Nonnull func testtFreeFunctionsWithoutNonnull() { let frtLocalVar1 = global_function_returning_FRT_wihout_Nonnull() - // CHECK: function_ref @{{.*}}global_function_returning_FRT_wihout_Nonnull{{.*}} : $@convention(c) () -> Optional + // CHECK: function_ref @$sSo44global_function_returning_FRT_wihout_NonnullSo9FRTStructVSgyFTo : $@convention(c) () -> Optional let frtLocalVar2 = global_function_returning_FRT_with_attr_returns_retained_wihout_Nonnull() - // CHECK: function_ref @{{.*}}global_function_returning_FRT_with_attr_returns_retained_wihout_Nonnull{{.*}} : $@convention(c) () -> @owned Optional - + // CHECK: function_ref @$sSo71global_function_returning_FRT_with_attr_returns_retained_wihout_NonnullSo9FRTStructVSgyFTo : $@convention(c) () -> @owned Optional + let frtLocalVar3 = global_function_returning_FRT_with_attr_returns_unretained_wihout_Nonnull() - // CHECK: function_ref @{{.*}}global_function_returning_FRT_with_attr_returns_unretained_wihout_Nonnull{{.*}} : $@convention(c) () -> Optional + // CHECK: function_ref @$sSo73global_function_returning_FRT_with_attr_returns_unretained_wihout_NonnullSo9FRTStructVSgyFTo : $@convention(c) () -> Optional let frtLocalVar4 = global_function_returning_copy_wihout_Nonnull() - // CHECK: function_ref @{{.*}}global_function_returning_copy_wihout_Nonnull{{.*}} : $@convention(c) () -> @owned Optional + // CHECK: function_ref @$sSo45global_function_returning_copy_wihout_NonnullSo9FRTStructVSgyFTo : $@convention(c) () -> @owned Optional let frtLocalVar5 = global_function_returning_create_wihout_Nonnull() - // CHECK: function_ref @{{.*}}global_function_returning_create_wihout_Nonnull{{.*}} : $@convention(c) () -> @owned Optional + // CHECK: function_ref @$sSo47global_function_returning_create_wihout_NonnullSo9FRTStructVSgyFTo : $@convention(c) () -> @owned Optional let frtLocalVar6 = global_function_returning_copy_with_attr_returns_retained_wihout_Nonnull() - // CHECK: function_ref @{{.*}}global_function_returning_copy_with_attr_returns_retained_wihout_Nonnull{{.*}} : $@convention(c) () -> @owned Optional + // CHECK: function_ref @$sSo72global_function_returning_copy_with_attr_returns_retained_wihout_NonnullSo9FRTStructVSgyFTo : $@convention(c) () -> @owned Optional let frtLocalVar7 = global_function_returning_copy_with_attr_returns_unretained_wihout_Nonnull() - // CHECK: function_ref @{{.*}}global_function_returning_copy_with_attr_returns_unretained_wihout_Nonnull{{.*}} : $@convention(c) () -> Optional + // CHECK: function_ref @$sSo74global_function_returning_copy_with_attr_returns_unretained_wihout_NonnullSo9FRTStructVSgyFTo : $@convention(c) () -> Optional } func testStaticMethodsWithoutAttrubutes() { let frtLocalVar1 = StructWithStaticMethodsReturningFRTWithoutAttributes.StaticMethodReturningFRT() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo52StructWithStaticMethodsReturningFRTWithoutAttributesV0c6MethodE3FRTSo9FRTStructVyFZTo : $@convention(c) () -> FRTStruct let frtLocalVar2 = StructWithStaticMethodsReturningFRTWithoutAttributes.StaticMethodReturningFRT_copy() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT_copy{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo52StructWithStaticMethodsReturningFRTWithoutAttributesV0c6MethodE8FRT_copySo9FRTStructVyFZTo : $@convention(c) () -> FRTStruct let frtLocalVar3 = StructWithStaticMethodsReturningFRTWithoutAttributes.StaticMethodReturningFRT_create() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT_create{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo52StructWithStaticMethodsReturningFRTWithoutAttributesV0c6MethodE10FRT_createSo9FRTStructVyFZTo : $@convention(c) () -> FRTStruct let frtLocalVar4 = StructWithStaticMethodsReturningFRTWithoutAttributes.StaticMethodReturningFRT_init() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT_init{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo52StructWithStaticMethodsReturningFRTWithoutAttributesV0c6MethodE8FRT_initSo9FRTStructVyFZTo : $@convention(c) () -> FRTStruct let frtLocalVar5 = StructWithStaticMethodsReturningFRTWithoutAttributes.StaticMethodReturningFRT_clone() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT_clone{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo52StructWithStaticMethodsReturningFRTWithoutAttributesV0c6MethodE9FRT_cloneSo9FRTStructVyFZTo : $@convention(c) () -> FRTStruct } func testStaticMethodsWithAttrubuteReturnsRetained() { let frtLocalVar1 = StructWithStaticMethodsReturningFRTWithAttributeReturnsRetained.StaticMethodReturningFRT() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo63StructWithStaticMethodsReturningFRTWithAttributeReturnsRetainedV0c6MethodE3FRTSo9FRTStructVyFZTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar2 = StructWithStaticMethodsReturningFRTWithAttributeReturnsRetained.StaticMethodReturningFRT_copy() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT_copy{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo63StructWithStaticMethodsReturningFRTWithAttributeReturnsRetainedV0c6MethodE8FRT_copySo9FRTStructVyFZTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar3 = StructWithStaticMethodsReturningFRTWithAttributeReturnsRetained.StaticMethodReturningFRT_create() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT_create{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo63StructWithStaticMethodsReturningFRTWithAttributeReturnsRetainedV0c6MethodE10FRT_createSo9FRTStructVyFZTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar4 = StructWithStaticMethodsReturningFRTWithAttributeReturnsRetained.StaticMethodReturningFRT_init() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT_init{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo63StructWithStaticMethodsReturningFRTWithAttributeReturnsRetainedV0c6MethodE8FRT_initSo9FRTStructVyFZTo : $@convention(c) () -> @owned FRTStruct let frtLocalVar5 = StructWithStaticMethodsReturningFRTWithAttributeReturnsRetained.StaticMethodReturningFRT_clone() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT_clone{{.*}} : $@convention(c) () -> @owned FRTStruct + // CHECK: function_ref @$sSo63StructWithStaticMethodsReturningFRTWithAttributeReturnsRetainedV0c6MethodE9FRT_cloneSo9FRTStructVyFZTo : $@convention(c) () -> @owned FRTStruct } func testStaticMethodsWithAttrubuteReturnsUnretained() { let frtLocalVar1 = StructWithStaticMethodsReturningFRTWithAttributeReturnsUnretained.StaticMethodReturningFRT() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo65StructWithStaticMethodsReturningFRTWithAttributeReturnsUnretainedV0c6MethodE3FRTSo9FRTStructVyFZTo : $@convention(c) () -> FRTStruct let frtLocalVar2 = StructWithStaticMethodsReturningFRTWithAttributeReturnsUnretained.StaticMethodReturningFRT_copy() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT_copy{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo65StructWithStaticMethodsReturningFRTWithAttributeReturnsUnretainedV0c6MethodE8FRT_copySo9FRTStructVyFZTo : $@convention(c) () -> FRTStruct let frtLocalVar3 = StructWithStaticMethodsReturningFRTWithAttributeReturnsUnretained.StaticMethodReturningFRT_create() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT_create{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo65StructWithStaticMethodsReturningFRTWithAttributeReturnsUnretainedV0c6MethodE10FRT_createSo9FRTStructVyFZTo : $@convention(c) () -> FRTStruct let frtLocalVar4 = StructWithStaticMethodsReturningFRTWithAttributeReturnsUnretained.StaticMethodReturningFRT_init() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT_init{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo65StructWithStaticMethodsReturningFRTWithAttributeReturnsUnretainedV0c6MethodE8FRT_initSo9FRTStructVyFZTo : $@convention(c) () -> FRTStruct let frtLocalVar5 = StructWithStaticMethodsReturningFRTWithAttributeReturnsUnretained.StaticMethodReturningFRT_clone() - // CHECK: function_ref @{{.*}}StaticMethodReturningFRT_clone{{.*}} : $@convention(c) () -> FRTStruct + // CHECK: function_ref @$sSo65StructWithStaticMethodsReturningFRTWithAttributeReturnsUnretainedV0c6MethodE9FRT_cloneSo9FRTStructVyFZTo : $@convention(c) () -> FRTStruct } func testFreeFunctionsReturningNonFRT() { let frtLocalVar1 = global_function_returning_non_FRT() - // CHECK: function_ref @{{.*}}global_function_returning_non_FRT{{.*}} : $@convention(c) () -> UnsafeMutablePointer + // CHECK: function_ref @$sSo33global_function_returning_non_FRTSpySo12NonFRTStructVGyFTo : $@convention(c) () -> UnsafeMutablePointer let frtLocalVar4 = global_function_returning_non_FRT_create() - // CHECK: function_ref @{{.*}}global_function_returning_non_FRT_create{{.*}} : $@convention(c) () -> UnsafeMutablePointer + // CHECK: function_ref @$sSo40global_function_returning_non_FRT_createSpySo12NonFRTStructVGyFTo : $@convention(c) () -> UnsafeMutablePointer let frtLocalVar5 = global_function_returning_non_FRT_copy() - // CHECK: function_ref @{{.*}}global_function_returning_non_FRT_copy{{.*}} : $@convention(c) () -> UnsafeMutablePointer + // CHECK: function_ref @$sSo38global_function_returning_non_FRT_copySpySo12NonFRTStructVGyFTo : $@convention(c) () -> UnsafeMutablePointer } func testStaticMethodsReturningNonFRT() { let frtLocalVar1 = StructWithStaticMethodsReturningNonFRT.StaticMethodReturningNonFRT() - // CHECK: function_ref @{{.*}}StaticMethodReturningNonFRT{{.*}} : $@convention(c) () -> UnsafeMutablePointer + // CHECK: function_ref @$sSo38StructWithStaticMethodsReturningNonFRTV0c6MethodefG0SpySo0F9FRTStructVGyFZTo : $@convention(c) () -> UnsafeMutablePointer let frtLocalVar4 = StructWithStaticMethodsReturningNonFRT.StaticMethodReturningNonFRT_create() - // CHECK: function_ref @{{.*}}StaticMethodReturningNonFRT_create{{.*}} : $@convention(c) () -> UnsafeMutablePointer + // CHECK: function_ref @$sSo38StructWithStaticMethodsReturningNonFRTV0c6MethodefG7_createSpySo0F9FRTStructVGyFZTo : $@convention(c) () -> UnsafeMutablePointer let frtLocalVar5 = StructWithStaticMethodsReturningNonFRT.StaticMethodReturningNonFRT_copy() - // CHECK: function_ref @{{.*}}StaticMethodReturningNonFRT_copy{{.*}} : $@convention(c) () -> UnsafeMutablePointer + // CHECK: function_ref @$sSo38StructWithStaticMethodsReturningNonFRTV0c6MethodefG5_copySpySo0F9FRTStructVGyFZTo : $@convention(c) () -> UnsafeMutablePointer } func testtFreeFunctionsTemplated(frt : FRTStruct, nonFrt: NonFRTStruct) { let frtLocalVar1 : Int = 1; - + let frtLocalVar2 = global_templated_function_returning_FRT(frtLocalVar1) - // CHECK: function_ref @{{.*}}global_templated_function_returning_FRT{{.*}} : $@convention(c) (Int) -> FRTStruct - + // CHECK: function_ref @$sSo39global_templated_function_returning_FRTySo9FRTStructVSiFTo : $@convention(c) (Int) -> FRTStruct + let frtLocalVar3 = global_templated_function_returning_FRT_copy(frtLocalVar1) - // CHECK: function_ref @{{.*}}global_templated_function_returning_FRT_copy{{.*}} : $@convention(c) (Int) -> @owned FRTStruct + // CHECK: function_ref @$sSo44global_templated_function_returning_FRT_copyySo9FRTStructVSiFTo : $@convention(c) (Int) -> @owned FRTStruct let frtLocalVar4 = global_templated_function_returning_FRT_create(frtLocalVar1) - // CHECK: function_ref @{{.*}}global_templated_function_returning_FRT_create{{.*}} : $@convention(c) (Int) -> @owned FRTStruct + // CHECK: function_ref @$sSo46global_templated_function_returning_FRT_createySo9FRTStructVSiFTo : $@convention(c) (Int) -> @owned FRTStruct let frtLocalVar5 = global_templated_function_returning_FRT_init(frtLocalVar1) - // CHECK: function_ref @{{.*}}global_templated_function_returning_FRT_init{{.*}} : $@convention(c) (Int) -> FRTStruct - + // CHECK: function_ref @$sSo44global_templated_function_returning_FRT_initySo9FRTStructVSiFTo : $@convention(c) (Int) -> FRTStruct + let frtLocalVar6 = global_templated_function_returning_FRT_clone(frtLocalVar1) - // CHECK: function_ref @{{.*}}global_templated_function_returning_FRT_clone{{.*}} : $@convention(c) (Int) -> FRTStruct + // CHECK: function_ref @$sSo45global_templated_function_returning_FRT_cloneySo9FRTStructVSiFTo : $@convention(c) (Int) -> FRTStruct let frtLocalVar7 = global_templated_function_returning_FRT_with_attr_returns_retained(frtLocalVar1) - // CHECK: function_ref @{{.*}}global_templated_function_returning_FRT_with_attr_returns_retained{{.*}} : $@convention(c) (Int) -> @owned FRTStruct - + // CHECK: function_ref @$sSo66global_templated_function_returning_FRT_with_attr_returns_retainedySo9FRTStructVSiFTo : $@convention(c) (Int) -> @owned FRTStruct + let frtLocalVar8 = global_templated_function_returning_FRT_copy_with_attr_returns_retained(frtLocalVar1) - // CHECK: function_ref @{{.*}}global_templated_function_returning_FRT_copy_with_attr_returns_retained{{.*}} : $@convention(c) (Int) -> @owned FRTStruct - + // CHECK: function_ref @$sSo71global_templated_function_returning_FRT_copy_with_attr_returns_retainedySo9FRTStructVSiFTo : $@convention(c) (Int) -> @owned FRTStruct + let frtLocalVar9 = global_templated_function_returning_FRT_create_with_attr_returns_retained(frtLocalVar1) - // CHECK: function_ref @{{.*}}global_templated_function_returning_FRT_create_with_attr_returns_retained{{.*}} : $@convention(c) (Int) -> @owned FRTStruct - + // CHECK: function_ref @$sSo73global_templated_function_returning_FRT_create_with_attr_returns_retainedySo9FRTStructVSiFTo : $@convention(c) (Int) -> @owned FRTStruct + let frtLocalVar10 = global_templated_function_returning_FRT_with_attr_returns_unretained(frtLocalVar1) - // CHECK: function_ref @{{.*}}global_templated_function_returning_FRT_with_attr_returns_unretained{{.*}} : $@convention(c) (Int) -> FRTStruct - + // CHECK: function_ref @$sSo68global_templated_function_returning_FRT_with_attr_returns_unretainedySo9FRTStructVSiFTo : $@convention(c) (Int) -> FRTStruct + let frtLocalVar11 = global_templated_function_returning_FRT_copy_with_attr_returns_unretained(frtLocalVar1) - // CHECK: function_ref @{{.*}}global_templated_function_returning_FRT_copy_with_attr_returns_unretained{{.*}} : $@convention(c) (Int) -> FRTStruct - + // CHECK: function_ref @$sSo73global_templated_function_returning_FRT_copy_with_attr_returns_unretainedySo9FRTStructVSiFTo : $@convention(c) (Int) -> FRTStruct + let frtLocalVar12 = global_templated_function_returning_FRT_create_with_attr_returns_unretained(frtLocalVar1) - // CHECK: function_ref @{{.*}}global_templated_function_returning_FRT_create_with_attr_returns_unretained{{.*}} : $@convention(c) (Int) -> FRTStruct + // CHECK: function_ref @$sSo75global_templated_function_returning_FRT_create_with_attr_returns_unretainedySo9FRTStructVSiFTo : $@convention(c) (Int) -> FRTStruct let frtLocalVar13 = global_function_returning_templated_retrun_frt(frt) - // CHECK: function_ref @{{.*}}global_function_returning_templated_retrun_frt{{.*}} : $@convention(c) (FRTStruct) -> FRTStruct + // CHECK: function_ref @$sSo46global_function_returning_templated_retrun_frtySo9FRTStructVACFTo : $@convention(c) (FRTStruct) -> FRTStruct let frtLocalVar14 = global_function_returning_templated_retrun_frt_owned(frt) - // CHECK: function_ref @{{.*}}global_function_returning_templated_retrun_frt_owned{{.*}} : $@convention(c) (FRTStruct) -> @owned FRTStruct + // CHECK: function_ref @$sSo52global_function_returning_templated_retrun_frt_ownedySo9FRTStructVACFTo : $@convention(c) (FRTStruct) -> @owned FRTStruct let nonFrtLocalVar1 = global_function_returning_templated_retrun_frt_owned(nonFrt) - // CHECK: function_ref @{{.*}}global_function_returning_templated_retrun_frt_owned{{.*}} : $@convention(c) (NonFRTStruct) -> NonFRTStruct + // CHECK: function_ref @$sSo52global_function_returning_templated_retrun_frt_ownedySo12NonFRTStructVACFTo : $@convention(c) (NonFRTStruct) -> NonFRTStruct } func testVirtualMethods(base: Base, derived: Derived) { @@ -236,56 +236,56 @@ func testVirtualMethods(base: Base, derived: Derived) { var mutableDerived = derived var frt1 = mutableBase.VirtualMethodReturningFRTUnowned() - // CHECK: function_ref @{{.*}}VirtualMethodReturningFRTUnowned{{.*}} : $@convention(cxx_method) (@inout Base) -> FRTStruct - + // CHECK: function_ref @$sSo4BaseV32VirtualMethodReturningFRTUnownedSo9FRTStructVyFTo : $@convention(cxx_method) (@inout Base) -> FRTStruct + var frt2 = mutableDerived.VirtualMethodReturningFRTUnowned() - // CHECK: function_ref @{{.*}}VirtualMethodReturningFRTUnowned{{.*}} : $@convention(cxx_method) (@inout Derived) -> FRTStruct - + // CHECK: function_ref @$sSo7DerivedV32VirtualMethodReturningFRTUnownedSo9FRTStructVyFTo : $@convention(cxx_method) (@inout Derived) -> FRTStruct + var frt3 = mutableBase.VirtualMethodReturningFRTOwned() - // CHECK: function_ref @{{.*}}VirtualMethodReturningFRTOwned{{.*}} : $@convention(cxx_method) (@inout Base) -> @owned FRTStruct - + // CHECK: function_ref @$sSo4BaseV30VirtualMethodReturningFRTOwnedSo9FRTStructVyFTo : $@convention(cxx_method) (@inout Base) -> @owned FRTStruct + var frt4 = mutableDerived.VirtualMethodReturningFRTOwned() - // CHECK: function_ref @{{.*}}VirtualMethodReturningFRTOwned{{.*}} : $@convention(cxx_method) (@inout Derived) -> @owned FRTStruct + // CHECK: function_ref @$sSo7DerivedV30VirtualMethodReturningFRTOwnedSo9FRTStructVyFTo : $@convention(cxx_method) (@inout Derived) -> @owned FRTStruct } func testDefaultOwnershipAnnotation() { let _ = DefaultOwnershipConventionOnCXXForeignRefType.returnRefTyDefUnretained() - // CHECK: function_ref {{.*}}returnRefTyDefUnretained{{.*}} : $@convention(c) () -> DefaultOwnershipConventionOnCXXForeignRefType.RefTyDefUnretained + // CHECK: function_ref @$sSo45DefaultOwnershipConventionOnCXXForeignRefTypeO06returnF15TyDefUnretainedAB0fijK0VyFZTo : $@convention(c) () -> DefaultOwnershipConventionOnCXXForeignRefType.RefTyDefUnretained let _ = FunctionAnnotationHasPrecedence.returnRefTyDefUnretained() - // CHECK: function_ref {{.*}}returnRefTyDefUnretained{{.*}} : $@convention(c) () -> FunctionAnnotationHasPrecedence.RefTyDefUnretained + // CHECK: function_ref @$sSo31FunctionAnnotationHasPrecedenceO24returnRefTyDefUnretainedAB0fghI0VyFZTo : $@convention(c) () -> FunctionAnnotationHasPrecedence.RefTyDefUnretained let _ = FunctionAnnotationHasPrecedence.returnRefTyDefUnretainedAnnotatedRetained() - // CHECK: function_ref {{.*}}returnRefTyDefUnretainedAnnotatedRetained{{.*}} : $@convention(c) () -> @owned FunctionAnnotationHasPrecedence.RefTyDefUnretained + // CHECK: function_ref @$sSo31FunctionAnnotationHasPrecedenceO41returnRefTyDefUnretainedAnnotatedRetainedAB0fghI0VyFZTo : $@convention(c) () -> @owned FunctionAnnotationHasPrecedence.RefTyDefUnretained let _ = DefaultOwnershipInheritance.createBaseType() - // CHECK: function_ref {{.*}}createBaseType{{.*}} : $@convention(c) () -> DefaultOwnershipInheritance.BaseType + // CHECK: function_ref @$sSo27DefaultOwnershipInheritanceO14createBaseTypeAB0eF0VyFZTo : $@convention(c) () -> DefaultOwnershipInheritance.BaseType let _ = DefaultOwnershipInheritance.createDerivedType() - // CHECK: function_ref {{.*}}createDerivedType{{.*}} : $@convention(c) () -> DefaultOwnershipInheritance.DerivedType + // CHECK: function_ref @$sSo27DefaultOwnershipInheritanceO17createDerivedTypeAB0eF0VyFZTo : $@convention(c) () -> DefaultOwnershipInheritance.DerivedType let _ = DefaultOwnershipInheritance.createDerivedType2() - // CHECK: function_ref {{.*}}createDerivedType2{{.*}} : $@convention(c) () -> DefaultOwnershipInheritance.DerivedType2 + // CHECK: function_ref @$sSo27DefaultOwnershipInheritanceO18createDerivedType2AB0eF0VyFZTo : $@convention(c) () -> DefaultOwnershipInheritance.DerivedType2 let _ = DefaultOwnershipInheritance.createBaseTypeNonDefault() - // CHECK: function_ref {{.*}}createBaseTypeNonDefault{{.*}} : $@convention(c) () -> @owned DefaultOwnershipInheritance.BaseTypeNonDefault + // CHECK: function_ref @$sSo27DefaultOwnershipInheritanceO017createBaseTypeNonA0AB0efgA0VyFZTo : $@convention(c) () -> @owned DefaultOwnershipInheritance.BaseTypeNonDefault let _ = DefaultOwnershipInheritance.createDerivedTypeNonDefault() - // CHECK: function_ref {{.*}}createDerivedTypeNonDefault{{.*}} : $@convention(c) () -> @owned DefaultOwnershipInheritance.DerivedTypeNonDefault + // CHECK: function_ref @$sSo27DefaultOwnershipInheritanceO020createDerivedTypeNonA0AB0efgA0VyFZTo : $@convention(c) () -> @owned DefaultOwnershipInheritance.DerivedTypeNonDefault let _ = DefaultOwnershipInheritance.createDerivedTypeNonDefaultUnretained() - // CHECK: function_ref {{.*}}createDerivedTypeNonDefaultUnretained{{.*}} : $@convention(c) () -> DefaultOwnershipInheritance.DerivedTypeNonDefault + // CHECK: function_ref @$sSo27DefaultOwnershipInheritanceO020createDerivedTypeNonA10UnretainedAB0efgA0VyFZTo : $@convention(c) () -> DefaultOwnershipInheritance.DerivedTypeNonDefault } func testTemplateMemberFunctions() { let refTemplate = FRTStructRef() let ptr = refTemplate.ptr() - // CHECK: function_ref {{.*}}ptr{{.*}} : $@convention(cxx_method) (@in_guaranteed RefTemplate) -> @owned FRTStruct + // CHECK: function_ref @$sSo0028RefTemplateFRTStruct_eBAGgsbV3ptrSo9FRTStructVyFTo : $@convention(cxx_method) (@in_guaranteed RefTemplate) -> @owned FRTStruct let get = refTemplate.get() - // CHECK: function_ref {{.*}}get{{.*}} : $@convention(cxx_method) (@in_guaranteed RefTemplate) -> FRTStruct + // CHECK: function_ref @$sSo0028RefTemplateFRTStruct_eBAGgsbV3getSo9FRTStructVyFTo : $@convention(cxx_method) (@in_guaranteed RefTemplate) -> FRTStruct let value = refTemplate.value() - // CHECK: function_ref {{.*}}value{{.*}} : $@convention(cxx_method) (@in_guaranteed RefTemplate) -> FRTStruct + // CHECK: function_ref @$sSo0028RefTemplateFRTStruct_eBAGgsbV5valueSo9FRTStructVyFTo : $@convention(cxx_method) (@in_guaranteed RefTemplate) -> FRTStruct } From 34e47290f16d3c056d86c75e91df698669d2b72d Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Wed, 29 Oct 2025 14:40:13 -0700 Subject: [PATCH 3/8] [C++ interop] Fix manual mangling of C++ base method thunks When creating a C++ method that thunks from a particular C++ derived class to call a method on one of its base classes, we do some manual name mangling. This name mangling did not properly capture all of the aspects of the thunk, so it was prone to collisions. In moving to SIL asmname, we got a different set of collisions from the ones that existed previously. Expanding the mangling to account for small differences (const or not) as well as the base class type eliminates these collisions. Most of the test changes account for the new mangling, but the member-inheritance test indicates that this change fixes an existing miscompile as well. --- lib/ClangImporter/SwiftDeclSynthesizer.cpp | 93 +++++++++++++++---- .../inheritance/functions-objc-irgen.swift | 4 +- .../class/inheritance/subscript-irgen.swift | 2 +- .../inheritance/virtual-methods-irgen.swift | 2 +- .../function-inheritance-irgen.swift | 2 +- .../member-inheritance.swift | 7 +- 6 files changed, 83 insertions(+), 27 deletions(-) diff --git a/lib/ClangImporter/SwiftDeclSynthesizer.cpp b/lib/ClangImporter/SwiftDeclSynthesizer.cpp index 9a17906955a30..b7c95dc53c99d 100644 --- a/lib/ClangImporter/SwiftDeclSynthesizer.cpp +++ b/lib/ClangImporter/SwiftDeclSynthesizer.cpp @@ -2066,34 +2066,91 @@ clang::CXXMethodDecl *SwiftDeclSynthesizer::synthesizeCXXForwardingMethod( // Create a new method in the derived class that calls the base method. clang::DeclarationName name = method->getNameInfo().getName(); + std::string newName; + llvm::raw_string_ostream os(newName); + bool useExistingName = false; if (name.isIdentifier()) { - std::string newName; - llvm::raw_string_ostream os(newName); os << (forwardingMethodKind == ForwardingMethodKind::Virtual ? "__synthesizedVirtualCall_" : "__synthesizedBaseCall_") << name.getAsIdentifierInfo()->getName(); - name = clang::DeclarationName( - &ImporterImpl.getClangPreprocessor().getIdentifierTable().get( - os.str())); - } else if (name.getCXXOverloadedOperator() == clang::OO_Subscript) { - name = clang::DeclarationName( - &ImporterImpl.getClangPreprocessor().getIdentifierTable().get( - (forwardingMethodKind == ForwardingMethodKind::Virtual + } else { + switch (auto op = name.getCXXOverloadedOperator()) { + case clang::OO_Subscript: + os << (forwardingMethodKind == ForwardingMethodKind::Virtual ? "__synthesizedVirtualCall_operatorSubscript" - : "__synthesizedBaseCall_operatorSubscript"))); - } else if (name.getCXXOverloadedOperator() == clang::OO_Star) { - name = clang::DeclarationName( - &ImporterImpl.getClangPreprocessor().getIdentifierTable().get( - (forwardingMethodKind == ForwardingMethodKind::Virtual + : "__synthesizedBaseCall_operatorSubscript"); + if (forceConstQualifier) + os << "C"; + break; + + case clang::OO_Star: + os << (forwardingMethodKind == ForwardingMethodKind::Virtual ? "__synthesizedVirtualCall_operatorStar" - : "__synthesizedBaseCall_operatorStar"))); - } else if (name.getCXXOverloadedOperator() == clang::OO_Call) { - assert(forwardingMethodKind != ForwardingMethodKind::Virtual); + : "__synthesizedBaseCall_operatorStar"); + if (forceConstQualifier) + os << "C"; + break; + + case clang::OO_Call: + assert(forwardingMethodKind != ForwardingMethodKind::Virtual); + os << "__synthesizedBaseCall_operatorCall"; + if (forceConstQualifier) + os << "C"; + break; + + case clang::OO_Plus: + case clang::OO_Minus: + case clang::OO_Slash: + case clang::OO_PlusEqual: + case clang::OO_MinusEqual: + case clang::OO_StarEqual: + case clang::OO_SlashEqual: + case clang::OO_Percent: + case clang::OO_Caret: + case clang::OO_Amp: + case clang::OO_Pipe: + case clang::OO_Tilde: + case clang::OO_Exclaim: + case clang::OO_Less: + case clang::OO_Greater: + case clang::OO_LessLess: + case clang::OO_GreaterGreater: + case clang::OO_EqualEqual: + case clang::OO_PlusPlus: + case clang::OO_ExclaimEqual: + case clang::OO_LessEqual: + case clang::OO_GreaterEqual: + case clang::OO_AmpAmp: + case clang::OO_PipePipe: + os << importer::getOperatorName(ImporterImpl.SwiftContext, op).str(); + break; + + default: + useExistingName = true; + break; + } + } + + if (!useExistingName) { + // The created method is inside the derived class already. If that's + // different from the base class, also include the base class in the + // mangling to keep this separate from other similar functions cloned from + // other base classes. + if (derivedClass != baseClass) { + os << "_"; + std::unique_ptr mangler{ + clang::ItaniumMangleContext::create(clangCtx, clangCtx.getDiagnostics())}; + auto derivedType = clangCtx.getTypeDeclType(baseClass) + .getCanonicalType(); + mangler->mangleCanonicalTypeName(derivedType, os); + } + name = clang::DeclarationName( &ImporterImpl.getClangPreprocessor().getIdentifierTable().get( - "__synthesizedBaseCall_operatorCall")); + os.str())); } + auto methodType = method->getType(); // Check if we need to drop the reference from the return type // of the new method. This is needed when a synthesized `operator []` diff --git a/test/Interop/Cxx/class/inheritance/functions-objc-irgen.swift b/test/Interop/Cxx/class/inheritance/functions-objc-irgen.swift index d83792dfcc867..1d49dbe920d37 100644 --- a/test/Interop/Cxx/class/inheritance/functions-objc-irgen.swift +++ b/test/Interop/Cxx/class/inheritance/functions-objc-irgen.swift @@ -5,7 +5,7 @@ import FunctionsObjC -// CHECK: define linkonce_odr {{.*}}ptr @_ZNK7Derived36__synthesizedBaseCall_virtual_methodEv(ptr {{.*}}%[[THIS:.*]]) +// CHECK: define linkonce_odr {{.*}}ptr @_ZNK7Derived46__synthesizedBaseCall_virtual_method__ZTS4BaseEv(ptr {{.*}}%[[THIS:.*]]) // CHECK: %[[THIS_ADDR:.*]] = alloca ptr, // CHECK: store ptr %[[THIS]], ptr %[[THIS_ADDR]], // CHECK: %[[THIS1:.*]] = load ptr, ptr %[[THIS_ADDR]], @@ -15,7 +15,7 @@ import FunctionsObjC // CHECK: %[[CALL:.*]] = call {{.*}}ptr %[[V0]](ptr {{.*}}%[[THIS1]]) // CHECK: ret ptr %[[CALL]] -// CHECK: define linkonce_odr {{.*}}ptr @_ZNK7Derived40__synthesizedBaseCall_non_virtual_methodEv(ptr {{.*}}%[[THIS:.*]]) +// CHECK: define linkonce_odr {{.*}}ptr @_ZNK7Derived50__synthesizedBaseCall_non_virtual_method__ZTS4BaseEv(ptr {{.*}}%[[THIS:.*]]) // CHECK: %[[THIS_ADDR:.*]] = alloca ptr, // CHECK: store ptr %[[THIS]], ptr %[[THIS_ADDR]], // CHECK: %[[THIS1:.*]] = load ptr, ptr %[[THIS_ADDR]], diff --git a/test/Interop/Cxx/class/inheritance/subscript-irgen.swift b/test/Interop/Cxx/class/inheritance/subscript-irgen.swift index 64b3038b07461..9e5258d586613 100644 --- a/test/Interop/Cxx/class/inheritance/subscript-irgen.swift +++ b/test/Interop/Cxx/class/inheritance/subscript-irgen.swift @@ -9,6 +9,6 @@ func testGetX() -> CInt { let _ = testGetX() -// CHECK: define {{.*}}linkonce_odr{{.*}} i32 @{{(.*)(30CopyTrackedDerivedDerivedClass39__synthesizedBaseCall_operatorSubscript|__synthesizedBaseCall_operatorSubscript@CopyTrackedDerivedDerivedClass)(.*)}}(ptr {{.*}} %[[THIS_PTR:.*]], i32 {{.*}}) +// CHECK: define {{.*}}linkonce_odr{{.*}} i32 @_ZNK30CopyTrackedDerivedDerivedClass67__synthesizedBaseCall_operatorSubscriptC__ZTS20CopyTrackedBaseClassEi(ptr {{.*}} %[[THIS_PTR:.*]], i32 {{.*}}) // CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %{{.*}}, i{{32|64}} 4 // CHECK: {{.*}}call {{.*}} i32 @{{.*}}CopyTrackedBaseClass{{.*}}(ptr {{.*}} %[[ADD_PTR]], i32 {{.*}}){{.*}} diff --git a/test/Interop/Cxx/class/inheritance/virtual-methods-irgen.swift b/test/Interop/Cxx/class/inheritance/virtual-methods-irgen.swift index 49d1ea0d5fad7..aeab7c4397280 100644 --- a/test/Interop/Cxx/class/inheritance/virtual-methods-irgen.swift +++ b/test/Interop/Cxx/class/inheritance/virtual-methods-irgen.swift @@ -23,7 +23,7 @@ d4.f() // CHECK: call swiftcc {{.*}} @"$sSo8Derived4V1fs5Int32VyF" // CHECK: define {{.*}} @"$sSo8Derived4V1fs5Int32VyF"(ptr swiftself dereferenceable -// CHECK: call {{.*}} @{{_ZN8Derived423__synthesizedBaseCall_fEv|"\?__synthesizedBaseCall_f@Derived4@@QEAAHXZ"}} +// CHECK: call {{.*}} @{{_ZN8Derived434__synthesizedBaseCall_f__ZTS5Base3Ev|"\?__synthesizedBaseCall_ZTS5Base3Ev@@QEAAHXZ"}} // CHECK: define {{.*}}void @{{_ZN7DerivedIiE3fooEv|"\?foo@\?\$Derived@H@@UEAAXXZ"}} // CHECK: call void @{{_Z21testFunctionCollectedv|"\?testFunctionCollected@@YAXXZ"}} diff --git a/test/Interop/Cxx/foreign-reference/function-inheritance-irgen.swift b/test/Interop/Cxx/foreign-reference/function-inheritance-irgen.swift index c0100971221ad..1ecf10d8629ba 100644 --- a/test/Interop/Cxx/foreign-reference/function-inheritance-irgen.swift +++ b/test/Interop/Cxx/foreign-reference/function-inheritance-irgen.swift @@ -10,6 +10,6 @@ func testGetX() -> CInt { let _ = testGetX() -// CHECK: define {{.*}}linkonce_odr{{.*}} i32 @{{(.*)(30CopyTrackedDerivedDerivedClass26__synthesizedBaseCall_getX|__synthesizedBaseCall_getX@CopyTrackedDerivedDerivedClass)(.*)}}(ptr {{.*}} %[[THIS_PTR:.*]]) +// CHECK: define {{.*}}linkonce_odr{{.*}} i32 @{{(.*)(_ZNK30CopyTrackedDerivedDerivedClass53__synthesizedBaseCall_getX__ZTS20CopyTrackedBaseClassEv|.*__synthesizedBaseCall_getX.*@CopyTrackedDerivedDerivedClass)(.*)}}(ptr {{.*}} %[[THIS_PTR:.*]]) // CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %{{.*}}, i{{32|64}} 4 // CHECK: call{{.*}} i32 @{{.*}}(ptr {{.*}} %[[ADD_PTR]]) diff --git a/test/Interop/Cxx/foreign-reference/member-inheritance.swift b/test/Interop/Cxx/foreign-reference/member-inheritance.swift index 2ea300b7c0445..e22af08eb81d6 100644 --- a/test/Interop/Cxx/foreign-reference/member-inheritance.swift +++ b/test/Interop/Cxx/foreign-reference/member-inheritance.swift @@ -151,10 +151,9 @@ if #available(SwiftStdlib 5.8, *) { expectEqual(d1.virtualMethod(), 111) expectEqual(d1.swiftBarRename(), 113) expectEqual(d1.swiftParamsRename(a1: 42), 42) - // FIXME the method calls below return incorrect values - expectEqual(d1.swiftVirtualMethod(), 111) // should be 121 - expectEqual(d1.A2BarRename(), 113) // should be 123 - expectEqual(d1.swiftParamsRename(a2: 42), 42) // should be 43 + expectEqual(d1.swiftVirtualMethod(), 121) + expectEqual(d1.A2BarRename(), 123) + expectEqual(d1.swiftParamsRename(a2: 42), 43) } } From 523b3b7ab76173fc407a891718de32f231b9e335 Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Thu, 30 Oct 2025 09:45:10 -0700 Subject: [PATCH 4/8] Various test updates for Linux, Windows, iOS, and x86_64 macOS --- .../class/inheritance/subscript-irgen.swift | 2 +- .../inheritance/virtual-methods-irgen.swift | 6 +++--- .../Cxx/class/method/methods-silgen.swift | 4 ++-- ...ification-non-trivial-silgen-windows.swift | 4 ++-- ...pe-classification-non-trivial-silgen.swift | 2 +- .../foreign-reference/move-only-silgen.swift | 2 +- .../Cxx/foreign-reference/pod-silgen.swift | 2 +- .../foreign-reference/singleton-silgen.swift | 6 +++--- .../Cxx/operators/member-inline-silgen.swift | 20 +++++++++---------- .../operators/member-out-of-line-silgen.swift | 4 ++-- .../static/static-member-func-silgen.swift | 4 ++-- .../templates/member-templates-silgen.swift | 14 ++++++------- test/SILGen/objc_bridging.swift | 8 ++++---- test/SILOptimizer/c_string_optimization.swift | 4 ++-- 14 files changed, 41 insertions(+), 41 deletions(-) diff --git a/test/Interop/Cxx/class/inheritance/subscript-irgen.swift b/test/Interop/Cxx/class/inheritance/subscript-irgen.swift index 9e5258d586613..858bf6bf653ab 100644 --- a/test/Interop/Cxx/class/inheritance/subscript-irgen.swift +++ b/test/Interop/Cxx/class/inheritance/subscript-irgen.swift @@ -9,6 +9,6 @@ func testGetX() -> CInt { let _ = testGetX() -// CHECK: define {{.*}}linkonce_odr{{.*}} i32 @_ZNK30CopyTrackedDerivedDerivedClass67__synthesizedBaseCall_operatorSubscriptC__ZTS20CopyTrackedBaseClassEi(ptr {{.*}} %[[THIS_PTR:.*]], i32 {{.*}}) +// CHECK: define {{.*}}linkonce_odr{{.*}} i32 @{{.*}}synthesizedBaseCall_operatorSubscriptC{{.*}}(ptr {{.*}} %[[THIS_PTR:.*]], i32 {{.*}}) // CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %{{.*}}, i{{32|64}} 4 // CHECK: {{.*}}call {{.*}} i32 @{{.*}}CopyTrackedBaseClass{{.*}}(ptr {{.*}} %[[ADD_PTR]], i32 {{.*}}){{.*}} diff --git a/test/Interop/Cxx/class/inheritance/virtual-methods-irgen.swift b/test/Interop/Cxx/class/inheritance/virtual-methods-irgen.swift index aeab7c4397280..ba6b95953150f 100644 --- a/test/Interop/Cxx/class/inheritance/virtual-methods-irgen.swift +++ b/test/Interop/Cxx/class/inheritance/virtual-methods-irgen.swift @@ -23,12 +23,12 @@ d4.f() // CHECK: call swiftcc {{.*}} @"$sSo8Derived4V1fs5Int32VyF" // CHECK: define {{.*}} @"$sSo8Derived4V1fs5Int32VyF"(ptr swiftself dereferenceable -// CHECK: call {{.*}} @{{_ZN8Derived434__synthesizedBaseCall_f__ZTS5Base3Ev|"\?__synthesizedBaseCall_ZTS5Base3Ev@@QEAAHXZ"}} +// CHECK: call {{.*}} @{{.*}}__synthesizedBaseCall_{{.*}} // CHECK: define {{.*}}void @{{_ZN7DerivedIiE3fooEv|"\?foo@\?\$Derived@H@@UEAAXXZ"}} -// CHECK: call void @{{_Z21testFunctionCollectedv|"\?testFunctionCollected@@YAXXZ"}} +// CHECK: call void @{{.*}}testFunctionCollected -// CHECK: define {{.*}}void @{{_Z21testFunctionCollectedv|"\?testFunctionCollected@@YAXXZ"}} +// CHECK: define {{.*}}void @{{.*}}testFunctionCollected // CHECK-NOT: _ZN6UnusedIiE3fooEv // CHECK-NOT: "\?foo@\?\$Unused@H@@UEAAXXZ" diff --git a/test/Interop/Cxx/class/method/methods-silgen.swift b/test/Interop/Cxx/class/method/methods-silgen.swift index c684429b23457..c41aa91ccde17 100644 --- a/test/Interop/Cxx/class/method/methods-silgen.swift +++ b/test/Interop/Cxx/class/method/methods-silgen.swift @@ -3,10 +3,10 @@ import Methods // clang name: ReferenceParams::ReferenceParams -// CHECK: sil [asmname "_ZN15ReferenceParamsC1ERKiS1_"] [clang ReferenceParams.init] @$sSo15ReferenceParamsVyABs5Int32V_ADtcfCTo : $@convention(c) (@in_guaranteed Int32, @in_guaranteed Int32) -> @out ReferenceParams +// CHECK: sil [asmname "{{.*}}"] [clang ReferenceParams.init] @$sSo15ReferenceParamsVyABs5Int32V_ADtcfCTo : $@convention(c) (@in_guaranteed Int32, @in_guaranteed Int32) -> @out ReferenceParams // clang name: ReferenceParams::staticMethod -// CHECK: sil [asmname "_ZN15ReferenceParams12staticMethodERKiS1_"] [clang ReferenceParams.staticMethod] @$sSo15ReferenceParamsV12staticMethodyys5Int32V_AEtFZTo : $@convention(c) (@in_guaranteed Int32, @in_guaranteed Int32) -> () +// CHECK: sil [asmname "{{.*}}staticMethod{{.*}}"] [clang ReferenceParams.staticMethod] @$sSo15ReferenceParamsV12staticMethodyys5Int32V_AEtFZTo : $@convention(c) (@in_guaranteed Int32, @in_guaranteed Int32) -> () public func use() { let a = CInt(42) diff --git a/test/Interop/Cxx/class/type-classification-non-trivial-silgen-windows.swift b/test/Interop/Cxx/class/type-classification-non-trivial-silgen-windows.swift index 828dfac61ae62..ac76c25650858 100644 --- a/test/Interop/Cxx/class/type-classification-non-trivial-silgen-windows.swift +++ b/test/Interop/Cxx/class/type-classification-non-trivial-silgen-windows.swift @@ -8,13 +8,13 @@ import TypeClassification // "destroy_addr". // CHECK-LABEL: sil [ossa] @$s4main24testStructWithDestructoryyF // CHECK: [[AS:%.*]] = alloc_stack [lexical] [var_decl] $StructWithDestructor -// CHECK: [[FN:%.*]] = function_ref @{{_ZN20StructWithDestructorC1Ev|\?\?0StructWithDestructor@@QEAA@XZ}} : $@convention(c) () -> @out StructWithDestructor +// CHECK: [[FN:%.*]] = function_ref @$sSo20StructWithDestructorVABycfCTo : $@convention(c) () -> @out StructWithDestructor // CHECK: apply [[FN]]([[AS]]) : $@convention(c) () -> @out StructWithDestructor // CHECK: destroy_addr [[AS]] // CHECK: dealloc_stack %0 : $*StructWithDestructor // CHECK-LABEL: end sil function '$s4main24testStructWithDestructoryyF' -// CHECK-LABEL: sil [clang StructWithDestructor.init] @{{_ZN20StructWithDestructorC1Ev|\?\?0StructWithDestructor@@QEAA@XZ}} : $@convention(c) () -> @out StructWithDestructor +// CHECK-LABEL: sil [asmname "{{.*}}"] [clang StructWithDestructor.init] @{{.*}}StructWithDestructor{{.*}} : $@convention(c) () -> @out StructWithDestructor public func testStructWithDestructor() { let d = StructWithDestructor() } diff --git a/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift b/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift index e2a7c6ae2f77f..749f13a98beba 100644 --- a/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift +++ b/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift @@ -1,6 +1,6 @@ // RUN: %target-swiftxx-frontend -I %S/Inputs -Xllvm -sil-print-types -emit-silgen %s | %FileCheck --dump-input-filter=all %s -// REQUIRES: OS=macosx || OS=linux-android +// REQUIRES: OS=macosx || OS=linux-android || OS=windows-msvc import TypeClassification diff --git a/test/Interop/Cxx/foreign-reference/move-only-silgen.swift b/test/Interop/Cxx/foreign-reference/move-only-silgen.swift index f88b8f9d30919..205652c0f5f74 100644 --- a/test/Interop/Cxx/foreign-reference/move-only-silgen.swift +++ b/test/Interop/Cxx/foreign-reference/move-only-silgen.swift @@ -25,4 +25,4 @@ public func test() { _ = x.test() } -// CHECK-LABEL: sil [available 13.3.0] [asmname "_ZN8MoveOnly6createEv"] [clang MoveOnly.create] @$sSo8MoveOnlyV6createAByFZTo : $@convention(c) () -> MoveOnly +// CHECK-LABEL: sil {{.*}}[asmname "{{.*}}create{{.*}}"] [clang MoveOnly.create] @$sSo8MoveOnlyV6createAByFZTo : $@convention(c) () -> MoveOnly diff --git a/test/Interop/Cxx/foreign-reference/pod-silgen.swift b/test/Interop/Cxx/foreign-reference/pod-silgen.swift index 096887c4b62ef..c94de3a016678 100644 --- a/test/Interop/Cxx/foreign-reference/pod-silgen.swift +++ b/test/Interop/Cxx/foreign-reference/pod-silgen.swift @@ -32,4 +32,4 @@ public func test() { _ = x.test() } -// CHECK-LABEL: sil [available 13.3.0] [asmname "_ZN7IntPair6createEv"] [clang IntPair.create] @$sSo7IntPairV6createAByFZTo : $@convention(c) () -> IntPair +// CHECK-LABEL: sil {{.*}}[asmname "{{.*}}create{{.*}}"] [clang IntPair.create] @$sSo7IntPairV6createAByFZTo : $@convention(c) () -> IntPair diff --git a/test/Interop/Cxx/foreign-reference/singleton-silgen.swift b/test/Interop/Cxx/foreign-reference/singleton-silgen.swift index b14f38699ccec..52dcd75e704c9 100644 --- a/test/Interop/Cxx/foreign-reference/singleton-silgen.swift +++ b/test/Interop/Cxx/foreign-reference/singleton-silgen.swift @@ -31,8 +31,8 @@ public func test() { mutateIt(x) } -// CHECK-LABEL: sil [available 13.3.0] [asmname "_ZN21DeletedSpecialMembers6createEv"] [clang DeletedSpecialMembers.create] @$sSo21DeletedSpecialMembersV6createAByFZTo : $@convention(c) () -> DeletedSpecialMembers +// CHECK-LABEL: sil {{.*}}[asmname "{{.*}}create{{.*}}"] [clang DeletedSpecialMembers.create] @$sSo21DeletedSpecialMembersV6createAByFZTo : $@convention(c) () -> DeletedSpecialMembers -// CHECK-LABEL: sil [available 13.3.0] [asmname "_ZNK21DeletedSpecialMembers4testEv"] [clang DeletedSpecialMembers.test] @$sSo21DeletedSpecialMembersV4tests5Int32VyFTo : $@convention(cxx_method) (DeletedSpecialMembers) -> Int32 +// CHECK-LABEL: sil {{.*}}[asmname "{{.*}}test{{.*}}"] [clang DeletedSpecialMembers.test] @$sSo21DeletedSpecialMembersV4tests5Int32VyFTo : $@convention(cxx_method) (DeletedSpecialMembers) -> Int32 -// CHECK-LABEL: sil [serialized] [asmname "_Z8mutateItR21DeletedSpecialMembers"] [clang mutateIt] @$sSo8mutateItyySo21DeletedSpecialMembersVFTo : $@convention(c) (DeletedSpecialMembers) -> () +// CHECK-LABEL: sil [serialized] [asmname "{{.*}}mutate{{.*}}"] [clang mutateIt] @$sSo8mutateItyySo21DeletedSpecialMembersVFTo : $@convention(c) (DeletedSpecialMembers) -> () diff --git a/test/Interop/Cxx/operators/member-inline-silgen.swift b/test/Interop/Cxx/operators/member-inline-silgen.swift index af789b6ca8ad3..754433bf3874f 100644 --- a/test/Interop/Cxx/operators/member-inline-silgen.swift +++ b/test/Interop/Cxx/operators/member-inline-silgen.swift @@ -28,7 +28,7 @@ public func call(_ wrapper: inout LoadableIntWrapper, _ arg: Int32) -> Int32 { w // CHECK: apply [[OP]]([[RHS]], [[SELFACCESS]]) : $@convention(cxx_method) (Int32, @inout LoadableIntWrapper) -> Int32 // CHECK: end_access [[SELFACCESS]] : $*LoadableIntWrapper -// CHECK: sil [asmname "_ZN18LoadableIntWrapperclEi"] [clang LoadableIntWrapper.callAsFunction] @$sSo18LoadableIntWrapperV14callAsFunctionys5Int32VAEFTo : $@convention(cxx_method) (Int32, @inout LoadableIntWrapper) -> Int32 +// CHECK: sil [asmname "{{.*}}"] [clang LoadableIntWrapper.callAsFunction] @$sSo18LoadableIntWrapperV14callAsFunctionys5Int32VAEFTo : $@convention(cxx_method) (Int32, @inout LoadableIntWrapper) -> Int32 public func call(_ wrapper: inout AddressOnlyIntWrapper) -> Int32 { wrapper() } @@ -38,7 +38,7 @@ public func call(_ wrapper: inout AddressOnlyIntWrapper) -> Int32 { wrapper() } // CHECK: apply [[OP]]([[SELFACCESS]]) : $@convention(cxx_method) (@inout AddressOnlyIntWrapper) -> Int32 // CHECK: end_access [[SELFACCESS]] : $*AddressOnlyIntWrapper -// CHECK: sil [asmname "_ZN21AddressOnlyIntWrapperclEv"] [clang AddressOnlyIntWrapper.callAsFunction] @$sSo21AddressOnlyIntWrapperV14callAsFunctions5Int32VyFTo : $@convention(cxx_method) (@inout AddressOnlyIntWrapper) -> Int32 +// CHECK: sil [asmname "{{.*}}"] [clang AddressOnlyIntWrapper.callAsFunction] @$sSo21AddressOnlyIntWrapperV14callAsFunctions5Int32VyFTo : $@convention(cxx_method) (@inout AddressOnlyIntWrapper) -> Int32 public func index(_ arr: ReadOnlyIntArray, _ arg: Int32) -> Int32 { arr[arg] } @@ -180,12 +180,12 @@ public func subscriptUnnamed(_ unnamed: SubscriptUnnamedParameter, _ arg: Int32) // CHECK: dealloc_stack [[SELFACCESS]] // CHECK: } // end sil function '$sSo25SubscriptUnnamedParameterVys5Int32VADcig' -// CHECK: sil [asmname "_ZNK16ReadOnlyIntArrayixEi"] [clang ReadOnlyIntArray.__operatorSubscriptConst] @$sSo16ReadOnlyIntArrayV24__operatorSubscriptConstySPys5Int32VGAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed ReadOnlyIntArray) -> UnsafePointer -// CHECK: sil [asmname "_ZN17ReadWriteIntArrayixEi"] [clang ReadWriteIntArray.__operatorSubscript] @$sSo17ReadWriteIntArrayV19__operatorSubscriptySpys5Int32VGAEFTo : $@convention(cxx_method) (Int32, @inout ReadWriteIntArray) -> UnsafeMutablePointer -// CHECK: sil [asmname "_ZNK23NonTrivialIntArrayByValixEi"] [clang NonTrivialIntArrayByVal.__operatorSubscriptConst] @$sSo23NonTrivialIntArrayByValV24__operatorSubscriptConstys5Int32VAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed NonTrivialIntArrayByVal) -> Int32 +// CHECK: sil [asmname "{{.*}}ReadOnlyIntArray{{.*}}"] [clang ReadOnlyIntArray.__operatorSubscriptConst] @$sSo16ReadOnlyIntArrayV24__operatorSubscriptConstySPys5Int32VGAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed ReadOnlyIntArray) -> UnsafePointer +// CHECK: sil [asmname "{{.*}}ReadWriteIntArray{{.*}}"] [clang ReadWriteIntArray.__operatorSubscript] @$sSo17ReadWriteIntArrayV19__operatorSubscriptySpys5Int32VGAEFTo : $@convention(cxx_method) (Int32, @inout ReadWriteIntArray) -> UnsafeMutablePointer +// CHECK: sil [asmname "{{.*}}NonTrivialIntArrayByVal{{.*}}"] [clang NonTrivialIntArrayByVal.__operatorSubscriptConst] @$sSo23NonTrivialIntArrayByValV24__operatorSubscriptConstys5Int32VAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed NonTrivialIntArrayByVal) -> Int32 -// CHECK: sil [asmname "_ZN8PtrByValixEi"] [clang PtrByVal.__operatorSubscript] @$sSo8PtrByValV19__operatorSubscriptySpys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @inout PtrByVal) -> Optional> -// CHECK: sil [asmname "_ZN8RefToPtrixEi"] [clang RefToPtr.__operatorSubscript] @$sSo8RefToPtrV19__operatorSubscriptySpySpys5Int32VGSgGAEFTo : $@convention(cxx_method) (Int32, @inout RefToPtr) -> UnsafeMutablePointer>> -// CHECK: sil [asmname "_ZN8PtrToPtrixEi"] [clang PtrToPtr.__operatorSubscript] @$sSo05PtrToA0V19__operatorSubscriptySpySpys5Int32VGSgGSgAEFTo : $@convention(cxx_method) (Int32, @inout PtrToPtr) -> Optional>>> -// CHECK: sil [asmname "_ZNK15ConstOpPtrByValixEi"] [clang ConstOpPtrByVal.__operatorSubscriptConst] @$sSo15ConstOpPtrByValV019__operatorSubscriptA0ySPys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed ConstOpPtrByVal) -> Optional> -// CHECK: sil [asmname "_ZN13ConstPtrByValixEi"] [clang ConstPtrByVal.__operatorSubscriptConst] @$sSo13ConstPtrByValV019__operatorSubscriptA0ySPys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @inout ConstPtrByVal) -> Optional> +// CHECK: sil [asmname "{{.*}}PtrByVal{{.*}}"] [clang PtrByVal.__operatorSubscript] @$sSo8PtrByValV19__operatorSubscriptySpys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @inout PtrByVal) -> Optional> +// CHECK: sil [asmname "{{.*}}RefToPtr{{.*}}"] [clang RefToPtr.__operatorSubscript] @$sSo8RefToPtrV19__operatorSubscriptySpySpys5Int32VGSgGAEFTo : $@convention(cxx_method) (Int32, @inout RefToPtr) -> UnsafeMutablePointer>> +// CHECK: sil [asmname "{{.*}}PtrToPtr{{.*}}"] [clang PtrToPtr.__operatorSubscript] @$sSo05PtrToA0V19__operatorSubscriptySpySpys5Int32VGSgGSgAEFTo : $@convention(cxx_method) (Int32, @inout PtrToPtr) -> Optional>>> +// CHECK: sil [asmname "{{.*}}ConstOpPtrByVal{{.*}}"] [clang ConstOpPtrByVal.__operatorSubscriptConst] @$sSo15ConstOpPtrByValV019__operatorSubscriptA0ySPys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @in_guaranteed ConstOpPtrByVal) -> Optional> +// CHECK: sil [asmname "{{.*}}ConstPtrByVal{{.*}}"] [clang ConstPtrByVal.__operatorSubscriptConst] @$sSo13ConstPtrByValV019__operatorSubscriptA0ySPys5Int32VGSgAEFTo : $@convention(cxx_method) (Int32, @inout ConstPtrByVal) -> Optional> diff --git a/test/Interop/Cxx/operators/member-out-of-line-silgen.swift b/test/Interop/Cxx/operators/member-out-of-line-silgen.swift index 8a7ca5496a889..8f63b6aa80091 100644 --- a/test/Interop/Cxx/operators/member-out-of-line-silgen.swift +++ b/test/Interop/Cxx/operators/member-out-of-line-silgen.swift @@ -9,11 +9,11 @@ public func add(_ lhs: LoadableIntWrapper, _ rhs: LoadableIntWrapper) -> Loadabl // CHECK-SYSV: [[FUNC:%.*]] = function_ref @$sSo18LoadableIntWrapperV14__operatorPlusyA2BFTo : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper // CHECK-SYSV: apply [[FUNC]]([[ACCESS:%.*]], [[STORE_LOC]]) : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper -// CHECK-SYSV: sil [asmname "_ZNK18LoadableIntWrapperplES_"] [clang LoadableIntWrapper.__operatorPlus] @$sSo18LoadableIntWrapperV14__operatorPlusyA2BFTo : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper +// CHECK-SYSV: sil [asmname "{{.*}}"] [clang LoadableIntWrapper.__operatorPlus] @$sSo18LoadableIntWrapperV14__operatorPlusyA2BFTo : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper // CHECK-WIN: bb0([[LHS:%.*]] : $LoadableIntWrapper, [[RHS:%.*]] : $LoadableIntWrapper): // CHECK-WIN: store [[LHS]] to [[STORE_LOC:%.*]] : $*LoadableIntWrapper // CHECK-WIN: [[FUNC:%.*]] = function_ref @$sSo18LoadableIntWrapperV14__operatorPlusyA2BFTo : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper // CHECK-WIN: apply [[FUNC]]([[ACCESS:%.*]], [[STORE_LOC]]) : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper -// CHECK-WIN: sil [asmname "_ZNK18LoadableIntWrapperplES_"] [clang LoadableIntWrapper.__operatorPlus] @$sSo18LoadableIntWrapperV14__operatorPlusyA2BFTo : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper +// CHECK-WIN: sil [asmname "{{.*}}"] [clang LoadableIntWrapper.__operatorPlus] @$sSo18LoadableIntWrapperV14__operatorPlusyA2BFTo : $@convention(cxx_method) (LoadableIntWrapper, @in_guaranteed LoadableIntWrapper) -> LoadableIntWrapper diff --git a/test/Interop/Cxx/static/static-member-func-silgen.swift b/test/Interop/Cxx/static/static-member-func-silgen.swift index 785db8c87b097..9dc193972df64 100644 --- a/test/Interop/Cxx/static/static-member-func-silgen.swift +++ b/test/Interop/Cxx/static/static-member-func-silgen.swift @@ -12,7 +12,7 @@ func callStaticMemberFunc() -> CInt { // CHECK: return [[VALUE]] : $Int32 // CHECK: // clang name: WithStaticMemberFunc::staticMemberFunc -// CHECK: sil [asmname "_ZN20WithStaticMemberFunc16staticMemberFuncEv"] [clang WithStaticMemberFunc.staticMemberFunc] @$sSo20WithStaticMemberFuncV06staticcD0s5Int32VyFZTo : $@convention(c) () -> Int32 +// CHECK: sil [asmname "{{.*}}staticMemberFunc{{.*}}"] [clang WithStaticMemberFunc.staticMemberFunc] @$sSo20WithStaticMemberFuncV06staticcD0s5Int32VyFZTo : $@convention(c) () -> Int32 func callStaticMemberFuncAddr() -> CInt { return WithStaticMemberFunc.getStaticMemberFuncAddress()!() @@ -23,4 +23,4 @@ func callStaticMemberFuncAddr() -> CInt { // CHECK: [[VALUE:%.*]] = apply [[FUNC]]() : $@convention(c) () -> Optional<@convention(c) () -> Int32> // CHECK: // clang name: WithStaticMemberFunc::getStaticMemberFuncAddress -// CHECK: sil [asmname "_ZN20WithStaticMemberFunc26getStaticMemberFuncAddressEv"] [clang WithStaticMemberFunc.getStaticMemberFuncAddress] @$sSo20WithStaticMemberFuncV03getbcD7Addresss5Int32VyXCSgyFZTo : $@convention(c) () -> Optional<@convention(c) () -> Int32> +// CHECK: sil [asmname "{{.*}}getStaticMemberFuncAddress{{.*}}"] [clang WithStaticMemberFunc.getStaticMemberFuncAddress] @$sSo20WithStaticMemberFuncV03getbcD7Addresss5Int32VyXCSgyFZTo : $@convention(c) () -> Optional<@convention(c) () -> Int32> diff --git a/test/Interop/Cxx/templates/member-templates-silgen.swift b/test/Interop/Cxx/templates/member-templates-silgen.swift index 036c5424ff7ab..3e4f941bfcc64 100644 --- a/test/Interop/Cxx/templates/member-templates-silgen.swift +++ b/test/Interop/Cxx/templates/member-templates-silgen.swift @@ -26,13 +26,13 @@ func basicTest() { obj.doNothingConstRef(i) } -// CHECK-LABEL: sil [asmname "_ZN18HasMemberTemplates17addSameTypeParamsIiEET_S1_S1_"] [clang HasMemberTemplates.addSameTypeParams] @$sSo18HasMemberTemplatesV17addSameTypeParamsys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 +// CHECK-LABEL: sil [asmname "{{.*}}addSameTypeParams{{.*}}"] [clang HasMemberTemplates.addSameTypeParams] @$sSo18HasMemberTemplatesV17addSameTypeParamsys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 -// CHECK-LABEL: sil [asmname "_ZN18HasMemberTemplates18addMixedTypeParamsIiiEET_S1_T0_"] [clang HasMemberTemplates.addMixedTypeParams] @$sSo18HasMemberTemplatesV18addMixedTypeParamsys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 +// CHECK-LABEL: sil [asmname "{{.*}}addMixedTypeParams{{.*}}"] [clang HasMemberTemplates.addMixedTypeParams] @$sSo18HasMemberTemplatesV18addMixedTypeParamsys5Int32VAE_AEtFTo : $@convention(cxx_method) (Int32, Int32, @inout HasMemberTemplates) -> Int32 -// CHECK-LABEL: sil [asmname "_ZN18HasMemberTemplates6addAllIiiEEiiT_T0_"] [clang HasMemberTemplates.addAll] @$sSo18HasMemberTemplatesV6addAllys5Int32VAE_A2EtFTo : $@convention(cxx_method) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32 +// CHECK-LABEL: sil [asmname "{{.*}}addAll{{.*}}"] [clang HasMemberTemplates.addAll] @$sSo18HasMemberTemplatesV6addAllys5Int32VAE_A2EtFTo : $@convention(cxx_method) (Int32, Int32, Int32, @inout HasMemberTemplates) -> Int32 -// CHECK-LABEL: sil [asmname "_ZN18HasMemberTemplates17doNothingConstRefIiEEvRKT_"] [clang HasMemberTemplates.doNothingConstRef] @$sSo18HasMemberTemplatesV17doNothingConstRefyys5Int32VFTo : $@convention(cxx_method) (@in_guaranteed Int32, @inout HasMemberTemplates) -> () +// CHECK-LABEL: sil [asmname "{{.*}}doNothingConstRef{{.*}}"] [clang HasMemberTemplates.doNothingConstRef] @$sSo18HasMemberTemplatesV17doNothingConstRefyys5Int32VFTo : $@convention(cxx_method) (@in_guaranteed Int32, @inout HasMemberTemplates) -> () // CHECK-LABEL: sil hidden @$s4main12testSetValueyyF : $@convention(thin) () -> () @@ -65,8 +65,8 @@ func testStaticMembers() { HasStaticMemberTemplates.removeReference(&x) } -// CHECK: sil hidden_external [asmname "_ZN24HasStaticMemberTemplates3addIlEET_S1_S1_"] [clang HasStaticMemberTemplates.add] @$sSo24HasStaticMemberTemplatesV3addyS2i_SitFZTo : $@convention(c) (Int, Int) -> Int +// CHECK: sil hidden_external [asmname "{{.*}}add{{.*}}"] [clang HasStaticMemberTemplates.add] @$sSo24HasStaticMemberTemplatesV3addyS2i_SitFZTo : $@convention(c) (Int, Int) -> Int -// CHECK: sil hidden_external [asmname "_ZN24HasStaticMemberTemplates15addTwoTemplatesIlcEET_S1_T0_"] [clang HasStaticMemberTemplates.addTwoTemplates] @$sSo24HasStaticMemberTemplatesV06addTwoD0yS2i_s4Int8VtFZTo : $@convention(c) (Int, Int8) -> Int +// CHECK: sil hidden_external [asmname "{{.*}}addTwoTemplates{{.*}}"] [clang HasStaticMemberTemplates.addTwoTemplates] @$sSo24HasStaticMemberTemplatesV06addTwoD0yS2i_s4Int8VtFZTo : $@convention(c) (Int, Int8) -> Int -// CHECK: sil hidden_external [asmname "_ZN24HasStaticMemberTemplates15removeReferenceIlEET_RS1_"] [clang HasStaticMemberTemplates.removeReference] @$sSo24HasStaticMemberTemplatesV15removeReferenceyS2izFZTo : $@convention(c) (@inout Int) -> Int +// CHECK: sil hidden_external [asmname "{{.*}}removeReference{{.*}}"] [clang HasStaticMemberTemplates.removeReference] @$sSo24HasStaticMemberTemplatesV15removeReferenceyS2izFZTo : $@convention(c) (@inout Int) -> Int diff --git a/test/SILGen/objc_bridging.swift b/test/SILGen/objc_bridging.swift index a18cd2edc0d21..9a985ba1b27c4 100644 --- a/test/SILGen/objc_bridging.swift +++ b/test/SILGen/objc_bridging.swift @@ -513,15 +513,15 @@ func forceNSArrayMembers() -> (NSArray, NSArray) { // imported C functions. // CHECK-ios-i386-LABEL: sil hidden [ossa] @$s13objc_bridging5boolsySb_SbtSbF -// CHECK-ios-i386: function_ref @$sSo7useBOOLyySo0B0VFTo : $@convention(c) (ObjCBool) -> () +// CHECK-ios-i386: function_ref @$sSo7useBOOLyySbFTo : $@convention(c) (ObjCBool) -> () // CHECK-ios-i386: function_ref @$sSo7useBoolyySbFTo : $@convention(c) (Bool) -> () -// CHECK-ios-i386: function_ref @$sSo7getBOOLSo0B0VyFTo : $@convention(c) () -> ObjCBool +// CHECK-ios-i386: function_ref @$sSo7getBOOLSbyFTo : $@convention(c) () -> ObjCBool // CHECK-ios-i386: function_ref @$sSo7getBoolSbyFTo : $@convention(c) () -> Bool // CHECK-macosx-x86_64-LABEL: sil hidden [ossa] @$s13objc_bridging5boolsySb_SbtSbF -// CHECK-macosx-x86_64: function_ref @$sSo7useBOOLyySo0B0VFTo : $@convention(c) (ObjCBool) -> () +// CHECK-macosx-x86_64: function_ref @$sSo7useBOOLyySbFTo : $@convention(c) (ObjCBool) -> () // CHECK-macosx-x86_64: function_ref @$sSo7useBoolyySbFTo : $@convention(c) (Bool) -> () -// CHECK-macosx-x86_64: function_ref @$sSo7getBOOLSo0B0VyFTo : $@convention(c) () -> ObjCBool +// CHECK-macosx-x86_64: function_ref @$sSo7getBOOLSbyFTo : $@convention(c) () -> ObjCBool // CHECK-macosx-x86_64: function_ref @$sSo7getBoolSbyFTo : $@convention(c) () -> Bool // FIXME: no distinction on x86_64, arm64 or watchos-i386, since SILGen looks diff --git a/test/SILOptimizer/c_string_optimization.swift b/test/SILOptimizer/c_string_optimization.swift index 9faea8afec9d2..475451a6f6a01 100644 --- a/test/SILOptimizer/c_string_optimization.swift +++ b/test/SILOptimizer/c_string_optimization.swift @@ -26,7 +26,7 @@ // CHECK-NOT: apply // CHECK: [[O:%[0-9]+]] = enum $Optional>, #Optional.some!enumelt, [[P]] // CHECK-NOT: apply -// CHECK: [[F:%[0-9]+]] = function_ref @puts +// CHECK: [[F:%[0-9]+]] = function_ref @$sSo4putsys5Int32VSPys4Int8VGSgFTo // CHECK: apply [[F]]([[O]]) // CHECK: } // end sil function '$s4test0A26StringConstantForCFunctionyyF' @inline(never) @@ -42,7 +42,7 @@ public func testStringConstantForCFunction() { // CHECK-NOT: apply // CHECK: [[O:%[0-9]+]] = enum $Optional>, #Optional.some!enumelt, [[P]] // CHECK-NOT: apply -// CHECK: [[F:%[0-9]+]] = function_ref @puts +// CHECK: [[F:%[0-9]+]] = function_ref @$sSo4putsys5Int32VSPys4Int8VGSgFTo // CHECK: apply [[F]]([[O]]) // CHECK: } // end sil function '$s4test0A17TypeInterpolationyyF' @inline(never) From 5d576470fd470eff89c88888fefd242fe43fb5db Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Fri, 31 Oct 2025 10:32:54 -0700 Subject: [PATCH 5/8] [IRGen] Detect duplicate definitions at the IR level --- include/swift/AST/DiagnosticsIRGen.def | 4 ++++ lib/IRGen/IRGenSIL.cpp | 21 +++++++++++++++------ lib/SIL/IR/SILFunction.cpp | 2 +- lib/SIL/IR/SILGlobalVariable.cpp | 2 +- lib/Serialization/DeserializeSIL.cpp | 2 +- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/swift/AST/DiagnosticsIRGen.def b/include/swift/AST/DiagnosticsIRGen.def index 638d6a05659c1..a04e22313bccb 100644 --- a/include/swift/AST/DiagnosticsIRGen.def +++ b/include/swift/AST/DiagnosticsIRGen.def @@ -117,5 +117,9 @@ NOTE(maybe_missing_parameter, none, "%select{constraint|parameter}0", (bool, const clang::NamedDecl *)) +ERROR(ir_function_redefinition_external,none, + "multiple definitions of symbol '%0'", + (StringRef)) + #define UNDEFINE_DIAGNOSTIC_MACROS #include "DefineDiagnosticMacros.h" diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index c73fd4f705cbd..f446df3a3930b 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -451,7 +451,7 @@ class IRGenSILFunction : llvm::DenseMap> StackPackAllocs; - IRGenSILFunction(IRGenModule &IGM, SILFunction *f); + IRGenSILFunction(IRGenModule &IGM, SILFunction *f, llvm::Function *llvmF); ~IRGenSILFunction(); /// Generate IR for the SIL Function. @@ -1887,10 +1887,9 @@ llvm::Value *LoweredValue::getSingletonExplosion(IRGenFunction &IGF, llvm_unreachable("bad kind"); } -IRGenSILFunction::IRGenSILFunction(IRGenModule &IGM, SILFunction *f) - : IRGenFunction(IGM, - IGM.getAddrOfSILFunction(f, ForDefinition, - f->isDynamicallyReplaceable()), +IRGenSILFunction::IRGenSILFunction(IRGenModule &IGM, SILFunction *f, + llvm::Function *llvmF) + : IRGenFunction(IGM, llvmF, f->isPerformanceConstraint(), f->getOptimizationMode(), f->getDebugScope(), f->getLocation()), @@ -2558,7 +2557,17 @@ void IRGenModule::emitSILFunction(SILFunction *f) { noteUseOfMetadataByCXXInterop(IRGen, f, TypeExpansionContext(*f)); PrettyStackTraceSILFunction stackTrace("emitting IR", f); - IRGenSILFunction(*this, f).emitSILFunction(); + + // Get the LLVM function we will emit. If it has already been defined, error. + auto llvmF = getAddrOfSILFunction(f, ForDefinition, + f->isDynamicallyReplaceable()); + if (!llvmF->empty()) { + auto &diags = Context.Diags; + diags.diagnose(f->getLocation().getSourceLoc(), diag::ir_function_redefinition_external, llvmF->getName()); + return; + } + + IRGenSILFunction(*this, f, llvmF).emitSILFunction(); } void IRGenSILFunction::emitSILFunction() { diff --git a/lib/SIL/IR/SILFunction.cpp b/lib/SIL/IR/SILFunction.cpp index 538af167ee190..13deeee9bc7ef 100644 --- a/lib/SIL/IR/SILFunction.cpp +++ b/lib/SIL/IR/SILFunction.cpp @@ -443,7 +443,7 @@ bool SILFunction::hasForeignBody() const { } void SILFunction::setAsmName(StringRef value) { - assert((AsmName.empty() || value == AsmName) && "Cannot change asmname"); + ASSERT((AsmName.empty() || value == AsmName) && "Cannot change asmname"); AsmName = value; if (!value.empty()) { diff --git a/lib/SIL/IR/SILGlobalVariable.cpp b/lib/SIL/IR/SILGlobalVariable.cpp index 9467e89f0a71b..8b8b5b1260b0c 100644 --- a/lib/SIL/IR/SILGlobalVariable.cpp +++ b/lib/SIL/IR/SILGlobalVariable.cpp @@ -85,7 +85,7 @@ SILGlobalVariable::~SILGlobalVariable() { } void SILGlobalVariable::setAsmName(StringRef value) { - assert((AsmName.empty() || value == AsmName) && "Cannot change asmname"); + ASSERT((AsmName.empty() || value == AsmName) && "Cannot change asmname"); AsmName = value; if (!value.empty()) { diff --git a/lib/Serialization/DeserializeSIL.cpp b/lib/Serialization/DeserializeSIL.cpp index edc5f84683958..430cdb0ff6c2a 100644 --- a/lib/Serialization/DeserializeSIL.cpp +++ b/lib/Serialization/DeserializeSIL.cpp @@ -4148,7 +4148,7 @@ SILGlobalVariable *SILDeserializer::lookupSILGlobalVariable(StringRef name, SILGlobalVariable *SILDeserializer::readGlobalVar(StringRef Name, bool byAsmName) { - // If we're looking up the function by its AsmName, check that table. + // If we're looking up the variable by its AsmName, check that table. if (byAsmName) { if (!AsmNameTable) return nullptr; From c814fe33b1ac345e759da701a88c69c56dc0061d Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Fri, 31 Oct 2025 10:45:25 -0700 Subject: [PATCH 6/8] Generalize test to cover Windows and remove the forked version --- ...ification-non-trivial-silgen-windows.swift | 176 ------------------ ...pe-classification-non-trivial-silgen.swift | 4 +- 2 files changed, 2 insertions(+), 178 deletions(-) delete mode 100644 test/Interop/Cxx/class/type-classification-non-trivial-silgen-windows.swift diff --git a/test/Interop/Cxx/class/type-classification-non-trivial-silgen-windows.swift b/test/Interop/Cxx/class/type-classification-non-trivial-silgen-windows.swift deleted file mode 100644 index ac76c25650858..0000000000000 --- a/test/Interop/Cxx/class/type-classification-non-trivial-silgen-windows.swift +++ /dev/null @@ -1,176 +0,0 @@ -// RUN: %target-swiftxx-frontend -I %S/Inputs -Xllvm -sil-print-types -emit-silgen %s | %FileCheck --dump-input-filter=all %s - -// REQUIRES: OS=windows-msvc - -import TypeClassification - -// Make sure that "StructWithDestructor" is marked as non-trivial by checking for a -// "destroy_addr". -// CHECK-LABEL: sil [ossa] @$s4main24testStructWithDestructoryyF -// CHECK: [[AS:%.*]] = alloc_stack [lexical] [var_decl] $StructWithDestructor -// CHECK: [[FN:%.*]] = function_ref @$sSo20StructWithDestructorVABycfCTo : $@convention(c) () -> @out StructWithDestructor -// CHECK: apply [[FN]]([[AS]]) : $@convention(c) () -> @out StructWithDestructor -// CHECK: destroy_addr [[AS]] -// CHECK: dealloc_stack %0 : $*StructWithDestructor -// CHECK-LABEL: end sil function '$s4main24testStructWithDestructoryyF' - -// CHECK-LABEL: sil [asmname "{{.*}}"] [clang StructWithDestructor.init] @{{.*}}StructWithDestructor{{.*}} : $@convention(c) () -> @out StructWithDestructor -public func testStructWithDestructor() { - let d = StructWithDestructor() -} - -// Make sure that "HasMemberWithDestructor" is marked as non-trivial by checking -// for a "destroy_addr". -// CHECK-LABEL: sil [ossa] @$s4main33testStructWithSubobjectDestructoryyF : $@convention(thin) () -> () -// CHECK: [[AS:%.*]] = alloc_stack [lexical] [var_decl] $StructWithSubobjectDestructor -// CHECK: [[FN:%.*]] = function_ref @{{_ZN29StructWithSubobjectDestructorC1Ev|\?\?0StructWithSubobjectDestructor@@QEAA@XZ}} : $@convention(c) () -> @out StructWithSubobjectDestructor -// CHECK: apply [[FN]]([[AS]]) : $@convention(c) () -> @out StructWithSubobjectDestructor -// CHECK: destroy_addr [[AS]] -// CHECK-LABEL: end sil function '$s4main33testStructWithSubobjectDestructoryyF' - -// CHECK-LABEL: sil [clang StructWithSubobjectDestructor.init] @{{_ZN29StructWithSubobjectDestructorC1Ev|\?\?0StructWithSubobjectDestructor@@QEAA@XZ}} : $@convention(c) () -> @out StructWithSubobjectDestructor -public func testStructWithSubobjectDestructor() { - let d = StructWithSubobjectDestructor() -} - -// CHECK-LABEL: sil [ossa] @$s4main37testStructWithCopyConstructorAndValueSbyF -// CHECK: [[AS:%.*]] = alloc_stack [lexical] [var_decl] $StructWithCopyConstructorAndValue -// CHECK: [[FN:%.*]] = function_ref @{{_ZN33StructWithCopyConstructorAndValueC1Ei|\?\?0StructWithCopyConstructorAndValue@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue -// CHECK: apply [[FN]]([[AS]], %{{.*}}) : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue -// CHECK: [[OBJ_VAL_ADDR:%.*]] = struct_element_addr [[AS]] : $*StructWithCopyConstructorAndValue, #StructWithCopyConstructorAndValue.value -// CHECK: [[OBJ_VAL:%.*]] = load [trivial] [[OBJ_VAL_ADDR]] : $*Int32 -// CHECK: [[IL_42:%.*]] = integer_literal $Builtin.IntLiteral, 42 -// CHECK: [[MAKE_INT_FN:%.*]] = function_ref @$ss5Int32V22_builtinIntegerLiteralABBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int32.Type) -> Int32 -// CHECK: [[INT_42:%.*]] = apply [[MAKE_INT_FN]]([[IL_42]], %{{.*}}) : $@convention(method) (Builtin.IntLiteral, @thin Int32.Type) -> Int32 -// CHECK: [[CMP_FN:%.*]] = function_ref @$ss5Int32V2eeoiySbAB_ABtFZ : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool -// CHECK: [[OUT:%.*]] = apply [[CMP_FN]]([[OBJ_VAL]], [[INT_42]], %{{.*}}) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool -// CHECK: destroy_addr [[AS]] : $*StructWithCopyConstructorAndValue -// CHECK: return [[OUT]] : $Bool -// CHECK-LABEL: end sil function '$s4main37testStructWithCopyConstructorAndValueSbyF' - -// CHECK-LABEL: sil [clang StructWithCopyConstructorAndValue.init] @{{_ZN33StructWithCopyConstructorAndValueC1Ei|\?\?0StructWithCopyConstructorAndValue@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue -public func testStructWithCopyConstructorAndValue() -> Bool { - let obj = StructWithCopyConstructorAndValue(42) - return obj.value == 42 -} - -// CHECK-LABEL: sil [ossa] @$s4main46testStructWithSubobjectCopyConstructorAndValueSbyF : $@convention(thin) () -> Bool -// CHECK: [[MEMBER_0:%.*]] = alloc_stack [lexical] [var_decl] $StructWithCopyConstructorAndValue -// CHECK: [[MAKE_MEMBER_FN:%.*]] = function_ref @{{_ZN33StructWithCopyConstructorAndValueC1Ei|\?\?0StructWithCopyConstructorAndValue@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue -// CHECK: apply [[MAKE_MEMBER_FN]]([[MEMBER_0]], %{{.*}}) : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue -// CHECK: [[AS:%.*]] = alloc_stack [lexical] [var_decl] $StructWithSubobjectCopyConstructorAndValue -// CHECK: [[META:%.*]] = metatype $@thin StructWithSubobjectCopyConstructorAndValue.Type -// CHECK: [[MEMBER_1:%.*]] = alloc_stack $StructWithCopyConstructorAndValue -// CHECK: copy_addr %0 to [init] [[MEMBER_1]] : $*StructWithCopyConstructorAndValue -// CHECK: [[FN:%.*]] = function_ref @$sSo42StructWithSubobjectCopyConstructorAndValueV6memberABSo0abdefG0V_tcfC : $@convention(method) (@in StructWithCopyConstructorAndValue, @thin StructWithSubobjectCopyConstructorAndValue.Type) -> @out StructWithSubobjectCopyConstructorAndValue -// CHECK: apply [[FN]]([[AS]], [[MEMBER_1]], [[META]]) : $@convention(method) (@in StructWithCopyConstructorAndValue, @thin StructWithSubobjectCopyConstructorAndValue.Type) -> @out StructWithSubobjectCopyConstructorAndValue -// CHECK: [[OBJ_MEMBER:%.*]] = struct_element_addr [[AS]] : $*StructWithSubobjectCopyConstructorAndValue, #StructWithSubobjectCopyConstructorAndValue.member -// CHECK: [[MEMBER_2:%.*]] = alloc_stack $StructWithCopyConstructorAndValue -// CHECK: copy_addr [[OBJ_MEMBER]] to [init] [[MEMBER_2]] : $*StructWithCopyConstructorAndValue -// CHECK: [[OBJ_VALUE_ADDR:%.*]] = struct_element_addr [[MEMBER_2]] : $*StructWithCopyConstructorAndValue, #StructWithCopyConstructorAndValue.value -// CHECK: [[OBJ_VALUE:%.*]] = load [trivial] [[OBJ_VALUE_ADDR]] : $*Int32 -// CHECK: [[MAKE_INT:%.*]] = function_ref @$ss5Int32V22_builtinIntegerLiteralABBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int32.Type) -> Int32 -// CHECK: [[INT_42:%.*]] = apply [[MAKE_INT]]({{.*}}) : $@convention(method) (Builtin.IntLiteral, @thin Int32.Type) -> Int32 -// CHECK: [[ICMP:%.*]] = function_ref @$ss5Int32V2eeoiySbAB_ABtFZ : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool -// CHECK: [[OUT:%.*]] = apply [[ICMP]]([[OBJ_VALUE]], [[INT_42]], %{{.*}}) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool -// CHECK: return [[OUT]] : $Bool -// CHECK-LABEL: end sil function '$s4main46testStructWithSubobjectCopyConstructorAndValueSbyF' -public func testStructWithSubobjectCopyConstructorAndValue() -> Bool { - let member = StructWithCopyConstructorAndValue(42) - let obj = StructWithSubobjectCopyConstructorAndValue(member: member) - return obj.member.value == 42 -} - -// StructWithSubobjectCopyConstructorAndValue.init(member:) -// CHECK-LABEL: sil shared [transparent] [serialized] [ossa] @$sSo42StructWithSubobjectCopyConstructorAndValueV6memberABSo0abdefG0V_tcfC : $@convention(method) (@in StructWithCopyConstructorAndValue, @thin StructWithSubobjectCopyConstructorAndValue.Type) -> @out StructWithSubobjectCopyConstructorAndValue -// CHECK: [[MEMBER:%.*]] = struct_element_addr %0 : $*StructWithSubobjectCopyConstructorAndValue, #StructWithSubobjectCopyConstructorAndValue.member -// CHECK: copy_addr [take] %1 to [init] [[MEMBER]] : $*StructWithCopyConstructorAndValue -// CHECK-LABEL: end sil function '$sSo42StructWithSubobjectCopyConstructorAndValueV6memberABSo0abdefG0V_tcfC' - -// testStructWithCopyConstructorAndSubobjectCopyConstructorAndValue() -// CHECK-LABEL: sil [ossa] @$s4main041testStructWithCopyConstructorAndSubobjectefG5ValueSbyF : $@convention(thin) () -> Bool -// CHECK: [[MEMBER_0:%.*]] = alloc_stack [lexical] [var_decl] $StructWithCopyConstructorAndValue -// CHECK: [[CREATE_MEMBER_FN:%.*]] = function_ref @{{_ZN33StructWithCopyConstructorAndValueC1Ei|\?\?0StructWithCopyConstructorAndValue@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue -// CHECK: apply [[CREATE_MEMBER_FN]]([[MEMBER_0]], %{{.*}}) : $@convention(c) (Int32) -> @out StructWithCopyConstructorAndValue -// CHECK: [[AS:%.*]] = alloc_stack [lexical] [var_decl] $StructWithCopyConstructorAndSubobjectCopyConstructorAndValue -// CHECK: [[MEMBER_1:%.*]] = alloc_stack $StructWithCopyConstructorAndValue -// CHECK: copy_addr [[MEMBER_0]] to [init] [[MEMBER_1]] : $*StructWithCopyConstructorAndValue -// CHECK: [[FN:%.*]] = function_ref @{{_ZN60StructWithCopyConstructorAndSubobjectCopyConstructorAndValueC1E33StructWithCopyConstructorAndValue|\?\?0StructWithCopyConstructorAndSubobjectCopyConstructorAndValue@@QEAA@UStructWithCopyConstructorAndValue@@@Z}} : $@convention(c) (@in StructWithCopyConstructorAndValue) -> @out StructWithCopyConstructorAndSubobjectCopyConstructorAndValue -// CHECK: apply [[FN]]([[AS]], [[MEMBER_1]]) : $@convention(c) (@in StructWithCopyConstructorAndValue) -> @out StructWithCopyConstructorAndSubobjectCopyConstructorAndValue -// CHECK: [[OBJ_MEMBER_ADDR:%.*]] = struct_element_addr [[AS]] : $*StructWithCopyConstructorAndSubobjectCopyConstructorAndValue, #StructWithCopyConstructorAndSubobjectCopyConstructorAndValue.member -// CHECK: [[MEMBER_2:%.*]] = alloc_stack $StructWithCopyConstructorAndValue -// CHECK: copy_addr [[OBJ_MEMBER_ADDR]] to [init] [[MEMBER_2]] : $*StructWithCopyConstructorAndValue -// CHECK: [[OBJ_MEMBER_VALUE_ADDR:%.*]] = struct_element_addr [[MEMBER_2]] : $*StructWithCopyConstructorAndValue, #StructWithCopyConstructorAndValue.value -// CHECK: [[OBJ_MEMBER_VALUE:%.*]] = load [trivial] [[OBJ_MEMBER_VALUE_ADDR]] : $*Int32 -// CHECK: [[ICMP:%.*]] = function_ref @$ss5Int32V2eeoiySbAB_ABtFZ : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool -// CHECK: [[OUT:%.*]] = apply [[ICMP]]([[OBJ_MEMBER_VALUE]], %{{.*}}) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool -// CHECK: return [[OUT]] : $Bool -// CHECK-LABEL: end sil function '$s4main041testStructWithCopyConstructorAndSubobjectefG5ValueSbyF' -public func testStructWithCopyConstructorAndSubobjectCopyConstructorAndValue() --> Bool { - let member = StructWithCopyConstructorAndValue(42) - let obj = StructWithCopyConstructorAndSubobjectCopyConstructorAndValue( - member - ) - return obj.member.value == 42 -} - -// CHECK-LABEL: sil [ossa] @$s4main4test3objSbSo33StructWithCopyConstructorAndValueV_tF : $@convention(thin) (@in_guaranteed StructWithCopyConstructorAndValue) -> Bool -// CHECK: [[META_1:%.*]] = metatype $@thin Int32.Type -// CHECK: [[OBJ_VAL_ADDR:%.*]] = struct_element_addr %0 : $*StructWithCopyConstructorAndValue, #StructWithCopyConstructorAndValue.value -// CHECK: [[OBJ_VAL:%.*]] = load [trivial] [[OBJ_VAL_ADDR]] : $*Int32 -// CHECK: [[IL_42:%.*]] = integer_literal $Builtin.IntLiteral, 42 -// CHECK: [[META_2:%.*]] = metatype $@thin Int32.Type -// CHECK: [[FN:%.*]] = function_ref @$ss5Int32V22_builtinIntegerLiteralABBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int32.Type) -> Int32 -// CHECK: [[INT:%.*]] = apply [[FN]]([[IL_42]], [[META_2]]) : $@convention(method) (Builtin.IntLiteral, @thin Int32.Type) -> Int32 -// CHECK: [[FN_2:%.*]] = function_ref @$ss5Int32V2eeoiySbAB_ABtFZ : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool -// CHECK: [[OUT:%.*]] = apply [[FN_2]]([[OBJ_VAL]], [[INT]], [[META_1]]) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool -// CHECK: return [[OUT]] : $Bool -// CHECK-LABEL: end sil function '$s4main4test3objSbSo33StructWithCopyConstructorAndValueV_tF' -public func test(obj: StructWithCopyConstructorAndValue) -> Bool { - return obj.value == 42 -} - -// CHECK-LABEL: sil [ossa] @$s4main4test3objSbSo42StructWithSubobjectCopyConstructorAndValueV_tF : $@convention(thin) (@in_guaranteed StructWithSubobjectCopyConstructorAndValue) -> Bool -// CHECK: [[INT_META:%.*]] = metatype $@thin Int32.Type -// CHECK: [[OBJ_MEMBER:%.*]] = struct_element_addr %0 : $*StructWithSubobjectCopyConstructorAndValue, #StructWithSubobjectCopyConstructorAndValue.member -// CHECK: [[MEMBER_TMP:%.*]] = alloc_stack $StructWithCopyConstructorAndValue -// CHECK: copy_addr [[OBJ_MEMBER]] to [init] [[MEMBER_TMP]] : $*StructWithCopyConstructorAndValue -// CHECK: [[OBJ_MEMBER_VALUE_ADDR:%.*]] = struct_element_addr [[MEMBER_TMP]] : $*StructWithCopyConstructorAndValue, #StructWithCopyConstructorAndValue.value -// CHECK: [[OBJ_MEMBER_VALUE:%.*]] = load [trivial] [[OBJ_MEMBER_VALUE_ADDR]] : $*Int32 -// CHECK: destroy_addr [[MEMBER_TMP]] : $*StructWithCopyConstructorAndValue -// CHECK: [[IL_42:%.*]] = integer_literal $Builtin.IntLiteral, 42 -// CHECK: [[INT_META_2:%.*]] = metatype $@thin Int32.Type -// CHECK: [[MAKE_INT_FN:%.*]] = function_ref @$ss5Int32V22_builtinIntegerLiteralABBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int32.Type) -> Int32 -// CHECK: [[INT_42:%.*]] = apply [[MAKE_INT_FN]]([[IL_42]], [[INT_META_2]]) : $@convention(method) (Builtin.IntLiteral, @thin Int32.Type) -> Int32 -// CHECK: [[FN:%.*]] = function_ref @$ss5Int32V2eeoiySbAB_ABtFZ : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool -// CHECK: [[OUT:%.*]] = apply [[FN]]([[OBJ_MEMBER_VALUE]], [[INT_42]], [[INT_META]]) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool -// CHECK: dealloc_stack [[MEMBER_TMP]] : $*StructWithCopyConstructorAndValue -// CHECK: return [[OUT]] : $Bool -// CHECK-LABEL: end sil function '$s4main4test3objSbSo42StructWithSubobjectCopyConstructorAndValueV_tF' -public func test(obj: StructWithSubobjectCopyConstructorAndValue) -> Bool { - return obj.member.value == 42 -} - -// CHECK-LABEL: sil [ossa] @$s4main4test3objSbSo037StructWithCopyConstructorAndSubobjectfgH5ValueV_tF -// CHECK: [[META_INT_1:%.*]] = metatype $@thin Int32.Type -// CHECK: [[OBJ_MEMBER:%.*]] = struct_element_addr %0 : $*StructWithCopyConstructorAndSubobjectCopyConstructorAndValue, #StructWithCopyConstructorAndSubobjectCopyConstructorAndValue.member -// CHECK: [[MEMBER_TMP:%.*]] = alloc_stack $StructWithCopyConstructorAndValue -// CHECK: copy_addr [[OBJ_MEMBER]] to [init] [[MEMBER_TMP]] : $*StructWithCopyConstructorAndValue -// CHECK: [[OBJ_MEMBER_VAL_ADDR:%.*]] = struct_element_addr [[MEMBER_TMP]] : $*StructWithCopyConstructorAndValue, #StructWithCopyConstructorAndValue.value -// CHECK: [[OBJ_MEMBER_VAL:%.*]] = load [trivial] [[OBJ_MEMBER_VAL_ADDR]] : $*Int32 -// CHECK: destroy_addr [[MEMBER_TMP]] : $*StructWithCopyConstructorAndValue -// CHECK: [[IL_42:%.*]] = integer_literal $Builtin.IntLiteral, 42 -// CHECK: [[META_INT_2:%.*]] = metatype $@thin Int32.Type -// CHECK: [[MAKE_INT_FN:%.*]] = function_ref @$ss5Int32V22_builtinIntegerLiteralABBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int32.Type) -> Int32 -// CHECK: [[INT_42:%.*]] = apply [[MAKE_INT_FN]]([[IL_42]], [[META_INT_2]]) : $@convention(method) (Builtin.IntLiteral, @thin Int32.Type) -> Int32 -// CHECK: [[ICMP_FN:%.*]] = function_ref @$ss5Int32V2eeoiySbAB_ABtFZ : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool -// CHECK: [[OUT:%.*]] = apply [[ICMP_FN]]([[OBJ_MEMBER_VAL]], [[INT_42]], [[META_INT_1]]) : $@convention(method) (Int32, Int32, @thin Int32.Type) -> Bool -// CHECK: dealloc_stack [[MEMBER_TMP]] : $*StructWithCopyConstructorAndValue -// CHECK: return [[OUT]] : $Bool -// CHECK-LABEL: end sil function '$s4main4test3objSbSo037StructWithCopyConstructorAndSubobjectfgH5ValueV_tF' -public func test( - obj: StructWithCopyConstructorAndSubobjectCopyConstructorAndValue -) -> Bool { - return obj.member.value == 42 -} diff --git a/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift b/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift index 749f13a98beba..672295fb358aa 100644 --- a/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift +++ b/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift @@ -92,8 +92,8 @@ public func testStructWithSubobjectCopyConstructorAndValue() -> Bool { // CHECK: [[AS:%.*]] = alloc_stack [lexical] [var_decl] $StructWithCopyConstructorAndSubobjectCopyConstructorAndValue // CHECK: [[MEMBER_1:%.*]] = alloc_stack $StructWithCopyConstructorAndValue // CHECK: copy_addr [[MEMBER_0]] to [init] [[MEMBER_1]] : $*StructWithCopyConstructorAndValue -// CHECK: [[FN:%.*]] = function_ref @$sSo037StructWithCopyConstructorAndSubobjectcdE5ValueVyABSo0abcdeG0VcfCTo : $@convention(c) (@in_cxx StructWithCopyConstructorAndValue) -> @out StructWithCopyConstructorAndSubobjectCopyConstructorAndValue -// CHECK: apply [[FN]]([[AS]], [[MEMBER_1]]) : $@convention(c) (@in_cxx StructWithCopyConstructorAndValue) -> @out StructWithCopyConstructorAndSubobjectCopyConstructorAndValue +// CHECK: [[FN:%.*]] = function_ref @$sSo037StructWithCopyConstructorAndSubobjectcdE5ValueVyABSo0abcdeG0VcfCTo : $@convention(c) (@in{{(_cxx)?}} StructWithCopyConstructorAndValue) -> @out StructWithCopyConstructorAndSubobjectCopyConstructorAndValue +// CHECK: apply [[FN]]([[AS]], [[MEMBER_1]]) : $@convention(c) (@in{{(_cxx)?}} StructWithCopyConstructorAndValue) -> @out StructWithCopyConstructorAndSubobjectCopyConstructorAndValue // CHECK: [[OBJ_MEMBER_ADDR:%.*]] = struct_element_addr [[AS]] : $*StructWithCopyConstructorAndSubobjectCopyConstructorAndValue, #StructWithCopyConstructorAndSubobjectCopyConstructorAndValue.member // CHECK: [[MEMBER_2:%.*]] = alloc_stack $StructWithCopyConstructorAndValue // CHECK: copy_addr [[OBJ_MEMBER_ADDR]] to [init] [[MEMBER_2]] : $*StructWithCopyConstructorAndValue From 576cb0257c72100353a5593033d5cb2243abb1ea Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Fri, 31 Oct 2025 22:09:07 -0700 Subject: [PATCH 7/8] Update iOS test for asmname change --- test/SILGen/UIApplicationMain.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SILGen/UIApplicationMain.swift b/test/SILGen/UIApplicationMain.swift index f707e21a3fb7f..8d379a2494d34 100644 --- a/test/SILGen/UIApplicationMain.swift +++ b/test/SILGen/UIApplicationMain.swift @@ -29,7 +29,7 @@ import UIKit class MyDelegate : UIApplicationDelegate {} // CHECK-LABEL: sil [ossa] @main -// CHECK: function_ref @UIApplicationMain +// CHECK: function_ref @$sSo17UIApplicationMainys5Int32VAC_SpySpys4Int8VGSgGSgSSSgAJtFTo // IR-LABEL: define{{( protected)?}} i32 @main // IR: call i32 @UIApplicationMain From f1ad1be9191a3bcf45f12dc4e4255dab8b66c069 Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Sat, 1 Nov 2025 10:54:41 -0700 Subject: [PATCH 8/8] MAke FileCheck more general to not worry about nullability of UIApplicationMain from C --- test/SILGen/UIApplicationMain.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SILGen/UIApplicationMain.swift b/test/SILGen/UIApplicationMain.swift index 8d379a2494d34..01e084b0ffac6 100644 --- a/test/SILGen/UIApplicationMain.swift +++ b/test/SILGen/UIApplicationMain.swift @@ -29,7 +29,7 @@ import UIKit class MyDelegate : UIApplicationDelegate {} // CHECK-LABEL: sil [ossa] @main -// CHECK: function_ref @$sSo17UIApplicationMainys5Int32VAC_SpySpys4Int8VGSgGSgSSSgAJtFTo +// CHECK: function_ref @$sSo17UIApplicationMainys5Int32VAC_SpySpys4Int8VGSg{{.*}}To // IR-LABEL: define{{( protected)?}} i32 @main // IR: call i32 @UIApplicationMain