diff --git a/include/swift/ABI/MetadataValues.h b/include/swift/ABI/MetadataValues.h index aaf4dc3810f..cc0922b20f8 100644 --- a/include/swift/ABI/MetadataValues.h +++ b/include/swift/ABI/MetadataValues.h @@ -1363,9 +1363,11 @@ public: }; /// Kinds of requests for metadata. -class MetadataRequest : public FlagSet { +template +class TargetMetadataRequest : public FlagSet { + using super = FlagSet; public: - enum BasicKind { + enum BasicKind : IntType { /// A request for fully-completed metadata. The metadata must be /// prepared for all supported type operations. This is a superset /// of the requirements of LayoutComplete. @@ -1387,7 +1389,7 @@ public: }; private: - enum { + enum : IntType { BasicKind_bit = 0, BasicKind_width = 8, @@ -1401,12 +1403,14 @@ private: }; public: - MetadataRequest(BasicKind kind, bool isNonBlocking = false) { + TargetMetadataRequest(BasicKind kind, bool isNonBlocking = false) { setBasicKind(kind); setIsNonBlocking(isNonBlocking); } - explicit MetadataRequest(size_t bits) : FlagSet(bits) {} - constexpr MetadataRequest() {} + explicit TargetMetadataRequest(IntType bits) : super(bits) {} + constexpr TargetMetadataRequest() {} + + FLAGSET_DEFINE_EQUALITY(TargetMetadataRequest) FLAGSET_DEFINE_FIELD_ACCESSORS(BasicKind_bit, BasicKind_width, @@ -1418,6 +1422,8 @@ public: isNonBlocking, setIsNonBlocking) }; +using MetadataRequest = + TargetMetadataRequest; } // end namespace swift diff --git a/include/swift/Basic/FlagSet.h b/include/swift/Basic/FlagSet.h index 8567163bf51..2dfc5d50855 100644 --- a/include/swift/Basic/FlagSet.h +++ b/include/swift/Basic/FlagSet.h @@ -83,20 +83,32 @@ protected: // Intended to be used in the body of a subclass of FlagSet. #define FLAGSET_DEFINE_FLAG_ACCESSORS(BIT, GETTER, SETTER) \ bool GETTER() const { \ - return getFlag(); \ + return this->template getFlag(); \ } \ void SETTER(bool value) { \ - setFlag(value); \ + this->template setFlag(value); \ } // A convenient macro for defining a getter and setter for a field. // Intended to be used in the body of a subclass of FlagSet. #define FLAGSET_DEFINE_FIELD_ACCESSORS(BIT, WIDTH, TYPE, GETTER, SETTER) \ TYPE GETTER() const { \ - return getField(); \ + return this->template getField(); \ } \ void SETTER(TYPE value) { \ - setField(value); \ + this->template setField(value); \ + } + + // A convenient macro to expose equality operators. + // These can't be provided directly by FlagSet because that would allow + // different flag sets to be compared if they happen to have the same + // underlying type. +#define FLAGSET_DEFINE_EQUALITY(TYPENAME) \ + friend bool operator==(TYPENAME lhs, TYPENAME rhs) { \ + return lhs.getOpaqueValue() == rhs.getOpaqueValue(); \ + } \ + friend bool operator!=(TYPENAME lhs, TYPENAME rhs) { \ + return lhs.getOpaqueValue() != rhs.getOpaqueValue(); \ } public: diff --git a/include/swift/Runtime/Metadata.h b/include/swift/Runtime/Metadata.h index 0af18f74511..b9182537126 100644 --- a/include/swift/Runtime/Metadata.h +++ b/include/swift/Runtime/Metadata.h @@ -189,6 +189,31 @@ class WeakReference; template struct TargetMetadata; using Metadata = TargetMetadata; +/// The result of requesting type metadata. Generally the return value of +/// a function. +/// +/// For performance, functions returning this type should use SWIFT_CC so +/// that the components are returned as separate values. +struct MetadataResponse { + /// For metadata access functions, this is the requested metadata. + /// + /// For metadata initialization functions, this is either null, + /// indicating that initialization was successful, or a metadata on + /// which initialization depends for further progress. + const Metadata *Value; + + /// For metadata access functions, this is the current state of the + /// metadata returned. Always use this instead of trying to inspect + /// the metadata directly; an incomplete metadata may be getting + /// initialized concurrently. This can generally be ignored if the + /// metadata request was for abstract metadata or if the request is + /// blocking. + /// + /// For metadata initialization functions, this is the state that the + /// given metadata needs to be in before initialization can continue. + MetadataRequest::BasicKind State; +}; + template struct TargetProtocolConformanceDescriptor; /// Storage for an arbitrary value. In C/C++ terms, this is an @@ -1983,6 +2008,16 @@ using TargetWitnessTablePointer = using WitnessTablePointer = TargetWitnessTablePointer; +using AssociatedTypeAccessFunction = + SWIFT_CC(swift) MetadataResponse(MetadataRequest request, + const Metadata *self, + const WitnessTable *selfConformance); + +using AssociatedWitnessTableAccessFunction = + SWIFT_CC(swift) WitnessTable *(const Metadata *associatedType, + const Metadata *self, + const WitnessTable *selfConformance); + /// The possible physical representations of existential types. enum class ExistentialTypeRepresentation { /// The type uses an opaque existential representation. @@ -3008,9 +3043,10 @@ struct MetadataCompletionContext { /// pointer to indicate that completion is blocked on the completion of /// some other type using MetadataCompleter = - Metadata *(const Metadata *type, - MetadataCompletionContext *context, - const TargetGenericMetadataPattern *pattern); + SWIFT_CC(swift) + MetadataResponse(const Metadata *type, + MetadataCompletionContext *context, + const TargetGenericMetadataPattern *pattern); /// An instantiation pattern for type metadata. template @@ -3229,45 +3265,13 @@ using TypeGenericContextDescriptorHeader = /// Wrapper class for the pointer to a metadata access function that provides /// operator() overloads to call it with the right calling convention. class MetadataAccessFunction { - const Metadata * (*Function)(...); + MetadataResponse (*Function)(...); static_assert(NumDirectGenericTypeMetadataAccessFunctionArgs == 3, "Need to account for change in number of direct arguments"); - template - const Metadata *applyN(const void *arg0, - const void *arg1, - const void *arg2, - llvm::ArrayRef argRest) const { - using FnN = const Metadata *(const void *, - const void *, - const void *, - const void *); - return reinterpret_cast(Function)(arg0, arg1, arg2, argRest.data()); - } - - template - const Metadata *variadic_apply(const void *arg0, - const void *arg1, - const void *arg2, - llvm::MutableArrayRef argRest, - unsigned n, - const void *arg3, - Args...argN) const { - argRest[n] = arg3; - return variadic_apply(arg0, arg1, arg2, argRest, n+1, argN...); - } - - const Metadata *variadic_apply(const void *arg0, - const void *arg1, - const void *arg2, - llvm::MutableArrayRef argRest, - unsigned n) const { - return applyN(arg0, arg1, arg2, argRest); - } - public: - explicit MetadataAccessFunction(const Metadata * (*Function)(...)) + explicit MetadataAccessFunction(MetadataResponse (*Function)(...)) : Function(Function) {} @@ -3275,52 +3279,78 @@ public: return Function != nullptr; } - // Invoke with an array of arguments. - template - const Metadata *operator()(llvm::ArrayRef args) const { + /// Invoke with an array of arguments of dynamic size. + MetadataResponse operator()(MetadataRequest request, + llvm::ArrayRef args) const { switch (args.size()) { case 0: - return (*this)(); + return operator()(request); case 1: - return (*this)(args[0]); + return operator()(request, args[0]); case 2: - return (*this)(args[0], args[1]); + return operator()(request, args[0], args[1]); case 3: - return (*this)(args[0], args[1], args[2]); + return operator()(request, args[0], args[1], args[2]); default: - return applyN(args[0], args[1], args[2], args); + return applyMany(request, args.data()); } } - // Invoke with n arguments. - const Metadata *operator()() const { - using Fn0 = const Metadata *(); - return reinterpret_cast(Function)(); + /// Invoke with exactly 0 arguments. + MetadataResponse operator()(MetadataRequest request) const { + using Fn0 = SWIFT_CC(swift) MetadataResponse(MetadataRequest request); + return reinterpret_cast(Function)(request); } - const Metadata *operator()(const void *arg0) const { - using Fn1 = const Metadata *(const void *); - return reinterpret_cast(Function)(arg0); + + /// Invoke with exactly 1 argument. + MetadataResponse operator()(MetadataRequest request, + const void *arg0) const { + using Fn1 = SWIFT_CC(swift) MetadataResponse(MetadataRequest request, + const void *arg0); + return reinterpret_cast(Function)(request, arg0); } - const Metadata *operator()(const void *arg0, - const void *arg1) const { - using Fn2 = const Metadata *(const void *, const void *); - return reinterpret_cast(Function)(arg0, arg1); + + /// Invoke with exactly 2 arguments. + MetadataResponse operator()(MetadataRequest request, + const void *arg0, + const void *arg1) const { + using Fn2 = SWIFT_CC(swift) MetadataResponse(MetadataRequest request, + const void *arg0, + const void *arg1); + return reinterpret_cast(Function)(request, arg0, arg1); } - const Metadata *operator()(const void *arg0, - const void *arg1, - const void *arg2) const { - using Fn3 = const Metadata *(const void *, const void *, const void *); - return reinterpret_cast(Function)(arg0, arg1, arg2); + + /// Invoke with exactly 3 arguments. + MetadataResponse operator()(MetadataRequest request, + const void *arg0, + const void *arg1, + const void *arg2) const { + using Fn3 = SWIFT_CC(swift) MetadataResponse(MetadataRequest request, + const void *arg0, + const void *arg1, + const void *arg2); + return reinterpret_cast(Function)(request, arg0, arg1, arg2); } + /// Invoke with more than 3 arguments. template - const Metadata *operator()(const void *arg0, - const void *arg1, - const void *arg2, - Args...argN) const { - const void *args[3 + sizeof...(Args)]; - return variadic_apply(arg0, arg1, arg2, args, 3, argN...); + MetadataResponse operator()(MetadataRequest request, + const void *arg0, + const void *arg1, + const void *arg2, + Args... argN) const { + const void *args[] = { arg0, arg1, arg2, argN... }; + return applyMany(request, args); + } + +private: + /// In the more-then-max case, just pass all the arguments as an array. + MetadataResponse applyMany(MetadataRequest request, + const void * const *args) const { + using FnN = SWIFT_CC(swift) MetadataResponse(MetadataRequest request, + const void * const *args); + return reinterpret_cast(Function)(request, args); } }; @@ -3336,7 +3366,7 @@ public: /// The function type here is a stand-in. You should use getAccessFunction() /// to wrap the function pointer in an accessor that uses the proper calling /// convention for a given number of arguments. - TargetRelativeDirectPointer AccessFunctionPtr; MetadataAccessFunction getAccessFunction() const { @@ -3855,27 +3885,11 @@ TargetTypeContextDescriptor::getFullGenericContextHeader() const { } /// \brief Fetch a uniqued metadata object for a generic nominal type. -/// -/// The basic algorithm for fetching a metadata object is: -/// func swift_getGenericMetadata(header, arguments) { -/// if (metadata = getExistingMetadata(&header.PrivateData, -/// arguments[0..header.NumArguments])) -/// return metadata -/// metadata = malloc(superclass.MetadataSize + -/// numImmediateMembers * sizeof(void *)) -/// memcpy(metadata, header.MetadataTemplate, header.TemplateSize) -/// for (i in 0..header.NumFillInstructions) -/// metadata[header.FillInstructions[i].ToIndex] -/// = arguments[header.FillInstructions[i].FromIndex] -/// setExistingMetadata(&header.PrivateData, -/// arguments[0..header.NumArguments], -/// metadata) -/// return metadata -/// } -SWIFT_RUNTIME_EXPORT -const Metadata * -swift_getGenericMetadata(const TypeContextDescriptor *description, - const void *arguments); +SWIFT_RUNTIME_EXPORT SWIFT_CC(swift) +MetadataResponse +swift_getGenericMetadata(MetadataRequest request, + const void * const *arguments, + const TypeContextDescriptor *description); /// Allocate a generic class metadata object. This is intended to be /// called by the metadata instantiation function of a generic class. diff --git a/include/swift/Runtime/RuntimeFunctions.def b/include/swift/Runtime/RuntimeFunctions.def index 0ed3e0481a2..a3fba192ecd 100644 --- a/include/swift/Runtime/RuntimeFunctions.def +++ b/include/swift/Runtime/RuntimeFunctions.def @@ -801,11 +801,12 @@ FUNCTION(GetForeignTypeMetadata, swift_getForeignTypeMetadata, C_CC, ARGS(TypeMetadataPtrTy), ATTRS(NoUnwind, ReadNone)) // only writes to runtime-private fields -// Metadata *swift_getGenericMetadata(TypeContextDescriptor *type, -// const void *arguments); -FUNCTION(GetGenericMetadata, swift_getGenericMetadata, C_CC, - RETURNS(TypeMetadataPtrTy), - ARGS(TypeContextDescriptorPtrTy, Int8PtrTy), +// MetadataResponse swift_getGenericMetadata(MetadataRequest request, +// const void * const *arguments, +// TypeContextDescriptor *type); +FUNCTION(GetGenericMetadata, swift_getGenericMetadata, SwiftCC, + RETURNS(TypeMetadataResponseTy), + ARGS(SizeTy, Int8PtrTy, TypeContextDescriptorPtrTy), ATTRS(NoUnwind, ReadOnly)) // Metadata *swift_allocateGenericClassMetadata(ClassDescriptor *type, diff --git a/lib/IRGen/CMakeLists.txt b/lib/IRGen/CMakeLists.txt index da06deb5b07..03fab5d7271 100644 --- a/lib/IRGen/CMakeLists.txt +++ b/lib/IRGen/CMakeLists.txt @@ -42,6 +42,7 @@ add_swift_library(swiftIRGen STATIC LoadableByAddress.cpp LocalTypeData.cpp MetadataLayout.cpp + MetadataRequest.cpp StructLayout.cpp SwiftTargetInfo.cpp TypeLayoutVerifier.cpp diff --git a/lib/IRGen/GenArchetype.cpp b/lib/IRGen/GenArchetype.cpp index d0e518678c8..9cff9d6a073 100644 --- a/lib/IRGen/GenArchetype.cpp +++ b/lib/IRGen/GenArchetype.cpp @@ -44,6 +44,7 @@ #include "IRGenDebugInfo.h" #include "IRGenFunction.h" #include "IRGenModule.h" +#include "MetadataRequest.h" #include "ProtocolInfo.h" #include "ResilientTypeInfo.h" #include "TypeInfo.h" @@ -52,27 +53,29 @@ using namespace swift; using namespace irgen; -llvm::Value *irgen::emitArchetypeTypeMetadataRef(IRGenFunction &IGF, - CanArchetypeType archetype) { +MetadataResponse +irgen::emitArchetypeTypeMetadataRef(IRGenFunction &IGF, + CanArchetypeType archetype, + DynamicMetadataRequest request) { // Check for an existing cache entry. - auto localDataKind = LocalTypeDataKind::forTypeMetadata(); - auto metadata = IGF.tryGetLocalTypeData(archetype, localDataKind); + if (auto response = IGF.tryGetLocalTypeMetadata(archetype, request)) + return response; // If that's not present, this must be an associated type. - if (!metadata) { - assert(!archetype->isPrimary() && - "type metadata for primary archetype was not bound in context"); + assert(!archetype->isPrimary() && + "type metadata for primary archetype was not bound in context"); - CanArchetypeType parent(archetype->getParent()); - AssociatedType association(archetype->getAssocType()); - metadata = emitAssociatedTypeMetadataRef(IGF, parent, association); + CanArchetypeType parent(archetype->getParent()); + AssociatedType association(archetype->getAssocType()); - setTypeMetadataName(IGF.IGM, metadata, archetype); + MetadataResponse response = + emitAssociatedTypeMetadataRef(IGF, parent, association, request); - IGF.setScopedLocalTypeData(archetype, localDataKind, metadata); - } + setTypeMetadataName(IGF.IGM, response.getMetadata(), archetype); - return metadata; + IGF.setScopedLocalTypeMetadata(archetype, response); + + return response; } namespace { @@ -286,18 +289,22 @@ llvm::Value *irgen::emitArchetypeWitnessTableRef(IRGenFunction &IGF, return wtable; } -llvm::Value *irgen::emitAssociatedTypeMetadataRef(IRGenFunction &IGF, - CanArchetypeType origin, - AssociatedType association) { +MetadataResponse +irgen::emitAssociatedTypeMetadataRef(IRGenFunction &IGF, + CanArchetypeType origin, + AssociatedType association, + DynamicMetadataRequest request) { // Find the conformance of the origin to the associated type's protocol. llvm::Value *wtable = emitArchetypeWitnessTableRef(IGF, origin, association.getSourceProtocol()); // Find the origin's type metadata. - llvm::Value *originMetadata = emitArchetypeTypeMetadataRef(IGF, origin); + llvm::Value *originMetadata = + emitArchetypeTypeMetadataRef(IGF, origin, MetadataRequest::Complete) + .getMetadata(); return emitAssociatedTypeMetadataRef(IGF, originMetadata, wtable, - association); + association, request); } const TypeInfo *TypeConverter::convertArchetypeType(ArchetypeType *archetype) { @@ -419,7 +426,9 @@ llvm::Value *irgen::emitDynamicTypeOfOpaqueArchetype(IRGenFunction &IGF, auto archetype = type.castTo(); // Acquire the archetype's static metadata. - llvm::Value *metadata = emitArchetypeTypeMetadataRef(IGF, archetype); + llvm::Value *metadata = + emitArchetypeTypeMetadataRef(IGF, archetype, MetadataRequest::Complete) + .getMetadata(); return IGF.Builder.CreateCall(IGF.IGM.getGetDynamicTypeFn(), {addr.getAddress(), metadata, llvm::ConstantInt::get(IGF.IGM.Int1Ty, 0)}); diff --git a/lib/IRGen/GenArchetype.h b/lib/IRGen/GenArchetype.h index 7f9c36bc8ec..a42e702bae6 100644 --- a/lib/IRGen/GenArchetype.h +++ b/lib/IRGen/GenArchetype.h @@ -32,13 +32,16 @@ namespace swift { namespace irgen { class Address; class IRGenFunction; + class DynamicMetadataRequest; + class MetadataResponse; using GetTypeParameterInContextFn = llvm::function_ref; /// Emit a type metadata reference for an archetype. - llvm::Value *emitArchetypeTypeMetadataRef(IRGenFunction &IGF, - CanArchetypeType archetype); + MetadataResponse emitArchetypeTypeMetadataRef(IRGenFunction &IGF, + CanArchetypeType archetype, + DynamicMetadataRequest request); /// Emit a witness table reference. llvm::Value *emitArchetypeWitnessTableRef(IRGenFunction &IGF, @@ -46,9 +49,10 @@ namespace irgen { ProtocolDecl *protocol); /// Emit a metadata reference for an associated type of an archetype. - llvm::Value *emitAssociatedTypeMetadataRef(IRGenFunction &IGF, - CanArchetypeType origin, - AssociatedType association); + MetadataResponse emitAssociatedTypeMetadataRef(IRGenFunction &IGF, + CanArchetypeType origin, + AssociatedType association, + DynamicMetadataRequest request); /// Emit a dynamic metatype lookup for the given archetype. llvm::Value *emitDynamicTypeOfOpaqueArchetype(IRGenFunction &IGF, diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp index e946b0d673b..d366c406ce2 100644 --- a/lib/IRGen/GenDecl.cpp +++ b/lib/IRGen/GenDecl.cpp @@ -3030,8 +3030,9 @@ IRGenModule::getAddrOfTypeMetadataAccessFunction(CanType type, return entry; } - auto fnType = llvm::FunctionType::get(TypeMetadataPtrTy, false); - Signature signature(fnType, llvm::AttributeList(), DefaultCC); + llvm::Type *params[] = { SizeTy }; // MetadataRequest + auto fnType = llvm::FunctionType::get(TypeMetadataResponseTy, params, false); + Signature signature(fnType, llvm::AttributeList(), SwiftCC); LinkInfo link = LinkInfo::get(*this, entity, forDefinition); entry = createFunction(*this, link, signature); return entry; @@ -3057,24 +3058,27 @@ IRGenModule::getAddrOfGenericTypeMetadataAccessFunction( return entry; } - // If we have more arguments than can be passed directly, the remaining - // arguments are packed into an array. - ArrayRef paramTypes; + // If we have more arguments than can be passed directly, all of the + // generic arguments are passed as an array. llvm::Type *paramTypesArray[NumDirectGenericTypeMetadataAccessFunctionArgs+1]; - if (genericArgs.size() > NumDirectGenericTypeMetadataAccessFunctionArgs) { - // Copy direct parameter types. - for (unsigned i : range(NumDirectGenericTypeMetadataAccessFunctionArgs)) - paramTypesArray[i] = genericArgs[i]; - paramTypesArray[NumDirectGenericTypeMetadataAccessFunctionArgs] = - Int8PtrPtrTy; - paramTypes = paramTypesArray; + paramTypesArray[0] = SizeTy; // MetadataRequest + size_t numParams = 1; + + size_t numGenericArgs = genericArgs.size(); + if (numGenericArgs > NumDirectGenericTypeMetadataAccessFunctionArgs) { + paramTypesArray[1] = Int8PtrPtrTy; + numParams++; } else { - paramTypes = genericArgs; + for (size_t i : indices(genericArgs)) + paramTypesArray[i + 1] = genericArgs[i]; + numParams += numGenericArgs; } - auto fnType = llvm::FunctionType::get(TypeMetadataPtrTy, paramTypes, false); - Signature signature(fnType, llvm::AttributeList(), DefaultCC); + auto paramTypes = llvm::makeArrayRef(paramTypesArray, numParams); + auto fnType = llvm::FunctionType::get(TypeMetadataResponseTy, + paramTypes, false); + Signature signature(fnType, llvm::AttributeList(), SwiftCC); LinkInfo link = LinkInfo::get(*this, entity, forDefinition); entry = createFunction(*this, link, signature); return entry; @@ -3412,9 +3416,9 @@ IRGenModule::getAddrOfTypeMetadataCompletionFunction(NominalTypeDecl *D, /// Generic metadata pattern. Int8PtrPtrTy }; - auto fnType = llvm::FunctionType::get(TypeMetadataPtrTy, + auto fnType = llvm::FunctionType::get(TypeMetadataResponseTy, argTys, /*isVarArg*/ false); - Signature signature(fnType, llvm::AttributeList(), DefaultCC); + Signature signature(fnType, llvm::AttributeList(), SwiftCC); LinkInfo link = LinkInfo::get(*this, entity, forDefinition); entry = createFunction(*this, link, signature); return entry; diff --git a/lib/IRGen/GenMeta.cpp b/lib/IRGen/GenMeta.cpp index f07c6c7c4fc..12aecb778f1 100644 --- a/lib/IRGen/GenMeta.cpp +++ b/lib/IRGen/GenMeta.cpp @@ -56,6 +56,7 @@ #include "IRGenMangler.h" #include "IRGenModule.h" #include "MetadataLayout.h" +#include "MetadataRequest.h" #include "ProtocolInfo.h" #include "ScalarTypeInfo.h" #include "StructLayout.h" @@ -445,12 +446,16 @@ static llvm::Value *emitNominalMetadataRef(IRGenFunction &IGF, genericArgs.Types, NotForDefinition); - auto result = - IGF.emitGenericTypeMetadataAccessFunctionCall(accessor, genericArgs.Values); + DynamicMetadataRequest request = MetadataRequest::Complete; - IGF.setScopedLocalTypeData(theType, LocalTypeDataKind::forTypeMetadata(), - result); - return result; + auto result = + IGF.emitGenericTypeMetadataAccessFunctionCall(accessor, genericArgs.Values, + request); + + IGF.setScopedLocalTypeMetadata(theType, result); + + // FIXME: propagate response + return result.getMetadata(); } @@ -1076,7 +1081,8 @@ namespace { } llvm::Value *visitArchetypeType(CanArchetypeType type) { - return emitArchetypeTypeMetadataRef(IGF, type); + return emitArchetypeTypeMetadataRef(IGF, type, MetadataRequest::Complete) + .getMetadata(); } llvm::Value *visitGenericTypeParamType(CanGenericTypeParamType type) { @@ -1151,8 +1157,8 @@ static bool isLoadFrom(llvm::Value *value, Address address) { void irgen::emitLazyCacheAccessFunction(IRGenModule &IGM, llvm::Function *accessor, llvm::GlobalVariable *cacheVariable, - const llvm::function_ref &getValue, - bool isReadNone) { + LazyCacheEmitter getValue, + bool isReadNone) { accessor->setDoesNotThrow(); // This function is logically 'readnone': the caller does not need @@ -1164,9 +1170,22 @@ void irgen::emitLazyCacheAccessFunction(IRGenModule &IGM, if (IGM.DebugInfo) IGM.DebugInfo->emitArtificialFunction(IGF, accessor); + auto parameters = IGF.collectParameters(); + + bool returnsResponse = + (accessor->getReturnType() == IGM.TypeMetadataResponseTy); + // If there's no cache variable, just perform the direct access. if (cacheVariable == nullptr) { - IGF.Builder.CreateRet(getValue(IGF)); + auto response = getValue(IGF, parameters); + llvm::Value *ret; + if (returnsResponse) { + ret = response.combine(IGF); + } else { + assert(response.isStaticallyKnownComplete()); + ret = response.getMetadata(); + } + IGF.Builder.CreateRet(ret); return; } @@ -1204,7 +1223,6 @@ void irgen::emitLazyCacheAccessFunction(IRGenModule &IGM, if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Thread) load->setOrdering(llvm::AtomicOrdering::Acquire); - // Compare the load result against null. auto isNullBB = IGF.createBasicBlock("cacheIsNull"); auto contBB = IGF.createBasicBlock("cont"); @@ -1214,7 +1232,27 @@ void irgen::emitLazyCacheAccessFunction(IRGenModule &IGM, // If the load yielded null, emit the type metadata. IGF.Builder.emitBlock(isNullBB); - llvm::Value *directResult = getValue(IGF); + MetadataResponse response = getValue(IGF, parameters); + auto directResult = response.getMetadata(); + + llvm::Constant *completedState = + (returnsResponse ? MetadataResponse::getCompletedState(IGM) : nullptr); + + // Skip caching if we're working with responses and the fetched result + // is statically known to be complete. + llvm::BasicBlock *completionCheckBB = nullptr; + llvm::Value *directState = nullptr; + if (returnsResponse && !response.isStaticallyKnownComplete()) { + completionCheckBB = IGF.Builder.GetInsertBlock(); + directState = response.getDynamicState(IGF); + + auto isCompleteBB = IGF.createBasicBlock("is_complete"); + auto isComplete = + IGF.Builder.CreateICmpEQ(directState, completedState); + + IGF.Builder.CreateCondBr(isComplete, isCompleteBB, contBB); + IGF.Builder.emitBlock(isCompleteBB); + } // Store it back to the cache variable. This needs to be a store-release // because it needs to propagate memory visibility to the other threads @@ -1235,30 +1273,52 @@ void irgen::emitLazyCacheAccessFunction(IRGenModule &IGM, // Emit the continuation block. IGF.Builder.emitBlock(contBB); - auto phi = IGF.Builder.CreatePHI(null->getType(), 2); + + // Add a phi for the metadata value. + auto phi = IGF.Builder.CreatePHI(null->getType(), 3); phi->addIncoming(load, loadBB); phi->addIncoming(directResult, storeBB); - IGF.Builder.CreateRet(phi); + // Add a phi for the metadata state if we're returning a response. + llvm::Value *stateToReturn = nullptr; + if (directState) { + phi->addIncoming(directResult, completionCheckBB); + + auto completionStatePHI = IGF.Builder.CreatePHI(IGM.SizeTy, 3); + completionStatePHI->addIncoming(completedState, loadBB); + completionStatePHI->addIncoming(directState, completionCheckBB); + completionStatePHI->addIncoming(completedState, storeBB); + stateToReturn = completionStatePHI; + } else if (returnsResponse) { + stateToReturn = completedState; + } + + // Build the return value. + llvm::Value *ret; + if (returnsResponse) { + ret = MetadataResponse(phi, stateToReturn).combine(IGF); + } else { + ret = phi; + } + + IGF.Builder.CreateRet(ret); } -llvm::CallInst *IRGenFunction::emitGenericTypeMetadataAccessFunctionCall( +MetadataResponse +IRGenFunction::emitGenericTypeMetadataAccessFunctionCall( llvm::Function *accessFunction, - ArrayRef args) { + ArrayRef args, + DynamicMetadataRequest request) { + + SmallVector callArgs; + + // Add the metadata request argument. + callArgs.push_back(request.get(*this)); - ArrayRef callArgs; - llvm::Value *callArgsVec[NumDirectGenericTypeMetadataAccessFunctionArgs + 1]; Address argsBuffer; bool allocatedArgsBuffer = false; if (args.size() > NumDirectGenericTypeMetadataAccessFunctionArgs) { - // Copy direct arguments. - for (unsigned i : range(NumDirectGenericTypeMetadataAccessFunctionArgs)) { - callArgsVec[i] = args[i]; - } - - // Allocate an array to pass the remaining arguments. Note that the - // buffer is allocated for the whole length so the callee can fill in - // the direct arguments and use the buffer. + // Allocate an array to pass the arguments. auto argsBufferTy = llvm::ArrayType::get(IGM.Int8PtrTy, args.size()); argsBuffer = createAlloca(argsBufferTy, IGM.getPointerAlignment()); @@ -1267,9 +1327,8 @@ llvm::CallInst *IRGenFunction::emitGenericTypeMetadataAccessFunctionCall( IGM.getPointerSize() * args.size()); allocatedArgsBuffer = true; - // Fill in the non-direct arguments. - for (unsigned i : range(NumDirectGenericTypeMetadataAccessFunctionArgs, - args.size())) { + // Fill in the buffer. + for (unsigned i : indices(args)) { Address elt = Builder.CreateStructGEP(argsBuffer, i, IGM.getPointerSize() * i); auto *arg = @@ -1277,59 +1336,46 @@ llvm::CallInst *IRGenFunction::emitGenericTypeMetadataAccessFunctionCall( Builder.CreateStore(arg, elt); } - // Fill in the buffer. - callArgsVec[NumDirectGenericTypeMetadataAccessFunctionArgs] = - Builder.CreateBitCast(argsBuffer.getAddress(), IGM.Int8PtrPtrTy); - callArgs = callArgsVec; + // Add the buffer to the call arguments. + callArgs.push_back( + Builder.CreateBitCast(argsBuffer.getAddress(), IGM.Int8PtrPtrTy)); } else { - callArgs = args; + callArgs.append(args.begin(), args.end()); } auto call = Builder.CreateCall(accessFunction, callArgs); call->setDoesNotThrow(); + call->setCallingConv(IGM.SwiftCC); call->addAttribute(llvm::AttributeList::FunctionIndex, allocatedArgsBuffer ? llvm::Attribute::InaccessibleMemOrArgMemOnly : llvm::Attribute::ReadNone); - // If we allocated a buffer for the arguments, end it's lifetime. + // If we allocated a buffer for the arguments, end its lifetime. if (allocatedArgsBuffer) Builder.CreateLifetimeEnd(argsBuffer, IGM.getPointerSize() * args.size()); - return call; + return MetadataResponse::split(*this, request, call); } -static llvm::Value *emitGenericMetadataAccessFunction(IRGenFunction &IGF, - NominalTypeDecl *nominal, - GenericArguments &genericArgs) { +static MetadataResponse +emitGenericTypeMetadataAccessFunction(IRGenFunction &IGF, + Explosion ¶ms, + NominalTypeDecl *nominal, + GenericArguments &genericArgs) { llvm::Value *descriptor = IGF.IGM.getAddrOfTypeContextDescriptor(nominal, RequireMetadata); - // Collect input arguments to the generic metadata accessor, as laid out - // by the GenericArguments class. - unsigned argIdx = 0; - llvm::Argument *callerArgArray = nullptr; - for (auto &arg : IGF.CurFn->args()) { - // If this an argument passed directly, record it. - if (argIdx < NumDirectGenericTypeMetadataAccessFunctionArgs) { - genericArgs.Values.push_back(&arg); - ++argIdx; - continue; - } + auto request = params.claimNext(); - assert(!callerArgArray && "Too many arguments"); - callerArgArray = &arg; - } - - assert((!genericArgs.Values.empty() || - nominal->getGenericSignature()->areAllParamsConcrete()) && - "no generic args?!"); + auto numArguments = genericArgs.Types.size(); + bool allocatedBuffer = false; Address argsBuffer; - if (callerArgArray) { + if (numArguments > NumDirectGenericTypeMetadataAccessFunctionArgs) { // The caller provided a buffer with enough space for all of the arguments; // use that. - argsBuffer = Address(callerArgArray, IGF.IGM.getPointerAlignment()); + argsBuffer = Address(params.claimNext(), IGF.IGM.getPointerAlignment()); } else { // Allocate a buffer with enough storage for the arguments. auto argsBufferTy = @@ -1339,23 +1385,18 @@ static llvm::Value *emitGenericMetadataAccessFunction(IRGenFunction &IGF, "generic.arguments"); IGF.Builder.CreateLifetimeStart(argsBuffer, IGF.IGM.getPointerSize() * genericArgs.Values.size()); - } + allocatedBuffer = true; - /// Store direct arguments into the buffer. - for (unsigned i = 0, e = genericArgs.Values.size(); i != e; ++i) { - Address elt; - if (callerArgArray) { - elt = IGF.Builder.CreateConstArrayGEP(argsBuffer, i, - IGF.IGM.getPointerSize()); - } else { - elt = IGF.Builder.CreateStructGEP(argsBuffer, i, - IGF.IGM.getPointerSize() * i); + // Store direct arguments into the buffer. + for (auto i : range(numArguments)) { + Address elt = IGF.Builder.CreateStructGEP(argsBuffer, i, + IGF.IGM.getPointerSize() * i); + + auto *arg = + IGF.Builder.CreateBitCast(params.claimNext(), + elt.getType()->getPointerElementType()); + IGF.Builder.CreateStore(arg, elt); } - - auto *arg = - IGF.Builder.CreateBitCast(genericArgs.Values[i], - elt.getType()->getPointerElementType()); - IGF.Builder.CreateStore(arg, elt); } llvm::Value *arguments = @@ -1363,19 +1404,19 @@ static llvm::Value *emitGenericMetadataAccessFunction(IRGenFunction &IGF, // Make the call. auto result = IGF.Builder.CreateCall(IGF.IGM.getGetGenericMetadataFn(), - {descriptor, arguments}); + {request, arguments, descriptor}); result->setDoesNotThrow(); + result->setCallingConv(IGF.IGM.SwiftCC); result->addAttribute(llvm::AttributeList::FunctionIndex, llvm::Attribute::ReadOnly); // If we allocated the array ourselves, end its lifetime. - if (!callerArgArray) { + if (allocatedBuffer) { IGF.Builder.CreateLifetimeEnd(argsBuffer, IGF.IGM.getPointerSize() * genericArgs.Values.size()); } - return result; - + return MetadataResponse::split(IGF, result); } using InPlaceMetadataInitializer = @@ -1423,7 +1464,7 @@ createInPlaceMetadataInitializationFunction(IRGenModule &IGM, /// Emit the function body for the type metadata accessor of a nominal type /// that might require in-place initialization. -static llvm::Value * +static MetadataResponse emitInPlaceTypeMetadataAccessFunctionBody(IRGenFunction &IGF, CanNominalType type, llvm::Constant *cacheVariable, @@ -1437,7 +1478,7 @@ emitInPlaceTypeMetadataAccessFunctionBody(IRGenFunction &IGF, assert((cacheVariable == nullptr) == isTypeMetadataAccessTrivial(IGF.IGM, type)); if (!cacheVariable) - return metadata; + return MetadataResponse(metadata); // Okay, we have non-trivial initialization to do. // Ensure that we don't have multiple threads racing to do this. @@ -1474,7 +1515,7 @@ emitInPlaceTypeMetadataAccessFunctionBody(IRGenFunction &IGF, // emitLazyCacheAccessFunction will see that the value was loaded from // the guard variable and skip the redundant store back. - return relocatedMetadata; + return MetadataResponse(relocatedMetadata); } /// Emit the body of a metadata accessor function for the given type. @@ -1483,8 +1524,9 @@ emitInPlaceTypeMetadataAccessFunctionBody(IRGenFunction &IGF, /// construction of the metadata value just involves calling idempotent /// metadata-construction functions. It is not used for the in-place /// initialization of non-generic nominal type metadata. -static llvm::Value *emitTypeMetadataAccessFunctionBody(IRGenFunction &IGF, - CanType type) { +static llvm::Value * +emitTypeMetadataAccessFunctionBody(IRGenFunction &IGF, + CanType type) { assert(!type->hasArchetype() && "cannot emit metadata accessor for context-dependent type"); @@ -1540,7 +1582,9 @@ static llvm::Value *emitTypeMetadataAccessFunctionBody(IRGenFunction &IGF, } using MetadataAccessGenerator = - llvm::function_ref; + llvm::function_ref; /// Get or create an accessor function to the given non-dependent type. static llvm::Function *getTypeMetadataAccessFunction(IRGenModule &IGM, @@ -1575,8 +1619,9 @@ static llvm::Function *getTypeMetadataAccessFunction(IRGenModule &IGM, } emitLazyCacheAccessFunction(IGM, accessor, cacheVariable, - [&](IRGenFunction &IGF) -> llvm::Value* { - return generator(IGF, cacheVariable); + [&](IRGenFunction &IGF, Explosion ¶ms) { + auto request = DynamicMetadataRequest(params.claimNext()); + return generator(IGF, request, cacheVariable); }); return accessor; @@ -1588,10 +1633,13 @@ static llvm::Function *getTypeMetadataAccessFunction(IRGenModule &IGM, ForDefinition_t shouldDefine) { return getTypeMetadataAccessFunction(IGM, type, shouldDefine, [&](IRGenFunction &IGF, + DynamicMetadataRequest request, llvm::Constant *cacheVariable) { // We should not be called with ForDefinition for nominal types // that require in-place initialization. - return emitTypeMetadataAccessFunctionBody(IGF, type); + // We should also not be called for types that require more interesting + // initialization that really requires the request/response machinery. + return MetadataResponse(emitTypeMetadataAccessFunctionBody(IGF, type)); }); } @@ -1621,9 +1669,9 @@ static llvm::Function *getGenericTypeMetadataAccessFunction(IRGenModule &IGM, (genericArgs.Types.size() <= NumDirectGenericTypeMetadataAccessFunctionArgs); emitLazyCacheAccessFunction(IGM, accessor, /*cacheVariable=*/nullptr, - [&](IRGenFunction &IGF) -> llvm::Value * { - return emitGenericMetadataAccessFunction( - IGF, nominal, genericArgs); + [&](IRGenFunction &IGF, Explosion ¶ms) { + return emitGenericTypeMetadataAccessFunction( + IGF, params, nominal, genericArgs); }, isReadNone); @@ -1645,43 +1693,56 @@ getRequiredTypeMetadataAccessFunction(IRGenModule &IGM, } /// Emit a call to the type metadata accessor for the given function. -static llvm::Value *emitCallToTypeMetadataAccessFunction(IRGenFunction &IGF, - CanType type, - ForDefinition_t shouldDefine) { +static MetadataResponse +emitCallToTypeMetadataAccessFunction(IRGenFunction &IGF, + CanType type, + DynamicMetadataRequest request, + ForDefinition_t shouldDefine) { // If we already cached the metadata, use it. - if (auto local = - IGF.tryGetLocalTypeData(type, LocalTypeDataKind::forTypeMetadata())) + if (auto local = IGF.tryGetLocalTypeMetadata(type, request)) return local; - + llvm::Constant *accessor = getTypeMetadataAccessFunction(IGF.IGM, type, shouldDefine); - llvm::CallInst *call = IGF.Builder.CreateCall(accessor, {}); - call->setCallingConv(IGF.IGM.DefaultCC); + llvm::CallInst *call = IGF.Builder.CreateCall(accessor, { request.get(IGF) }); + call->setCallingConv(IGF.IGM.SwiftCC); call->setDoesNotAccessMemory(); call->setDoesNotThrow(); + + MetadataResponse result = MetadataResponse::split(IGF, request, call); // Save the metadata for future lookups. - IGF.setScopedLocalTypeData(type, LocalTypeDataKind::forTypeMetadata(), call); + IGF.setScopedLocalTypeMetadata(type, result); - return call; + return result; } /// Produce the type metadata pointer for the given type. llvm::Value *IRGenFunction::emitTypeMetadataRef(CanType type) { + return emitTypeMetadataRef(type, MetadataRequest::Complete).getMetadata(); +} + +/// Produce the type metadata pointer for the given type. +MetadataResponse +IRGenFunction::emitTypeMetadataRef(CanType type, + DynamicMetadataRequest request) { type = getRuntimeReifiedType(IGM, type); if (type->hasArchetype() || isTypeMetadataAccessTrivial(IGM, type)) { - return emitDirectTypeMetadataRef(*this, type); + // FIXME: propagate metadata request! + return MetadataResponse(emitDirectTypeMetadataRef(*this, type)); } switch (getTypeMetadataAccessStrategy(type)) { case MetadataAccessStrategy::PublicUniqueAccessor: case MetadataAccessStrategy::HiddenUniqueAccessor: case MetadataAccessStrategy::PrivateAccessor: - return emitCallToTypeMetadataAccessFunction(*this, type, NotForDefinition); + return emitCallToTypeMetadataAccessFunction(*this, type, request, + NotForDefinition); case MetadataAccessStrategy::NonUniqueAccessor: - return emitCallToTypeMetadataAccessFunction(*this, type, ForDefinition); + return emitCallToTypeMetadataAccessFunction(*this, type, request, + ForDefinition); } llvm_unreachable("bad type metadata access strategy"); } @@ -1738,7 +1799,9 @@ namespace { IGF.IGM.getAddrOfGenericTypeMetadataAccessFunction( type->getDecl(), types, NotForDefinition); - return IGF.emitGenericTypeMetadataAccessFunctionCall(accessor, args); + return IGF.emitGenericTypeMetadataAccessFunctionCall(accessor, args, + MetadataRequest::Complete) + .getMetadata(); } // Otherwise, generic arguments are not lowered. @@ -3305,9 +3368,9 @@ namespace { void emitCompletionFunction() { // using MetadataCompleter = - // Metadata *(Metadata *type, - // MetadataCompletionContext *context, - // const GenericMetadataPattern *pattern); + // MetadataResponse(Metadata *type, + // MetadataCompletionContext *context, + // const GenericMetadataPattern *pattern); llvm::Function *f = IGM.getAddrOfTypeMetadataCompletionFunction(Target, ForDefinition); f->setAttributes(IGM.constructInitialAttributes()); @@ -3348,7 +3411,7 @@ namespace { // The metadata is now complete. Return null to indicate success. auto nullDependency = - llvm::ConstantPointerNull::get(IGM.TypeMetadataPtrTy); + llvm::ConstantAggregateZero::get(IGM.TypeMetadataResponseTy); IGF.Builder.CreateRet(nullDependency); } @@ -4206,7 +4269,8 @@ namespace { auto type =cast(Target->getDeclaredType()->getCanonicalType()); (void) getTypeMetadataAccessFunction(IGM, type, ForDefinition, - [&](IRGenFunction &IGF, llvm::Constant *cacheVar) -> llvm::Value* { + [&](IRGenFunction &IGF, DynamicMetadataRequest request, + llvm::Constant *cacheVar) -> MetadataResponse { // There's an interesting special case where we can do the // initialization idempotently and thus avoid the need for a lock. if (!HasUnfilledSuperclass && @@ -4215,7 +4279,8 @@ namespace { auto type = Target->getDeclaredType()->getCanonicalType(); auto metadata = IGF.IGM.getAddrOfTypeMetadata(type); - return emitFinishIdempotentInitialization(IGF, metadata); + return MetadataResponse( + emitFinishIdempotentInitialization(IGF, metadata)); } // Otherwise, use the generic path. @@ -4987,6 +5052,7 @@ static void createInPlaceValueTypeMetadataAccessFunction(IRGenModule &IGM, (void) getTypeMetadataAccessFunction(IGM, type, ForDefinition, [&](IRGenFunction &IGF, + DynamicMetadataRequest request, llvm::Constant *cacheVariable) { return emitInPlaceTypeMetadataAccessFunctionBody(IGF, type, cacheVariable, [&](IRGenFunction &IGF, llvm::Value *metadata) { @@ -5559,6 +5625,7 @@ namespace { (void) getTypeMetadataAccessFunction(IGM, type, ForDefinition, [&](IRGenFunction &IGF, + DynamicMetadataRequest request, llvm::Constant *cacheVariable) { return emitInPlaceTypeMetadataAccessFunctionBody(IGF, type, cacheVariable, diff --git a/lib/IRGen/GenMeta.h b/lib/IRGen/GenMeta.h index 3f398c8256c..f9602aeffbe 100644 --- a/lib/IRGen/GenMeta.h +++ b/lib/IRGen/GenMeta.h @@ -48,6 +48,7 @@ namespace irgen { class GenericTypeRequirements; class IRGenFunction; class IRGenModule; + class MetadataResponse; enum RequireMetadata_t : bool; class Size; class StructLayout; @@ -66,12 +67,15 @@ namespace irgen { /// metadata? bool hasKnownSwiftMetadata(IRGenModule &IGM, CanType theType); + using LazyCacheEmitter = + llvm::function_ref; + /// Emit the body of a lazy cache access function. void emitLazyCacheAccessFunction(IRGenModule &IGM, llvm::Function *accessor, - llvm::GlobalVariable *cacheVariable, - const llvm::function_ref &getValue, - bool isReadNone = true); + llvm::GlobalVariable *cache, + LazyCacheEmitter getValue, + bool isReadNone = true); /// Emit a declaration reference to a metatype object. void emitMetatypeRef(IRGenFunction &IGF, CanMetatypeType type, diff --git a/lib/IRGen/GenProto.cpp b/lib/IRGen/GenProto.cpp index 5f73d35e4e3..895d885963a 100644 --- a/lib/IRGen/GenProto.cpp +++ b/lib/IRGen/GenProto.cpp @@ -66,6 +66,7 @@ #include "IRGenFunction.h" #include "IRGenModule.h" #include "MetadataPath.h" +#include "MetadataRequest.h" #include "NecessaryBindings.h" #include "ProtocolInfo.h" #include "TypeInfo.h" @@ -1087,10 +1088,10 @@ getWitnessTableLazyAccessFunction(IRGenModule &IGM, cast(IGM.getAddrOfWitnessTableLazyCacheVariable( rootConformance, conformingType, ForDefinition)); emitLazyCacheAccessFunction(IGM, accessor, cacheVariable, - [&](IRGenFunction &IGF) -> llvm::Value* { + [&](IRGenFunction &IGF, Explosion ¶ms) { llvm::Value *conformingMetadataCache = nullptr; - return emitWitnessTableAccessorCall(IGF, conformance, - &conformingMetadataCache); + return MetadataResponse(emitWitnessTableAccessorCall(IGF, conformance, + &conformingMetadataCache)); }); return accessor; @@ -1394,7 +1395,7 @@ public: void emitReturnOfCheckedLoadFromCache(IRGenFunction &IGF, Address destTable, llvm::Value *selfMetadata, - llvm::function_ref body); + llvm::function_ref body); /// Allocate another word of private data storage in the conformance table. unsigned getNextPrivateDataIndex() { @@ -1474,6 +1475,7 @@ getAssociatedTypeMetadataAccessFunction(AssociatedType requirement, IGM.DebugInfo->emitArtificialFunction(IGF, accessor); Explosion parameters = IGF.collectParameters(); + auto request = DynamicMetadataRequest(parameters.claimNext()); llvm::Value *self = parameters.claimNext(); setTypeMetadataName(IGM, self, ConcreteType); @@ -1498,7 +1500,8 @@ getAssociatedTypeMetadataAccessFunction(AssociatedType requirement, llvm::Value *metadata = fulfillment->Path.followFromTypeMetadata(IGF, ConcreteType, self, /*cache*/ nullptr); - IGF.Builder.CreateRet(metadata); + auto returnValue = MetadataResponse(metadata).combine(IGF); + IGF.Builder.CreateRet(returnValue); return accessor; } @@ -1508,15 +1511,16 @@ getAssociatedTypeMetadataAccessFunction(AssociatedType requirement, // For now, assume that an associated type is cheap enough to access // that it doesn't need a new cache entry. if (auto archetype = dyn_cast(associatedType)) { - llvm::Value *metadata = emitArchetypeTypeMetadataRef(IGF, archetype); - IGF.Builder.CreateRet(metadata); + auto response = emitArchetypeTypeMetadataRef(IGF, archetype, request); + auto returnValue = response.combine(IGF); + IGF.Builder.CreateRet(returnValue); return accessor; } // Otherwise, we need a cache entry. emitReturnOfCheckedLoadFromCache(IGF, destTable, self, - [&]() -> llvm::Value* { - return IGF.emitTypeMetadataRef(associatedType); + [&]() -> MetadataResponse { + return IGF.emitTypeMetadataRef(associatedType, request); }); return accessor; @@ -1666,8 +1670,10 @@ getAssociatedTypeWitnessTableAccessFunction(AssociatedConformance requirement, // Otherwise, we need a cache entry. emitReturnOfCheckedLoadFromCache(IGF, destTable, self, - [&]() -> llvm::Value* { - return conformanceI->getTable(IGF, &associatedTypeMetadata); + [&]() -> MetadataResponse { + // Pretend that we have a response here. + return MetadataResponse( + conformanceI->getTable(IGF, &associatedTypeMetadata)); }); return accessor; @@ -1676,12 +1682,18 @@ getAssociatedTypeWitnessTableAccessFunction(AssociatedConformance requirement, void WitnessTableBuilder:: emitReturnOfCheckedLoadFromCache(IRGenFunction &IGF, Address destTable, llvm::Value *selfMetadata, - llvm::function_ref body) { + llvm::function_ref body) { // Allocate a new cache slot and drill down to it. auto cache = getAddressOfPrivateDataSlot(IGF, destTable, getNextPrivateDataIndex()); llvm::Type *expectedTy = IGF.CurFn->getReturnType(); + + bool isReturningResponse = false; + if (expectedTy == IGF.IGM.TypeMetadataResponseTy) { + isReturningResponse = true; + expectedTy = IGF.IGM.TypeMetadataPtrTy; + } cache = IGF.Builder.CreateBitCast(cache, expectedTy->getPointerTo()); // Load and check whether it was null. @@ -1695,18 +1707,65 @@ emitReturnOfCheckedLoadFromCache(IRGenFunction &IGF, Address destTable, llvm::BasicBlock *entryBB = IGF.Builder.GetInsertBlock(); IGF.Builder.CreateCondBr(cacheIsEmpty, fetchBB, contBB); + unsigned expectedPHICount = (isReturningResponse ? 3 : 2); + // Create a phi in the continuation block and use the loaded value if // we branched directly here. Note that we arrange blocks so that we // fall through into this. IGF.Builder.emitBlock(contBB); - auto result = IGF.Builder.CreatePHI(expectedTy, 2); + llvm::PHINode *result = IGF.Builder.CreatePHI(expectedTy, expectedPHICount); result->addIncoming(cachedResult, entryBB); - IGF.Builder.CreateRet(result); - // In the fetch block, bind the archetypes and evaluate the body. + llvm::Constant *completedState = nullptr; + llvm::PHINode *resultState = nullptr; + if (isReturningResponse) { + completedState = MetadataResponse::getCompletedState(IGF.IGM); + + resultState = IGF.Builder.CreatePHI(IGF.IGM.SizeTy, expectedPHICount); + resultState->addIncoming(completedState, entryBB); + + llvm::Value *returnValue = + MetadataResponse(result, resultState).combine(IGF); + IGF.Builder.CreateRet(returnValue); + } else { + IGF.Builder.CreateRet(result); + } + + // In the fetch block, evaluate the body. IGF.Builder.emitBlock(fetchBB); + MetadataResponse response = body(); - llvm::Value *fetchedResult = body(); + // The way we jam witness tables into this infrastructure involves + // pretending that they're statically-complete metadata. + assert(isReturningResponse || response.isStaticallyKnownComplete()); + llvm::Value *fetchedResult = response.getMetadata(); + llvm::Value *fetchedState = nullptr; + + if (isReturningResponse) + fetchedState = response.getDynamicState(IGF); + + // Skip caching if we're working with responses and the fetched result + // is not complete. + if (isReturningResponse && !response.isStaticallyKnownComplete()) { + auto isCompleteBB = IGF.createBasicBlock("is_complete"); + auto isComplete = + IGF.Builder.CreateICmpEQ(fetchedState, completedState); + + auto fetchingBB = IGF.Builder.GetInsertBlock(); + IGF.Builder.CreateCondBr(isComplete, isCompleteBB, contBB); + result->addIncoming(fetchedResult, fetchingBB); + resultState->addIncoming(fetchedState, fetchingBB); + + IGF.Builder.emitBlock(isCompleteBB); + + // If the fetched result is statically known to be complete, there is no + // patch which involves not returning the completed state, so destroy the + // PHI node we created for the state. + } else if (isReturningResponse) { + resultState->replaceAllUsesWith(completedState); + resultState->eraseFromParent(); + resultState = nullptr; + } // Store the fetched result back to the cache. // We need to transitively ensure that any stores initializing the result @@ -1714,9 +1773,11 @@ emitReturnOfCheckedLoadFromCache(IRGenFunction &IGF, Address destTable, IGF.Builder.CreateStore(fetchedResult, cache)->setOrdering( llvm::AtomicOrdering::Release); - auto fetchedResultBB = IGF.Builder.GetInsertBlock(); + auto cachingBB = IGF.Builder.GetInsertBlock(); IGF.Builder.CreateBr(contBB); - result->addIncoming(fetchedResult, fetchedResultBB); + result->addIncoming(fetchedResult, cachingBB); + if (resultState) + resultState->addIncoming(completedState, cachingBB); } /// Emit the access function for this witness table. @@ -3051,8 +3112,9 @@ irgen::emitWitnessMethodValue(IRGenFunction &IGF, Signature IRGenModule::getAssociatedTypeMetadataAccessFunctionSignature() { auto &fnType = AssociatedTypeMetadataAccessFunctionTy; if (!fnType) { - fnType = llvm::FunctionType::get(TypeMetadataPtrTy, - { TypeMetadataPtrTy, + fnType = llvm::FunctionType::get(TypeMetadataResponseTy, + { SizeTy, + TypeMetadataPtrTy, WitnessTablePtrTy }, /*varargs*/ false); } @@ -3061,13 +3123,15 @@ Signature IRGenModule::getAssociatedTypeMetadataAccessFunctionSignature() { llvm::AttributeList::FunctionIndex, llvm::Attribute::NoUnwind); - return Signature(fnType, attrs, DefaultCC); + return Signature(fnType, attrs, SwiftCC); } -llvm::Value *irgen::emitAssociatedTypeMetadataRef(IRGenFunction &IGF, - llvm::Value *parentMetadata, - llvm::Value *wtable, - AssociatedType associatedType) { +MetadataResponse +irgen::emitAssociatedTypeMetadataRef(IRGenFunction &IGF, + llvm::Value *parentMetadata, + llvm::Value *wtable, + AssociatedType associatedType, + DynamicMetadataRequest request) { auto &pi = IGF.IGM.getProtocolInfo(associatedType.getSourceProtocol()); auto index = pi.getAssociatedTypeIndex(associatedType); llvm::Value *witness = emitInvariantLoadOfOpaqueWitness(IGF, wtable, @@ -3084,9 +3148,11 @@ llvm::Value *irgen::emitAssociatedTypeMetadataRef(IRGenFunction &IGF, assert((!IGF.IGM.DebugInfo || IGF.Builder.getCurrentDebugLocation()) && "creating a function call without a debug location"); auto call = IGF.Builder.CreateCall(witnessFnPtr, - { parentMetadata, wtable }); + { request.get(IGF), + parentMetadata, + wtable }); - return call; + return MetadataResponse::split(IGF, request, call); } Signature @@ -3106,5 +3172,5 @@ IRGenModule::getAssociatedTypeWitnessTableAccessFunctionSignature() { llvm::AttributeList::FunctionIndex, llvm::Attribute::NoUnwind); - return Signature(fnType, attrs, DefaultCC); + return Signature(fnType, attrs, SwiftCC); } diff --git a/lib/IRGen/GenProto.h b/lib/IRGen/GenProto.h index c7d839569a6..346860c7957 100644 --- a/lib/IRGen/GenProto.h +++ b/lib/IRGen/GenProto.h @@ -38,11 +38,13 @@ namespace swift { namespace irgen { class Address; + class DynamicMetadataRequest; class Explosion; class FunctionPointer; class IRGenFunction; class IRGenModule; class MetadataPath; + class MetadataResponse; class ProtocolInfo; class TypeInfo; @@ -73,10 +75,11 @@ namespace irgen { /// \param parentMetadata - the type metadata for T /// \param wtable - the witness table witnessing the conformance of T to P /// \param associatedType - the declaration of X; a member of P - llvm::Value *emitAssociatedTypeMetadataRef(IRGenFunction &IGF, - llvm::Value *parentMetadata, - llvm::Value *wtable, - AssociatedType associatedType); + MetadataResponse emitAssociatedTypeMetadataRef(IRGenFunction &IGF, + llvm::Value *parentMetadata, + llvm::Value *wtable, + AssociatedType associatedType, + DynamicMetadataRequest request); // Return the offset one should do on a witness table pointer to retrieve the // `index`th piece of private data. diff --git a/lib/IRGen/IRGenFunction.h b/lib/IRGen/IRGenFunction.h index 7ae4a15a60b..2aec7bffbe0 100644 --- a/lib/IRGen/IRGenFunction.h +++ b/lib/IRGen/IRGenFunction.h @@ -47,6 +47,7 @@ namespace Lowering { } namespace irgen { + class DynamicMetadataRequest; class Explosion; class FunctionRef; class HeapLayout; @@ -54,6 +55,7 @@ namespace irgen { class IRGenModule; class LinkEntity; class LocalTypeDataCache; + class MetadataResponse; class Scope; class TypeInfo; enum class ValueWitness : unsigned; @@ -225,9 +227,10 @@ public: llvm::Value *emitAllocEmptyBoxCall(); // Emit a call to the given generic type metadata access function. - llvm::CallInst *emitGenericTypeMetadataAccessFunctionCall( + MetadataResponse emitGenericTypeMetadataAccessFunctionCall( llvm::Function *accessFunction, - ArrayRef args); + ArrayRef args, + DynamicMetadataRequest request); // Emit a reference to the canonical type metadata record for the given AST // type. This can be used to identify the type at runtime. For types with @@ -236,6 +239,9 @@ public: // correct for all uses of reabstractable values in opaque contexts. llvm::Value *emitTypeMetadataRef(CanType type); + MetadataResponse emitTypeMetadataRef(CanType type, + DynamicMetadataRequest request); + // Emit a reference to a type layout record for the given type. The referenced // data is enough to lay out an aggregate containing a value of the type, but // can't uniquely represent the type or perform value witness operations on @@ -458,6 +464,9 @@ public: } llvm::Value *tryGetLocalTypeData(LocalTypeDataKey key); + MetadataResponse tryGetLocalTypeMetadata(CanType type, + DynamicMetadataRequest request); + /// Look up a local type data reference, returning null if no entry was /// found or if the only viable entries are abstract. This will never /// emit code. @@ -481,6 +490,7 @@ public: setScopedLocalTypeData(LocalTypeDataKey{type, kind}, data); } void setScopedLocalTypeData(LocalTypeDataKey key, llvm::Value *data); + void setScopedLocalTypeMetadata(CanType type, MetadataResponse response); /// The same as tryGetLocalTypeData, just for the Layout metadata. /// diff --git a/lib/IRGen/IRGenModule.cpp b/lib/IRGen/IRGenModule.cpp index f2dad2f760f..ee864545c8c 100644 --- a/lib/IRGen/IRGenModule.cpp +++ b/lib/IRGen/IRGenModule.cpp @@ -186,6 +186,11 @@ IRGenModule::IRGenModule(IRGenerator &irgen, }); TypeMetadataPtrTy = TypeMetadataStructTy->getPointerTo(DefaultAS); + TypeMetadataResponseTy = createStructType(*this, "swift.metadata_response", { + TypeMetadataPtrTy, + SizeTy + }); + // A protocol descriptor describes a protocol. It is not type metadata in // and of itself, but is referenced in the structure of existential type // metadata records. diff --git a/lib/IRGen/IRGenModule.h b/lib/IRGen/IRGenModule.h index 5150bc7c11e..a31b4b7b75d 100644 --- a/lib/IRGen/IRGenModule.h +++ b/lib/IRGen/IRGenModule.h @@ -517,6 +517,7 @@ public: llvm::FunctionType *DeallocatingDtorTy; /// void (%swift.refcounted*) llvm::StructType *TypeMetadataStructTy; /// %swift.type = type { ... } llvm::PointerType *TypeMetadataPtrTy;/// %swift.type* + llvm::StructType *TypeMetadataResponseTy; /// { %swift.type*, iSize } llvm::PointerType *TupleTypeMetadataPtrTy; /// %swift.tuple_type* llvm::StructType *FullHeapMetadataStructTy; /// %swift.full_heapmetadata = type { ... } llvm::PointerType *FullHeapMetadataPtrTy;/// %swift.full_heapmetadata* diff --git a/lib/IRGen/LocalTypeData.cpp b/lib/IRGen/LocalTypeData.cpp index 480a7819da2..a661f1e671c 100644 --- a/lib/IRGen/LocalTypeData.cpp +++ b/lib/IRGen/LocalTypeData.cpp @@ -23,6 +23,7 @@ #include "IRGenDebugInfo.h" #include "IRGenFunction.h" #include "IRGenModule.h" +#include "MetadataRequest.h" #include "swift/AST/IRGenOptions.h" #include "swift/AST/ProtocolConformance.h" #include "swift/SIL/SILModule.h" @@ -77,6 +78,26 @@ void LocalTypeDataCache::CacheEntry::erase() const { llvm_unreachable("bad cache entry kind"); } +MetadataResponse +IRGenFunction::tryGetLocalTypeMetadata(CanType type, + DynamicMetadataRequest request) { + // For now, forTypeMetadata always means *complete* type metadata. + auto localDataKind = LocalTypeDataKind::forTypeMetadata(); + if (auto metadata = tryGetLocalTypeData(type, localDataKind)) + return MetadataResponse(metadata); + + return MetadataResponse(); +} + +void IRGenFunction::setScopedLocalTypeMetadata(CanType type, + MetadataResponse response) { + // For now, forTypeMetadata always means *complete* type metadata. + if (response.isStaticallyKnownComplete()) { + auto localDataKind = LocalTypeDataKind::forTypeMetadata(); + setScopedLocalTypeData(type, localDataKind, response.getMetadata()); + } +} + llvm::Value *IRGenFunction::getLocalTypeData(CanType type, LocalTypeDataKind kind) { assert(LocalTypeData); diff --git a/lib/IRGen/MetadataRequest.cpp b/lib/IRGen/MetadataRequest.cpp new file mode 100644 index 00000000000..7e5e30d4933 --- /dev/null +++ b/lib/IRGen/MetadataRequest.cpp @@ -0,0 +1,71 @@ +//===--- MetadataRequest.cpp - IR generation for metadata requests --------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// +// +// This file implements IR generation for accessing metadata. +// +//===----------------------------------------------------------------------===// + +#include "IRGenFunction.h" +#include "IRGenModule.h" + +#include "MetadataRequest.h" + +using namespace swift; +using namespace irgen; + +llvm::Value *DynamicMetadataRequest::get(IRGenFunction &IGF) const { + if (isStatic()) { + return IGF.IGM.getSize(Size(StaticRequest.getOpaqueValue())); + } else { + return DynamicRequest; + } +} + +MetadataResponse +MetadataResponse::split(IRGenFunction &IGF, DynamicMetadataRequest request, + llvm::Value *response) { + if (request.isStaticallyBlockingComplete()) { + assert(response->getType() == IGF.IGM.TypeMetadataResponseTy); + auto value = IGF.Builder.CreateExtractValue(response, 0); + return MetadataResponse(value); + } else { + return split(IGF, response); + } +} + +MetadataResponse +MetadataResponse::split(IRGenFunction &IGF, llvm::Value *response) { + assert(response->getType() == IGF.IGM.TypeMetadataResponseTy); + auto value = IGF.Builder.CreateExtractValue(response, 0); + auto state = IGF.Builder.CreateExtractValue(response, 1); + return MetadataResponse(value, state); +} + +llvm::Value *MetadataResponse::combine(IRGenFunction &IGF) const { + assert(isValid()); + llvm::Value *pair = + llvm::UndefValue::get(IGF.IGM.TypeMetadataResponseTy); + pair = IGF.Builder.CreateInsertValue(pair, Metadata, 0); + pair = IGF.Builder.CreateInsertValue(pair, getDynamicState(IGF), 1); + return pair; +} + +llvm::Value *MetadataResponse::getDynamicState(IRGenFunction &IGF) const { + assert(isValid()); + return State ? State : getCompletedState(IGF.IGM); +} + +llvm::Constant *MetadataResponse::getCompletedState(IRGenModule &IGM) { + return IGM.getSize(Size(MetadataRequest::Complete)); +} + +// TODO: move most of the rest of metadata-reference emission here... diff --git a/lib/IRGen/MetadataRequest.h b/lib/IRGen/MetadataRequest.h new file mode 100644 index 00000000000..5244e5eed24 --- /dev/null +++ b/lib/IRGen/MetadataRequest.h @@ -0,0 +1,114 @@ +//===--- MetadataRequest.h - Operations for accessing metadata --*- C++ -*-===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// +// +// This file defines some types and operations for accessing type metadata. +// +//===----------------------------------------------------------------------===// + +#ifndef SWIFT_IRGEN_METADATAREQUEST_H +#define SWIFT_IRGEN_METADATAREQUEST_H + +#include "swift/ABI/MetadataValues.h" + +namespace llvm { + class Value; +} + +namespace swift { +namespace irgen { + class IRGenFunction; + +/// A dynamic metadata request. +class DynamicMetadataRequest { + MetadataRequest StaticRequest; + llvm::Value *DynamicRequest = nullptr; +public: + DynamicMetadataRequest(MetadataRequest::BasicKind request) + : DynamicMetadataRequest(MetadataRequest(request)) {} + DynamicMetadataRequest(MetadataRequest request) + : StaticRequest(request), DynamicRequest(nullptr) {} + explicit DynamicMetadataRequest(llvm::Value *request) + : StaticRequest(), DynamicRequest(request) {} + + bool isStatic() const { return DynamicRequest == nullptr; } + MetadataRequest getStaticRequest() const { + assert(isStatic()); + return StaticRequest; + } + + llvm::Value *getDynamicRequest() const { + assert(!isStatic()); + return DynamicRequest; + } + + /// Is this request statically known to be blocking on success? + /// + /// This is a useful query because the result of such a request is + /// always statically-known complete. + bool isStaticallyBlockingComplete() const { + return isStatic() && StaticRequest == MetadataRequest::Complete; + } + + llvm::Value *get(IRGenFunction &IGF) const; +}; + +/// See the comment for swift::MetadataResponse in Metadata.h. +class MetadataResponse { + llvm::Value *Metadata; + llvm::Value *State; + +public: + MetadataResponse() : Metadata(nullptr) {} + + /// A metadata response that's known to be complete. + explicit MetadataResponse(llvm::Value *metadata) + : Metadata(metadata), State(nullptr) { + assert(metadata && "must be valid"); + } + + /// A metadata response that might not be dynamically complete. + explicit MetadataResponse(llvm::Value *metadata, llvm::Value *state) + : Metadata(metadata), State(state) { + assert(metadata && "must be valid"); + assert(state && "must be valid"); + } + + bool isValid() const { return Metadata != nullptr; } + explicit operator bool() const { return isValid(); } + + bool isStaticallyKnownComplete() const { + assert(isValid()); + return State == nullptr; + } + + llvm::Value *getMetadata() const { + assert(isValid()); + return Metadata; + } + llvm::Value *getDynamicState(IRGenFunction &IGF) const; + + static MetadataResponse split(IRGenFunction &IGF, + DynamicMetadataRequest request, + llvm::Value *responsePair); + static MetadataResponse split(IRGenFunction &IGF, + llvm::Value *responsePair); + llvm::Value *combine(IRGenFunction &IGF) const; + + /// Return a constant value representing the fully-completed state + /// (MetadataRequest::Complete). + static llvm::Constant *getCompletedState(IRGenModule &IGM); +}; + +} // end namespace irgen +} // end namespace swift + +#endif diff --git a/stdlib/public/runtime/Metadata.cpp b/stdlib/public/runtime/Metadata.cpp index b9067119ba3..4d28c4e7915 100644 --- a/stdlib/public/runtime/Metadata.cpp +++ b/stdlib/public/runtime/Metadata.cpp @@ -216,15 +216,11 @@ namespace { // Complete the metadata's instantiation. auto dependency = pattern->CompletionFunction(metadata, context, pattern); - // FIXME: use a more precise dependency requirement returned by the - // completion function. - auto dependencyRequirement = MetadataRequest::Complete; - - auto state = dependency == nullptr + auto state = dependency.Value == nullptr ? MetadataRequest::Complete : inferStateForMetadata(metadata); - return { state, dependencyRequirement, dependency }; + return { state, dependency.State, dependency.Value }; } }; } // end anonymous namespace @@ -488,21 +484,18 @@ swift::swift_allocateGenericValueMetadata(const ValueTypeDescriptor *description } /// The primary entrypoint. -const Metadata * -swift::swift_getGenericMetadata(const TypeContextDescriptor *description, - const void *arguments) { - auto genericArgs = (const void * const *) arguments; +MetadataResponse +swift::swift_getGenericMetadata(MetadataRequest request, + const void * const *arguments, + const TypeContextDescriptor *description) { auto &generics = description->getFullGenericContextHeader(); size_t numGenericArgs = generics.Base.NumKeyArguments; - MetadataRequest request(MetadataRequest::Complete); - - auto key = MetadataCacheKey(genericArgs, numGenericArgs); + auto key = MetadataCacheKey(arguments, numGenericArgs); auto result = - getCache(generics).getOrInsert(key, request, description, genericArgs); + getCache(generics).getOrInsert(key, request, description, arguments); - // TODO: report cases where the state is inadequate - return result.second.Value; + return result.second; } /***************************************************************************/ @@ -3237,7 +3230,7 @@ swift::swift_getGenericWitnessTable(GenericWitnessTable *genericTable, /***************************************************************************/ template -static Result performOnMetadataCache(Metadata *metadata, +static Result performOnMetadataCache(const Metadata *metadata, Callbacks &&callbacks) { // Handle different kinds of type that can delay their metadata. const TypeContextDescriptor *description; @@ -3264,12 +3257,12 @@ static Result performOnMetadataCache(Metadata *metadata, bool swift::addToMetadataQueue( std::unique_ptr &&queueEntry, - Metadata *dependency, + const Metadata *dependency, MetadataRequest::BasicKind dependencyRequirement) { struct EnqueueCallbacks { std::unique_ptr &&QueueEntry; - bool forGenericMetadata(Metadata *metadata, + bool forGenericMetadata(const Metadata *metadata, const TypeContextDescriptor *description, GenericMetadataCache &cache, MetadataCacheKey key) && { @@ -3293,7 +3286,7 @@ void swift::resumeMetadataCompletion( /*non-blocking*/ true); } - void forGenericMetadata(Metadata *metadata, + void forGenericMetadata(const Metadata *metadata, const TypeContextDescriptor *description, GenericMetadataCache &cache, MetadataCacheKey key) && { diff --git a/stdlib/public/runtime/MetadataCache.h b/stdlib/public/runtime/MetadataCache.h index 8ad13edf88f..41010d52c69 100644 --- a/stdlib/public/runtime/MetadataCache.h +++ b/stdlib/public/runtime/MetadataCache.h @@ -524,7 +524,7 @@ struct MetadataCompletionQueueEntry { /// \return false if the entry was not added because the dependency /// has already reached the desired requirement bool addToMetadataQueue(std::unique_ptr &&queueEntry, - Metadata *dependency, + const Metadata *dependency, MetadataRequest::BasicKind dependencyRequirement); @@ -567,10 +567,7 @@ class MetadataCacheEntryBase public: using ValueType = Metadata *; - struct Status { - ValueType Value; - MetadataRequest::BasicKind State; - }; + using Status = MetadataResponse; protected: template @@ -692,7 +689,7 @@ public: asImpl().allocate(std::forward(args)...); // Publish the value. - Value = allocationResult.Value; + Value = const_cast(allocationResult.Value); auto newState = MetadataState::forRequestState(allocationResult.State); publishMetadataState(concurrency, newState); @@ -725,7 +722,7 @@ protected: struct TryInitializeResult { MetadataRequest::BasicKind NewState; MetadataRequest::BasicKind DependencyRequirement; - Metadata *Dependency; + const Metadata *Dependency; }; private: diff --git a/stdlib/public/runtime/MetadataLookup.cpp b/stdlib/public/runtime/MetadataLookup.cpp index 9233234a437..25b92b116ad 100644 --- a/stdlib/public/runtime/MetadataLookup.cpp +++ b/stdlib/public/runtime/MetadataLookup.cpp @@ -847,7 +847,7 @@ public: auto accessFunction = typeDecl->getAccessFunction(); if (!accessFunction) return BuiltType(); - return accessFunction(allGenericArgs); + return accessFunction(MetadataRequest::Complete, allGenericArgs).Value; } BuiltType createBuiltinType(StringRef mangledName) const { @@ -1015,10 +1015,10 @@ swift::_getTypeByMangledName(StringRef typeName, if (!assocTypeReqIndex) return nullptr; // Call the associated type access function. - using AssociatedTypeAccessFn = - const Metadata *(*)(const Metadata *base, const WitnessTable *); - return ((const AssociatedTypeAccessFn *)witnessTable)[*assocTypeReqIndex] - (base, witnessTable); + // TODO: can we just request abstract metadata? If so, do we have + // a responsibility to try to finish it later? + return ((const AssociatedTypeAccessFunction * const *)witnessTable)[*assocTypeReqIndex] + (MetadataRequest::Complete, base, witnessTable).Value; }); auto type = Demangle::decodeMangledType(builder, node); diff --git a/test/ClangImporter/attr-swift_private.swift b/test/ClangImporter/attr-swift_private.swift index a9e8421a924..bb0a6f4349b 100644 --- a/test/ClangImporter/attr-swift_private.swift +++ b/test/ClangImporter/attr-swift_private.swift @@ -91,7 +91,7 @@ public func testTopLevel() { #endif } -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$SSo10PrivFooSubCMa{{.*}} { +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$SSo10PrivFooSubCMa{{.*}} { // CHECK: %objc_class** @"OBJC_CLASS_REF_$_PrivFooSub" // CHECK: } diff --git a/test/DebugInfo/cleanupskip.swift b/test/DebugInfo/cleanupskip.swift index 799d470203b..b8dd8081073 100644 --- a/test/DebugInfo/cleanupskip.swift +++ b/test/DebugInfo/cleanupskip.swift @@ -6,7 +6,7 @@ public class NSCoder : NSObject {} public class AClass : NSObject { // Ensure that the call to the type metadata accessor has a line number. - // CHECK: call %swift.type* @"$S11cleanupskip7NSCoderCMa"() + // CHECK: call swiftcc %swift.metadata_response @"$S11cleanupskip7NSCoderCMa" // CHECK-SAME: !dbg ![[LINEZ:[0-9]+]] // CHECK: ![[LINEZ]] = {{.*}}line: 0 public required init?(coder aDecoder: NSCoder) { diff --git a/test/DebugInfo/initializer.swift b/test/DebugInfo/initializer.swift index e13a7898753..b3ec83b312c 100644 --- a/test/DebugInfo/initializer.swift +++ b/test/DebugInfo/initializer.swift @@ -8,7 +8,7 @@ protocol Named { // initializer.Person.__allocating_init (initializer.Person.Type)() -> initializer.Person // CHECK: define hidden {{.*}}%T11initializer6PersonC* @"$S11initializer6PersonCACycfC"(%swift.type*{{.*}}) {{.*}} { -// CHECK: call {{.*}}%T11initializer6PersonC* @"$S11initializer6PersonCACycfc"(%T11initializer6PersonC* {{.*}}%3), !dbg ![[ALLOCATING_INIT:.*]] +// CHECK: call {{.*}}%T11initializer6PersonC* @"$S11initializer6PersonCACycfc"(%T11initializer6PersonC* {{.*}}), !dbg ![[ALLOCATING_INIT:.*]] // initializer.Person.init (initializer.Person.Type)() -> initializer.Person // CHECK: define hidden {{.*}}%T11initializer6PersonC* @"$S11initializer6PersonCACycfc"(%T11initializer6PersonC*{{.*}}) {{.*}} { diff --git a/test/DebugInfo/return.swift b/test/DebugInfo/return.swift index 2da1ff0a762..740104e58a7 100644 --- a/test/DebugInfo/return.swift +++ b/test/DebugInfo/return.swift @@ -9,7 +9,8 @@ class X { public func ifelseexpr() -> Int64 { var x = X(i:0) // CHECK: [[ALLOCA:%.*]] = alloca %T6return1XC* - // CHECK: [[META:%.*]] = call %swift.type* @"$S6return1XCMa"() + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S6return1XCMa"( + // CHECK: [[META:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[X:%.*]] = call {{.*}}%T6return1XC* @"$S6return1XC1iACs5Int64V_tcfC"( // CHECK-SAME: i64 0, %swift.type* swiftself [[META]]) // CHECK: store %T6return1XC* [[X]], %T6return1XC** [[ALLOCA]] diff --git a/test/IRGen/associated_type_witness.swift b/test/IRGen/associated_type_witness.swift index ef329c1a9a7..64862d8f38d 100644 --- a/test/IRGen/associated_type_witness.swift +++ b/test/IRGen/associated_type_witness.swift @@ -31,7 +31,7 @@ protocol HasThreeAssocTypes { // Witness table for WithUniversal : Assocked. // GLOBAL-LABEL: @"$S23associated_type_witness13WithUniversalVAA8AssockedAAWP" = hidden constant [4 x i8*] [ // GLOBAL-SAME: @"$S23associated_type_witness13WithUniversalVAA8AssockedAAMc" -// GLOBAL-SAME: i8* bitcast (%swift.type* ()* @"$S23associated_type_witness9UniversalVMa" to i8*) +// GLOBAL-SAME: i8* bitcast (%swift.metadata_response (i64)* @"$S23associated_type_witness9UniversalVMa" to i8*) // GLOBAL-SAME: i8* bitcast (i8** ()* @"$S23associated_type_witness9UniversalVAA1PAAWa" to i8*) // GLOBAL-SAME: i8* bitcast (i8** ()* @"$S23associated_type_witness9UniversalVAA1QAAWa" to i8*) // GLOBAL-SAME: ] @@ -42,7 +42,7 @@ struct WithUniversal : Assocked { // Witness table for GenericWithUniversal : Assocked. // GLOBAL-LABEL: @"$S23associated_type_witness20GenericWithUniversalVyxGAA8AssockedAAWP" = hidden constant [4 x i8*] [ // GLOBAL-SAME: @"$S23associated_type_witness20GenericWithUniversalVyxGAA8AssockedAAMc" -// GLOBAL-SAME: i8* bitcast (%swift.type* ()* @"$S23associated_type_witness9UniversalVMa" to i8*) +// GLOBAL-SAME: i8* bitcast (%swift.metadata_response (i64)* @"$S23associated_type_witness9UniversalVMa" to i8*) // GLOBAL-SAME: i8* bitcast (i8** ()* @"$S23associated_type_witness9UniversalVAA1PAAWa" to i8*) // GLOBAL-SAME: i8* bitcast (i8** ()* @"$S23associated_type_witness9UniversalVAA1QAAWa" to i8*) // GLOBAL-SAME: ] @@ -53,7 +53,7 @@ struct GenericWithUniversal : Assocked { // Witness table for Fulfilled : Assocked. // GLOBAL-LABEL: @"$S23associated_type_witness9FulfilledVyxGAA8AssockedAAWP" = hidden constant [4 x i8*] [ // GLOBAL-SAME: @"$S23associated_type_witness9FulfilledVyxGAA8AssockedAAMc" -// GLOBAL-SAME: i8* bitcast (%swift.type* (%swift.type*, i8**)* @"$S23associated_type_witness9FulfilledVyxGAA8AssockedAA5AssocWt" to i8*) +// GLOBAL-SAME: i8* bitcast (%swift.metadata_response (i64, %swift.type*, i8**)* @"$S23associated_type_witness9FulfilledVyxGAA8AssockedAA5AssocWt" to i8*) // GLOBAL-SAME: i8* bitcast (i8** (%swift.type*, %swift.type*, i8**)* @"$S23associated_type_witness9FulfilledVyxGAA8AssockedAA5Assoc_AA1PPWT" to i8*) // GLOBAL-SAME: i8* bitcast (i8** (%swift.type*, %swift.type*, i8**)* @"$S23associated_type_witness9FulfilledVyxGAA8AssockedAA5Assoc_AA1QPWT" to i8*) // GLOBAL-SAME: ] @@ -62,21 +62,23 @@ struct Fulfilled : Assocked { } // Associated type metadata access function for Fulfilled.Assoc. -// CHECK-LABEL: define internal %swift.type* @"$S23associated_type_witness9FulfilledVyxGAA8AssockedAA5AssocWt"(%swift.type* %"Fulfilled", i8** %"Fulfilled.Assocked") +// CHECK-LABEL: define internal swiftcc %swift.metadata_response @"$S23associated_type_witness9FulfilledVyxGAA8AssockedAA5AssocWt"(i64, %swift.type* %"Fulfilled", i8** %"Fulfilled.Assocked") // CHECK: [[T0:%.*]] = bitcast %swift.type* %"Fulfilled" to %swift.type** // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[T0]], i64 2 // CHECK-NEXT: [[T2:%.*]] = load %swift.type*, %swift.type** [[T1]], align 8, !invariant.load -// CHECK-NEXT: ret %swift.type* [[T2]] +// CHECK-NEXT: [[T3:%.*]] = insertvalue %swift.metadata_response undef, %swift.type* [[T2]], 0 +// CHECK-NEXT: [[T4:%.*]] = insertvalue %swift.metadata_response [[T3]], i64 0, 1 +// CHECK-NEXT: ret %swift.metadata_response [[T4]] // Associated type witness table access function for Fulfilled.Assoc : P. -// CHECK-LABEL: define internal i8** @"$S23associated_type_witness9FulfilledVyxGAA8AssockedAA5Assoc_AA1PPWT"(%swift.type* %"Fulfilled.Assoc", %swift.type* %"Fulfilled", i8** %"Fulfilled.Assocked") +// CHECK-LABEL: define internal swiftcc i8** @"$S23associated_type_witness9FulfilledVyxGAA8AssockedAA5Assoc_AA1PPWT"(%swift.type* %"Fulfilled.Assoc", %swift.type* %"Fulfilled", i8** %"Fulfilled.Assocked") // CHECK: [[T0:%.*]] = bitcast %swift.type* %"Fulfilled" to i8*** // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8**, i8*** [[T0]], i64 3 // CHECK-NEXT: [[T2:%.*]] = load i8**, i8*** [[T1]], align 8, !invariant.load // CHECK-NEXT: ret i8** [[T2]] // Associated type witness table access function for Fulfilled.Assoc : Q. -// CHECK-LABEL: define internal i8** @"$S23associated_type_witness9FulfilledVyxGAA8AssockedAA5Assoc_AA1QPWT"(%swift.type* %"Fulfilled.Assoc", %swift.type* %"Fulfilled", i8** %"Fulfilled.Assocked") +// CHECK-LABEL: define internal swiftcc i8** @"$S23associated_type_witness9FulfilledVyxGAA8AssockedAA5Assoc_AA1QPWT"(%swift.type* %"Fulfilled.Assoc", %swift.type* %"Fulfilled", i8** %"Fulfilled.Assocked") // CHECK: [[T0:%.*]] = bitcast %swift.type* %"Fulfilled" to i8*** // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8**, i8*** [[T0]], i64 4 // CHECK-NEXT: [[T2:%.*]] = load i8**, i8*** [[T1]], align 8, !invariant.load @@ -87,7 +89,7 @@ struct Pair : P, Q {} // Generic witness table pattern for Computed : Assocked. // GLOBAL-LABEL: @"$S23associated_type_witness8ComputedVyxq_GAA8AssockedAAWP" = hidden constant [4 x i8*] [ // GLOBAL-SAME: @"$S23associated_type_witness8ComputedVyxq_GAA8AssockedAAMc" -// GLOBAL-SAME: i8* bitcast (%swift.type* (%swift.type*, i8**)* @"$S23associated_type_witness8ComputedVyxq_GAA8AssockedAA5AssocWt" to i8*) +// GLOBAL-SAME: i8* bitcast (%swift.metadata_response (i64, %swift.type*, i8**)* @"$S23associated_type_witness8ComputedVyxq_GAA8AssockedAA5AssocWt" to i8*) // GLOBAL-SAME: i8* bitcast (i8** (%swift.type*, %swift.type*, i8**)* @"$S23associated_type_witness8ComputedVyxq_GAA8AssockedAA5Assoc_AA1PPWT" to i8*) // GLOBAL-SAME: i8* bitcast (i8** (%swift.type*, %swift.type*, i8**)* @"$S23associated_type_witness8ComputedVyxq_GAA8AssockedAA5Assoc_AA1QPWT" to i8*) // GLOBAL-SAME: ] @@ -112,7 +114,7 @@ struct Computed : Assocked { } // Associated type metadata access function for Computed.Assoc. -// CHECK-LABEL: define internal %swift.type* @"$S23associated_type_witness8ComputedVyxq_GAA8AssockedAA5AssocWt"(%swift.type* %"Computed", i8** %"Computed.Assocked") +// CHECK-LABEL: define internal swiftcc %swift.metadata_response @"$S23associated_type_witness8ComputedVyxq_GAA8AssockedAA5AssocWt"(i64, %swift.type* %"Computed", i8** %"Computed.Assocked") // CHECK: entry: // CHECK: [[T0:%.*]] = getelementptr inbounds i8*, i8** %"Computed.Assocked", i32 -1 // CHECK-NEXT: [[CACHE:%.*]] = bitcast i8** [[T0]] to %swift.type** @@ -121,7 +123,9 @@ struct Computed : Assocked { // CHECK-NEXT: br i1 [[T1]], label %fetch, label %cont // CHECK: cont: // CHECK-NEXT: [[T0:%.*]] = phi %swift.type* [ [[CACHE_RESULT]], %entry ], [ [[FETCH_RESULT:%.*]], %fetch ] -// CHECK-NEXT: ret %swift.type* [[T0]] +// CHECK-NEXT: [[T2:%.*]] = insertvalue %swift.metadata_response undef, %swift.type* [[T0]], 0 +// CHECK-NEXT: [[T3:%.*]] = insertvalue %swift.metadata_response [[T2]], i64 0, 1 +// CHECK-NEXT: ret %swift.metadata_response [[T3]] // CHECK: fetch: // CHECK-NEXT: [[T0:%.*]] = bitcast %swift.type* %"Computed" to %swift.type** // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[T0]], i64 2 @@ -129,7 +133,8 @@ struct Computed : Assocked { // CHECK: [[T0:%.*]] = bitcast %swift.type* %"Computed" to %swift.type** // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[T0]], i64 3 // CHECK-NEXT: [[U:%.*]] = load %swift.type*, %swift.type** [[T1]], align 8, !invariant.load -// CHECK-NEXT: [[FETCH_RESULT]] = call %swift.type* @"$S23associated_type_witness4PairVMa"(%swift.type* [[T]], %swift.type* [[U]]) +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S23associated_type_witness4PairVMa"(i64 0, %swift.type* [[T]], %swift.type* [[U]]) +// CHECK-NEXT: [[FETCH_RESULT]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: store atomic %swift.type* [[FETCH_RESULT]], %swift.type** [[CACHE]] release, align 8 // CHECK-NEXT: br label %cont diff --git a/test/IRGen/associated_types.swift b/test/IRGen/associated_types.swift index 05148bb039d..131bb7de337 100644 --- a/test/IRGen/associated_types.swift +++ b/test/IRGen/associated_types.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir -primary-file %s | %FileCheck %s +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir -primary-file %s | %FileCheck %s -DINT=i%target-ptrsize // REQUIRES: CPU=i386 || CPU=x86_64 @@ -77,24 +77,26 @@ func testFastRuncible(_ t: T, u: U) // Note that we actually look things up in T, which is going to prove unfortunate. // CHECK: [[T0_GEP:%.*]] = getelementptr inbounds i8*, i8** %T.Runcible, i32 1 // CHECK: [[T0:%.*]] = load i8*, i8** [[T0_GEP]] -// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to %swift.type* (%swift.type*, i8**)* -// CHECK-NEXT: %T.RuncerType = call %swift.type* [[T1]](%swift.type* %T, i8** %T.Runcible) +// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to %swift.metadata_response ([[INT]], %swift.type*, i8**)* +// CHECK-NEXT: [[T2:%.*]] = call swiftcc %swift.metadata_response [[T1]]([[INT]] 0, %swift.type* %T, i8** %T.Runcible) +// CHECK-NEXT: %T.RuncerType = extractvalue %swift.metadata_response [[T2]], 0 // 2. Get the witness table for U.RuncerType.Runcee : Speedy // 2a. Get the protocol witness table for U.RuncerType : FastRuncer. // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds i8*, i8** %U.FastRuncible, i32 2 // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[T0]], // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to i8** (%swift.type*, %swift.type*, i8**)* -// CHECK-NEXT: %T.RuncerType.FastRuncer = call i8** [[T2]](%swift.type* %T.RuncerType, %swift.type* %U, i8** %U.FastRuncible) +// CHECK-NEXT: %T.RuncerType.FastRuncer = call swiftcc i8** [[T2]](%swift.type* %T.RuncerType, %swift.type* %U, i8** %U.FastRuncible) // 1c. Get the type metadata for U.RuncerType.Runcee. // CHECK-NEXT: [[T0_GEP:%.*]] = getelementptr inbounds i8*, i8** %T.RuncerType.FastRuncer, i32 1 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[T0_GEP]] -// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to %swift.type* (%swift.type*, i8**)* -// CHECK-NEXT: %T.RuncerType.Runcee = call %swift.type* [[T1]](%swift.type* %T.RuncerType, i8** %T.RuncerType.FastRuncer) +// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to %swift.metadata_response ([[INT]], %swift.type*, i8**)* +// CHECK-NEXT: [[T2:%.*]] = call swiftcc %swift.metadata_response [[T1]]([[INT]] 0, %swift.type* %T.RuncerType, i8** %T.RuncerType.FastRuncer) +// CHECK-NEXT: %T.RuncerType.Runcee = extractvalue %swift.metadata_response [[T2]], 0 // 2b. Get the witness table for U.RuncerType.Runcee : Speedy. // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds i8*, i8** %T.RuncerType.FastRuncer, i32 2 // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[T0]], // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to i8** (%swift.type*, %swift.type*, i8**)* -// CHECK-NEXT: %T.RuncerType.Runcee.Speedy = call i8** [[T2]](%swift.type* %T.RuncerType.Runcee, %swift.type* %T.RuncerType, i8** %T.RuncerType.FastRuncer) +// CHECK-NEXT: %T.RuncerType.Runcee.Speedy = call swiftcc i8** [[T2]](%swift.type* %T.RuncerType.Runcee, %swift.type* %T.RuncerType, i8** %T.RuncerType.FastRuncer) // 3. Perform the actual call. // CHECK-NEXT: [[T0_GEP:%.*]] = getelementptr inbounds i8*, i8** %T.RuncerType.Runcee.Speedy, i32 1 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[T0_GEP]] diff --git a/test/IRGen/big_types_corner_cases.swift b/test/IRGen/big_types_corner_cases.swift index 88df2d9bd3f..837e05ca848 100644 --- a/test/IRGen/big_types_corner_cases.swift +++ b/test/IRGen/big_types_corner_cases.swift @@ -206,13 +206,15 @@ public func testGetFunc() { } // CHECK-LABEL: define{{( protected)?}} hidden swiftcc void @"$S22big_types_corner_cases7TestBigC4testyyF"(%T22big_types_corner_cases7TestBigC* swiftself) -// CHECK: [[CALL1:%.*]] = call %swift.type* @"$SSayy22big_types_corner_cases9BigStructVcSgGMa" +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$SSayy22big_types_corner_cases9BigStructVcSgGMa" +// CHECK: [[CALL1:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: [[CALL2:%.*]] = call i8** @"$SSayy22big_types_corner_cases9BigStructVcSgGSayxGs10CollectionsWl // CHECK: call swiftcc void @"$Ss10CollectionPsE5index5where5IndexQzSgSb7ElementQzKXE_tKF"(%TSq.{{.*}}* noalias nocapture sret {{.*}}, i8* bitcast (i1 (%T22big_types_corner_cases9BigStructVytIegir_Sg*, %swift.refcounted*, %swift.error**)* @"$S22big_types_corner_cases9BigStructVIegy_SgSbs5Error_pIgxdzo_ACytIegir_SgSbsAE_pIegidzo_TRTA" to i8*), %swift.opaque* {{.*}}, %swift.type* [[CALL1]], i8** [[CALL2]], %swift.opaque* noalias nocapture swiftself // CHECK: ret void // CHECK-LABEL: define{{( protected)?}} hidden swiftcc void @"$S22big_types_corner_cases7TestBigC5test2yyF"(%T22big_types_corner_cases7TestBigC* swiftself) -// CHECK: [[CALL1:%.*]] = call %swift.type* @"$SSaySS2ID_y22big_types_corner_cases9BigStructVcSg7handlertGMa" +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$SSaySS2ID_y22big_types_corner_cases9BigStructVcSg7handlertGMa" +// CHECK: [[CALL1:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: [[CALL2:%.*]] = call i8** @"$SSaySS2ID_y22big_types_corner_cases9BigStructVcSg7handlertGSayxGs10CollectionsWl" // CHECK: call swiftcc void @"$Ss10CollectionPss16IndexingIteratorVyxG0C0RtzrlE04makeC0AEyF"(%Ts16IndexingIteratorV* noalias nocapture sret {{.*}}, %swift.type* [[CALL1]], i8** [[CALL2]], %swift.opaque* noalias nocapture swiftself {{.*}}) // CHECK: ret void diff --git a/test/IRGen/c_function_pointer.sil b/test/IRGen/c_function_pointer.sil index a8186b45f84..6c8d6b5251a 100644 --- a/test/IRGen/c_function_pointer.sil +++ b/test/IRGen/c_function_pointer.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s -DINT=i%target-ptrsize import Swift @@ -19,12 +19,12 @@ entry(%f : $@convention(c) () -> ()): // CHECK-LABEL: define{{( protected)?}} swiftcc %swift.type* @c_function_pointer_metadata() sil @c_function_pointer_metadata : $@convention(thin) () -> @thick Any.Type { entry: - // CHECK: call %swift.type* @"$SyyXCMa"() + // CHECK: call swiftcc %swift.metadata_response @"$SyyXCMa"([[INT]] 0) %m = metatype $@thick (@convention(c) () -> ()).Type %a = init_existential_metatype %m : $@thick (@convention(c) () -> ()).Type, $@thick Any.Type return %a : $@thick Any.Type } -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$SyyXCMa"() +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$SyyXCMa"( // -- 0x3000001 -- C convention, 1 argument // CHECK: call %swift.type* @swift_getFunctionTypeMetadata0([[WORD:i(32|64)]] 196608, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) diff --git a/test/IRGen/casts.sil b/test/IRGen/casts.sil index 965a0e12964..1d8b0de90a4 100644 --- a/test/IRGen/casts.sil +++ b/test/IRGen/casts.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck %s +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck %s -DINT=i%target-ptrsize // REQUIRES: CPU=i386 || CPU=x86_64 // XFAIL: linux @@ -223,7 +223,8 @@ nay: // CHECK-LABEL: define{{( protected)?}} swiftcc %T5casts1AC* @checked_downcast_optional({{(i32|i64)}}) {{.*}} { // CHECK: [[T0:%.*]] = inttoptr {{(i32|i64)}} %0 to %T5casts1AC* // CHECK: [[OBJ_PTR:%.*]] = bitcast %T5casts1AC* [[T0]] to i8* -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S5casts1ACMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S5casts1ACMa"([[INT]] 0) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: [[METADATA_PTR:%.*]] = bitcast %swift.type* [[METADATA]] to i8* // CHECK: [[RESULT_PTR:%.*]] = call i8* @swift_dynamicCastClass(i8* [[OBJ_PTR]], i8* [[METADATA_PTR]]) // CHECK: [[RESULT:%.*]] = bitcast i8* [[RESULT_PTR]] to %T5casts1AC* @@ -240,7 +241,8 @@ nay: // CHECK-LABEL: define{{( protected)?}} swiftcc %swift.type* @checked_downcast_optional_metatype({{(i32|i64)}}) {{.*}} { // CHECK: [[VALUE:%.*]] = inttoptr {{(i32|i64)}} %0 to %swift.type* -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S5casts1BCMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S5casts1BCMa"([[INT]] 0) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: [[RESULT:%.*]] = call %swift.type* @swift_dynamicCastMetatype(%swift.type* [[VALUE]], %swift.type* [[METADATA]]) // CHECK: [[COND:%.*]] = icmp ne %swift.type* [[RESULT]], null // CHECK: br i1 [[COND]] @@ -255,7 +257,8 @@ nay: // CHECK-LABEL: define{{( protected)?}} swiftcc %swift.type* @checked_downcast_optional_exmetatype({{(i32, i32|i64, i64)}}) {{.*}} { // CHECK: [[VALUE:%.*]] = inttoptr {{(i32|i64)}} %0 to %swift.type* -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S5casts1BCMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S5casts1BCMa"([[INT]] 0) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: [[RESULT:%.*]] = call %swift.type* @swift_dynamicCastMetatype(%swift.type* [[VALUE]], %swift.type* [[METADATA]]) // CHECK: [[COND:%.*]] = icmp ne %swift.type* [[RESULT]], null // CHECK: br i1 [[COND]] diff --git a/test/IRGen/cf.sil b/test/IRGen/cf.sil index f25ffc6a3ee..d3234db804c 100644 --- a/test/IRGen/cf.sil +++ b/test/IRGen/cf.sil @@ -1,6 +1,6 @@ // RUN: %empty-directory(%t) // RUN: %utils/chex.py < %s > %t/cf.sil -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -sdk %S/Inputs %t/cf.sil -emit-ir -import-cf-types | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize %t/cf.sil +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -sdk %S/Inputs %t/cf.sil -emit-ir -import-cf-types | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize %t/cf.sil -DINT=i%target-ptrsize // REQUIRES: CPU=i386 || CPU=x86_64 // REQUIRES: objc_interop @@ -49,14 +49,16 @@ bb0(%0 : $CCRefrigerator, %1: $CCMutableRefrigerator): // CHECK: define{{( protected)?}} swiftcc void @call_generic([[REFRIGERATOR]]*, [[MUTABLE_REFRIGERATOR]]*) {{.*}} { // CHECK: [[T0:%.*]] = bitcast [[REFRIGERATOR]]* %0 to [[OBJC]]* -// CHECK-NEXT: [[T1:%.*]] = call [[TYPE]]* @"$SSo17CCRefrigeratorRefaMa"() -// CHECK-NEXT: call swiftcc void @generic_function([[OBJC]]* [[T0]], [[TYPE]]* [[T1]]) +// CHECK-NEXT: [[T1:%.*]] = call swiftcc %swift.metadata_response @"$SSo17CCRefrigeratorRefaMa"([[INT]] 0) +// CHECK-NEXT: [[T2:%.*]] = extractvalue %swift.metadata_response [[T1]], 0 +// CHECK-NEXT: call swiftcc void @generic_function([[OBJC]]* [[T0]], [[TYPE]]* [[T2]]) // CHECK: [[T0:%.*]] = bitcast [[MUTABLE_REFRIGERATOR]]* %1 to [[OBJC]]* -// CHECK-NEXT: [[T1:%.*]] = call [[TYPE]]* @"$SSo24CCMutableRefrigeratorRefaMa"() -// CHECK-NEXT: call swiftcc void @generic_function([[OBJC]]* [[T0]], [[TYPE]]* [[T1]]) +// CHECK-NEXT: [[T1:%.*]] = call swiftcc %swift.metadata_response @"$SSo24CCMutableRefrigeratorRefaMa"([[INT]] 0) +// CHECK-NEXT: [[T2:%.*]] = extractvalue %swift.metadata_response [[T1]], 0 +// CHECK-NEXT: call swiftcc void @generic_function([[OBJC]]* [[T0]], [[TYPE]]* [[T2]]) // CHECK-NEXT: ret void -// CHECK: define linkonce_odr hidden [[TYPE]]* @"$SSo17CCRefrigeratorRefaMa"() +// CHECK: define linkonce_odr hidden swiftcc %swift.metadata_response @"$SSo17CCRefrigeratorRefaMa"( // CHECK-32: call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo17CCRefrigeratorRefaN" to i8*), i32 8) to [[TYPE]]*)) // CHECK-64: call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo17CCRefrigeratorRefaN" to i8*), i64 16) to [[TYPE]]*)) diff --git a/test/IRGen/class_bounded_generics.swift b/test/IRGen/class_bounded_generics.swift index e439780c754..33b599117a9 100644 --- a/test/IRGen/class_bounded_generics.swift +++ b/test/IRGen/class_bounded_generics.swift @@ -1,6 +1,6 @@ // REQUIRES: plus_one_runtime -// RUN: %target-swift-frontend -module-name class_bounded_generics -emit-ir -primary-file %s -disable-objc-attr-requires-foundation-module | %FileCheck %s +// RUN: %target-swift-frontend -module-name class_bounded_generics -emit-ir -primary-file %s -disable-objc-attr-requires-foundation-module | %FileCheck %s -DINT=i%target-ptrsize // REQUIRES: CPU=x86_64 // XFAIL: linux @@ -168,7 +168,8 @@ func class_bounded_protocol_method(_ x: ClassBound) { func class_bounded_archetype_cast(_ x: T) -> ConcreteClass { return x as! ConcreteClass // CHECK: [[IN_PTR:%.*]] = bitcast %objc_object* {{%.*}} to i8* - // CHECK: [[T0:%.*]] = call %swift.type* @"$S22class_bounded_generics13ConcreteClassCMa"() + // CHECK: [[T0R:%.*]] = call swiftcc %swift.metadata_response @"$S22class_bounded_generics13ConcreteClassCMa"([[INT]] 0) + // CHECK: [[T0:%.*]] = extractvalue %swift.metadata_response [[T0R]], 0 // CHECK: [[T1:%.*]] = bitcast %swift.type* [[T0]] to i8* // CHECK: [[OUT_PTR:%.*]] = call i8* @swift_dynamicCastClassUnconditional(i8* [[IN_PTR]], i8* [[T1]]) // CHECK: [[OUT:%.*]] = bitcast i8* [[OUT_PTR]] to %T22class_bounded_generics13ConcreteClassC* @@ -179,7 +180,8 @@ func class_bounded_archetype_cast(_ x: T) -> ConcreteClass { func class_bounded_protocol_cast(_ x: ClassBound) -> ConcreteClass { return x as! ConcreteClass // CHECK: [[IN_PTR:%.*]] = bitcast %objc_object* {{%.*}} to i8* - // CHECK: [[T0:%.*]] = call %swift.type* @"$S22class_bounded_generics13ConcreteClassCMa"() + // CHECK: [[T0R:%.*]] = call swiftcc %swift.metadata_response @"$S22class_bounded_generics13ConcreteClassCMa"([[INT]] 0) + // CHECK: [[T0:%.*]] = extractvalue %swift.metadata_response [[T0R]], 0 // CHECK: [[T1:%.*]] = bitcast %swift.type* [[T0]] to i8* // CHECK: [[OUT_PTR:%.*]] = call i8* @swift_dynamicCastClassUnconditional(i8* [[IN_PTR]], i8* [[T1]]) // CHECK: [[OUT:%.*]] = bitcast i8* [[OUT_PTR]] to %T22class_bounded_generics13ConcreteClassC* @@ -304,7 +306,8 @@ func archetype_with_generic_class_constraint(t: T) where T : A { // CHECK-NEXT: [[ISA_PTR:%.*]] = bitcast %swift.type* [[ISA]] to %swift.type** // CHECK-NEXT: [[T_ADDR:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[ISA_PTR]], i64 10 // CHECK-NEXT: [[T:%.*]] = load %swift.type*, %swift.type** [[T_ADDR]] -// CHECK-NEXT: [[A_OF_T:%.*]] = call %swift.type* @"$S22class_bounded_generics1ACMa"(%swift.type* [[T]]) +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S22class_bounded_generics1ACMa"([[INT]] 0, %swift.type* [[T]]) +// CHECK-NEXT: [[A_OF_T:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: call swiftcc void @"$S22class_bounded_generics023archetype_with_generic_A11_constraint1tyx_tAA1ACyq_GRbzr0_lF"(%T22class_bounded_generics1AC.1* [[SELF]], %swift.type* [[A_OF_T]]) // CHECK: ret void diff --git a/test/IRGen/class_resilience.sil b/test/IRGen/class_resilience.sil index 6f1fe46f190..186be230a63 100644 --- a/test/IRGen/class_resilience.sil +++ b/test/IRGen/class_resilience.sil @@ -21,7 +21,8 @@ import resilient_class // be an issue. // CHECK-LABEL: define {{(protected )?}}swiftcc void @allocResilientOutsideParent() -// CHECK: [[META:%.*]] = call %swift.type* @"$S15resilient_class22ResilientOutsideParentCMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S15resilient_class22ResilientOutsideParentCMa"(i64 0) +// CHECK-NEXT: [[META:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[META_ADDR:%.*]] = bitcast %swift.type* [[META]] to i8* // CHECK-NEXT: [[SIZE_ADDR:%.*]] = getelementptr inbounds i8, i8* [[META_ADDR]], i32 48 // CHECK-NEXT: [[SIZE_PTR:%.*]] = bitcast i8* [[SIZE_ADDR]] to i32* diff --git a/test/IRGen/class_resilience.swift b/test/IRGen/class_resilience.swift index e040b4a5e1f..e6e49be4b56 100644 --- a/test/IRGen/class_resilience.swift +++ b/test/IRGen/class_resilience.swift @@ -3,11 +3,9 @@ // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_enum.swiftmodule -module-name=resilient_enum -I %t %S/../Inputs/resilient_enum.swift // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_class.swiftmodule -module-name=resilient_class -I %t %S/../Inputs/resilient_class.swift -// RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience %t/class_resilience.swift | %FileCheck %t/class_resilience.swift --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize +// RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience %t/class_resilience.swift | %FileCheck %t/class_resilience.swift --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -DINT=i%target-ptrsize // RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience -O %t/class_resilience.swift -// CHECK: %swift.type = type { [[INT:i32|i64]] } - // CHECK: @"$S16class_resilience26ClassWithResilientPropertyC1s16resilient_struct4SizeVvpWvd" = hidden global [[INT]] 0 // CHECK: @"$S16class_resilience26ClassWithResilientPropertyC5colors5Int32VvpWvd" = hidden global [[INT]] 0 @@ -202,7 +200,7 @@ extension ResilientGenericOutsideParent { // ClassWithResilientProperty metadata accessor -// CHECK-LABEL: define{{( protected)?}} %swift.type* @"$S16class_resilience26ClassWithResilientPropertyCMa"() +// CHECK-LABEL: define{{( protected)?}} swiftcc %swift.metadata_response @"$S16class_resilience26ClassWithResilientPropertyCMa"( // CHECK: [[CACHE:%.*]] = load %swift.type*, %swift.type** @"$S16class_resilience26ClassWithResilientPropertyCML" // CHECK-NEXT: [[COND:%.*]] = icmp eq %swift.type* [[CACHE]], null // CHECK-NEXT: br i1 [[COND]], label %cacheIsNull, label %cont @@ -214,7 +212,9 @@ extension ResilientGenericOutsideParent { // CHECK: cont: // CHECK-NEXT: [[RESULT:%.*]] = phi %swift.type* [ [[CACHE]], %entry ], [ [[METADATA]], %cacheIsNull ] -// CHECK-NEXT: ret %swift.type* [[RESULT]] +// CHECK-NEXT: [[T0:%.*]] = insertvalue %swift.metadata_response undef, %swift.type* [[RESULT]], 0 +// CHECK-NEXT: [[T1:%.*]] = insertvalue %swift.metadata_response [[T0]], [[INT]] 0, 1 +// CHECK-NEXT: ret %swift.metadata_response [[T1]] // ClassWithResilientlySizedProperty.color getter @@ -229,7 +229,7 @@ extension ResilientGenericOutsideParent { // ClassWithResilientlySizedProperty metadata accessor -// CHECK-LABEL: define{{( protected)?}} %swift.type* @"$S16class_resilience33ClassWithResilientlySizedPropertyCMa"() +// CHECK-LABEL: define{{( protected)?}} swiftcc %swift.metadata_response @"$S16class_resilience33ClassWithResilientlySizedPropertyCMa"( // CHECK: [[CACHE:%.*]] = load %swift.type*, %swift.type** @"$S16class_resilience33ClassWithResilientlySizedPropertyCML" // CHECK-NEXT: [[COND:%.*]] = icmp eq %swift.type* [[CACHE]], null // CHECK-NEXT: br i1 [[COND]], label %cacheIsNull, label %cont @@ -241,8 +241,9 @@ extension ResilientGenericOutsideParent { // CHECK: cont: // CHECK-NEXT: [[RESULT:%.*]] = phi %swift.type* [ [[CACHE]], %entry ], [ [[METADATA]], %cacheIsNull ] -// CHECK-NEXT: ret %swift.type* [[RESULT]] - +// CHECK-NEXT: [[T0:%.*]] = insertvalue %swift.metadata_response undef, %swift.type* [[RESULT]], 0 +// CHECK-NEXT: [[T1:%.*]] = insertvalue %swift.metadata_response [[T0]], [[INT]] 0, 1 +// CHECK-NEXT: ret %swift.metadata_response [[T1]] // ClassWithIndirectResilientEnum.color getter @@ -320,7 +321,8 @@ extension ResilientGenericOutsideParent { // CHECK-LABEL: define private void @initialize_metadata_ClassWithResilientProperty // CHECK: [[METADATA:%.*]] = call %swift.type* @swift_relocateClassMetadata({{.*}}, [[INT]] {{60|96}}, [[INT]] 4) -// CHECK: [[SIZE_METADATA:%.*]] = call %swift.type* @"$S16resilient_struct4SizeVMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S16resilient_struct4SizeVMa"([[INT]] 0) +// CHECK-NEXT: [[SIZE_METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: call void @swift_initClassMetadata_UniversalStrategy(%swift.type* [[METADATA]], [[INT]] 3, {{.*}}) // CHECK-native: [[METADATA_PTR:%.*]] = bitcast %swift.type* [[METADATA]] to [[INT]]* // CHECK-native-NEXT: [[FIELD_OFFSET_PTR:%.*]] = getelementptr inbounds [[INT]], [[INT]]* [[METADATA_PTR]], [[INT]] {{12|15}} @@ -337,7 +339,8 @@ extension ResilientGenericOutsideParent { // CHECK-LABEL: define private void @initialize_metadata_ClassWithResilientlySizedProperty // CHECK: [[METADATA:%.*]] = call %swift.type* @swift_relocateClassMetadata({{.*}}, [[INT]] {{60|96}}, [[INT]] 3) -// CHECK: [[RECTANGLE_METADATA:%.*]] = call %swift.type* @"$S16resilient_struct9RectangleVMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S16resilient_struct9RectangleVMa"([[INT]] 0) +// CHECK-NEXT: [[RECTANGLE_METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: call void @swift_initClassMetadata_UniversalStrategy(%swift.type* [[METADATA]], [[INT]] 2, {{.*}}) // CHECK-native: [[METADATA_PTR:%.*]] = bitcast %swift.type* [[METADATA]] to [[INT]]* // CHECK-native-NEXT: [[FIELD_OFFSET_PTR:%.*]] = getelementptr inbounds [[INT]], [[INT]]* [[METADATA_PTR]], [[INT]] {{11|14}} @@ -355,7 +358,8 @@ extension ResilientGenericOutsideParent { // CHECK-LABEL: define private void @initialize_metadata_ResilientChild(i8*) // Initialize the superclass field... -// CHECK: [[SUPER:%.*]] = call %swift.type* @"$S15resilient_class22ResilientOutsideParentCMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S15resilient_class22ResilientOutsideParentCMa"([[INT]] 0) +// CHECK: [[SUPER:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: store %swift.type* [[SUPER]], %swift.type** getelementptr inbounds ({{.*}}) // Relocate metadata if necessary... @@ -422,7 +426,8 @@ extension ResilientGenericOutsideParent { // CHECK-LABEL: define private void @initialize_metadata_FixedLayoutChild(i8*) // Initialize the superclass field... -// CHECK: [[SUPER:%.*]] = call %swift.type* @"$S15resilient_class22ResilientOutsideParentCMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S15resilient_class22ResilientOutsideParentCMa"([[INT]] 0) +// CHECK: [[SUPER:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: store %swift.type* [[SUPER]], %swift.type** getelementptr inbounds ({{.*}}) // Relocate metadata if necessary... @@ -437,14 +442,15 @@ extension ResilientGenericOutsideParent { // CHECK: [[METADATA:%.*]] = call %swift.type* @swift_allocateGenericClassMetadata(%swift.type_descriptor* %0, i8** %1, i8** %2) // CHECK: ret %swift.type* [[METADATA]] -// CHECK-LABEL: define internal %swift.type* @"$S16class_resilience21ResilientGenericChildCMr" +// CHECK-LABEL: define internal swiftcc %swift.metadata_response @"$S16class_resilience21ResilientGenericChildCMr" // CHECK-SAME: (%swift.type* [[METADATA:%.*]], i8*, i8**) // Initialize the superclass pointer... -// CHECK: [[SUPER:%.*]] = call %swift.type* @"$S15resilient_class29ResilientGenericOutsideParentCMa"(%swift.type* %T) +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S15resilient_class29ResilientGenericOutsideParentCMa"([[INT]] 0, %swift.type* %T) +// CHECK: [[SUPER:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: [[T0:%.*]] = bitcast %swift.type* [[METADATA]] to %swift.type** // CHECK: [[SUPER_ADDR:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[T0]], i32 1 // CHECK: store %swift.type* [[SUPER]], %swift.type** [[SUPER_ADDR]], // CHECK: call void @swift_initClassMetadata_UniversalStrategy(%swift.type* [[METADATA]], -// CHECK: ret %swift.type* null +// CHECK: ret %swift.metadata_response zeroinitializer diff --git a/test/IRGen/class_stack_alloc.sil b/test/IRGen/class_stack_alloc.sil index 8b05be78573..cfc9d39b955 100644 --- a/test/IRGen/class_stack_alloc.sil +++ b/test/IRGen/class_stack_alloc.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -stack-promotion-limit 48 -Onone -emit-ir %s | %FileCheck %s +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -stack-promotion-limit 48 -Onone -emit-ir %s | %FileCheck %s -DINT=i%target-ptrsize import Builtin import Swift @@ -30,7 +30,8 @@ sil_vtable BigClass {} // CHECK-LABEL: define{{( protected)?}} swiftcc void @simple_promote // CHECK: %reference.raw = alloca %[[C:[a-zA-Z0-9_]+]], align 8 -// CHECK-NEXT: [[M:%[0-9]+]] = call %swift.type* @"$S17class_stack_alloc9TestClassCMa"() +// CHECK-NEXT: [[MR:%[0-9]+]] = call swiftcc %swift.metadata_response @"$S17class_stack_alloc9TestClassCMa"([[INT]] 0) +// CHECK-NEXT: [[M:%.*]] = extractvalue %swift.metadata_response [[MR]], 0 // CHECK-NEXT: [[O:%[0-9]+]] = bitcast %[[C]]* %reference.raw to %swift.refcounted* // CHECK-NEXT: %reference.new = call %swift.refcounted* @swift_initStackObject(%swift.type* [[M]], %swift.refcounted* [[O]]) // CHECK-NEXT: [[R:%[0-9]+]] = bitcast %swift.refcounted* %reference.new to %[[C]]* @@ -81,7 +82,8 @@ bb0: // CHECK-LABEL: define{{( protected)?}} swiftcc void @promoted_with_devirtualized_release // CHECK: %reference.raw = alloca %[[C:[a-zA-Z0-9_]+]], align 8 -// CHECK-NEXT: [[M:%[0-9]+]] = call %swift.type* @"$S17class_stack_alloc9TestClassCMa"() +// CHECK-NEXT: [[MR:%[0-9]+]] = call swiftcc %swift.metadata_response @"$S17class_stack_alloc9TestClassCMa"([[INT]] 0) +// CHECK-NEXT: [[M:%.*]] = extractvalue %swift.metadata_response [[MR]], 0 // CHECK-NEXT: [[O:%[0-9]+]] = bitcast %[[C]]* %reference.raw to %swift.refcounted* // CHECK-NEXT: %reference.new = call %swift.refcounted* @swift_initStackObject(%swift.type* [[M]], %swift.refcounted* [[O]]) // CHECK-NEXT: [[R:%[0-9]+]] = bitcast %swift.refcounted* %reference.new to %[[C]]* @@ -104,7 +106,8 @@ bb0: // CHECK-LABEL: define{{( protected)?}} swiftcc void @promoted_with_inlined_devirtualized_release // CHECK: %reference.raw = alloca %[[C:[a-zA-Z0-9_]+]], align 8 -// CHECK-NEXT: [[M:%[0-9]+]] = call %swift.type* @"$S17class_stack_alloc9TestClassCMa"() +// CHECK-NEXT: [[MR:%[0-9]+]] = call swiftcc %swift.metadata_response @"$S17class_stack_alloc9TestClassCMa"([[INT]] 0) +// CHECK-NEXT: [[M:%.*]] = extractvalue %swift.metadata_response [[MR]], 0 // CHECK-NEXT: [[O:%[0-9]+]] = bitcast %[[C]]* %reference.raw to %swift.refcounted* // CHECK-NEXT: %reference.new = call %swift.refcounted* @swift_initStackObject(%swift.type* [[M]], %swift.refcounted* [[O]]) // CHECK-NEXT: [[R:%[0-9]+]] = bitcast %swift.refcounted* %reference.new to %[[C]]* diff --git a/test/IRGen/concrete_inherits_generic_base.swift b/test/IRGen/concrete_inherits_generic_base.swift index d2a031f917d..25896195035 100644 --- a/test/IRGen/concrete_inherits_generic_base.swift +++ b/test/IRGen/concrete_inherits_generic_base.swift @@ -1,6 +1,6 @@ -// RUN: %target-swift-frontend -module-name foo -emit-ir %s | %FileCheck %s +// RUN: %target-swift-frontend -module-name foo -emit-ir %s | %FileCheck %s -DINT=i%target-ptrsize -// CHECK: %swift.type = type { [[INT:i32|i64]] } +// CHECK: %swift.type = type { [[INT]] } // -- Classes with generic bases can't go in the @objc_classes list, since // they need runtime initialization before they're valid. @@ -19,7 +19,7 @@ class Base { } } -// CHECK-LABEL: define hidden %swift.type* @"$S3foo12SuperDerivedCMa"() +// CHECK-LABEL: define hidden swiftcc %swift.metadata_response @"$S3foo12SuperDerivedCMa"( // CHECK: [[CACHE:%.*]] = load %swift.type*, %swift.type** @"$S3foo12SuperDerivedCML" // CHECK-NEXT: [[COND:%.*]] = icmp eq %swift.type* [[CACHE]], null // CHECK-NEXT: br i1 [[COND]], label %cacheIsNull, label %cont @@ -30,12 +30,14 @@ class Base { // CHECK-NEXT: br label %cont // CHECK: cont: // CHECK-NEXT: [[RESULT:%.*]] = phi %swift.type* [ [[CACHE]], %entry ], [ [[METADATA]], %cacheIsNull ] -// CHECK-NEXT: ret %swift.type* [[RESULT]] +// CHECK-NEXT: [[T0:%.*]] = insertvalue %swift.metadata_response undef, %swift.type* [[RESULT]], 0 +// CHECK-NEXT: [[T1:%.*]] = insertvalue %swift.metadata_response [[T0]], [[INT]] 0, 1 +// CHECK-NEXT: ret %swift.metadata_response [[T1]] class SuperDerived: Derived { } -// CHECK-LABEL: define hidden %swift.type* @"$S3foo7DerivedCMa"() +// CHECK-LABEL: define hidden swiftcc %swift.metadata_response @"$S3foo7DerivedCMa"( // CHECK: [[CACHE:%.*]] = load %swift.type*, %swift.type** @"$S3foo7DerivedCML" // CHECK-NEXT: [[COND:%.*]] = icmp eq %swift.type* [[CACHE]], null // CHECK-NEXT: br i1 [[COND]], label %cacheIsNull, label %cont @@ -46,7 +48,9 @@ class SuperDerived: Derived { // CHECK-NEXT: br label %cont // CHECK: cont: // CHECK-NEXT: [[RESULT:%.*]] = phi %swift.type* [ [[CACHE]], %entry ], [ [[METADATA]], %cacheIsNull ] -// CHECK-NEXT: ret %swift.type* [[RESULT]] +// CHECK-NEXT: [[T0:%.*]] = insertvalue %swift.metadata_response undef, %swift.type* [[RESULT]], 0 +// CHECK-NEXT: [[T1:%.*]] = insertvalue %swift.metadata_response [[T0]], [[INT]] 0, 1 +// CHECK-NEXT: ret %swift.metadata_response [[T1]] class Derived: Base { var third: String @@ -72,7 +76,8 @@ presentBase(Base(x: "two")) presentBase(Base(x: 2)) // CHECK-LABEL: define{{( protected)?}} private void @initialize_metadata_SuperDerived(i8*) -// CHECK: [[TMP:%.*]] = call %swift.type* @"$S3foo7DerivedCMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S3foo7DerivedCMa"([[INT]] 0) +// CHECK: [[TMP:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: store %swift.type* [[TMP]], %swift.type** getelementptr inbounds ({{.*}} @"$S3foo12SuperDerivedCMf{{.*}}, i32 1), align // CHECK: [[METADATA:%.*]] = call %swift.type* @swift_relocateClassMetadata({{.*}}, [[INT]] {{60|96}}, [[INT]] 0) // CHECK: call void @swift_initClassMetadata_UniversalStrategy(%swift.type* [[METADATA]], [[INT]] 0, {{.*}}) diff --git a/test/IRGen/conformance_access_path.swift b/test/IRGen/conformance_access_path.swift index e3b9eb6e270..0a31c581244 100644 --- a/test/IRGen/conformance_access_path.swift +++ b/test/IRGen/conformance_access_path.swift @@ -21,7 +21,7 @@ extension Validatable { // CHECK-NEXT: [[S_VALIDATABLE_ADDR:%[0-9]+]] = getelementptr inbounds i8*, i8** [[S_VALIDATOR_BASE]], i32 2 // CHECK-NEXT: [[S_VALIDATABLE_FN_RAW:%[0-9]+]] = load i8*, i8** [[S_VALIDATABLE_ADDR]] // CHECK-NEXT: [[S_VALIDATABLE_FN:%[0-9]+]] = bitcast i8* [[S_VALIDATABLE_FN_RAW]] to i8** (%swift.type*, %swift.type*, i8**)* - // CHECK-NEXT: call i8** [[S_VALIDATABLE_FN]](%swift.type* %Self, %swift.type* %S, i8** %S.Validator) + // CHECK-NEXT: call swiftcc i8** [[S_VALIDATABLE_FN]](%swift.type* %Self, %swift.type* %S, i8** %S.Validator) tested() } } diff --git a/test/IRGen/dllexport.swift b/test/IRGen/dllexport.swift index a8523a60a5d..90b0c9bf07e 100644 --- a/test/IRGen/dllexport.swift +++ b/test/IRGen/dllexport.swift @@ -40,8 +40,8 @@ open class d { // CHECK-DAG-NO-OPT: define dllexport swiftcc void @"$S9dllexport1dC1m33_C57BA610BA35E21738CC992438E660E9LLyyF"(%T9dllexport1dC*) // CHECK-DAG-NO-OPT: define dllexport swiftcc void @"$S9dllexport1dCfD"(%T9dllexport1dC*) // CHECK-DAG: define dllexport swiftcc %swift.refcounted* @"$S9dllexport1dCfd"(%T9dllexport1dC*{{.*}}) -// CHECK-DAG: define dllexport %swift.type* @"$S9dllexport1cCMa"() -// CHECK-DAG: define dllexport %swift.type* @"$S9dllexport1dCMa"() +// CHECK-DAG: define dllexport swiftcc %swift.metadata_response @"$S9dllexport1cCMa"(i32) +// CHECK-DAG: define dllexport swiftcc %swift.metadata_response @"$S9dllexport1dCMa"(i32) // CHECK-DAG-NO-OPT: define dllexport swiftcc %T9dllexport1dC* @"$S9dllexport1dCACycfc"(%T9dllexport1dC*) // CHECK-DAG-OPT: define dllexport swiftcc void @"$S9dllexport1dCfD"(%T9dllexport1dC*) diff --git a/test/IRGen/dllimport.swift b/test/IRGen/dllimport.swift index b46c279304f..5fc13a0ed21 100644 --- a/test/IRGen/dllimport.swift +++ b/test/IRGen/dllimport.swift @@ -46,7 +46,7 @@ public func g() { // CHECK-NO-OPT-DAG: @"$SBoWV" = external dllimport global i8* // CHECK-NO-OPT-DAG: declare dllimport swiftcc i8* @"$S9dllexport2ciAA1cCvau"() // CHECK-NO-OPT-DAG: declare dllimport swiftcc %swift.refcounted* @"$S9dllexport1cCfd"(%T9dllexport1cC* swiftself) -// CHECK-NO-OPT-DAG: declare dllimport %swift.type* @"$S9dllexport1cCMa"() +// CHECK-NO-OPT-DAG: declare dllimport swiftcc %swift.metadata_response @"$S9dllexport1cCMa"(i32) // CHECK-NO-OPT-DAG: declare dllimport void @swift_deallocClassInstance(%swift.refcounted*, i32, i32) // CHECK-OPT-DAG: declare dllimport %swift.refcounted* @swift_retain(%swift.refcounted* returned) local_unnamed_addr @@ -54,6 +54,6 @@ public func g() { // CHECK-OPT-DAG: @"$S9dllexport1cCN" = external dllimport global %swift.type // CHECK-OPT-DAG: @"__imp_$S9dllexport1pMp" = external externally_initialized constant %swift.protocol* // CHECK-OPT-DAG: declare dllimport swiftcc i8* @"$S9dllexport2ciAA1cCvau"() -// CHECK-OPT-DAG: declare dllimport %swift.type* @"$S9dllexport1cCMa"() +// CHECK-OPT-DAG: declare dllimport swiftcc %swift.metadata_response @"$S9dllexport1cCMa"(i32) // CHECK-OPT-DAG: declare dllimport void @swift_deallocClassInstance(%swift.refcounted*, i32, i32) // CHECK-OPT-DAG: declare dllimport swiftcc %swift.refcounted* @"$S9dllexport1cCfd"(%T9dllexport1cC* swiftself) diff --git a/test/IRGen/dynamic_cast.sil b/test/IRGen/dynamic_cast.sil index dc35f9ba5c1..2e55f28497e 100644 --- a/test/IRGen/dynamic_cast.sil +++ b/test/IRGen/dynamic_cast.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s -DINT=i%target-ptrsize // REQUIRES: CPU=i386 || CPU=x86_64 @@ -17,16 +17,15 @@ struct S { var v: Int } -// CHECK: [[INT:%TSi]] = type <{ [[LLVM_PTRSIZE_INT:i(32|64)]] }> - // CHECK-LABEL: define{{( protected)?}} swiftcc void @testUnconditional0( sil @testUnconditional0 : $@convention(thin) (@in P) -> () { bb0(%0 : $*P): // CHECK: [[T0:%.*]] = alloca [[S:%.*]], align // CHECK: [[T1:%.*]] = bitcast [[S]]* [[T0]] to [[OPAQUE:%swift.opaque]]* // CHECK: [[T2:%.*]] = bitcast [[P:%.*]]* {{%.*}} to [[OPAQUE]]* - // CHECK: [[T3:%.*]] = call [[TYPE:%.*]]* @"$S12dynamic_cast1P_pMa"() - // CHECK: call i1 @swift_dynamicCast([[OPAQUE]]* [[T1]], [[OPAQUE]]* [[T2]], [[TYPE]]* [[T3]], [[TYPE]]* {{.*}}, [[LLVM_PTRSIZE_INT]] 7) + // CHECK: [[T3:%.*]] = call swiftcc %swift.metadata_response @"$S12dynamic_cast1P_pMa"([[INT]] 0) + // CHECK: [[T4:%.*]] = extractvalue %swift.metadata_response [[T3]], 0 + // CHECK: call i1 @swift_dynamicCast([[OPAQUE]]* [[T1]], [[OPAQUE]]* [[T2]], %swift.type* [[T4]], %swift.type* {{.*}}, [[INT]] 7) %1 = alloc_stack $S unconditional_checked_cast_addr P in %0 : $*P to S in %1 : $*S destroy_addr %1 : $*S @@ -35,7 +34,7 @@ bb0(%0 : $*P): return %2 : $() } -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$S12dynamic_cast1P_pMa"() +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$S12dynamic_cast1P_pMa"( // CHECK: call %swift.type* @swift_getExistentialTypeMetadata( // CHECK-LABEL: define{{( protected)?}} swiftcc void @testUnconditional1( @@ -44,8 +43,9 @@ bb0(%0 : $*P): // CHECK: [[T0:%.*]] = alloca [[S:%.*]], align // CHECK: [[T1:%.*]] = bitcast [[S]]* [[T0]] to [[OPAQUE:%swift.opaque]]* // CHECK: [[T2:%.*]] = bitcast [[P:%.*]]* {{%.*}} to [[OPAQUE]]* - // CHECK: [[T3:%.*]] = call [[TYPE:%.*]]* @"$S12dynamic_cast1P_pMa"() - // CHECK: call i1 @swift_dynamicCast([[OPAQUE]]* [[T1]], [[OPAQUE]]* [[T2]], [[TYPE]]* [[T3]], [[TYPE]]* {{.*}}, [[LLVM_PTRSIZE_INT]] 7) + // CHECK: [[T3:%.*]] = call swiftcc %swift.metadata_response @"$S12dynamic_cast1P_pMa"([[INT]] 0) + // CHECK: [[T4:%.*]] = extractvalue %swift.metadata_response [[T3]], 0 + // CHECK: call i1 @swift_dynamicCast([[OPAQUE]]* [[T1]], [[OPAQUE]]* [[T2]], %swift.type* [[T4]], %swift.type* {{.*}}, [[INT]] 7) %1 = alloc_stack $S unconditional_checked_cast_addr P in %0 : $*P to S in %1 : $*S destroy_addr %1 : $*S @@ -60,9 +60,10 @@ bb0(%0 : $*P): // CHECK: [[T0:%.*]] = alloca [[S:%.*]], align // CHECK: [[T1:%.*]] = bitcast [[S]]* [[T0]] to [[OPAQUE:%swift.opaque]]* // CHECK: [[T2:%.*]] = bitcast [[P:%.*]]* {{%.*}} to [[OPAQUE]]* - // CHECK: [[T3:%.*]] = call [[TYPE:%.*]]* @"$S12dynamic_cast1P_pMa"() - // CHECK: [[T4:%.*]] = call i1 @swift_dynamicCast([[OPAQUE]]* [[T1]], [[OPAQUE]]* [[T2]], [[TYPE]]* [[T3]], [[TYPE]]* {{.*}}, [[LLVM_PTRSIZE_INT]] 6) - // CHECK: br i1 [[T4]], + // CHECK: [[T3:%.*]] = call swiftcc %swift.metadata_response @"$S12dynamic_cast1P_pMa"([[INT]] 0) + // CHECK: [[T4:%.*]] = extractvalue %swift.metadata_response [[T3]], 0 + // CHECK: [[T5:%.*]] = call i1 @swift_dynamicCast([[OPAQUE]]* [[T1]], [[OPAQUE]]* [[T2]], %swift.type* [[T4]], %swift.type* {{.*}}, [[INT]] 6) + // CHECK: br i1 [[T5]], %1 = alloc_stack $S checked_cast_addr_br take_always P in %0 : $*P to S in %1 : $*S, bb1, bb2 bb1: @@ -80,9 +81,10 @@ bb0(%0 : $*P): // CHECK: [[T0:%.*]] = alloca [[S:%.*]], align // CHECK: [[T1:%.*]] = bitcast [[S]]* [[T0]] to [[OPAQUE:%swift.opaque]]* // CHECK: [[T2:%.*]] = bitcast [[P:%.*]]* {{%.*}} to [[OPAQUE]]* - // CHECK: [[T3:%.*]] = call [[TYPE:%.*]]* @"$S12dynamic_cast1P_pMa"() - // CHECK: [[T4:%.*]] = call i1 @swift_dynamicCast([[OPAQUE]]* [[T1]], [[OPAQUE]]* [[T2]], [[TYPE]]* [[T3]], [[TYPE]]* {{.*}}, [[LLVM_PTRSIZE_INT]] 2) - // CHECK: br i1 [[T4]], + // CHECK: [[T3:%.*]] = call swiftcc %swift.metadata_response @"$S12dynamic_cast1P_pMa"([[INT]] 0) + // CHECK: [[T4:%.*]] = extractvalue %swift.metadata_response [[T3]], 0 + // CHECK: [[T5:%.*]] = call i1 @swift_dynamicCast([[OPAQUE]]* [[T1]], [[OPAQUE]]* [[T2]], %swift.type* [[T4]], %swift.type* {{.*}}, [[INT]] 2) + // CHECK: br i1 [[T5]], %1 = alloc_stack $S checked_cast_addr_br take_on_success P in %0 : $*P to S in %1 : $*S, bb1, bb2 bb1: @@ -100,9 +102,10 @@ bb0(%0 : $*P): // CHECK: [[T0:%.*]] = alloca [[S:%.*]], align // CHECK: [[T1:%.*]] = bitcast [[S]]* [[T0]] to [[OPAQUE:%swift.opaque]]* // CHECK: [[T2:%.*]] = bitcast [[P:%.*]]* {{%.*}} to [[OPAQUE]]* - // CHECK: [[T3:%.*]] = call [[TYPE:%.*]]* @"$S12dynamic_cast1P_pMa"() - // CHECK: [[T4:%.*]] = call i1 @swift_dynamicCast([[OPAQUE]]* [[T1]], [[OPAQUE]]* [[T2]], [[TYPE]]* [[T3]], [[TYPE]]* {{.*}}, [[LLVM_PTRSIZE_INT]] 0) - // CHECK: br i1 [[T4]], + // CHECK: [[T3:%.*]] = call swiftcc %swift.metadata_response @"$S12dynamic_cast1P_pMa"([[INT]] 0) + // CHECK: [[T4:%.*]] = extractvalue %swift.metadata_response [[T3]], 0 + // CHECK: [[T5:%.*]] = call i1 @swift_dynamicCast([[OPAQUE]]* [[T1]], [[OPAQUE]]* [[T2]], %swift.type* [[T4]], %swift.type* {{.*}}, [[INT]] 0) + // CHECK: br i1 [[T5]], %1 = alloc_stack $S checked_cast_addr_br copy_on_success P in %0 : $*P to S in %1 : $*S, bb1, bb2 bb1: diff --git a/test/IRGen/dynamic_self_metadata.swift b/test/IRGen/dynamic_self_metadata.swift index 92d3406938e..e49e913ec93 100644 --- a/test/IRGen/dynamic_self_metadata.swift +++ b/test/IRGen/dynamic_self_metadata.swift @@ -27,6 +27,7 @@ class C { // CHECK-LABEL: define hidden swiftcc i64 @"$S21dynamic_self_metadata1CC0A12SelfArgumentACXDSgyF"(%T21dynamic_self_metadata1CC* swiftself) // CHECK: [[CAST1:%.+]] = bitcast %T21dynamic_self_metadata1CC* %0 to [[METATYPE:%.+]] // CHECK: [[TYPE1:%.+]] = call %swift.type* @swift_getObjectType([[METATYPE]] [[CAST1]]) - // CHECK: [[TYPE2:%.+]] = call %swift.type* @"$SSqMa"(%swift.type* [[TYPE1]]) + // CHECK: [[T0:%.+]] = call swiftcc %swift.metadata_response @"$SSqMa"(i64 0, %swift.type* [[TYPE1]]) + // CHECK: [[TYPE2:%.+]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: call swiftcc void @"$S21dynamic_self_metadata2idyxxlF"({{.*}}, %swift.type* [[TYPE2]]) } diff --git a/test/IRGen/enum.sil b/test/IRGen/enum.sil index 3d10927f94e..31337a29828 100644 --- a/test/IRGen/enum.sil +++ b/test/IRGen/enum.sil @@ -2684,21 +2684,21 @@ entry(%x : $*MyOptional): // CHECK: [[METADATA:%.*]] = call %swift.type* @swift_allocateGenericValueMetadata(%swift.type_descriptor* %0, i8** %1, i8** %2, [[WORD]] {{4|8}}) // CHECK-NEXT: ret %swift.type* [[METADATA]] -// CHECK-LABEL: define{{( protected)?}} internal %swift.type* @"$S4enum16DynamicSingletonOMr" +// CHECK-LABEL: define{{( protected)?}} internal swiftcc %swift.metadata_response @"$S4enum16DynamicSingletonOMr" // CHECK-SAME: (%swift.type* [[METADATA:%.*]], i8*, i8**) {{.*}} { // CHECK: [[T_VWTS:%.*]] = bitcast %swift.type* [[T]] to i8*** // CHECK: [[T_VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[T_VWTS]], [[WORD]] -1 // CHECK: [[T_VWT:%.*]] = load i8**, i8*** [[T_VWT_ADDR]] // CHECK: [[T_LAYOUT:%.*]] = getelementptr inbounds i8*, i8** [[T_VWT]], i32 9 // CHECK: call void @swift_initEnumMetadataSingleCase(%swift.type* [[METADATA]], [[WORD]] 0, i8** [[T_LAYOUT]]) -// CHECK: ret %swift.type* null +// CHECK: ret %swift.metadata_response zeroinitializer // -- Fill function for dynamic single-payload. Call into the runtime to // calculate the size. // CHECK-LABEL: define{{( protected)?}} internal %swift.type* @"$S4enum20DynamicSinglePayloadOMi" // CHECK: [[METADATA:%.*]] = call %swift.type* @swift_allocateGenericValueMetadata -// CHECK-LABEL: define{{( protected)?}} internal %swift.type* @"$S4enum20DynamicSinglePayloadOMr" +// CHECK-LABEL: define{{( protected)?}} internal swiftcc %swift.metadata_response @"$S4enum20DynamicSinglePayloadOMr" // CHECK-SAME: (%swift.type* [[METADATA:%.*]], i8*, i8**) {{.*}} { // CHECK: [[T_VWTS:%.*]] = bitcast %swift.type* [[T]] to i8*** // CHECK: [[T_VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[T_VWTS]], [[WORD]] -1 diff --git a/test/IRGen/enum_dynamic_multi_payload.sil b/test/IRGen/enum_dynamic_multi_payload.sil index 089ade9340b..bec3c168438 100644 --- a/test/IRGen/enum_dynamic_multi_payload.sil +++ b/test/IRGen/enum_dynamic_multi_payload.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -gnone -emit-ir -I %S/Inputs | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -gnone -emit-ir -I %S/Inputs | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -DINT=i%target-ptrsize import Builtin @@ -420,7 +420,7 @@ entry(%a : $*EitherOr, %b : $*EitherOr): // CHECK: define{{( protected)?}} internal %swift.type* @"$S26enum_dynamic_multi_payload8EitherOrOMi"(%swift.type_descriptor*, i8**, i8**) {{.*}} { // CHECK: [[METADATA:%.*]] = call %swift.type* @swift_allocateGenericValueMetadata -// CHECK: define{{( protected)?}} internal %swift.type* @"$S26enum_dynamic_multi_payload8EitherOrOMr" +// CHECK: define{{( protected)?}} internal swiftcc %swift.metadata_response @"$S26enum_dynamic_multi_payload8EitherOrOMr" // CHECK-SAME: (%swift.type* [[METADATA:%.*]], i8*, i8**) {{.*}} { // CHECK: [[BUF:%.*]] = alloca [2 x i8**] diff --git a/test/IRGen/enum_resilience.swift b/test/IRGen/enum_resilience.swift index 359164c3855..df187bda9e3 100644 --- a/test/IRGen/enum_resilience.swift +++ b/test/IRGen/enum_resilience.swift @@ -3,14 +3,12 @@ // RUN: %empty-directory(%t) // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_enum.swiftmodule -module-name=resilient_enum -I %t %S/../Inputs/resilient_enum.swift -// RUN: %target-swift-frontend -module-name enum_resilience -I %t -emit-ir -enable-resilience %s | %FileCheck %s +// RUN: %target-swift-frontend -module-name enum_resilience -I %t -emit-ir -enable-resilience %s | %FileCheck %s -DINT=i%target-ptrsize // RUN: %target-swift-frontend -module-name enum_resilience -I %t -emit-ir -enable-resilience -O %s import resilient_enum import resilient_struct -// CHECK: %swift.type = type { [[INT:i32|i64]] } - // CHECK: %T15enum_resilience5ClassC = type <{ %swift.refcounted }> // CHECK: %T15enum_resilience9ReferenceV = type <{ %T15enum_resilience5ClassC* }> @@ -67,9 +65,10 @@ enum InternalEither { // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S15enum_resilience25functionWithResilientEnumy010resilient_A06MediumOAEF"(%swift.opaque* noalias nocapture sret, %swift.opaque* noalias nocapture) public func functionWithResilientEnum(_ m: Medium) -> Medium { -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S14resilient_enum6MediumOMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S14resilient_enum6MediumOMa"([[INT]] 0) +// CHECK-NEXT: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[METADATA_ADDR:%.*]] = bitcast %swift.type* [[METADATA]] to i8*** -// CHECK-NEXT: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR]], [[INT:i32|i64]] -1 +// CHECK-NEXT: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR]], [[INT]] -1 // CHECK-NEXT: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]] // CHECK-NEXT: [[WITNESS_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], i32 4 // CHECK-NEXT: [[WITNESS:%.*]] = load i8*, i8** [[WITNESS_ADDR]] @@ -83,9 +82,10 @@ public func functionWithResilientEnum(_ m: Medium) -> Medium { // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S15enum_resilience33functionWithIndirectResilientEnumy010resilient_A00E8ApproachOAEF"(%swift.opaque* noalias nocapture sret, %swift.opaque* noalias nocapture) public func functionWithIndirectResilientEnum(_ ia: IndirectApproach) -> IndirectApproach { -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S14resilient_enum16IndirectApproachOMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S14resilient_enum16IndirectApproachOMa"([[INT]] 0) +// CHECK-NEXT: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[METADATA_ADDR:%.*]] = bitcast %swift.type* [[METADATA]] to i8*** -// CHECK-NEXT: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR]], [[INT:i32|i64]] -1 +// CHECK-NEXT: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR]], [[INT]] -1 // CHECK-NEXT: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]] // CHECK-NEXT: [[WITNESS_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], i32 4 // CHECK-NEXT: [[WITNESS:%.*]] = load i8*, i8** [[WITNESS_ADDR]] @@ -98,9 +98,10 @@ public func functionWithIndirectResilientEnum(_ ia: IndirectApproach) -> Indirec // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S15enum_resilience31constructResilientEnumNoPayload010resilient_A06MediumOyF" public func constructResilientEnumNoPayload() -> Medium { -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S14resilient_enum6MediumOMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S14resilient_enum6MediumOMa"([[INT]] 0) +// CHECK-NEXT: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[METADATA_ADDR:%.*]] = bitcast %swift.type* [[METADATA]] to i8*** -// CHECK-NEXT: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR]], [[INT:i32|i64]] -1 +// CHECK-NEXT: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR]], [[INT]] -1 // CHECK-NEXT: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]] // CHECK-NEXT: [[WITNESS_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], i32 17 @@ -114,9 +115,10 @@ public func constructResilientEnumNoPayload() -> Medium { // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S15enum_resilience29constructResilientEnumPayloady010resilient_A06MediumO0G7_struct4SizeVF" public func constructResilientEnumPayload(_ s: Size) -> Medium { -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S16resilient_struct4SizeVMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S16resilient_struct4SizeVMa"([[INT]] 0) +// CHECK-NEXT: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[METADATA_ADDR:%.*]] = bitcast %swift.type* [[METADATA]] to i8*** -// CHECK-NEXT: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR]], [[INT:i32|i64]] -1 +// CHECK-NEXT: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR]], [[INT]] -1 // CHECK-NEXT: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]] // CHECK-NEXT: [[WITNESS_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], i32 2 @@ -124,9 +126,10 @@ public func constructResilientEnumPayload(_ s: Size) -> Medium { // CHECK-NEXT: [[WITNESS_FN:%.*]] = bitcast i8* [[WITNESS]] // CHECK-NEXT: [[COPY:%.*]] = call %swift.opaque* %initializeWithCopy(%swift.opaque* noalias %0, %swift.opaque* noalias %1, %swift.type* [[METADATA]]) -// CHECK-NEXT: [[METADATA2:%.*]] = call %swift.type* @"$S14resilient_enum6MediumOMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S14resilient_enum6MediumOMa"([[INT]] 0) +// CHECK-NEXT: [[METADATA2:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[METADATA_ADDR2:%.*]] = bitcast %swift.type* [[METADATA2]] to i8*** -// CHECK-NEXT: [[VWT_ADDR2:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR2]], [[INT:i32|i64]] -1 +// CHECK-NEXT: [[VWT_ADDR2:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR2]], [[INT]] -1 // CHECK-NEXT: [[VWT2:%.*]] = load i8**, i8*** [[VWT_ADDR2]] // CHECK-NEXT: [[WITNESS_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[VWT2]], i32 17 @@ -144,7 +147,8 @@ public func constructResilientEnumPayload(_ s: Size) -> Medium { } // CHECK-LABEL: define{{( protected)?}} swiftcc {{i32|i64}} @"$S15enum_resilience19resilientSwitchTestySi0c1_A06MediumOF"(%swift.opaque* noalias nocapture) -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S14resilient_enum6MediumOMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S14resilient_enum6MediumOMa"([[INT]] 0) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: [[METADATA_ADDR:%.*]] = bitcast %swift.type* [[METADATA]] to i8*** // CHECK: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR]], [[INT]] -1 // CHECK: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]] @@ -228,7 +232,8 @@ public enum EnumWithResilientPayload { // resilient layout. // CHECK-LABEL: define{{( protected)?}} swiftcc %swift.type* @"$S15enum_resilience20getResilientEnumTypeypXpyF"() -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S15enum_resilience24EnumWithResilientPayloadOMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S15enum_resilience24EnumWithResilientPayloadOMa"([[INT]] 0) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: ret %swift.type* [[METADATA]] public func getResilientEnumType() -> Any.Type { @@ -236,7 +241,7 @@ public func getResilientEnumType() -> Any.Type { } // Public metadata accessor for our resilient enum -// CHECK-LABEL: define{{( protected)?}} %swift.type* @"$S15enum_resilience24EnumWithResilientPayloadOMa"() +// CHECK-LABEL: define{{( protected)?}} swiftcc %swift.metadata_response @"$S15enum_resilience24EnumWithResilientPayloadOMa"( // CHECK: [[METADATA:%.*]] = load %swift.type*, %swift.type** @"$S15enum_resilience24EnumWithResilientPayloadOML" // CHECK-NEXT: [[COND:%.*]] = icmp eq %swift.type* [[METADATA]], null // CHECK-NEXT: br i1 [[COND]], label %cacheIsNull, label %cont @@ -248,7 +253,6 @@ public func getResilientEnumType() -> Any.Type { // CHECK: cont: // CHECK-NEXT: [[RESULT:%.*]] = phi %swift.type* [ [[METADATA]], %entry ], [ [[METADATA2]], %cacheIsNull ] -// CHECK-NEXT: ret %swift.type* [[RESULT]] // Methods inside extensions of resilient enums fish out type parameters // from metadata -- make sure we can do that diff --git a/test/IRGen/extension_type_metadata_linking.swift b/test/IRGen/extension_type_metadata_linking.swift index 1c3ff9da48a..356213647ff 100644 --- a/test/IRGen/extension_type_metadata_linking.swift +++ b/test/IRGen/extension_type_metadata_linking.swift @@ -25,11 +25,11 @@ import Foundation // CHECK-LABEL: @"$SSo8NSNumberC31extension_type_metadata_linkingE7DerivedCN" = alias // CHECK-LABEL: @"$SSo8NSNumberC31extension_type_metadata_linkingE6StructVN" = alias -// CHECK-LABEL: define %swift.type* @"$SSo8NSNumberC31extension_type_metadata_linkingE4BaseCMa"() -// CHECK-LABEL: define %swift.type* @"$SSo8NSNumberC31extension_type_metadata_linkingE7DerivedCMa" +// CHECK-LABEL: define swiftcc %swift.metadata_response @"$SSo8NSNumberC31extension_type_metadata_linkingE4BaseCMa" +// CHECK-LABEL: define swiftcc %swift.metadata_response @"$SSo8NSNumberC31extension_type_metadata_linkingE7DerivedCMa" // FIXME: Not needed -// CHECK-LABEL: define %swift.type* @"$SSo8NSNumberC31extension_type_metadata_linkingE6StructVMa" +// CHECK-LABEL: define swiftcc %swift.metadata_response @"$SSo8NSNumberC31extension_type_metadata_linkingE6StructVMa" extension NSNumber { public class Base : CustomStringConvertible { diff --git a/test/IRGen/foreign_types.sil b/test/IRGen/foreign_types.sil index b82a51f6e5a..4f95ddae0fb 100644 --- a/test/IRGen/foreign_types.sil +++ b/test/IRGen/foreign_types.sil @@ -37,8 +37,8 @@ bb0: return %ret : $() } -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$SSo14HasNestedUnionVMa +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$SSo14HasNestedUnionVMa"( // CHECK: call %swift.type* @swift_getForeignTypeMetadata{{.*}}$SSo14HasNestedUnionVN -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$SSo12AmazingColorVMa"() +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$SSo12AmazingColorVMa"( // CHECK: call %swift.type* @swift_getForeignTypeMetadata{{.*}}@"$SSo12AmazingColorVN" diff --git a/test/IRGen/function_metadata.swift b/test/IRGen/function_metadata.swift index 1a45ecc8dd6..40207018e6a 100644 --- a/test/IRGen/function_metadata.swift +++ b/test/IRGen/function_metadata.swift @@ -4,33 +4,43 @@ func arch(_ f: F) {} // CHECK: define hidden swiftcc void @"$S17function_metadata9test_archyyF"() func test_arch() { + // CHECK-LABEL: define{{( protected)?}} linkonce_odr hidden swiftcc %swift.metadata_response @"$SyycMa" // CHECK: call %swift.type* @swift_getFunctionTypeMetadata0([[WORD:i(32|64)]] 67108864, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) arch( {() -> () in } ) + // CHECK-LABEL: define{{( protected)?}} linkonce_odr hidden swiftcc %swift.metadata_response @"$SySicMa" // CHECK: call %swift.type* @swift_getFunctionTypeMetadata1([[WORD:i(32|64)]] 67108865, %swift.type* @"$SSiN", %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) {{#[0-9]+}} arch({(x: Int) -> () in }) + // CHECK-LABEL: define{{( protected)?}} linkonce_odr hidden swiftcc %swift.metadata_response @"$Syyt_tcMa" // CHECK: call %swift.type* @swift_getFunctionTypeMetadata1([[WORD]] 67108865, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1), %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) arch({(_: ()) -> () in }) - // CHECK: call %swift.type* @swift_getFunctionTypeMetadata([[WORD]] 100663297, %swift.type** %3, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @parameter-flags, i32 0, i32 0), %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) + // CHECK-LABEL: define{{( protected)?}} linkonce_odr hidden swiftcc %swift.metadata_response @"$SySizcMa" + // CHECK: call %swift.type* @swift_getFunctionTypeMetadata([[WORD]] 100663297, %swift.type** {{%.*}}, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @parameter-flags, i32 0, i32 0), %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) arch({(x: inout Int) -> () in }) - // CHECK: call %swift.type* @swift_getFunctionTypeMetadata1([[WORD]] 67108865, %swift.type* %2, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) + // CHECK-LABEL: define{{( protected)?}} linkonce_odr hidden swiftcc %swift.metadata_response @"$SySi_Sft_tcMa" + // CHECK: call %swift.type* @swift_getFunctionTypeMetadata1([[WORD]] 67108865, %swift.type* {{%.*}}, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) arch({(x: (Int, Float)) -> () in }) - // CHECK: call %swift.type* @swift_getFunctionTypeMetadata([[WORD]] 100663298, %swift.type** %3, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @parameter-flags.17, i32 0, i32 0), %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) + // CHECK-LABEL: define{{( protected)?}} linkonce_odr hidden swiftcc %swift.metadata_response @"$SySiz_SitcMa" + // CHECK: call %swift.type* @swift_getFunctionTypeMetadata([[WORD]] 100663298, %swift.type** {{%.*}}, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @parameter-flags.17, i32 0, i32 0), %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) arch({(x: inout Int, y: Int) -> () in }) + // CHECK-LABEL: define{{( protected)?}} linkonce_odr hidden swiftcc %swift.metadata_response @"$SySf_SitcMa" // CHECK: call %swift.type* @swift_getFunctionTypeMetadata2([[WORD]] 67108866, %swift.type* @"$SSfN", %swift.type* @"$SSiN", %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) arch({(a: Float, b: Int) -> () in }) - // CHECK: call %swift.type* @swift_getFunctionTypeMetadata([[WORD]] 100663299, %swift.type** %3, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @parameter-flags.24, i32 0, i32 0), %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) + // CHECK-LABEL: define{{( protected)?}} linkonce_odr hidden swiftcc %swift.metadata_response @"$SySiz_SfSStcMa" + // CHECK: call %swift.type* @swift_getFunctionTypeMetadata([[WORD]] 100663299, %swift.type** {{%.*}}, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @parameter-flags.24, i32 0, i32 0), %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) arch({(x: inout Int, y: Float, z: String) -> () in }) + // CHECK-LABEL: define{{( protected)?}} linkonce_odr hidden swiftcc %swift.metadata_response @"$SySf_SfSitcMa" // CHECK: call %swift.type* @swift_getFunctionTypeMetadata3([[WORD]] 67108867, %swift.type* @"$SSfN", %swift.type* @"$SSfN", %swift.type* @"$SSiN", %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) arch({(a: Float, b: Float, c: Int) -> () in }) + // CHECK-LABEL: define{{( protected)?}} linkonce_odr hidden swiftcc %swift.metadata_response @"$SySiz_SdSSs4Int8VtcMa" // CHECK: getelementptr inbounds [4 x %swift.type*], [4 x %swift.type*]* %function-parameters, i32 0, i32 0 // CHECK: store %swift.type* @"$SSiN", %swift.type** [[T:%.*]], align [[ALIGN:(4|8)]] // CHECK: getelementptr inbounds [4 x %swift.type*], [4 x %swift.type*]* %function-parameters, i32 0, i32 1 @@ -39,6 +49,6 @@ func test_arch() { // CHECK: store %swift.type* @"$SSSN", %swift.type** [[T:%.*]], align [[ALIGN:(4|8)]] // CHECK: getelementptr inbounds [4 x %swift.type*], [4 x %swift.type*]* %function-parameters, i32 0, i32 3 // CHECK: store %swift.type* @"$Ss4Int8VN", %swift.type** [[T:%.*]], align [[ALIGN:(4|8)]] - // CHECK: call %swift.type* @swift_getFunctionTypeMetadata([[WORD]] 100663300, %swift.type** %3, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @parameter-flags.{{.*}}, i32 0, i32 0), %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) + // CHECK: call %swift.type* @swift_getFunctionTypeMetadata([[WORD]] 100663300, %swift.type** {{%.*}}, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @parameter-flags.{{.*}}, i32 0, i32 0), %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* @"$SytN", i32 0, i32 1)) arch({(x: inout Int, y: Double, z: String, w: Int8) -> () in }) } diff --git a/test/IRGen/generic_casts.swift b/test/IRGen/generic_casts.swift index 1459261b05d..a9253242165 100644 --- a/test/IRGen/generic_casts.swift +++ b/test/IRGen/generic_casts.swift @@ -100,7 +100,8 @@ func classExistentialToOpaqueArchetype(_ x: ObjCProto1) -> T { // CHECK: [[X:%.*]] = alloca %T13generic_casts10ObjCProto1P // CHECK: [[LOCAL:%.*]] = alloca %T13generic_casts10ObjCProto1P // CHECK: [[LOCAL_OPAQUE:%.*]] = bitcast %T13generic_casts10ObjCProto1P* [[LOCAL]] to %swift.opaque* - // CHECK: [[PROTO_TYPE:%.*]] = call %swift.type* @"$S13generic_casts10ObjCProto1_pMa"() + // CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S13generic_casts10ObjCProto1_pMa"(i64 0) + // CHECK: [[PROTO_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: call i1 @swift_dynamicCast(%swift.opaque* %0, %swift.opaque* [[LOCAL_OPAQUE]], %swift.type* [[PROTO_TYPE]], %swift.type* %T, i64 7) return x as! T } diff --git a/test/IRGen/generic_classes.sil b/test/IRGen/generic_classes.sil index 0d87d734b90..7b13979ea34 100644 --- a/test/IRGen/generic_classes.sil +++ b/test/IRGen/generic_classes.sil @@ -243,7 +243,8 @@ sil @$S15generic_classes024RecursiveGenericInheritsD0CfD : $@convention(method) // CHECK: define{{( protected)?}} swiftcc [[ROOTGENERIC]]* @RootGeneric_fragile_dependent_alloc -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S15generic_classes11RootGenericCMa" +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S15generic_classes11RootGenericCMa"(i64 0, %swift.type* %G) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: [[METADATA_ARRAY:%.*]] = bitcast %swift.type* [[METADATA]] to i8* // CHECK: [[T0:%.*]] = getelementptr inbounds i8, i8* [[METADATA_ARRAY]], i32 48 // CHECK: [[T1:%.*]] = bitcast i8* [[T0]] to i32* @@ -339,9 +340,9 @@ entry(%c : $RootGeneric): */ // CHECK-LABEL: define{{( protected)?}} internal %swift.type* @"$S15generic_classes11RootGenericCMi"(%swift.type_descriptor*, i8**, i8**) {{.*}} { -// CHECK: [[METADATA:%.*]] ={{( tail)?}} call %swift.type* @swift_allocateGenericClassMetadata(%swift.type_descriptor* %0, i8** %1, i8** %2) +// CHECK: [[METADATA:%.*]] = call{{( tail)?}} %swift.type* @swift_allocateGenericClassMetadata(%swift.type_descriptor* %0, i8** %1, i8** %2) -// CHECK-LABEL: define{{( protected)?}} internal %swift.type* @"$S15generic_classes11RootGenericCMr" +// CHECK-LABEL: define{{( protected)?}} internal swiftcc %swift.metadata_response @"$S15generic_classes11RootGenericCMr" // CHECK-SAME: (%swift.type* [[METADATA:%.*]], i8*, i8**) {{.*}} { // -- initialize the dependent field offsets // CHECK: call void @swift_initClassMetadata_UniversalStrategy(%swift.type* [[METADATA]], i64 3, i8*** {{%.*}}, i64* {{%.*}}) @@ -350,7 +351,7 @@ entry(%c : $RootGeneric): // CHECK-LABEL: define{{( protected)?}} internal %swift.type* @"$S15generic_classes22RootGenericFixedLayoutCMi"(%swift.type_descriptor*, i8**, i8**) {{.*}} { // CHECK: [[METADATA:%.*]] ={{( tail)?}} call %swift.type* @swift_allocateGenericClassMetadata(%swift.type_descriptor* %0, i8** %1, i8** %2) -// CHECK-LABEL: define{{( protected)?}} internal %swift.type* @"$S15generic_classes22RootGenericFixedLayoutCMr" +// CHECK-LABEL: define{{( protected)?}} internal swiftcc %swift.metadata_response @"$S15generic_classes22RootGenericFixedLayoutCMr" // CHECK-SAME: (%swift.type* [[METADATA:%.*]], i8*, i8**) {{.*}} { // CHECK: call void @swift_initClassMetadata_UniversalStrategy(%swift.type* [[METADATA]], i64 3, i8*** {{%.*}}, i64* {{%.*}}) // CHECK: } @@ -365,9 +366,10 @@ entry(%c : $RootGeneric): // CHECK: [[METADATA:%.*]] ={{( tail)?}} call %swift.type* @swift_allocateGenericClassMetadata(%swift.type_descriptor* %0, i8** %1, i8** %2) // CHECK-NEXT: ret %swift.type* [[METADATA]] -// CHECK-LABEL: define{{( protected)?}} internal %swift.type* @"$S15generic_classes015GenericInheritsC0CMr" +// CHECK-LABEL: define{{( protected)?}} internal swiftcc %swift.metadata_response @"$S15generic_classes015GenericInheritsC0CMr" // CHECK-SAME: (%swift.type* [[METADATA:%.*]], i8*, i8**) {{.*}} { -// CHECK: [[SUPER:%.*]] ={{( tail)?}} call %swift.type* @"$S15generic_classes11RootGenericCMa"(%swift.type* %A) +// CHECK: [[T0:%.*]] = call{{( tail)?}} swiftcc %swift.metadata_response @"$S15generic_classes11RootGenericCMa"(i64 0, %swift.type* %A) +// CHECK: [[SUPER:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: [[T0:%.*]] = bitcast %swift.type* [[METADATA]] to %swift.type** // CHECK: [[T1:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[T0]], i32 1 // CHECK: store %swift.type* [[SUPER]], %swift.type** [[T1]], @@ -382,8 +384,8 @@ entry(%c : $RootGeneric): // CHECK: [[T1:%.*]] = getelementptr inbounds i8**, i8*** [[FIELDS_ADDR]], i32 0 // CHECK: store i8** [[T0]], i8*** [[T1]], align 8 // CHECK: call void @swift_initClassMetadata_UniversalStrategy(%swift.type* [[METADATA]], i64 1, i8*** [[FIELDS_ADDR]], i64* [[OFFSETS]]) -// CHECK: ret %swift.type* null +// CHECK: ret %swift.metadata_response zeroinitializer // CHECK: } -// OSIZE: define hidden %swift.type* @"$S15generic_classes11RootGenericCMa"(%swift.type*) [[ATTRS:#[0-9]+]] { +// OSIZE: define hidden swiftcc %swift.metadata_response @"$S15generic_classes11RootGenericCMa"(i64, %swift.type*) [[ATTRS:#[0-9]+]] { // OSIZE: [[ATTRS]] = {{{.*}}noinline diff --git a/test/IRGen/generic_metatypes.swift b/test/IRGen/generic_metatypes.swift index 2f82e1dc358..efbff0c3573 100644 --- a/test/IRGen/generic_metatypes.swift +++ b/test/IRGen/generic_metatypes.swift @@ -1,14 +1,21 @@ // REQUIRES: plus_one_runtime -// RUN: %swift -module-name generic_metatypes -target x86_64-apple-macosx10.9 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 %s -// RUN: %swift -module-name generic_metatypes -target i386-apple-ios7.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 %s -// RUN: %swift -module-name generic_metatypes -target x86_64-apple-ios7.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 %s -// RUN: %swift -module-name generic_metatypes -target i386-apple-tvos9.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 %s -// RUN: %swift -module-name generic_metatypes -target x86_64-apple-tvos9.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 %s -// RUN: %swift -module-name generic_metatypes -target i386-apple-watchos2.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 %s -// RUN: %swift -module-name generic_metatypes -target x86_64-unknown-linux-gnu -disable-objc-interop -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 %s +// RUN: %swift -module-name generic_metatypes -target x86_64-apple-macosx10.9 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s +// RUN: %swift -module-name generic_metatypes -target i386-apple-ios7.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s +// RUN: %swift -module-name generic_metatypes -target x86_64-apple-ios7.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s +// RUN: %swift -module-name generic_metatypes -target i386-apple-tvos9.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s +// RUN: %swift -module-name generic_metatypes -target x86_64-apple-tvos9.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s +// RUN: %swift -module-name generic_metatypes -target i386-apple-watchos2.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s +// RUN: %swift -module-name generic_metatypes -target x86_64-unknown-linux-gnu -disable-objc-interop -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s + +// RUN: %swift -module-name generic_metatypes -target armv7-apple-ios7.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s +// RUN: %swift -module-name generic_metatypes -target arm64-apple-ios7.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s +// RUN: %swift -module-name generic_metatypes -target armv7-apple-tvos9.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s +// RUN: %swift -module-name generic_metatypes -target arm64-apple-tvos9.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s +// RUN: %swift -module-name generic_metatypes -target armv7k-apple-watchos2.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s // REQUIRES: CODEGENERATOR=X86 +// REQUIRES: CODEGENERATOR=ARM // CHECK: define hidden swiftcc %swift.type* [[GENERIC_TYPEOF:@"\$S17generic_metatypes0A6TypeofyxmxlF"]](%swift.opaque* noalias nocapture, %swift.type* [[TYPE:%.*]]) func genericTypeof(_ x: T) -> T.Type { @@ -25,8 +32,9 @@ func remapToSubstitutedMetatypes(_ x: Foo, y: Bar) -> (Foo.Type, Bar.Type) { // CHECK: call swiftcc %swift.type* [[GENERIC_TYPEOF]](%swift.opaque* noalias nocapture undef, %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}) - // CHECK: [[T0:%.*]] = call %swift.type* @"$S17generic_metatypes3BarCMa"() - // CHECK: [[BAR_META:%.*]] = call swiftcc %swift.type* [[GENERIC_TYPEOF]](%swift.opaque* noalias nocapture {{%.*}}, %swift.type* [[T0]]) + // CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S17generic_metatypes3BarCMa"([[INT]] 0) + // CHECK: [[BAR:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 + // CHECK: [[BAR_META:%.*]] = call swiftcc %swift.type* [[GENERIC_TYPEOF]](%swift.opaque* noalias nocapture {{%.*}}, %swift.type* [[BAR]]) // CHECK: ret %swift.type* [[BAR_META]] return (genericTypeof(x), genericTypeof(y)) } @@ -34,8 +42,9 @@ func remapToSubstitutedMetatypes(_ x: Foo, y: Bar) // CHECK-LABEL: define hidden swiftcc void @"$S17generic_metatypes23remapToGenericMetatypesyyF"() func remapToGenericMetatypes() { - // CHECK: [[T0:%.*]] = call %swift.type* @"$S17generic_metatypes3BarCMa"() - // CHECK: call swiftcc void @"$S17generic_metatypes0A9Metatypes{{.*}}"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}} %swift.type* [[T0]], %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}} %swift.type* [[T0]]) + // CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S17generic_metatypes3BarCMa"([[INT]] 0) + // CHECK: [[BAR:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 + // CHECK: call swiftcc void @"$S17generic_metatypes0A9Metatypes{{.*}}"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}} %swift.type* [[BAR]], %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}} %swift.type* [[BAR]]) genericMetatypes(Foo.self, Bar.self) } @@ -86,95 +95,108 @@ func genericMetatype(_ x: A.Type) {} // CHECK-LABEL: define hidden swiftcc void @"$S17generic_metatypes20makeGenericMetatypesyyF"() {{.*}} { func makeGenericMetatypes() { - // CHECK: call %swift.type* @"$S17generic_metatypes6OneArgVyAA3FooVGMa"() [[NOUNWIND_READNONE:#[0-9]+]] + // CHECK: call swiftcc %swift.metadata_response @"$S17generic_metatypes6OneArgVyAA3FooVGMa"([[INT]] 0) [[NOUNWIND_READNONE:#[0-9]+]] genericMetatype(OneArg.self) - // CHECK: call %swift.type* @"$S17generic_metatypes7TwoArgsVyAA3FooVAA3BarCGMa"() [[NOUNWIND_READNONE]] + // CHECK: call swiftcc %swift.metadata_response @"$S17generic_metatypes7TwoArgsVyAA3FooVAA3BarCGMa"([[INT]] 0) [[NOUNWIND_READNONE]] genericMetatype(TwoArgs.self) - // CHECK: call %swift.type* @"$S17generic_metatypes9ThreeArgsVyAA3FooVAA3BarCAEGMa"() [[NOUNWIND_READNONE]] + // CHECK: call swiftcc %swift.metadata_response @"$S17generic_metatypes9ThreeArgsVyAA3FooVAA3BarCAEGMa"([[INT]] 0) [[NOUNWIND_READNONE]] genericMetatype(ThreeArgs.self) - // CHECK: call %swift.type* @"$S17generic_metatypes8FourArgsVyAA3FooVAA3BarCAeGGMa"() [[NOUNWIND_READNONE]] + // CHECK: call swiftcc %swift.metadata_response @"$S17generic_metatypes8FourArgsVyAA3FooVAA3BarCAeGGMa"([[INT]] 0) [[NOUNWIND_READNONE]] genericMetatype(FourArgs.self) - // CHECK: call %swift.type* @"$S17generic_metatypes8FiveArgsVyAA3FooVAA3BarCAegEGMa"() [[NOUNWIND_READNONE]] + // CHECK: call swiftcc %swift.metadata_response @"$S17generic_metatypes8FiveArgsVyAA3FooVAA3BarCAegEGMa"([[INT]] 0) [[NOUNWIND_READNONE]] genericMetatype(FiveArgs.self) } -// CHECK: define linkonce_odr hidden %swift.type* @"$S17generic_metatypes6OneArgVyAA3FooVGMa"() [[NOUNWIND_READNONE_OPT:#[0-9]+]] -// CHECK: call %swift.type* @"$S17generic_metatypes6OneArgVMa"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}) [[NOUNWIND_READNONE:#[0-9]+]] +// CHECK: define linkonce_odr hidden swiftcc %swift.metadata_response @"$S17generic_metatypes6OneArgVyAA3FooVGMa"([[INT]]) [[NOUNWIND_READNONE_OPT:#[0-9]+]] +// CHECK: call swiftcc %swift.metadata_response @"$S17generic_metatypes6OneArgVMa"([[INT]] 0, %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}) [[NOUNWIND_READNONE:#[0-9]+]] -// CHECK-LABEL: define hidden %swift.type* @"$S17generic_metatypes6OneArgVMa"(%swift.type*) +// CHECK-LABEL: define hidden swiftcc %swift.metadata_response @"$S17generic_metatypes6OneArgVMa" +// CHECK-SAME: ([[INT]], %swift.type*) // CHECK: [[BUFFER:%.*]] = alloca { %swift.type* } // CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type* }* [[BUFFER]] to i8* // CHECK: call void @llvm.lifetime.start // CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type* }, { %swift.type* }* [[BUFFER]], i32 0, i32 0 -// CHECK: store %swift.type* %0, %swift.type** [[BUFFER_ELT]] +// CHECK: store %swift.type* %1, %swift.type** [[BUFFER_ELT]] // CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type* }* [[BUFFER]] to i8* -// CHECK: [[METADATA:%.*]] = call %swift.type* @swift_getGenericMetadata(%swift.type_descriptor* {{.*}} @"$S17generic_metatypes6OneArgVMn" {{.*}}, i8* [[BUFFER_PTR]]) -// CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type* }* [[BUFFER]] to i8* -// CHECK: call void @llvm.lifetime.end -// CHECK: ret %swift.type* [[METADATA]] +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @swift_getGenericMetadata([[INT]] %0, i8* [[BUFFER_PTR]], %swift.type_descriptor* {{.*}} @"$S17generic_metatypes6OneArgVMn" {{.*}}) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 -// CHECK: define linkonce_odr hidden %swift.type* @"$S17generic_metatypes7TwoArgsVyAA3FooVAA3BarCGMa"() [[NOUNWIND_READNONE_OPT]] -// CHECK: [[T0:%.*]] = call %swift.type* @"$S17generic_metatypes3BarCMa"() -// CHECK: call %swift.type* @"$S17generic_metatypes7TwoArgsVMa"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, %swift.type* [[T0]]) +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$S17generic_metatypes7TwoArgsVyAA3FooVAA3BarCGMa" +// CHECK-SAME: ([[INT]]) [[NOUNWIND_READNONE_OPT]] +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S17generic_metatypes3BarCMa"([[INT]] 0) +// CHECK: [[BAR:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 +// CHECK: call swiftcc %swift.metadata_response @"$S17generic_metatypes7TwoArgsVMa"([[INT]] 0, %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, %swift.type* [[BAR]]) -// CHECK-LABEL: define hidden %swift.type* @"$S17generic_metatypes7TwoArgsVMa"(%swift.type*, %swift.type*) +// CHECK-LABEL: define hidden swiftcc %swift.metadata_response @"$S17generic_metatypes7TwoArgsVMa" +// CHECK-SAME: ([[INT]], %swift.type*, %swift.type*) // CHECK: [[BUFFER:%.*]] = alloca { %swift.type*, %swift.type* } // CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type*, %swift.type* }* [[BUFFER]] to i8* // CHECK: call void @llvm.lifetime.start // CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type* }, { %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 0 -// CHECK: store %swift.type* %0, %swift.type** [[BUFFER_ELT]] -// CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type* }, { %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 1 // CHECK: store %swift.type* %1, %swift.type** [[BUFFER_ELT]] +// CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type* }, { %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 1 +// CHECK: store %swift.type* %2, %swift.type** [[BUFFER_ELT]] // CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type*, %swift.type* }* [[BUFFER]] to i8* -// CHECK: [[METADATA:%.*]] = call %swift.type* @swift_getGenericMetadata(%swift.type_descriptor* {{.*}} @"$S17generic_metatypes7TwoArgsVMn" {{.*}}, i8* [[BUFFER_PTR]]) -// CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type*, %swift.type* }* [[BUFFER]] to i8* -// CHECK: call void @llvm.lifetime.end -// CHECK: ret %swift.type* [[METADATA]] +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @swift_getGenericMetadata([[INT]] %0, i8* [[BUFFER_PTR]], %swift.type_descriptor* {{.*}} @"$S17generic_metatypes7TwoArgsVMn" {{.*}}) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 -// CHECK: define linkonce_odr hidden %swift.type* @"$S17generic_metatypes9ThreeArgsVyAA3FooVAA3BarCAEGMa"() [[NOUNWIND_READNONE_OPT]] -// CHECK: [[T0:%.*]] = call %swift.type* @"$S17generic_metatypes3BarCMa"() -// CHECK: call %swift.type* @"$S17generic_metatypes9ThreeArgsVMa"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, %swift.type* [[T0]], %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}) [[NOUNWIND_READNONE]] +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$S17generic_metatypes9ThreeArgsVyAA3FooVAA3BarCAEGMa" +// CHECK-SAME: ([[INT]]) [[NOUNWIND_READNONE_OPT]] +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S17generic_metatypes3BarCMa"([[INT]] 0) +// CHECK: [[BAR:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 +// CHECK: call swiftcc %swift.metadata_response @"$S17generic_metatypes9ThreeArgsVMa"([[INT]] 0, %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, %swift.type* [[BAR]], %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}) [[NOUNWIND_READNONE]] -// CHECK-LABEL: define hidden %swift.type* @"$S17generic_metatypes9ThreeArgsVMa"(%swift.type*, %swift.type*, %swift.type*) +// CHECK-LABEL: define hidden swiftcc %swift.metadata_response @"$S17generic_metatypes9ThreeArgsVMa" +// CHECK-SAME: ({{i[0-9]+}}, %swift.type*, %swift.type*, %swift.type*) // CHECK: [[BUFFER:%.*]] = alloca { %swift.type*, %swift.type*, %swift.type* } // CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]] to i8* // CHECK: call void @llvm.lifetime.start // CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type*, %swift.type* }, { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 0 -// CHECK: store %swift.type* %0, %swift.type** [[BUFFER_ELT]] -// CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type*, %swift.type* }, { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 1 // CHECK: store %swift.type* %1, %swift.type** [[BUFFER_ELT]] -// CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type*, %swift.type* }, { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 2 +// CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type*, %swift.type* }, { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 1 // CHECK: store %swift.type* %2, %swift.type** [[BUFFER_ELT]] +// CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type*, %swift.type* }, { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 2 +// CHECK: store %swift.type* %3, %swift.type** [[BUFFER_ELT]] // CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]] to i8* -// CHECK: [[METADATA:%.*]] = call %swift.type* @swift_getGenericMetadata(%swift.type_descriptor* {{.*}} @"$S17generic_metatypes9ThreeArgsVMn" {{.*}}, i8* [[BUFFER_PTR]]) -// CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]] to i8* -// CHECK: call void @llvm.lifetime.end -// CHECK: ret %swift.type* [[METADATA]] +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @swift_getGenericMetadata([[INT]] %0, i8* [[BUFFER_PTR]], %swift.type_descriptor* {{.*}} @"$S17generic_metatypes9ThreeArgsVMn" {{.*}}) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 -// CHECK: define linkonce_odr hidden %swift.type* @"$S17generic_metatypes8FourArgsVyAA3FooVAA3BarCAeGGMa"() [[NOUNWIND_READNONE_OPT]] +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$S17generic_metatypes8FourArgsVyAA3FooVAA3BarCAeGGMa" +// CHECK-SAME: ([[INT]]) [[NOUNWIND_READNONE_OPT]] // CHECK: [[BUFFER:%.*]] = alloca [4 x i8*] -// CHECK: [[T0:%.*]] = call %swift.type* @"$S17generic_metatypes3BarCMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S17generic_metatypes3BarCMa"([[INT]] 0) +// CHECK: [[BAR:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: call void @llvm.lifetime.start +// CHECK-NEXT: [[SLOT_0:%.*]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[BUFFER]], i32 0, i32 0 +// CHECK-NEXT: store {{.*}}@"$S17generic_metatypes3FooVMf"{{.*}}, i8** [[SLOT_0]] +// CHECK-NEXT: [[SLOT_1:%.*]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[BUFFER]], i32 0, i32 1 +// CHECK-NEXT: [[T0:%.*]] = bitcast %swift.type* [[BAR]] to i8* +// CHECK-NEXT: store i8* [[T0]], i8** [[SLOT_1]] +// CHECK-NEXT: [[SLOT_2:%.*]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[BUFFER]], i32 0, i32 2 +// CHECK-NEXT: store {{.*}}@"$S17generic_metatypes3FooVMf"{{.*}}, i8** [[SLOT_2]] // CHECK-NEXT: [[SLOT_3:%.*]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[BUFFER]], i32 0, i32 3 -// CHECK-NEXT: [[T0_AS_VOIDPTR:%.*]] = bitcast %swift.type* [[T0]] to i8* -// CHECK-NEXT: store i8* [[T0_AS_VOIDPTR]], i8** [[SLOT_3]] -// CHECK-NEXT: [[BUFFER_PTR:%.*]] = bitcast [4 x i8*]* [[BUFFER]] to i8** -// CHECK-NEXT: call %swift.type* @"$S17generic_metatypes8FourArgsVMa"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, %swift.type* [[T0]], %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, i8** [[BUFFER_PTR]]) [[NOUNWIND_ARGMEM:#[0-9]+]] +// CHECK-NEXT: [[T0:%.*]] = bitcast %swift.type* [[BAR]] to i8* +// CHECK-NEXT: store i8* [[T0]], i8** [[SLOT_3]] +// CHECK-NEXT: [[BUFFER_PTR:%.*]] = bitcast [4 x i8*]* [[BUFFER]] to i8** +// CHECK-NEXT: call swiftcc %swift.metadata_response @"$S17generic_metatypes8FourArgsVMa"([[INT]] 0, i8** [[BUFFER_PTR]]) [[NOUNWIND_ARGMEM:#[0-9]+]] // CHECK: call void @llvm.lifetime.end.p0i8 -// CHECK: define linkonce_odr hidden %swift.type* @"$S17generic_metatypes8FiveArgsVyAA3FooVAA3BarCAegEGMa"() [[NOUNWIND_READNONE_OPT]] -// CHECK: [[T0:%.*]] = call %swift.type* @"$S17generic_metatypes3BarCMa"() -// CHECK: call %swift.type* @"$S17generic_metatypes8FiveArgsVMa"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, %swift.type* [[T0]], %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, i8** +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$S17generic_metatypes8FiveArgsVyAA3FooVAA3BarCAegEGMa" +// CHECK-SAME: ([[INT]]) [[NOUNWIND_READNONE_OPT]] +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S17generic_metatypes3BarCMa"([[INT]] 0) +// CHECK: [[BAR:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 +// CHECK: call swiftcc %swift.metadata_response @"$S17generic_metatypes8FiveArgsVMa"([[INT]] 0, i8** -// CHECK: define hidden %swift.type* @"$S17generic_metatypes8FiveArgsVMa"(%swift.type*, %swift.type*, %swift.type*, i8**) [[NOUNWIND_OPT:#[0-9]+]] +// CHECK-LABEL: define hidden swiftcc %swift.metadata_response @"$S17generic_metatypes8FiveArgsVMa" +// CHECK-SAME: ([[INT]], i8**) [[NOUNWIND_OPT:#[0-9]+]] // CHECK-NOT: alloc -// CHECK: call %swift.type* @swift_getGenericMetadata(%swift.type_descriptor* {{.*}} @"$S17generic_metatypes8FiveArgsVMn" {{.*}}, i8* +// CHECK: call swiftcc %swift.metadata_response @swift_getGenericMetadata([[INT]] %0, i8* {{.*}}, %swift.type_descriptor* {{.*}} @"$S17generic_metatypes8FiveArgsVMn" {{.*}}) // CHECK-NOT: call void @llvm.lifetime.end -// CHECK: ret %swift.type* +// CHECK: ret %swift.metadata_response // CHECK: attributes [[NOUNWIND_READNONE_OPT]] = { nounwind readnone "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "target-cpu" // CHECK: attributes [[NOUNWIND_OPT]] = { nounwind "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "target-cpu" diff --git a/test/IRGen/generic_metatypes_arm.swift b/test/IRGen/generic_metatypes_arm.swift deleted file mode 100644 index 5d7c1e692e6..00000000000 --- a/test/IRGen/generic_metatypes_arm.swift +++ /dev/null @@ -1,177 +0,0 @@ -// REQUIRES: plus_one_runtime - -// RUN: %swift -target armv7-apple-ios7.0 -module-name generic_metatypes -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 %s -// RUN: %swift -target arm64-apple-ios7.0 -emit-ir -module-name generic_metatypes -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 %s -// RUN: %swift -target armv7-apple-tvos9.0 -emit-ir -module-name generic_metatypes -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 %s -// RUN: %swift -target arm64-apple-tvos9.0 -emit-ir -module-name generic_metatypes -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 %s -// RUN: %swift -target armv7k-apple-watchos2.0 -emit-ir -module-name generic_metatypes -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 %s - -// REQUIRES: CODEGENERATOR=ARM - -// CHECK: define hidden swiftcc %swift.type* [[GENERIC_TYPEOF:@"\$S17generic_metatypes0A6TypeofyxmxlF"]](%swift.opaque* noalias nocapture, %swift.type* [[TYPE:%.*]]) -func genericTypeof(_ x: T) -> T.Type { - // CHECK: [[METATYPE:%.*]] = call %swift.type* @swift_getDynamicType(%swift.opaque* {{.*}}, %swift.type* [[TYPE]], i1 false) - // CHECK: ret %swift.type* [[METATYPE]] - return type(of: x) -} - -struct Foo {} -class Bar {} - -// CHECK-LABEL: define hidden swiftcc %swift.type* @"$S17generic_metatypes27remapToSubstitutedMetatypes{{.*}}"(%T17generic_metatypes3BarC*) {{.*}} { -func remapToSubstitutedMetatypes(_ x: Foo, y: Bar) - -> (Foo.Type, Bar.Type) -{ - // CHECK: call swiftcc %swift.type* [[GENERIC_TYPEOF]](%swift.opaque* noalias nocapture undef, %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}) - // CHECK: [[T0:%.*]] = call %swift.type* @"$S17generic_metatypes3BarCMa"() - // CHECK: [[BAR_META:%.*]] = call swiftcc %swift.type* [[GENERIC_TYPEOF]](%swift.opaque* noalias nocapture {{%.*}}, %swift.type* [[T0]]) - // CHECK: ret %swift.type* [[BAR_META]] - return (genericTypeof(x), genericTypeof(y)) -} - - -// CHECK-LABEL: define hidden swiftcc void @"$S17generic_metatypes23remapToGenericMetatypesyyF"() -func remapToGenericMetatypes() { - // CHECK: [[T0:%.*]] = call %swift.type* @"$S17generic_metatypes3BarCMa"() - // CHECK: call swiftcc void @"$S17generic_metatypes0A9Metatypes{{.*}}"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}} %swift.type* [[T0]], %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}} %swift.type* [[T0]]) - genericMetatypes(Foo.self, Bar.self) -} - -func genericMetatypes(_ t: T.Type, _ u: U.Type) {} - -protocol Bas {} - -// CHECK: define hidden swiftcc { %swift.type*, i8** } @"$S17generic_metatypes14protocolTypeof{{.*}}"(%T17generic_metatypes3BasP* noalias nocapture dereferenceable({{.*}})) -func protocolTypeof(_ x: Bas) -> Bas.Type { - // CHECK: [[METADATA_ADDR:%.*]] = getelementptr inbounds %T17generic_metatypes3BasP, %T17generic_metatypes3BasP* [[X:%.*]], i32 0, i32 1 - // CHECK: [[METADATA:%.*]] = load %swift.type*, %swift.type** [[METADATA_ADDR]] - // CHECK: [[BUFFER:%.*]] = getelementptr inbounds %T17generic_metatypes3BasP, %T17generic_metatypes3BasP* [[X]], i32 0, i32 0 - // CHECK: [[VALUE_ADDR:%.*]] = call %swift.opaque* @__swift_project_boxed_opaque_existential_1({{.*}} [[BUFFER]], %swift.type* [[METADATA]]) - // CHECK: [[METATYPE:%.*]] = call %swift.type* @swift_getDynamicType(%swift.opaque* [[VALUE_ADDR]], %swift.type* [[METADATA]], i1 true) - // CHECK: [[WTABLE_ADDR:%.*]] = getelementptr inbounds %T17generic_metatypes3BasP, %T17generic_metatypes3BasP* %0, i32 0, i32 2 - // CHECK: [[WTABLE:%.*]] = load i8**, i8*** [[WTABLE_ADDR]] - // CHECK: call void @__swift_destroy_boxed_opaque_existential_1(%T17generic_metatypes3BasP* %0) - // CHECK: [[T0:%.*]] = insertvalue { %swift.type*, i8** } undef, %swift.type* [[METATYPE]], 0 - // CHECK: [[T1:%.*]] = insertvalue { %swift.type*, i8** } [[T0]], i8** [[WTABLE]], 1 - // CHECK: ret { %swift.type*, i8** } [[T1]] - return type(of: x) -} - -struct Zim : Bas {} -class Zang : Bas {} - -// CHECK-LABEL: define hidden swiftcc { %swift.type*, i8** } @"$S17generic_metatypes15metatypeErasureyAA3Bas_pXpAA3ZimVmF"() #0 -func metatypeErasure(_ z: Zim.Type) -> Bas.Type { - // CHECK: ret { %swift.type*, i8** } {{.*}} @"$S17generic_metatypes3ZimVMf", {{.*}} @"$S17generic_metatypes3ZimVAA3BasAAWP" - return z -} - -// CHECK-LABEL: define hidden swiftcc { %swift.type*, i8** } @"$S17generic_metatypes15metatypeErasureyAA3Bas_pXpAA4ZangCmF"(%swift.type*) #0 -func metatypeErasure(_ z: Zang.Type) -> Bas.Type { - // CHECK: [[RET:%.*]] = insertvalue { %swift.type*, i8** } undef, %swift.type* %0, 0 - // CHECK: [[RET2:%.*]] = insertvalue { %swift.type*, i8** } [[RET]], i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @"$S17generic_metatypes4ZangCAA3BasAAWP", i32 0, i32 0), 1 - // CHECK: ret { %swift.type*, i8** } [[RET2]] - return z -} - -struct OneArg {} -struct TwoArgs {} -struct ThreeArgs {} -struct FourArgs {} -struct FiveArgs {} - -func genericMetatype(_ x: A.Type) {} - -// CHECK-LABEL: define hidden swiftcc void @"$S17generic_metatypes20makeGenericMetatypesyyF"() {{.*}} { -func makeGenericMetatypes() { - // CHECK: call %swift.type* @"$S17generic_metatypes6OneArgVyAA3FooVGMa"() [[NOUNWIND_READNONE:#[0-9]+]] - genericMetatype(OneArg.self) - - // CHECK: call %swift.type* @"$S17generic_metatypes7TwoArgsVyAA3FooVAA3BarCGMa"() [[NOUNWIND_READNONE]] - genericMetatype(TwoArgs.self) - - // CHECK: call %swift.type* @"$S17generic_metatypes9ThreeArgsVyAA3FooVAA3BarCAEGMa"() [[NOUNWIND_READNONE]] - genericMetatype(ThreeArgs.self) - - // CHECK: call %swift.type* @"$S17generic_metatypes8FourArgsVyAA3FooVAA3BarCAeGGMa"() [[NOUNWIND_READNONE]] - genericMetatype(FourArgs.self) - - // CHECK: call %swift.type* @"$S17generic_metatypes8FiveArgsVyAA3FooVAA3BarCAegEGMa"() [[NOUNWIND_READNONE]] - genericMetatype(FiveArgs.self) -} - -// CHECK: define linkonce_odr hidden %swift.type* @"$S17generic_metatypes6OneArgVyAA3FooVGMa"() [[NOUNWIND_READNONE_OPT:#[0-9]+]] -// CHECK: call %swift.type* @"$S17generic_metatypes6OneArgVMa"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}) [[NOUNWIND_READNONE:#[0-9]+]] - -// CHECK-LABEL: define hidden %swift.type* @"$S17generic_metatypes6OneArgVMa"(%swift.type*) -// CHECK: [[BUFFER:%.*]] = alloca { %swift.type* } -// CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type* }* [[BUFFER]] to i8* -// CHECK: call void @llvm.lifetime.start -// CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type* }, { %swift.type* }* [[BUFFER]], i32 0, i32 0 -// CHECK: store %swift.type* %0, %swift.type** [[BUFFER_ELT]] -// CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type* }* [[BUFFER]] to i8* -// CHECK: [[METADATA:%.*]] = call %swift.type* @swift_getGenericMetadata(%swift.type_descriptor* {{.*}} @"$S17generic_metatypes6OneArgVMn" {{.*}}, i8* [[BUFFER_PTR]]) -// CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type* }* [[BUFFER]] to i8* -// CHECK: call void @llvm.lifetime.end -// CHECK: ret %swift.type* [[METADATA]] - -// CHECK: define linkonce_odr hidden %swift.type* @"$S17generic_metatypes7TwoArgsVyAA3FooVAA3BarCGMa"() [[NOUNWIND_READNONE_OPT]] -// CHECK: [[T0:%.*]] = call %swift.type* @"$S17generic_metatypes3BarCMa"() -// CHECK: call %swift.type* @"$S17generic_metatypes7TwoArgsVMa"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, %swift.type* [[T0]]) - -// CHECK-LABEL: define hidden %swift.type* @"$S17generic_metatypes7TwoArgsVMa"(%swift.type*, %swift.type*) -// CHECK: [[BUFFER:%.*]] = alloca { %swift.type*, %swift.type* } -// CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type*, %swift.type* }* [[BUFFER]] to i8* -// CHECK: call void @llvm.lifetime.start -// CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type* }, { %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 0 -// CHECK: store %swift.type* %0, %swift.type** [[BUFFER_ELT]] -// CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type* }, { %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 1 -// CHECK: store %swift.type* %1, %swift.type** [[BUFFER_ELT]] -// CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type*, %swift.type* }* [[BUFFER]] to i8* -// CHECK: [[METADATA:%.*]] = call %swift.type* @swift_getGenericMetadata(%swift.type_descriptor* {{.*}} @"$S17generic_metatypes7TwoArgsVMn" {{.*}}, i8* [[BUFFER_PTR]]) -// CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type*, %swift.type* }* [[BUFFER]] to i8* -// CHECK: call void @llvm.lifetime.end -// CHECK: ret %swift.type* [[METADATA]] - -// CHECK: define linkonce_odr hidden %swift.type* @"$S17generic_metatypes9ThreeArgsVyAA3FooVAA3BarCAEGMa"() [[NOUNWIND_READNONE_OPT]] -// CHECK: [[T0:%.*]] = call %swift.type* @"$S17generic_metatypes3BarCMa"() -// CHECK: call %swift.type* @"$S17generic_metatypes9ThreeArgsVMa"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, %swift.type* [[T0]], %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}) [[NOUNWIND_READNONE]] - -// CHECK-LABEL: define hidden %swift.type* @"$S17generic_metatypes9ThreeArgsVMa"(%swift.type*, %swift.type*, %swift.type*) -// CHECK: [[BUFFER:%.*]] = alloca { %swift.type*, %swift.type*, %swift.type* } -// CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]] to i8* -// CHECK: call void @llvm.lifetime.start -// CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type*, %swift.type* }, { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 0 -// CHECK: store %swift.type* %0, %swift.type** [[BUFFER_ELT]] -// CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type*, %swift.type* }, { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 1 -// CHECK: store %swift.type* %1, %swift.type** [[BUFFER_ELT]] -// CHECK: [[BUFFER_ELT:%.*]] = getelementptr inbounds { %swift.type*, %swift.type*, %swift.type* }, { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]], i32 0, i32 2 -// CHECK: store %swift.type* %2, %swift.type** [[BUFFER_ELT]] -// CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]] to i8* -// CHECK: [[METADATA:%.*]] = call %swift.type* @swift_getGenericMetadata(%swift.type_descriptor* {{.*}} @"$S17generic_metatypes9ThreeArgsVMn" {{.*}}, i8* [[BUFFER_PTR]]) -// CHECK: [[BUFFER_PTR:%.*]] = bitcast { %swift.type*, %swift.type*, %swift.type* }* [[BUFFER]] to i8* -// CHECK: call void @llvm.lifetime.end -// CHECK: ret %swift.type* [[METADATA]] - -// CHECK: define linkonce_odr hidden %swift.type* @"$S17generic_metatypes8FourArgsVyAA3FooVAA3BarCAeGGMa"() [[NOUNWIND_READNONE_OPT]] -// CHECK: [[T0:%.*]] = call %swift.type* @"$S17generic_metatypes3BarCMa"() -// CHECK: call %swift.type* @"$S17generic_metatypes8FourArgsVMa"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, %swift.type* [[T0]], %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, i8** - -// CHECK-LABEL: define hidden %swift.type* @"$S17generic_metatypes8FourArgsVMa"(%swift.type*, %swift.type*, %swift.type*, i8**) -// CHECK-NOT: alloc -// CHECK: call %swift.type* @swift_getGenericMetadata( -// CHECK-NOT: call void @llvm.lifetime.end -// CHECK: ret %swift.type* - -// CHECK: define linkonce_odr hidden %swift.type* @"$S17generic_metatypes8FiveArgsVyAA3FooVAA3BarCAegEGMa"() [[NOUNWIND_READNONE_OPT]] -// CHECK: [[T0:%.*]] = call %swift.type* @"$S17generic_metatypes3BarCMa"() -// CHECK: call %swift.type* @"$S17generic_metatypes8FiveArgsVMa"(%swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, %swift.type* [[T0]], %swift.type* {{.*}} @"$S17generic_metatypes3FooVMf", {{.*}}, i8** - -// CHECK-LABEL: define hidden %swift.type* @"$S17generic_metatypes8FiveArgsVMa"(%swift.type*, %swift.type*, %swift.type*, i8**) -// CHECK-NOT: alloca -// CHECK: call %swift.type* @swift_getGenericMetadata(%swift.type_descriptor* {{.*}} @"$S17generic_metatypes8FiveArgsVMn" {{.*}}, i8* -// CHECK-NOT: call void @llvm.lifetime.end -// CHECK: ret %swift.type* - -// CHECK: attributes [[NOUNWIND_READNONE_OPT]] = { nounwind readnone "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "target-cpu" -// CHECK: attributes [[NOUNWIND_READNONE]] = { nounwind readnone } diff --git a/test/IRGen/generic_structs.sil b/test/IRGen/generic_structs.sil index a0c14eea844..67ffff912a7 100644 --- a/test/IRGen/generic_structs.sil +++ b/test/IRGen/generic_structs.sil @@ -202,14 +202,14 @@ entry(%0 : $*ComplexDynamic, %1 : $*Byteful, %2 : $*A, %3 : $*B, %4 : $*Ch // CHECK-NEXT: ret %swift.type* [[METADATA]] // CHECK: } -// CHECK-LABEL: define{{( protected)?}} internal %swift.type* @"$S15generic_structs13SingleDynamicVMr" +// CHECK-LABEL: define{{( protected)?}} internal swiftcc %swift.metadata_response @"$S15generic_structs13SingleDynamicVMr" // CHECK-SAME: (%swift.type* [[METADATA:%.*]], i8*, i8**) {{.*}} { // Lay out fields. // CHECK: [[T0:%.*]] = bitcast %swift.type* [[METADATA]] to i64* // CHECK: [[T1:%.*]] = getelementptr inbounds i64, i64* [[T0]], i64 3 // CHECK: [[T2:%.*]] = getelementptr inbounds i8**, i8*** [[TYPES:%.*]], i32 0 // CHECK: call void @swift_initStructMetadata(%swift.type* [[METADATA]], i64 0, i64 1, i8*** [[TYPES]], i64* [[T1]]) -// CHECK: ret %swift.type* null +// CHECK: ret %swift.metadata_response zeroinitializer // CHECK: } // Check that we directly delegate buffer witnesses to a single dynamic field: @@ -267,15 +267,17 @@ struct GenericLayoutWithAssocType { // CHECK: [[T1:%.*]] = bitcast i8* [[T0]] to i8** // CHECK: [[T2_GEP:%.*]] = getelementptr inbounds i8*, i8** [[T1]], i32 1 // CHECK: [[T2:%.*]] = load i8*, i8** [[T2_GEP]], align 8, !invariant.load -// CHECK: [[T3:%.*]] = bitcast i8* [[T2]] to %swift.type* -// CHECK: %T.Assoc = call %swift.type* [[T3]](%swift.type* %T, i8** [[T1]]) +// CHECK: [[T3:%.*]] = bitcast i8* [[T2]] to %swift.metadata_response ( +// CHECK: [[T4:%.*]] = call swiftcc %swift.metadata_response [[T3]](i64 0, %swift.type* %T, i8** [[T1]]) +// CHECK: %T.Assoc = extractvalue %swift.metadata_response [[T4]], 0 // CHECK: [[T0:%.*]] = getelementptr inbounds i8*, i8** %T.ParentHasAssociatedType, i32 3 // CHECK: [[T1:%.*]] = load i8*, i8** [[T0]], // CHECK: [[T2:%.*]] = bitcast i8* [[T1]] to i8** (%swift.type*, %swift.type*, i8**)* -// CHECK: %T.Assoc.HasAssociatedType = call i8** [[T2]](%swift.type* %T.Assoc, %swift.type* %T, i8** %T.ParentHasAssociatedType) +// CHECK: %T.Assoc.HasAssociatedType = call swiftcc i8** [[T2]](%swift.type* %T.Assoc, %swift.type* %T, i8** %T.ParentHasAssociatedType) // CHECK: [[T0_GEP:%.*]] = getelementptr inbounds i8*, i8** %T.Assoc.HasAssociatedType, i32 1 // CHECK: [[T0:%.*]] = load i8*, i8** [[T0_GEP]] -// CHECK: [[T1:%.*]] = bitcast i8* [[T0]] to %swift.type* (%swift.type*, i8**)* -// CHECK: %T.Assoc.Assoc = call %swift.type* [[T1]](%swift.type* %T.Assoc, i8** %T.Assoc.HasAssociatedType) +// CHECK: [[T1:%.*]] = bitcast i8* [[T0]] to %swift.metadata_response (i64, %swift.type*, i8**)* +// CHECK: [[T2:%.*]] = call swiftcc %swift.metadata_response [[T1]](i64 0, %swift.type* %T.Assoc, i8** %T.Assoc.HasAssociatedType) +// CHECK: %T.Assoc.Assoc = extractvalue %swift.metadata_response [[T2]], 0 diff --git a/test/IRGen/generic_structs.swift b/test/IRGen/generic_structs.swift index 86963d9b4a0..77fa9553838 100644 --- a/test/IRGen/generic_structs.swift +++ b/test/IRGen/generic_structs.swift @@ -39,7 +39,8 @@ public struct GenericStruct { } // CHECK-32-LABEL: define{{.*}} swiftcc void @"$S15generic_structs13GenericStructVACyxGycfC" -// CHECK-32: [[TYPE:%.*]] = call %swift.type* @"$S15generic_structs13GenericStructVMa"(%swift.type* %T, i8** %T.Proto) +// CHECK-32: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S15generic_structs13GenericStructVMa"(i32 0, %swift.type* %T, i8** %T.Proto) +// CHECK-32: [[TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-32: [[PTR:%.*]] = bitcast %swift.type* [[TYPE]] to i32* // CHECK-32: [[FIELDOFFSETS:%.*]] = getelementptr inbounds i32, i32* [[PTR]], i32 4 // CHECK-32: [[FIELDOFFSET:%.*]] = getelementptr inbounds i32, i32* [[FIELDOFFSETS]], i32 2 @@ -49,7 +50,8 @@ public struct GenericStruct { // CHECK-32: call %TSq* @"$S15generic_structsytWb3_"(%TSq* {{.*}}, %TSq* [[OPTPTR]] // CHECK-64-LABEL: define{{.*}} swiftcc void @"$S15generic_structs13GenericStructVACyxGycfC" -// CHECK-64: [[TYPE:%.*]] = call %swift.type* @"$S15generic_structs13GenericStructVMa"(%swift.type* %T, i8** %T.Proto) +// CHECK-64: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S15generic_structs13GenericStructVMa"(i64 0, %swift.type* %T, i8** %T.Proto) +// CHECK-64: [[TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-64: [[PTR:%.*]] = bitcast %swift.type* [[TYPE]] to i64* // CHECK-64: [[FIELDOFFSETS:%.*]] = getelementptr inbounds i64, i64* [[PTR]], i64 4 // CHECK-64: [[FIELDOFFSET:%.*]] = getelementptr inbounds i64, i64* [[FIELDOFFSETS]], i32 2 diff --git a/test/IRGen/generic_tuples.swift b/test/IRGen/generic_tuples.swift index 88ddd0500a5..66894c44d5b 100644 --- a/test/IRGen/generic_tuples.swift +++ b/test/IRGen/generic_tuples.swift @@ -63,7 +63,8 @@ func callDupC(_ c: C) { _ = dupC(c) } // CHECK-NEXT: entry: // CHECK-NEXT: [[REF:%.*]] = bitcast %T14generic_tuples1CC* %0 to %swift.refcounted* // CHECK-NEXT: call %swift.refcounted* @swift_retain(%swift.refcounted* returned [[REF]]) -// CHECK-NEXT: [[METATYPE:%.*]] = call %swift.type* @"$S14generic_tuples1CCMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S14generic_tuples1CCMa"(i64 0) +// CHECK-NEXT: [[METATYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[TUPLE:%.*]] = call swiftcc { %T14generic_tuples1CC*, %T14generic_tuples1CC* } @"$S14generic_tuples4dupCyx_xtxAA1CCRbzlF"(%T14generic_tuples1CC* %0, %swift.type* [[METATYPE]]) // CHECK-NEXT: [[LEFT:%.*]] = extractvalue { %T14generic_tuples1CC*, %T14generic_tuples1CC* } [[TUPLE]], 0 // CHECK-NEXT: [[RIGHT:%.*]] = extractvalue { %T14generic_tuples1CC*, %T14generic_tuples1CC* } [[TUPLE]], 1 diff --git a/test/IRGen/generic_vtable.swift b/test/IRGen/generic_vtable.swift index 89dc4d87408..c0febd8e672 100644 --- a/test/IRGen/generic_vtable.swift +++ b/test/IRGen/generic_vtable.swift @@ -106,7 +106,7 @@ public class Concrete : Derived { // CHECK: [[METADATA:%.*]] = call %swift.type* @swift_allocateGenericClassMetadata(%swift.type_descriptor* %0, i8** %1, i8** %2) // CHECK: ret %swift.type* [[METADATA]] -// CHECK-LABEL: define internal %swift.type* @"$S14generic_vtable7DerivedCMr" +// CHECK-LABEL: define internal swiftcc %swift.metadata_response @"$S14generic_vtable7DerivedCMr" // CHECK-SAME: (%swift.type* [[METADATA:%.*]], i8*, i8**) {{.*}} { // CHECK: call void @swift_initClassMetadata_UniversalStrategy(%swift.type* [[METADATA]], i64 0, {{.*}}) @@ -120,14 +120,15 @@ public class Concrete : Derived { // CHECK: [[VTABLE1:%.*]] = getelementptr inbounds i8*, i8** [[WORDS]], i64 12 // CHECK: store i8* bitcast (%T14generic_vtable7DerivedC* (%T14generic_vtable7DerivedC*)* @"$S14generic_vtable7DerivedCACyxGycfc" to i8*), i8** [[VTABLE1]], align 8 -// CHECK: ret %swift.type* null +// CHECK: ret %swift.metadata_response zeroinitializer //// Metadata initialization function for 'Concrete' copies superclass vtable //// and installs overrides for 'init()' and 'm3()'. // CHECK-LABEL: define private void @initialize_metadata_Concrete(i8*) -// CHECK: [[SUPERCLASS:%.*]] = call %swift.type* @"$S14generic_vtable7DerivedCySiGMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S14generic_vtable7DerivedCySiGMa"(i64 0) +// CHECK: [[SUPERCLASS:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: store %swift.type* [[SUPERCLASS]], %swift.type** getelementptr inbounds {{.*}} @"$S14generic_vtable8ConcreteCMf" // CHECK: [[METADATA:%.*]] = call %swift.type* @swift_relocateClassMetadata({{.*}}, i64 96, i64 1) // CHECK: call void @swift_initClassMetadata_UniversalStrategy(%swift.type* [[METADATA]], i64 0, {{.*}}) diff --git a/test/IRGen/global_resilience.sil b/test/IRGen/global_resilience.sil index d66c1f0dc43..cfeff9a6483 100644 --- a/test/IRGen/global_resilience.sil +++ b/test/IRGen/global_resilience.sil @@ -106,11 +106,12 @@ bb0: // CHECK-LABEL: define {{.*}} @testOtherGlobal sil @testOtherGlobal : $@convention(thin) () -> () { bb0: - // CHECK: [[METADATA:%.*]] = call %swift.type* @"$S16resilient_struct4SizeVMa"() - // CHECK: call %swift.opaque* @__swift_allocate_value_buffer(%swift.type* %0, %swift.opaque* bitcast ([{{.*}} x i8]* @otherGlobal to %swift.opaque*)) + // CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S16resilient_struct4SizeVMa"([[INT]] 0) + // CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 + // CHECK: call %swift.opaque* @__swift_allocate_value_buffer(%swift.type* [[METADATA]], %swift.opaque* bitcast ([{{.*}} x i8]* @otherGlobal to %swift.opaque*)) alloc_global @otherGlobal - // CHECK: call %swift.opaque* @__swift_project_value_buffer(%swift.type* %0, %swift.opaque* bitcast ([{{.*}} x i8]* @otherGlobal to %swift.opaque*)) + // CHECK: call %swift.opaque* @__swift_project_value_buffer(%swift.type* [[METADATA]], %swift.opaque* bitcast ([{{.*}} x i8]* @otherGlobal to %swift.opaque*)) %addr = global_addr @otherGlobal : $*Size %tuple = tuple () diff --git a/test/IRGen/keypaths.sil b/test/IRGen/keypaths.sil index 2628a661c09..9052628eae9 100644 --- a/test/IRGen/keypaths.sil +++ b/test/IRGen/keypaths.sil @@ -284,7 +284,8 @@ entry: %j = keypath $KeyPath, U>, (root $Gen; stored_property #Gen.y : $A) // CHECK: [[PTR:%.*]] = bitcast i8* [[ARGS:%.*]] to - // CHECK: [[FOO_T:%.*]] = call %swift.type* @"$S8keypaths3FooVMa"(%swift.type* %T) + // CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S8keypaths3FooVMa"([[WORD]] 0, %swift.type* %T) + // CHECK: [[FOO_T:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: store %swift.type* [[FOO_T]], %swift.type** [[PTR]] // CHECK: call %swift.refcounted* @swift_getKeyPath(i8* bitcast ({{.*}} [[KP_I]] to i8*), i8* [[ARGS]]) %i2 = keypath $KeyPath,Foo>, Foo>, (root $Gen; stored_property #Gen.x : $A) > @@ -295,7 +296,8 @@ entry: // CHECK: define private %swift.type* [[I_GET_GEN_A_A]](i8*) // CHECK: [[BUF:%.*]] = bitcast i8* %0 // CHECK: [[A:%.*]] = load %swift.type*, %swift.type** [[BUF]] -// CHECK: [[GEN:%.*]] = call %swift.type* @"$S8keypaths3GenVMa"(%swift.type* [[A]], %swift.type* [[A]]) +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S8keypaths3GenVMa"([[WORD]] 0, %swift.type* [[A]], %swift.type* [[A]]) +// CHECK: [[GEN:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: ret %swift.type* [[GEN]] diff --git a/test/IRGen/metadata_dominance.swift b/test/IRGen/metadata_dominance.swift index b66e1e0031d..d19eb4f7735 100644 --- a/test/IRGen/metadata_dominance.swift +++ b/test/IRGen/metadata_dominance.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir -primary-file %s | %FileCheck %s -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -O -emit-ir -primary-file %s | %FileCheck %s --check-prefix=CHECK-OPT +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir -primary-file %s | %FileCheck %s -DINT=i%target-ptrsize +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -O -emit-ir -primary-file %s | %FileCheck %s --check-prefix=CHECK-OPT -DINT=i%target-ptrsize func use_metadata(_ f: F) {} @@ -12,7 +12,8 @@ func cond() -> Bool { return true } func test1() { // CHECK: call swiftcc i1 @"$S18metadata_dominance4condSbyF"() if cond() { -// CHECK: [[T0:%.*]] = call %swift.type* @"$SyycMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$SyycMa"([[INT]] 0) +// CHECK: [[T0:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: call swiftcc void @"$S18metadata_dominance04use_A0yyxlF"(%swift.opaque* {{.*}}, %swift.type* [[T0]]) use_metadata(voidToVoid) // CHECK: call swiftcc i1 @"$S18metadata_dominance4condSbyF"() @@ -26,7 +27,8 @@ func test1() { use_metadata(voidToVoid) } } -// CHECK: [[T1:%.*]] = call %swift.type* @"$SyycMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$SyycMa"([[INT]] 0) +// CHECK: [[T1:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: call swiftcc void @"$S18metadata_dominance04use_A0yyxlF"(%swift.opaque* {{.*}}, %swift.type* [[T1]]) use_metadata(voidToVoid) } @@ -36,17 +38,20 @@ func test2() { // CHECK: call swiftcc i1 @"$S18metadata_dominance4condSbyF"() if cond() { // CHECK: call swiftcc i1 @"$S18metadata_dominance4condSbyF"() -// CHECK: [[T0:%.*]] = call %swift.type* @"$SyycMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$SyycMa"([[INT]] 0) +// CHECK: [[T0:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: call swiftcc void @"$S18metadata_dominance04use_A0yyxlF"(%swift.opaque* {{.*}}, %swift.type* [[T0]]) if cond() { use_metadata(voidToVoid) } else { -// CHECK: [[T1:%.*]] = call %swift.type* @"$SyycMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$SyycMa"([[INT]] 0) +// CHECK: [[T1:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: call swiftcc void @"$S18metadata_dominance04use_A0yyxlF"(%swift.opaque* {{.*}}, %swift.type* [[T1]]) use_metadata(voidToVoid) } } -// CHECK: [[T2:%.*]] = call %swift.type* @"$SyycMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$SyycMa"([[INT]] 0) +// CHECK: [[T2:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: call swiftcc void @"$S18metadata_dominance04use_A0yyxlF"(%swift.opaque* {{.*}}, %swift.type* [[T2]]) use_metadata(voidToVoid) } diff --git a/test/IRGen/metatype_casts.sil b/test/IRGen/metatype_casts.sil index a3b4410c70c..34b1882e9c8 100644 --- a/test/IRGen/metatype_casts.sil +++ b/test/IRGen/metatype_casts.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir | %FileCheck %s +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir | %FileCheck %s -DINT=i%target-ptrsize // REQUIRES: CPU=i386 || CPU=x86_64 // XFAIL: linux @@ -103,7 +103,8 @@ entry(%0 : $@thick Any.Type): // to check. // CHECK-LABEL: define{{( protected)?}} swiftcc %swift.type* @checked_cast_class_to_anyobject_type -// CHECK: [[METATYPE:%.*]] = call %swift.type* @"$S14metatype_casts9SomeClassCMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S14metatype_casts9SomeClassCMa"([[INT]] 0) +// CHECK: [[METATYPE:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: ret %swift.type* [[METATYPE]] sil @checked_cast_class_to_anyobject_type : $@convention(thin) () -> @thick AnyObject.Type { entry: diff --git a/test/IRGen/mixed_mode_class_with_unimportable_fields.sil b/test/IRGen/mixed_mode_class_with_unimportable_fields.sil index b88d7e1498e..08e324be565 100644 --- a/test/IRGen/mixed_mode_class_with_unimportable_fields.sil +++ b/test/IRGen/mixed_mode_class_with_unimportable_fields.sil @@ -1,7 +1,7 @@ // RUN: %empty-directory(%t) // RUN: %target-swift-frontend -emit-module -o %t/UsingObjCStuff.swiftmodule -module-name UsingObjCStuff -I %t -I %S/Inputs/mixed_mode -swift-version 4 %S/Inputs/mixed_mode/UsingObjCStuff.swift -// RUN: %target-swift-frontend -emit-ir -I %t -I %S/Inputs/mixed_mode -module-name main -swift-version 3 %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -// RUN: %target-swift-frontend -emit-ir -I %t -I %S/Inputs/mixed_mode -module-name main -swift-version 4 %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize +// RUN: %target-swift-frontend -emit-ir -I %t -I %S/Inputs/mixed_mode -module-name main -swift-version 3 %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -DWORD=i%target-ptrsize +// RUN: %target-swift-frontend -emit-ir -I %t -I %S/Inputs/mixed_mode -module-name main -swift-version 4 %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -DWORD=i%target-ptrsize // REQUIRES: objc_interop @@ -26,18 +26,21 @@ sil @getHolder: $@convention(thin) () -> @owned ButtHolder { entry: // We should load the dimensions of the class instance from metadata, not try // to hardcode constants. - // CHECK: [[METADATA:%.*]] = call %swift.type* @"$S14UsingObjCStuff10ButtHolderCMa"() + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S14UsingObjCStuff10ButtHolderCMa"([[WORD]] 0) + // CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-64: [[SIZE32:%.*]] = load i32 // CHECK-64: [[SIZE:%.*]] = zext i32 [[SIZE32]] to // CHECK-32: [[SIZE:%.*]] = load i32 // CHECK: [[ALIGN16:%.*]] = load i16 - // CHECK: [[ALIGN:%.*]] = zext i16 [[ALIGN16]] to [[WORD:i32|i64]] + // CHECK: [[ALIGN:%.*]] = zext i16 [[ALIGN16]] to [[WORD]] // CHECK: call noalias %swift.refcounted* @swift_allocObject(%swift.type* [[METADATA]], [[WORD]] [[SIZE]], [[WORD]] [[ALIGN]]) %x = alloc_ref $ButtHolder - // CHECK: [[METADATA:%.*]] = call %swift.type* @"$S4main13SubButtHolderCMa"() + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S4main13SubButtHolderCMa"([[WORD]] 0) + // CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: call noalias %swift.refcounted* @swift_allocObject(%swift.type* [[METADATA]], [[WORD]] %{{.*}}, [[WORD]] %{{.*}}) %y = alloc_ref $SubButtHolder - // CHECK: [[METADATA:%.*]] = call %swift.type* @"$S4main03SubB10ButtHolderCMa"() + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S4main03SubB10ButtHolderCMa"([[WORD]] 0) + // CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: call noalias %swift.refcounted* @swift_allocObject(%swift.type* [[METADATA]], [[WORD]] %{{.*}}, [[WORD]] %{{.*}}) %z = alloc_ref $SubSubButtHolder return %x : $ButtHolder diff --git a/test/IRGen/nested_generics.swift b/test/IRGen/nested_generics.swift index e90f92066bf..dd6ffe00863 100644 --- a/test/IRGen/nested_generics.swift +++ b/test/IRGen/nested_generics.swift @@ -14,20 +14,20 @@ public func makeAMetadata() { } // Type constructor for OuterGenericStruct.InnerGenericStruct -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$S15nested_generics18OuterGenericStructV05InnerdE0VySi_SSGMa"() -// CHECK: call %swift.type* @"$S15nested_generics18OuterGenericStructV05InnerdE0VMa"(%swift.type* @"$SSiN", %swift.type* @"$SSSN") -// CHECK: ret %swift.type +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$S15nested_generics18OuterGenericStructV05InnerdE0VySi_SSGMa"(i64) +// CHECK: call swiftcc %swift.metadata_response @"$S15nested_generics18OuterGenericStructV05InnerdE0VMa"(i64 0, %swift.type* @"$SSiN", %swift.type* @"$SSSN") +// CHECK: ret %swift.metadata_response // Type constructor for OuterGenericStruct.InnerGenericStruct -// CHECK-LABEL: define{{( protected)?}} %swift.type* @"$S15nested_generics18OuterGenericStructV05InnerdE0VMa"(%swift.type*, %swift.type*) +// CHECK-LABEL: define{{( protected)?}} swiftcc %swift.metadata_response @"$S15nested_generics18OuterGenericStructV05InnerdE0VMa"(i64, %swift.type*, %swift.type*) // Type constructor for OuterGenericStruct.InnerConcreteStruct -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$S15nested_generics18OuterGenericStructV013InnerConcreteE0VySi_GMa"() -// CHECK: call %swift.type* @"$S15nested_generics18OuterGenericStructV013InnerConcreteE0VMa"(%swift.type* @"$SSiN") -// CHECK: ret %swift.type +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$S15nested_generics18OuterGenericStructV013InnerConcreteE0VySi_GMa"(i64) +// CHECK: call swiftcc %swift.metadata_response @"$S15nested_generics18OuterGenericStructV013InnerConcreteE0VMa"(i64 0, %swift.type* @"$SSiN") +// CHECK: ret %swift.metadata_response // Type constructor for OuterGenericStruct.InnerConcreteStruct -// CHECK-LABEL: define{{( protected)?}} %swift.type* @"$S15nested_generics18OuterGenericStructV013InnerConcreteE0VMa"(%swift.type*) +// CHECK-LABEL: define{{( protected)?}} swiftcc %swift.metadata_response @"$S15nested_generics18OuterGenericStructV013InnerConcreteE0VMa"(i64, %swift.type*) public struct OuterGenericStruct { public struct InnerGenericStruct { @@ -45,25 +45,25 @@ public struct OuterGenericStruct { } // Type constructor for OuterGenericClass.InnerGenericClass -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$S15nested_generics17OuterGenericClassC05InnerdE0CySi_SSGMa"() -// CHECK: call %swift.type* @"$S15nested_generics17OuterGenericClassC05InnerdE0CMa"(%swift.type* @"$SSiN", %swift.type* @"$SSSN") +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$S15nested_generics17OuterGenericClassC05InnerdE0CySi_SSGMa"(i64) +// CHECK: call swiftcc %swift.metadata_response @"$S15nested_generics17OuterGenericClassC05InnerdE0CMa"(i64 0, %swift.type* @"$SSiN", %swift.type* @"$SSSN") // Type constructor for OuterGenericClass.InnerGenericClass -// CHECK-LABEL: define{{( protected)?}} %swift.type* @"$S15nested_generics17OuterGenericClassC05InnerdE0CMa"(%swift.type*, %swift.type*) +// CHECK-LABEL: define{{( protected)?}} swiftcc %swift.metadata_response @"$S15nested_generics17OuterGenericClassC05InnerdE0CMa"(i64, %swift.type*, %swift.type*) // Type constructor for OuterGenericClass.InnerConcreteClass -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$S15nested_generics17OuterGenericClassC013InnerConcreteE0CySi_GMa"() -// CHECK: call %swift.type* @"$S15nested_generics17OuterGenericClassC013InnerConcreteE0CMa"(%swift.type* @"$SSiN") -// CHECK: ret %swift.type +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$S15nested_generics17OuterGenericClassC013InnerConcreteE0CySi_GMa"(i64) +// CHECK: call swiftcc %swift.metadata_response @"$S15nested_generics17OuterGenericClassC013InnerConcreteE0CMa"(i64 0, %swift.type* @"$SSiN") +// CHECK: ret %swift.metadata_response // Type constructor for OuterGenericClass.InnerConcreteClass -// CHECK-LABEL: define{{( protected)?}} %swift.type* @"$S15nested_generics17OuterGenericClassC013InnerConcreteE0CMa"(%swift.type*) +// CHECK-LABEL: define{{( protected)?}} swiftcc %swift.metadata_response @"$S15nested_generics17OuterGenericClassC013InnerConcreteE0CMa"(i64, %swift.type*) // Type constructor for OuterGenericStruct -// CHECK-LABEL: define{{( protected)?}} %swift.type* @"$S15nested_generics18OuterGenericStructVMa"(%swift.type*) +// CHECK-LABEL: define{{( protected)?}} swiftcc %swift.metadata_response @"$S15nested_generics18OuterGenericStructVMa"(i64, %swift.type*) // Type constructor for OuterGenericClass -// CHECK-LABEL: define{{( protected)?}} %swift.type* @"$S15nested_generics17OuterGenericClassCMa"(%swift.type*) +// CHECK-LABEL: define{{( protected)?}} swiftcc %swift.metadata_response @"$S15nested_generics17OuterGenericClassCMa"(i64, %swift.type*) public class OuterGenericClass { public class InnerGenericClass { diff --git a/test/IRGen/nested_types.sil b/test/IRGen/nested_types.sil index 7d09ca54435..c4662bbc198 100644 --- a/test/IRGen/nested_types.sil +++ b/test/IRGen/nested_types.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s -DINT=i%target-ptrsize sil_stage canonical @@ -20,8 +20,9 @@ bb0(%0 : $@thick Outer.Inner.Type): return %1 : $@thick Outer.Type } // CHECK-LABEL: define{{ | protected }}swiftcc %swift.type* @test0(%swift.type*) -// CHECK: [[T0:%.*]] = call %swift.type* @"$S12nested_types5OuterCMa"() -// CHECK-NEXT: ret %swift.type* [[T0]] +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S12nested_types5OuterCMa"([[INT]] 0) +// CHECK-NEXT: [[T1:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 +// CHECK-NEXT: ret %swift.type* [[T1]] -// CHECK-LABEL: define hidden %swift.type* @"$S12nested_types5OuterC5InnerVMa"() -// CHECK: ret %swift.type* bitcast {{.*}} @"$S12nested_types5OuterC5InnerVMf" \ No newline at end of file +// CHECK-LABEL: define hidden swiftcc %swift.metadata_response @"$S12nested_types5OuterC5InnerVMa"( +// CHECK: ret %swift.metadata_response { %swift.type* bitcast {{.*}}@"$S12nested_types5OuterC5InnerVMf"{{.*}}, [[INT]] 0 } diff --git a/test/IRGen/objc_dealloc.sil b/test/IRGen/objc_dealloc.sil index 62c76552c47..c5491cfcfb8 100644 --- a/test/IRGen/objc_dealloc.sil +++ b/test/IRGen/objc_dealloc.sil @@ -100,7 +100,8 @@ bb0(%0 : @unowned $SwiftGizmo): // Call super -dealloc. // CHECK: [[SUPER:%[a-zA-Z0-9]+]] = bitcast [[SGIZMO]]* [[SGIZMOVAL]] to [[GIZMO]]* // CHECK-NEXT: [[SUPER_OBJ:%[a-zA-Z0-9]+]] = bitcast [[GIZMO]]* [[SUPER]] to %objc_object* - // CHECK-NEXT: [[T0:%.*]] = call %swift.type* @"$S12objc_dealloc10SwiftGizmoCMa"() + // CHECK-NEXT: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S12objc_dealloc10SwiftGizmoCMa"(i64 0) + // CHECK-NEXT: [[T0:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[T1:%.*]] = bitcast %swift.type* [[T0]] to %objc_class* // CHECK-NEXT: [[OBJC_SUPER_RECEIVER:%[a-zA-Z0-9]+]] = getelementptr inbounds %objc_super, %objc_super* [[OBJC_SUPER]], i32 0, i32 0 // CHECK-NEXT: store %objc_object* [[SUPER_OBJ]], %objc_object** [[OBJC_SUPER_RECEIVER]], align 8 diff --git a/test/IRGen/objc_generic_class_metadata.sil b/test/IRGen/objc_generic_class_metadata.sil index 9f48ddb2805..3bd9e5a3493 100644 --- a/test/IRGen/objc_generic_class_metadata.sil +++ b/test/IRGen/objc_generic_class_metadata.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -emit-ir | %FileCheck %s +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -emit-ir | %FileCheck %s -DINT=i%target-ptrsize // REQUIRES: objc_interop @@ -29,7 +29,8 @@ entry: // All instances of the generic ObjC class are erased to the same metadata // at runtime. - // CHECK: [[METADATA:%.*]] = call %swift.type* @"$SSo12GenericClassCMa"() + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$SSo12GenericClassCMa"([[INT]] 0) + // CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 %a = metatype $@thick GenericClass.Type // CHECK: call swiftcc void @metatype_sink(%swift.type* [[METADATA]], %swift.type* [[METADATA]]) apply %z>(%a) : $@convention(thin) (@thick T.Type) -> () @@ -45,7 +46,8 @@ entry: apply %y>(%c) : $@convention(thin) (@objc_metatype T.Type) -> () // Check that generic classes are erased at depth. - // CHECK: [[TUPLE_METADATA:%.*]] = call %swift.type* @"$SSaySo12GenericClassC_SitGMa"() + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$SSaySo12GenericClassC_SitGMa"([[INT]] 0) + // CHECK: [[TUPLE_METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 %d = metatype $@thick Array<(GenericClass, Int)>.Type // CHECK: call swiftcc void @metatype_sink(%swift.type* [[TUPLE_METADATA]], %swift.type* [[TUPLE_METADATA]]) apply %z, Int)>>(%d) : $@convention(thin) (@thick T.Type) -> () @@ -76,14 +78,18 @@ entry(%0: $Subclass, %1: $NSDictionary): unreachable } -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$SSo12GenericClassCMa"() +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$SSo12GenericClassCMa"( // CHECK: [[T0:%.*]] = load %objc_class*, %objc_class** @"OBJC_CLASS_REF_$_GenericClass", // CHECK: call %objc_class* @swift_getInitializedObjCClass(%objc_class* [[T0]]) -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$SSaySo12GenericClassC_SitGMa"() -// CHECK: [[TUPLE:%.*]] = call %swift.type* @"$SSo12GenericClassC_SitMa"() -// CHECK: call %swift.type* @"$SSaMa"(%swift.type* [[TUPLE]]) +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$SSaySo12GenericClassC_SitGMa" +// CHECK-SAME: ([[INT]]) +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$SSo12GenericClassC_SitMa"([[INT]] 0) +// CHECK: [[TUPLE:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 +// CHECK: call swiftcc %swift.metadata_response @"$SSaMa"([[INT]] 0, %swift.type* [[TUPLE]]) -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$SSo12GenericClassC_SitMa"() -// CHECK: [[CLASS:%.*]] = call %swift.type* @"$SSo12GenericClassCMa"() +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$SSo12GenericClassC_SitMa" +// CHECK-SAME: ([[INT]]) +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$SSo12GenericClassCMa"([[INT]] 0) +// CHECK: [[CLASS:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: call %swift.type* @swift_getTupleTypeMetadata2(%swift.type* [[CLASS]], %swift.type* @"$SSiN", diff --git a/test/IRGen/objc_ns_enum.swift b/test/IRGen/objc_ns_enum.swift index 9bac9f9eecd..2838eab4740 100644 --- a/test/IRGen/objc_ns_enum.swift +++ b/test/IRGen/objc_ns_enum.swift @@ -14,7 +14,7 @@ import gizmo // CHECK: @"$SSo28NeverActuallyMentionedByNameVs9EquatableSCWP" = linkonce_odr hidden constant // CHECK-LABEL: define{{( protected)?}} i32 @main -// CHECK: call %swift.type* @"$SSo16NSRuncingOptionsVMa"() +// CHECK: call swiftcc %swift.metadata_response @"$SSo16NSRuncingOptionsVMa"(i64 0) // CHECK: define hidden swiftcc i16 @"$S12objc_ns_enum09imported_C9_inject_aSo16NSRuncingOptionsVyF"() // CHECK: ret i16 123 @@ -85,7 +85,7 @@ func test_enum_without_name_Equatable(_ obj: TestThatEnumType) -> Bool { func use_metadata(_ t:T){} use_metadata(NSRuncingOptions.mince) -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$SSo16NSRuncingOptionsVMa"() +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$SSo16NSRuncingOptionsVMa"(i64) // CHECK: call %swift.type* @swift_getForeignTypeMetadata({{.*}} @"$SSo16NSRuncingOptionsVN" {{.*}}) [[NOUNWIND_READNONE:#[0-9]+]] @objc enum ExportedToObjC: Int { diff --git a/test/IRGen/objc_super.swift b/test/IRGen/objc_super.swift index 7b7e426e3d2..5cd6f8433d8 100644 --- a/test/IRGen/objc_super.swift +++ b/test/IRGen/objc_super.swift @@ -1,6 +1,6 @@ // RUN: %empty-directory(%t) // RUN: %build-irgen-test-overlays -// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir | %FileCheck %s +// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir | %FileCheck %s -DINT=i%target-ptrsize // REQUIRES: CPU=x86_64 // REQUIRES: objc_interop @@ -19,8 +19,9 @@ import gizmo class Hoozit : Gizmo { // CHECK: define hidden swiftcc void @"$S10objc_super6HoozitC4frobyyF"([[HOOZIT]]* swiftself) {{.*}} { override func frob() { - // CHECK: [[T0:%.*]] = call [[TYPE]]* @"$S10objc_super6HoozitCMa"() - // CHECK: [[T1:%.*]] = bitcast [[TYPE]]* [[T0]] to [[CLASS]]* + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S10objc_super6HoozitCMa"([[INT]] 0) + // CHECK: [[T0:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 + // CHECK: [[T1:%.*]] = bitcast %swift.type* [[T0]] to [[CLASS]]* // CHECK: store [[CLASS]]* [[T1]], [[CLASS]]** {{.*}}, align 8 // CHECK: load i8*, i8** @"\01L_selector(frob)" // CHECK: call void bitcast (void ()* @objc_msgSendSuper2 to void ([[SUPER]]*, i8*)*)([[SUPER]]* {{.*}}, i8* {{.*}}) @@ -28,7 +29,7 @@ class Hoozit : Gizmo { } // CHECK: } - // CHECK: define hidden swiftcc void @"$S10objc_super6HoozitC5runceyyFZ"([[TYPE]]* swiftself) {{.*}} { + // CHECK: define hidden swiftcc void @"$S10objc_super6HoozitC5runceyyFZ"(%swift.type* swiftself) {{.*}} { override class func runce() { // CHECK: store [[CLASS]]* @"OBJC_METACLASS_$__TtC10objc_super6Hoozit", [[CLASS]]** {{.*}}, align 8 // CHECK: load i8*, i8** @"\01L_selector(runce)" @@ -39,8 +40,9 @@ class Hoozit : Gizmo { // CHECK: define hidden swiftcc { double, double, double, double } @"$S10objc_super6HoozitC5frameSo6NSRectVyF"(%T10objc_super6HoozitC* swiftself) {{.*}} { override func frame() -> NSRect { - // CHECK: [[T0:%.*]] = call [[TYPE]]* @"$S10objc_super6HoozitCMa"() - // CHECK: [[T1:%.*]] = bitcast [[TYPE]]* [[T0]] to [[CLASS]]* + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S10objc_super6HoozitCMa"([[INT]] 0) + // CHECK: [[T0:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 + // CHECK: [[T1:%.*]] = bitcast %swift.type* [[T0]] to [[CLASS]]* // CHECK: store [[CLASS]]* [[T1]], [[CLASS]]** {{.*}}, align 8 // CHECK: load i8*, i8** @"\01L_selector(frame)" // CHECK: call void bitcast (void ()* @objc_msgSendSuper2_stret to void ([[NSRECT]]*, [[SUPER]]*, i8*)*)([[NSRECT]]* noalias nocapture sret {{.*}}, [[SUPER]]* {{.*}}, i8* {{.*}}) @@ -108,7 +110,8 @@ class GenericRuncer : Gizmo { // CHECK: define hidden swiftcc void @"$S10objc_super13GenericRuncerC5runceyyFZ"(%swift.type* swiftself) {{.*}} { override class func runce() { - // CHECK: [[CLASS:%.*]] = call %swift.type* @"$S10objc_super13GenericRuncerCMa"(%swift.type* %T) + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S10objc_super13GenericRuncerCMa"([[INT]] 0, %swift.type* %T) + // CHECK-NEXT: [[CLASS:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[CLASS1:%.*]] = bitcast %swift.type* [[CLASS]] to %objc_class* // CHECK-NEXT: [[CLASS2:%.*]] = bitcast %objc_class* [[CLASS1]] to i64* // CHECK-NEXT: [[ISA:%.*]] = load i64, i64* [[CLASS2]], align 8 @@ -126,7 +129,7 @@ class GenericRuncer : Gizmo { } // CHECK: define internal swiftcc void [[PARTIAL_FORWARDING_THUNK]](%swift.refcounted* swiftself) #0 { -// CHECK: call %swift.type* @"$S10objc_super12PartialApplyCMa"() +// CHECK: call swiftcc %swift.metadata_response @"$S10objc_super12PartialApplyCMa"([[INT]] 0) // CHECK: @"\01L_selector(frob)" // CHECK: call void bitcast (void ()* @objc_msgSendSuper2 // CHECK: } diff --git a/test/IRGen/objc_types_as_member.sil b/test/IRGen/objc_types_as_member.sil index 70f3a169cf9..c613ea0c7c2 100644 --- a/test/IRGen/objc_types_as_member.sil +++ b/test/IRGen/objc_types_as_member.sil @@ -1,6 +1,6 @@ // RUN: %empty-directory(%t) // RUN: %build-irgen-test-overlays -// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir | %FileCheck %s +// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir | %FileCheck %s -DINT=i%target-ptrsize // REQUIRES: objc_interop @@ -9,7 +9,8 @@ import gizmo sil @use_metatype : $@convention(thin) (@thin T.Type) -> () // CHECK-LABEL: define swiftcc void @test(%TSo014OuterTypeInnerB0C* swiftself, %swift.type* %Self, i8** %SelfWitnessTable) -// CHECK: [[TMP:%.*]] = call %swift.type* @"$SSo9OuterTypeCMa"() +// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$SSo9OuterTypeCMa"([[INT]] 0) +// CHECK: [[TMP:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK: call swiftcc void @use_metatype(%swift.type* [[TMP]]) // CHECK: ret void @@ -21,7 +22,8 @@ bb0(%0 : $OuterType.InnerType): return %3 : $() } -// CHECK-LABEL: define {{.*}}%swift.type* @"$SSo9OuterTypeCMa"() +// CHECK-LABEL: define {{.*}}swiftcc %swift.metadata_response @"$SSo9OuterTypeCMa" +// CHECK-SAME: ([[INT]]) // CHECK: [[TMP:%.*]] = call %objc_class* @swift_getInitializedObjCClass( // CHECK: call %swift.type* @swift_getObjCClassMetadata(%objc_class* [[TMP]]) // CHECK: ret diff --git a/test/IRGen/partial_apply.sil b/test/IRGen/partial_apply.sil index 6f3e8c6c0d3..b68b96f856b 100644 --- a/test/IRGen/partial_apply.sil +++ b/test/IRGen/partial_apply.sil @@ -331,7 +331,8 @@ sil public_external @receive_closure : $@convention(thin) (@o // CHECK-LABEL: define{{( protected)?}} swiftcc void @test_partial_apply(%T13partial_apply4BaseC*) // CHECK: [[CTX:%.*]] = bitcast %T13partial_apply4BaseC* %0 to %swift.refcounted* -// CHECK: [[TYPE:%.*]] = call %swift.type* @"$S13partial_apply3SubCMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S13partial_apply3SubCMa"(i64 0) +// CHECK: [[TYPE:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: call swiftcc void @receive_closure(i8* bitcast (%T13partial_apply3SubC* (%swift.refcounted*)* @"$S26parametric_casting_closureTA.{{[0-9]+}}" to i8*), %swift.refcounted* [[CTX]], %swift.type* [[TYPE]]) // CHECK-LABEL: define internal swiftcc %T13partial_apply3SubC* @"$S26parametric_casting_closureTA"(%T13partial_apply4BaseC*, %swift.refcounted* swiftself) @@ -341,7 +342,8 @@ sil public_external @receive_closure : $@convention(thin) (@o // CHECK-LABEL: define internal swiftcc %T13partial_apply3SubC* @"$S26parametric_casting_closureTA.{{[0-9]+}}"(%swift.refcounted* swiftself) -// CHECK: [[TYPE:%.*]] = call %swift.type* @"$S13partial_apply3SubCMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S13partial_apply3SubCMa"(i64 0) +// CHECK: [[TYPE:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[CTX:%.*]] = bitcast %swift.refcounted* %0 to %T13partial_apply4BaseC* // CHECK: [[CALL:%.*]] = tail call swiftcc %T13partial_apply4BaseC* @parametric_casting_closure(%T13partial_apply4BaseC* [[CTX]], %swift.type* [[TYPE]]) // CHECK: [[CAST:%.*]] = bitcast %T13partial_apply4BaseC* [[CALL]] to %T13partial_apply3SubC* diff --git a/test/IRGen/partial_apply_forwarder.sil b/test/IRGen/partial_apply_forwarder.sil index 5c8a4f7694b..0c2d4eef55d 100644 --- a/test/IRGen/partial_apply_forwarder.sil +++ b/test/IRGen/partial_apply_forwarder.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir | %FileCheck %s +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir | %FileCheck %s -DINT=i%target-ptrsize sil_stage canonical import Builtin @@ -25,7 +25,8 @@ bb0(%0 : $*S): } // CHECK-LABEL: define internal swiftcc %T23partial_apply_forwarder1DCyAA1CCG* @"$S23unspecialized_uncurriedTA"(%swift.refcounted* -// CHECK: [[TYPE:%.*]] = call %swift.type* @"$S23partial_apply_forwarder1CCMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S23partial_apply_forwarder1CCMa"([[INT]] 0) +// CHECK: [[TYPE:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[CAST:%.*]] = bitcast %swift.refcounted* %0 to %T23partial_apply_forwarder1EC* // CHECK: [[CALL:%.*]] = call swiftcc %T23partial_apply_forwarder1DC* @unspecialized_uncurried(%swift.type* [[TYPE]], i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @"$S23partial_apply_forwarder1CCAA1PAAWP", i32 0, i32 0), %T23partial_apply_forwarder1EC* swiftself [[CAST]]) @@ -41,7 +42,8 @@ sil hidden_external @unspecialized_uncurried : $@convention(method) <Ï„_0_0 wher // CHECK-LABEL: define internal swiftcc void @"$S7takingPTA"(%swift.refcounted* // CHECK: [[CONTEXT:%.*]] = alloca %swift.refcounted* -// CHECK: [[TYPE:%.*]] = call %swift.type* @"$S23partial_apply_forwarder1CCMa" +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S23partial_apply_forwarder1CCMa"([[INT]] 0) +// CHECK: [[TYPE:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: store %swift.refcounted* %0, %swift.refcounted** [[CONTEXT]] // CHECK: [[CAST:%.*]] = bitcast %swift.refcounted** [[CONTEXT]] to %swift.opaque* // CHECK: call swiftcc void @takingP(%swift.type* [[TYPE]], i8**{{.*}}$S23partial_apply_forwarder1CCAA1PAAWP{{.*}}, %swift.opaque* {{.*}} swiftself [[CAST]] @@ -78,8 +80,10 @@ sil hidden_external @takingEmptyAndQ : $@convention(thin) <Ï„_0_0 where Ï„_0_0 // CHECK-LABEL: define{{( protected)?}} swiftcc { i8*, %swift.refcounted* } @bind_polymorphic_param_from_context(%swift.opaque* noalias nocapture, %swift.type* %"\CF\84_0_1") // CHECK: entry: -// CHECK: [[BPTYPE:%.*]] = call %swift.type* @"$S23partial_apply_forwarder12BaseProducerVMa"(%swift.type* %"\CF\84_0_1") -// CHECK: [[WEAKBOXTYPE:%.*]] = call %swift.type* @"$S23partial_apply_forwarder7WeakBoxCMa"(%swift.type* [[BPTYPE]]) +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S23partial_apply_forwarder12BaseProducerVMa"([[INT]] 0, %swift.type* %"\CF\84_0_1") +// CHECK: [[BPTYPE:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S23partial_apply_forwarder7WeakBoxCMa"([[INT]] 0, %swift.type* [[BPTYPE]]) +// CHECK: [[WEAKBOXTYPE:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[OBJ:%.*]] = call noalias %swift.refcounted* @swift_allocObject(%swift.type* [[WEAKBOXTYPE]] // CHECK: [[WB:%.*]] = bitcast %swift.refcounted* [[OBJ]] to %T23partial_apply_forwarder7WeakBoxC* // CHECK: [[REF:%.*]] = bitcast %T23partial_apply_forwarder7WeakBoxC* [[WB]] to %swift.refcounted* @@ -138,8 +142,10 @@ bb0(%0 : $*Ï„_0_1, %2: $EmptyType): // CHECK-LABEL: define{{( protected)?}} swiftcc void @bind_polymorphic_param_from_forwarder_parameter(%swift.opaque* noalias nocapture, %swift.type* %"\CF\84_0_1") // CHECK: entry: -// CHECK: [[BPTY:%.*]] = call %swift.type* @"$S23partial_apply_forwarder12BaseProducerVMa"(%swift.type* %"\CF\84_0_1") -// CHECK: [[WBTY:%.*]] = call %swift.type* @"$S23partial_apply_forwarder7WeakBoxCMa"(%swift.type* [[BPTY]] +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S23partial_apply_forwarder12BaseProducerVMa"([[INT]] 0, %swift.type* %"\CF\84_0_1") +// CHECK: [[BPTY:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S23partial_apply_forwarder7WeakBoxCMa"([[INT]] 0, %swift.type* [[BPTY]] +// CHECK: [[WBTY:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: call noalias %swift.refcounted* @swift_allocObject(%swift.type* [[WBTY]] // CHECK: ret void @@ -172,8 +178,10 @@ sil hidden_external @takingQAndS : $@convention(thin) <Ï„_0_0 where Ï„_0_0 : Q> // CHECK-LABEL: define{{( protected)?}} swiftcc { i8*, %swift.refcounted* } @bind_polymorphic_param_from_context_with_layout(%swift.opaque* noalias nocapture, i64, %swift.type* %"\CF\84_0_1") // CHECK: entry: -// CHECK: [[BPTY:%.*]] = call %swift.type* @"$S23partial_apply_forwarder12BaseProducerVMa"(%swift.type* %"\CF\84_0_1") -// CHECK: [[WBTY:%.*]] = call %swift.type* @"$S23partial_apply_forwarder7WeakBoxCMa"(%swift.type* [[BPTY]] +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S23partial_apply_forwarder12BaseProducerVMa"([[INT]] 0, %swift.type* %"\CF\84_0_1") +// CHECK: [[BPTY:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S23partial_apply_forwarder7WeakBoxCMa"([[INT]] 0, %swift.type* [[BPTY]] +// CHECK: [[WBTY:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[WBREF:%.*]] = call noalias %swift.refcounted* @swift_allocObject(%swift.type* [[WBTY]] // CHECK: [[WB:%.*]] = bitcast %swift.refcounted* [[WBREF]] to %T23partial_apply_forwarder7WeakBoxC* // CHECK: [[CONTEXT0:%.*]] = call noalias %swift.refcounted* @swift_allocObject diff --git a/test/IRGen/protocol_resilience.sil b/test/IRGen/protocol_resilience.sil index 29ecd845b28..58dcacc83a4 100644 --- a/test/IRGen/protocol_resilience.sil +++ b/test/IRGen/protocol_resilience.sil @@ -1,6 +1,6 @@ // RUN: %empty-directory(%t) // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_protocol.swiftmodule -module-name=resilient_protocol %S/../Inputs/resilient_protocol.swift -// RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience -assume-parsing-unqualified-ownership-sil %s | %FileCheck %s +// RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience -assume-parsing-unqualified-ownership-sil %s | %FileCheck %s -DINT=i%target-ptrsize // RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience -O -assume-parsing-unqualified-ownership-sil %s sil_stage canonical @@ -18,16 +18,16 @@ import resilient_protocol // CHECK-SAME: [%swift.protocol_requirement { i32 6, i32 0 }, // CHECK-SAME: %swift.protocol_requirement { i32 7, i32 0 }, // CHECK-SAME: %swift.protocol_requirement { i32 17, i32 0 }, -// CHECK-SAME: %swift.protocol_requirement { i32 17, i32{{ | trunc \(i64 }}sub ({{i32|i64}} ptrtoint (void (%swift.opaque*, %swift.type*, i8**)* @defaultC to {{i32|i64}}), {{i32|i64}} ptrtoint (i32* getelementptr inbounds ([8 x %swift.protocol_requirement], [8 x %swift.protocol_requirement]* [[RP_REQTS]], i32 0, i32 4, i32 1) to {{i32|i64}})){{ | to i32\) }}}, -// CHECK-SAME: %swift.protocol_requirement { i32 17, i32{{ | trunc \(i64 }}sub ({{i32|i64}} ptrtoint (void (%swift.opaque*, %swift.type*, i8**)* @defaultD to {{i32|i64}}), {{i32|i64}} ptrtoint (i32* getelementptr inbounds ([8 x %swift.protocol_requirement], [8 x %swift.protocol_requirement]* [[RP_REQTS]], i32 0, i32 5, i32 1) to {{i32|i64}})){{ | to i32\) }}}, -// CHECK-SAME: %swift.protocol_requirement { i32 1, i32{{ | trunc \(i64 }}sub ({{i32|i64}} ptrtoint (void (%swift.type*, %swift.type*, i8**)* @defaultE to {{i32|i64}}), {{i32|i64}} ptrtoint (i32* getelementptr inbounds ([8 x %swift.protocol_requirement], [8 x %swift.protocol_requirement]* [[RP_REQTS]], i32 0, i32 6, i32 1) to {{i32|i64}})){{ | to i32\) }}}, -// CHECK-SAME: %swift.protocol_requirement { i32 1, i32{{ | trunc \(i64 }}sub ({{i32|i64}} ptrtoint (void (%swift.type*, %swift.type*, i8**)* @defaultF to {{i32|i64}}), {{i32|i64}} ptrtoint (i32* getelementptr inbounds ([8 x %swift.protocol_requirement], [8 x %swift.protocol_requirement]* [[RP_REQTS]], i32 0, i32 7, i32 1) to {{i32|i64}})){{ | to i32\) }}}] +// CHECK-SAME: %swift.protocol_requirement { i32 17, i32{{ | trunc \(i64 }}sub ([[INT]] ptrtoint (void (%swift.opaque*, %swift.type*, i8**)* @defaultC to [[INT]]), [[INT]] ptrtoint (i32* getelementptr inbounds ([8 x %swift.protocol_requirement], [8 x %swift.protocol_requirement]* [[RP_REQTS]], i32 0, i32 4, i32 1) to [[INT]])){{ | to i32\) }}}, +// CHECK-SAME: %swift.protocol_requirement { i32 17, i32{{ | trunc \(i64 }}sub ([[INT]] ptrtoint (void (%swift.opaque*, %swift.type*, i8**)* @defaultD to [[INT]]), [[INT]] ptrtoint (i32* getelementptr inbounds ([8 x %swift.protocol_requirement], [8 x %swift.protocol_requirement]* [[RP_REQTS]], i32 0, i32 5, i32 1) to [[INT]])){{ | to i32\) }}}, +// CHECK-SAME: %swift.protocol_requirement { i32 1, i32{{ | trunc \(i64 }}sub ([[INT]] ptrtoint (void (%swift.type*, %swift.type*, i8**)* @defaultE to [[INT]]), [[INT]] ptrtoint (i32* getelementptr inbounds ([8 x %swift.protocol_requirement], [8 x %swift.protocol_requirement]* [[RP_REQTS]], i32 0, i32 6, i32 1) to [[INT]])){{ | to i32\) }}}, +// CHECK-SAME: %swift.protocol_requirement { i32 1, i32{{ | trunc \(i64 }}sub ([[INT]] ptrtoint (void (%swift.type*, %swift.type*, i8**)* @defaultF to [[INT]]), [[INT]] ptrtoint (i32* getelementptr inbounds ([8 x %swift.protocol_requirement], [8 x %swift.protocol_requirement]* [[RP_REQTS]], i32 0, i32 7, i32 1) to [[INT]])){{ | to i32\) }}}] // CHECK: @"$S19protocol_resilience17ResilientProtocolMp" = {{(protected )?}}constant %swift.protocol { // CHECK-SAME: i32 1031, // CHECK-SAME: i16 4, // CHECK-SAME: i16 8, -// CHECK-SAME: i32{{ | trunc \(i64 }}sub ({{i32|i64}} ptrtoint ([8 x %swift.protocol_requirement]* [[RP_REQTS]] to {{i32|i64}}), {{i32|i64}} ptrtoint (i32* getelementptr inbounds (%swift.protocol, %swift.protocol* @"$S19protocol_resilience17ResilientProtocolMp", i32 0 +// CHECK-SAME: i32{{ | trunc \(i64 }}sub ([[INT]] ptrtoint ([8 x %swift.protocol_requirement]* [[RP_REQTS]] to [[INT]]), [[INT]] ptrtoint (i32* getelementptr inbounds (%swift.protocol, %swift.protocol* @"$S19protocol_resilience17ResilientProtocolMp", i32 0 // CHECK-SAME: } @@ -49,7 +49,7 @@ public protocol ResilientProtocol { // CHECK-SAME: i32 7, // CHECK-SAME: i16 1, // CHECK-SAME: i16 1, -// CHECK-SAME: i32{{ | trunc \(i64 }}sub ({{i32|i64}} ptrtoint ([1 x %swift.protocol_requirement]* [[IP_REQTS:@.*]] to {{i32|i64}}), {{i32|i64}} ptrtoint (i32* getelementptr inbounds (%swift.protocol, %swift.protocol* @"$S19protocol_resilience16InternalProtocolMp", i32 0 +// CHECK-SAME: i32{{ | trunc \(i64 }}sub ([[INT]] ptrtoint ([1 x %swift.protocol_requirement]* [[IP_REQTS:@.*]] to [[INT]]), [[INT]] ptrtoint (i32* getelementptr inbounds (%swift.protocol, %swift.protocol* @"$S19protocol_resilience16InternalProtocolMp", i32 0 // CHECK-SAME: } protocol InternalProtocol { @@ -60,7 +60,7 @@ protocol InternalProtocol { // Witness table for conformance with resilient associated type // CHECK: @"$S19protocol_resilience26ConformsWithResilientAssocVAA03HaseF0AAWP" = {{(protected )?}}hidden constant [3 x i8*] [ -// CHECK-SAME: i8* bitcast (%swift.type* ()* @"$S19protocol_resilience23ResilientConformingTypeVMa" to i8*), +// CHECK-SAME: i8* bitcast (%swift.metadata_response ([[INT]])* @"$S19protocol_resilience23ResilientConformingTypeVMa" to i8*), // CHECK-SAME: i8* bitcast (i8** ()* @"$S19protocol_resilience23ResilientConformingTypeV010resilient_A005OtherC8ProtocolAAWa" to i8*) // CHECK-SAME: ] diff --git a/test/IRGen/same_type_constraints.swift b/test/IRGen/same_type_constraints.swift index 80ccdc544d3..a8ca7fe8618 100644 --- a/test/IRGen/same_type_constraints.swift +++ b/test/IRGen/same_type_constraints.swift @@ -60,5 +60,5 @@ where Self : CodingType, print(Self.ValueType.self) } -// OSIZE: define internal i8** @"$S21same_type_constraints12GenericKlazzCyxq_GAA1EAA4Data_AA0F4TypePWT"(%swift.type* %"GenericKlazz.Data", %swift.type* nocapture readonly %"GenericKlazz", i8** nocapture readnone %"GenericKlazz.E") [[ATTRS:#[0-9]+]] { +// OSIZE: define internal swiftcc i8** @"$S21same_type_constraints12GenericKlazzCyxq_GAA1EAA4Data_AA0F4TypePWT"(%swift.type* %"GenericKlazz.Data", %swift.type* nocapture readonly %"GenericKlazz", i8** nocapture readnone %"GenericKlazz.E") [[ATTRS:#[0-9]+]] { // OSIZE: [[ATTRS]] = {{{.*}}noinline diff --git a/test/IRGen/sil_witness_tables.swift b/test/IRGen/sil_witness_tables.swift index c83060b417d..066dbbadb92 100644 --- a/test/IRGen/sil_witness_tables.swift +++ b/test/IRGen/sil_witness_tables.swift @@ -42,7 +42,7 @@ struct Conformer: Q, QQ { // CHECK: i8* bitcast (void (%T18sil_witness_tables9ConformerV*, %swift.type*, i8**)* @"$S18sil_witness_tables9ConformerVAA1QA2aDP7qMethod{{[_0-9a-zA-Z]*}}FTW" to i8*) // CHECK: ] // CHECK: [[CONFORMER_P_WITNESS_TABLE]] = hidden constant [5 x i8*] [ -// CHECK: i8* bitcast (%swift.type* ()* @"$S18sil_witness_tables14AssocConformerVMa" to i8*), +// CHECK: i8* bitcast (%swift.metadata_response (i64)* @"$S18sil_witness_tables14AssocConformerVMa" to i8*), // CHECK: i8* bitcast (i8** ()* @"$S18sil_witness_tables14AssocConformerVAA1AAAWa" to i8*) // CHECK: i8* bitcast (void (%swift.type*, %swift.type*, i8**)* @"$S18sil_witness_tables9ConformerVAA1PA2aDP12staticMethod{{[_0-9a-zA-Z]*}}FZTW" to i8*), // CHECK: i8* bitcast (void (%T18sil_witness_tables9ConformerV*, %swift.type*, i8**)* @"$S18sil_witness_tables9ConformerVAA1PA2aDP14instanceMethod{{[_0-9a-zA-Z]*}}FTW" to i8*) @@ -73,8 +73,8 @@ func externalErasure(c: ExternalConformer) -> ExternalP { // FIXME: why do these have different linkages? -// CHECK-LABEL: define hidden %swift.type* @"$S18sil_witness_tables14AssocConformerVMa"() -// CHECK: ret %swift.type* bitcast (i64* getelementptr inbounds {{.*}} @"$S18sil_witness_tables14AssocConformerVMf", i32 0, i32 1) to %swift.type*) +// CHECK-LABEL: define hidden swiftcc %swift.metadata_response @"$S18sil_witness_tables14AssocConformerVMa"(i64) +// CHECK: ret %swift.metadata_response { %swift.type* bitcast (i64* getelementptr inbounds {{.*}} @"$S18sil_witness_tables14AssocConformerVMf", i32 0, i32 1) to %swift.type*), i64 0 } // CHECK-LABEL: define hidden i8** @"$S18sil_witness_tables9ConformerVAA1PAAWa"() // CHECK: ret i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @"$S18sil_witness_tables9ConformerVAA1PAAWP", i32 0, i32 0) diff --git a/test/IRGen/static_initializer.sil b/test/IRGen/static_initializer.sil index 13c382b8774..e6ec2222491 100644 --- a/test/IRGen/static_initializer.sil +++ b/test/IRGen/static_initializer.sil @@ -149,7 +149,8 @@ bb0: // CHECK-LABEL: define{{( protected)?}} swiftcc %T18static_initializer16TestArrayStorageC* @return_static_array() {{.*}} { sil @return_static_array : $@convention(thin) () -> TestArray { bb0: - // CHECK: [[MD:%[0-9]+]] = call %swift.type* @"$S18static_initializer16TestArrayStorageCMa"() + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S18static_initializer16TestArrayStorageCMa"(i64 0) + // CHECK: [[MD:%[0-9]+]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[O:%[0-9a-z]+]] = call %swift.refcounted* @swift_initStaticObject(%swift.type* [[MD]], %swift.refcounted* getelementptr inbounds (%T18static_initializer16TestArrayStorageC_tailelems0c, %T18static_initializer16TestArrayStorageC_tailelems0c* @static_array, i32 0, i32 1, i32 0)) // CHECK: [[R:%[0-9]+]] = bitcast %swift.refcounted* [[O]] to %T18static_initializer16TestArrayStorageC_tailelems0* // CHECK: [[R2:%[0-9]+]] = bitcast %T18static_initializer16TestArrayStorageC_tailelems0* [[R]] to %T18static_initializer16TestArrayStorageC* diff --git a/test/IRGen/struct_resilience.swift b/test/IRGen/struct_resilience.swift index 3c79ea4a3f6..14137b14296 100644 --- a/test/IRGen/struct_resilience.swift +++ b/test/IRGen/struct_resilience.swift @@ -20,7 +20,8 @@ import resilient_enum public func functionWithResilientTypes(_ s: Size, f: (Size) -> Size) -> Size { -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S16resilient_struct4SizeVMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S16resilient_struct4SizeVMa"([[INT]] 0) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[METADATA_ADDR:%.*]] = bitcast %swift.type* [[METADATA]] to i8*** // CHECK: [[VWT_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[METADATA_ADDR]], [[INT]] -1 // CHECK: [[VWT:%.*]] = load i8**, i8*** [[VWT_ADDR]] @@ -37,7 +38,8 @@ public func functionWithResilientTypes(_ s: Size, f: (Size) -> Size) -> Size { // CHECK: [[STRUCT_LOC:%.*]] = call %swift.opaque* [[initializeWithCopy]](%swift.opaque* noalias [[STRUCT_ADDR]], %swift.opaque* noalias %1, %swift.type* [[METADATA]]) // CHECK: [[FN:%.*]] = bitcast i8* %2 to void (%swift.opaque*, %swift.opaque*, %swift.refcounted*)* -// CHECK: call swiftcc void [[FN]](%swift.opaque* noalias nocapture sret %0, %swift.opaque* noalias nocapture [[STRUCT_ADDR]], %swift.refcounted* swiftself %15) +// CHECK: [[SELF:%.*]] = bitcast %swift.opaque* %3 to %swift.refcounted* +// CHECK: call swiftcc void [[FN]](%swift.opaque* noalias nocapture sret %0, %swift.opaque* noalias nocapture [[STRUCT_ADDR]], %swift.refcounted* swiftself [[SELF]]) // CHECK: [[WITNESS_PTR:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], i32 1 // CHECK: [[WITNESS:%.*]] = load i8*, i8** [[WITNESS_PTR]] @@ -48,7 +50,8 @@ public func functionWithResilientTypes(_ s: Size, f: (Size) -> Size) -> Size { return f(s) } -// CHECK-LABEL: declare %swift.type* @"$S16resilient_struct4SizeVMa"() +// CHECK-LABEL: declare swiftcc %swift.metadata_response @"$S16resilient_struct4SizeVMa" +// CHECK-SAME: ([[INT]]) // Rectangle has fixed layout inside its resilience domain, and dynamic // layout on the outside. @@ -59,7 +62,8 @@ public func functionWithResilientTypes(_ s: Size, f: (Size) -> Size) -> Size { // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S17struct_resilience26functionWithResilientTypesyy010resilient_A09RectangleVF"(%T16resilient_struct9RectangleV* noalias nocapture) public func functionWithResilientTypes(_ r: Rectangle) { -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S16resilient_struct9RectangleVMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S16resilient_struct9RectangleVMa"([[INT]] 0) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[METADATA_ADDR:%.*]] = bitcast %swift.type* [[METADATA]] to [[INT]]* // CHECK-NEXT: [[FIELD_OFFSET_VECTOR:%.*]] = getelementptr inbounds [[INT]], [[INT]]* [[METADATA_ADDR]], [[INT]] 2 // CHECK-NEXT: [[FIELD_OFFSET_PTR:%.*]] = getelementptr inbounds [[INT]], [[INT]]* [[FIELD_OFFSET_VECTOR]], i32 2 @@ -116,7 +120,8 @@ public struct StructWithResilientStorage { // metadata when accessing stored properties. // CHECK-LABEL: define{{( protected)?}} swiftcc {{i32|i64}} @"$S17struct_resilience26StructWithResilientStorageV1nSivg"(%T17struct_resilience26StructWithResilientStorageV* {{.*}}) -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S17struct_resilience26StructWithResilientStorageVMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S17struct_resilience26StructWithResilientStorageVMa"([[INT]] 0) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[METADATA_ADDR:%.*]] = bitcast %swift.type* [[METADATA]] to [[INT]]* // CHECK-NEXT: [[FIELD_OFFSET_VECTOR:%.*]] = getelementptr inbounds [[INT]], [[INT]]* [[METADATA_ADDR]], [[INT]] 2 // CHECK-NEXT: [[FIELD_OFFSET_PTR:%.*]] = getelementptr inbounds [[INT]], [[INT]]* [[FIELD_OFFSET_VECTOR]], i32 2 @@ -166,8 +171,9 @@ public func partialApplyOfResilientMethod(s: Size) { // Public metadata accessor for our resilient struct -// CHECK-LABEL: define{{( protected)?}} %swift.type* @"$S17struct_resilience6MySizeVMa"() -// CHECK: ret %swift.type* bitcast ([[INT]]* getelementptr inbounds {{.*}} @"$S17struct_resilience6MySizeVMf", i32 0, i32 1) to %swift.type*) +// CHECK-LABEL: define{{( protected)?}} swiftcc %swift.metadata_response @"$S17struct_resilience6MySizeVMa" +// CHECK-SAME: ([[INT]]) +// CHECK: ret %swift.metadata_response { %swift.type* bitcast ([[INT]]* getelementptr inbounds {{.*}} @"$S17struct_resilience6MySizeVMf", i32 0, i32 1) to %swift.type*), [[INT]] 0 } // CHECK-LABEL: define{{( protected)?}} private void @initialize_metadata_StructWithResilientStorage(i8*) diff --git a/test/IRGen/subclass.swift b/test/IRGen/subclass.swift index e91d242f85d..e3dbce1a39d 100644 --- a/test/IRGen/subclass.swift +++ b/test/IRGen/subclass.swift @@ -59,7 +59,7 @@ class G : A { // CHECK: define hidden swiftcc %T8subclass1GCySiG* @"$S8subclass9a_to_gint1aAA1GCySiGAA1AC_tF"(%T8subclass1AC*) {{.*}} { func a_to_gint(a: A) -> G { - // CHECK: call %swift.type* @"$S8subclass1GCySiGMa"() + // CHECK: call swiftcc %swift.metadata_response @"$S8subclass1GCySiGMa"(i64 0) // CHECK: call i8* @swift_dynamicCastClassUnconditional return a as! G } diff --git a/test/IRGen/subclass_existentials.sil b/test/IRGen/subclass_existentials.sil index 7df7c0ba8bd..50c8a080adc 100644 --- a/test/IRGen/subclass_existentials.sil +++ b/test/IRGen/subclass_existentials.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -primary-file %s -emit-ir | %FileCheck %s --check-prefix=CHECK-%target-runtime --check-prefix=CHECK +// RUN: %target-swift-frontend -primary-file %s -emit-ir | %FileCheck %s --check-prefix=CHECK-%target-runtime --check-prefix=CHECK -DINT=i%target-ptrsize sil_stage canonical @@ -41,18 +41,21 @@ sil @takesMetadata : $@convention(thin) (@thick T.Type) -> () // CHECK-LABEL: define{{( protected)?}} swiftcc void @checkMetadata() // CHECK-NEXT: entry: -// CHECK-NEXT: %0 = call %swift.type* @"$S21subclass_existentials1P_AA1CCXcMa"() -// CHECK-NEXT: call swiftcc void @takesMetadata(%swift.type* %0, %swift.type* %0) +// CHECK-NEXT: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S21subclass_existentials1P_AA1CCXcMa"([[INT]] 0) +// CHECK-NEXT: [[TYPE:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 +// CHECK-NEXT: call swiftcc void @takesMetadata(%swift.type* [[TYPE]], %swift.type* [[TYPE]]) // CHECK-NEXT: ret void -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$S21subclass_existentials1P_AA1CCXcMa"() +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$S21subclass_existentials1P_AA1CCXcMa" +// CHECK-SAME: ([[INT]]) // CHECK: entry: // CHECK-NEXT: [[PROTOCOL_ARRAY:%.*]] = alloca [1 x %swift.protocol*] // CHECK: cacheIsNull: // CHECK: [[PROTOCOLS:%.*]] = bitcast [1 x %swift.protocol*]* [[PROTOCOL_ARRAY]] to %swift.protocol** // CHECK-NEXT: [[PROTOCOL:%.*]] = getelementptr inbounds %swift.protocol*, %swift.protocol** [[PROTOCOLS]], i32 0 // CHECK-NEXT: store %swift.protocol* @"$S21subclass_existentials1PMp", %swift.protocol** [[PROTOCOL]] -// CHECK-NEXT: [[SUPERCLASS:%.*]] = call %swift.type* @"$S21subclass_existentials1CCMa"() +// CHECK-NEXT: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S21subclass_existentials1CCMa"([[INT]] 0) +// CHECK-NEXT: [[SUPERCLASS:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[METATYPE:%.*]] = call %swift.type* @swift_getExistentialTypeMetadata(i1 false, %swift.type* [[SUPERCLASS]], {{i32|i64}} 1, %swift.protocol** [[PROTOCOLS]]) // CHECK: ret @@ -95,7 +98,8 @@ bb0(%0 : $C, %1 : $C & P): // CHECK: [[METATYPE_PTR:%.*]] = bitcast %T21subclass_existentials1CC* %0 to %swift.type** // CHECK-NEXT: [[METATYPE:%.*]] = load %swift.type*, %swift.type** [[METATYPE_PTR]], align {{4|8}} // CHECK-NEXT: [[VALUE:%.*]] = bitcast %T21subclass_existentials1CC* %0 to i8* -// CHECK-NEXT: [[SUPERCLASS:%.*]] = call %swift.type* @"$S21subclass_existentials1DCMa"() +// CHECK-NEXT: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S21subclass_existentials1DCMa"([[INT]] 0) +// CHECK-NEXT: [[SUPERCLASS:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[RESULT:%.*]] = call { i8*, i8** } @dynamic_cast_existential_1_superclass_unconditional(i8* [[VALUE]], %swift.type* [[METATYPE]], %swift.type* [[SUPERCLASS]], %swift.protocol* @"$S21subclass_existentials1RMp") // CHECK-NEXT: [[VALUE_ADDR:%.*]] = extractvalue { i8*, i8** } [[RESULT]], 0 // CHECK-NEXT: [[VALUE:%.*]] = bitcast i8* [[VALUE_ADDR]] to %T21subclass_existentials1DC* @@ -180,7 +184,8 @@ sil @checkExistentialMetatypeDowncast : $@convention(thin) (@owned @thick C.Type bb0(%0 : $@thick C.Type, %1 : $@thick (C & P).Type): // CHECK: [[METATYPE:%.*]] = bitcast %swift.type* %0 to i8* -// CHECK-NEXT: [[SUPERCLASS:%.*]] = call %swift.type* @"$S21subclass_existentials1DCMa"() +// CHECK-NEXT: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S21subclass_existentials1DCMa"([[INT]] 0) +// CHECK-NEXT: [[SUPERCLASS:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[RESULT:%.*]] = call { i8*, i8** } @dynamic_cast_existential_1_superclass_unconditional(i8* [[METATYPE]], %swift.type* %0, %swift.type* [[SUPERCLASS]], %swift.protocol* @"$S21subclass_existentials1RMp") // CHECK-NEXT: [[VALUE_ADDR:%.*]] = extractvalue { i8*, i8** } [[RESULT]], 0 // CHECK-NEXT: [[VALUE:%.*]] = bitcast i8* [[VALUE_ADDR]] to %swift.type* diff --git a/test/IRGen/super.sil b/test/IRGen/super.sil index e236e472c1d..005b700e1dd 100644 --- a/test/IRGen/super.sil +++ b/test/IRGen/super.sil @@ -53,7 +53,8 @@ bb0(%0 : $ChildToResilientParent): // ChildToResilientParent is in our resilience domain - can load the superclass's metadata directly. // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S5super22ChildToResilientParentC6methodyyF"(%T5super22ChildToResilientParentC* swiftself) -// CHECK: [[SUPER_METADATA:%.*]] = call %swift.type* @"$S15resilient_class22ResilientOutsideParentCMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S15resilient_class22ResilientOutsideParentCMa"([[INT]] 0) +// CHECK: [[SUPER_METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[BASE:%.*]] = load [[INT]], [[INT]]* getelementptr inbounds ([[BOUNDS:{.*}]], {{.*}}* @"$S15resilient_class22ResilientOutsideParentCMo", i32 0, i32 0) // CHECK: [[VTABLE_OFFSET:%.*]] = add [[INT]] [[BASE]], {{20|40}} // CHECK: [[SUPER_ADDR:%.*]] = bitcast %swift.type* [[SUPER_METADATA]] to i8* @@ -75,7 +76,8 @@ bb0(%0 : $@thick ChildToResilientParent.Type): // ChildToResilientParent is in our resilience domain - can load the superclass's metadata directly. // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S5super22ChildToResilientParentC11classMethodyyFZ"(%swift.type* swiftself) -// CHECK: [[SUPER_METADATA:%.*]] = call %swift.type* @"$S15resilient_class22ResilientOutsideParentCMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S15resilient_class22ResilientOutsideParentCMa"([[INT]] 0) +// CHECK: [[SUPER_METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[BASE:%.*]] = load [[INT]], [[INT]]* getelementptr inbounds ([[BOUNDS]], [[BOUNDS]]* @"$S15resilient_class22ResilientOutsideParentCMo", i32 0, i32 0) // CHECK: [[VTABLE_OFFSET:%.*]] = add [[INT]] [[BASE]], {{24|48}} // CHECK: [[SUPER_ADDR:%.*]] = bitcast %swift.type* [[SUPER_METADATA]] to i8* @@ -105,7 +107,8 @@ bb0(%0 : $ChildToFixedParent): } // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S5super18ChildToFixedParentC6methodyyF"(%T5super18ChildToFixedParentC* swiftself) -// CHECK: [[SUPER_METADATA:%.*]] = call %swift.type* @"$S15resilient_class13OutsideParentCMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S15resilient_class13OutsideParentCMa"([[INT]] 0) +// CHECK: [[SUPER_METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[OPAQUE_SUPER_METADATA:%.*]] = bitcast %swift.type* [[SUPER_METADATA]] to void (%T15resilient_class13OutsideParentC*)** // CHECK: [[VTABLE_SLOT:%.*]] = getelementptr inbounds void (%T15resilient_class13OutsideParentC*)*, void (%T15resilient_class13OutsideParentC*)** [[OPAQUE_SUPER_METADATA]] // CHECK: [[FN_PTR:%.*]] = load void (%T15resilient_class13OutsideParentC*)*, void (%T15resilient_class13OutsideParentC*)** [[VTABLE_SLOT]] @@ -125,7 +128,8 @@ bb0(%0 : $@thick ChildToFixedParent.Type): // ChildToFixedParent is in our resilience domain - load super metadata directly. // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S5super18ChildToFixedParentC11classMethodyyFZ"(%swift.type* swiftself) -// CHECK: [[SUPER_METADATA:%.*]] = call %swift.type* @"$S15resilient_class13OutsideParentCMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S15resilient_class13OutsideParentCMa"([[INT]] 0) +// CHECK: [[SUPER_METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[OPAQUE_SUPER_METADATA:%.*]] = bitcast %swift.type* [[SUPER_METADATA]] to void (%swift.type*)** // CHECK: [[VTABLE_SLOT:%.*]] = getelementptr inbounds void (%swift.type*)*, void (%swift.type*)** [[OPAQUE_SUPER_METADATA]] // CHECK: [[FN_PTR:%.*]] = load void (%swift.type*)*, void (%swift.type*)** [[VTABLE_SLOT]] @@ -147,7 +151,8 @@ bb0(%0 : $ResilientOutsideChild): // Extending a resilient class - load super metadata indirectly. // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S15resilient_class21ResilientOutsideChildC5superE15callSuperMethodyyF"(%T15resilient_class21ResilientOutsideChildC* swiftself) -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S15resilient_class21ResilientOutsideChildCMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S15resilient_class21ResilientOutsideChildCMa"([[INT]] 0) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[OPAQUE_METADATA:%.*]] = bitcast %swift.type* [[METADATA]] to %swift.type** // CHECK: [[SUPER_METADATA_PTR:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[OPAQUE_METADATA]], i32 1 // CHECK: [[SUPER_METADATA:%.*]] = load %swift.type*, %swift.type** [[SUPER_METADATA_PTR]] @@ -173,7 +178,8 @@ bb0(%0 : $@thick ResilientOutsideChild.Type): // Extending a resilient class - load super metadata indirectly. // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S15resilient_class21ResilientOutsideChildC5superE20callSuperClassMethodyyFZ"(%swift.type* swiftself) -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S15resilient_class21ResilientOutsideChildCMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S15resilient_class21ResilientOutsideChildCMa"([[INT]] 0) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[OPAQUE_METADATA:%.*]] = bitcast %swift.type* [[METADATA]] to %swift.type** // CHECK: [[SUPER_METADATA_PTR:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[OPAQUE_METADATA]], i32 1 // CHECK: [[SUPER_METADATA:%.*]] = load %swift.type*, %swift.type** [[SUPER_METADATA_PTR]] @@ -216,7 +222,8 @@ sil_vtable Derived { } // CHECK-LABEL: define{{.*}} @test_super_method_of_generic_base -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S5super4BaseCyAA3StrVGMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S5super4BaseCyAA3StrVGMa"([[INT]] 0) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[BASEMETADATA:%.*]] = bitcast %swift.type* [[METADATA]] to void (%T5super4BaseC*)** // CHECK: [[GEP:%.*]] = getelementptr inbounds void (%T5super4BaseC*)*, void (%T5super4BaseC*)** [[BASEMETADATA]] // CHECK: [[SUPERMT:%.*]] = load void (%T5super4BaseC*)*, void (%T5super4BaseC*)** [[GEP]] diff --git a/test/IRGen/tail_alloc.sil b/test/IRGen/tail_alloc.sil index e643840f960..f33fc770975 100644 --- a/test/IRGen/tail_alloc.sil +++ b/test/IRGen/tail_alloc.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -stack-promotion-limit 48 -Onone -emit-ir %s | %FileCheck %s +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -stack-promotion-limit 48 -Onone -emit-ir %s | %FileCheck %s -DINT=i%target-ptrsize // // REQUIRES: CPU=x86_64 @@ -17,7 +17,8 @@ sil_vtable TestClass {} // CHECK-LABEL: define{{( protected)?}} swiftcc void @alloc_on_stack // CHECK: %reference.raw = alloca i8, i32 28, align 8 -// CHECK-NEXT: [[M:%[0-9]+]] = call %swift.type* @"$S{{[a-zA-Z0-9_]+}}Ma"() +// CHECK-NEXT: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S{{[a-zA-Z0-9_]+}}Ma"([[INT]] 0) +// CHECK-NEXT: [[M:%[0-9]+]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[O:%[0-9]+]] = bitcast i8* %reference.raw to %swift.refcounted* // CHECK-NEXT: %reference.new = call %swift.refcounted* @swift_initStackObject(%swift.type* [[M]], %swift.refcounted* [[O]]) // CHECK-NEXT: [[R:%[0-9]+]] = bitcast %swift.refcounted* %reference.new to %[[C:.*TestClass.*]]* @@ -34,7 +35,8 @@ bb0: } // CHECK-LABEL: define{{( protected)?}} {{.*}}* @alloc_on_heap -// CHECK: [[M:%[0-9]+]] = call %swift.type* @"$S{{[a-zA-Z0-9_]+}}Ma"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S{{[a-zA-Z0-9_]+}}Ma"([[INT]] 0) +// CHECK: [[M:%[0-9]+]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[O:%[0-9]+]] = call noalias %swift.refcounted* @swift_allocObject(%swift.type* [[M]], i64 28, i64 7) // CHECK-NEXT: [[O2:%[0-9]+]] = bitcast %swift.refcounted* [[O]] to %[[C:.*TestClass.*]]* // CHECK-NEXT: ret %[[C]]* [[O2]] @@ -46,7 +48,8 @@ bb0: } // CHECK-LABEL: define{{( protected)?}} {{.*}}* @alloc_3_on_heap -// CHECK: [[M:%[0-9]+]] = call %swift.type* @"$S{{[a-zA-Z0-9_]+}}CMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S{{[a-zA-Z0-9_]+}}CMa"([[INT]] 0) +// CHECK: [[M:%[0-9]+]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[O:%[0-9]+]] = call noalias %swift.refcounted* @swift_allocObject(%swift.type* [[M]], i64 40, i64 7) // CHECK-NEXT: [[O2:%[0-9]+]] = bitcast %swift.refcounted* [[O]] to %[[C:.*TestClass.*]]* // CHECK-NEXT: ret %[[C]]* [[O2]] @@ -60,7 +63,8 @@ bb0: } // CHECK-LABEL: define{{( protected)?}} {{.*}}* @alloc_non_const_count -// CHECK: [[M:%[0-9]+]] = call %swift.type* @"$S{{[a-zA-Z0-9_]+}}Ma"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S{{[a-zA-Z0-9_]+}}Ma"([[INT]] 0) +// CHECK: [[M:%[0-9]+]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[S:%[0-9]+]] = mul i64 4, %0 // CHECK-NEXT: [[A:%[0-9]+]] = add i64 20, [[S]] // CHECK-NEXT: [[O:%[0-9]+]] = call noalias %swift.refcounted* @swift_allocObject(%swift.type* [[M]], i64 [[A]], i64 7) @@ -73,7 +77,8 @@ bb0(%c : $Builtin.Word): } // CHECK-LABEL: define{{( protected)?}} {{.*}}* @alloc_2_non_const_count -// CHECK: [[M:%[0-9]+]] = call %swift.type* @"$S{{[a-zA-Z0-9_]+}}Ma"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S{{[a-zA-Z0-9_]+}}Ma"([[INT]] 0) +// CHECK: [[M:%[0-9]+]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[S1:%[0-9]+]] = mul i64 1, %0 // CHECK-NEXT: [[S2:%[0-9]+]] = add i64 17, [[S1]] // CHECK-NEXT: [[S3:%[0-9]+]] = add i64 [[S2]], 3 @@ -205,7 +210,7 @@ bb0(%0 : $Builtin.RawPointer, %1 : $Int32): } // CHECK-LABEL: define{{( protected)?}} swiftcc i8* @project_tail_index_generic_struct -// CHECK: call %swift.type* @{{.*Str.*}}(%swift.type* %T) +// CHECK: call swiftcc %swift.metadata_response @{{.*Str.*}}([[INT]] 0, %swift.type* %T) // CHECK: load // CHECK: and // CHECK: xor diff --git a/test/IRGen/type_layout.swift b/test/IRGen/type_layout.swift index 80d327c6e3c..9c0a0f58aa0 100644 --- a/test/IRGen/type_layout.swift +++ b/test/IRGen/type_layout.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -DINT=i%target-ptrsize class C {} @@ -57,7 +57,8 @@ struct TypeLayoutTest { // CHECK: store i8** [[T_LAYOUT]] var i: GSing // -- Multi-element generic struct, need to derive from metadata - // CHECK: [[METADATA:%.*]] = call %swift.type* @"$S11type_layout5GMultVMa" + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S11type_layout5GMultVMa"([[INT]] 0, %swift.type* %T) + // CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[T0:%.*]] = bitcast %swift.type* [[METADATA]] to i8*** // CHECK: [[T1:%.*]] = getelementptr inbounds i8**, i8*** [[T0]], {{i32|i64}} -1 // CHECK: [[VALUE_WITNESSES:%.*]] = load i8**, i8*** [[T1]] diff --git a/test/IRGen/type_layout_objc.swift b/test/IRGen/type_layout_objc.swift index 450696c1e65..544e59d0962 100644 --- a/test/IRGen/type_layout_objc.swift +++ b/test/IRGen/type_layout_objc.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -DINT=i%target-ptrsize // REQUIRES: objc_interop import Foundation @@ -59,7 +59,8 @@ struct TypeLayoutTest { // CHECK: store i8** [[T_LAYOUT]] var i: GSing // -- Multi-element generic struct, need to derive from metadata - // CHECK: [[METADATA:%.*]] = call %swift.type* @"$S16type_layout_objc5GMultVMa"(%swift.type* %T) + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S16type_layout_objc5GMultVMa"([[INT]] 0, %swift.type* %T) + // CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[T0:%.*]] = bitcast %swift.type* [[METADATA]] to i8*** // CHECK: [[T1:%.*]] = getelementptr inbounds i8**, i8*** [[T0]], {{i32|i64}} -1 // CHECK: [[VALUE_WITNESSES:%.*]] = load i8**, i8*** [[T1]] diff --git a/test/IRGen/type_layout_reference_storage.swift b/test/IRGen/type_layout_reference_storage.swift index 640e1672584..4128fae73ce 100644 --- a/test/IRGen/type_layout_reference_storage.swift +++ b/test/IRGen/type_layout_reference_storage.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s --check-prefix=CHECK-%target-ptrsize --check-prefix=CHECK +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s --check-prefix=CHECK-%target-ptrsize --check-prefix=CHECK -DINT=i%target-ptrsize class C {} protocol P: class {} @@ -98,7 +98,7 @@ public class Base { } // CHECK-LABEL: %swift.type* @{{.*}}7DerivedCMi"(%swift.type_descriptor*, i8**, i8**) // CHECK-NOT: store {{.*}}getelementptr{{.*}}SBomWV -// CHECK: call %swift.type* @"$S29type_layout_reference_storage1P_pXmTMa"() +// CHECK: call swiftcc %swift.metadata_response @"$S29type_layout_reference_storage1P_pXmTMa"([[INT]] 0) // CHECK: store {{.*}}getelementptr{{.*}}SBoWV // CHECK: ret public class Derived : Base { diff --git a/test/IRGen/typed_boxes.sil b/test/IRGen/typed_boxes.sil index 106aa350141..b4c246c29f1 100644 --- a/test/IRGen/typed_boxes.sil +++ b/test/IRGen/typed_boxes.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -DINT=i%target-ptrsize sil_stage canonical import Builtin @@ -120,7 +120,8 @@ sil @take_t : $@convention(thin) (@in T) -> () // CHECK-LABEL: define{{( protected)?}} swiftcc void @dyn_box_a sil @dyn_box_a : $@convention(thin) () -> () { entry: - // CHECK: [[METADATA:%.*]] = call %swift.type* @"$S11typed_boxes3DynVMa"(%swift.type* %T) + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S11typed_boxes3DynVMa"([[INT]] 0, %swift.type* %T) + // CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[ALLOC:%.*]] = call swiftcc { %swift.refcounted*, %swift.opaque* } @swift_allocBox(%swift.type* [[METADATA]]) // CHECK: [[BOX:%.*]] = extractvalue { %swift.refcounted*, %swift.opaque* } [[ALLOC]], 0 // CHECK: [[PTR:%.*]] = extractvalue { %swift.refcounted*, %swift.opaque* } [[ALLOC]], 1 diff --git a/test/IRGen/typemetadata.sil b/test/IRGen/typemetadata.sil index 2c125f9c48c..fd2810dc441 100644 --- a/test/IRGen/typemetadata.sil +++ b/test/IRGen/typemetadata.sil @@ -1,5 +1,5 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s -// RUN: %target-swift-frontend -Osize -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s --check-prefix=OSIZE +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s -DINT=i%target-ptrsize +// RUN: %target-swift-frontend -Osize -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s --check-prefix=OSIZE -DINT=i%target-ptrsize // REQUIRES: CPU=x86_64 // XFAIL: linux @@ -26,7 +26,8 @@ bb0: return %100 : $() } -// CHECK-LABEL: define hidden %swift.type* @"$S12typemetadata1CCMa"() +// CHECK-LABEL: define hidden swiftcc %swift.metadata_response @"$S12typemetadata1CCMa" +// CHECK-SAME: ([[INT]]) // CHECK: [[T0:%.*]] = load %swift.type*, %swift.type** @"$S12typemetadata1CCML", align 8 // CHECK-NEXT: [[T1:%.*]] = icmp eq %swift.type* [[T0]], null // CHECK-NEXT: br i1 [[T1]] @@ -35,20 +36,26 @@ bb0: // CHECK: store atomic %swift.type* [[T1]], %swift.type** @"$S12typemetadata1CCML" release, align 8 // CHECK-NEXT: br label // CHECK: [[RES:%.*]] = phi -// CHECK-NEXT: ret %swift.type* [[RES]] +// CHECK-NEXT: [[T0:%.*]] = insertvalue %swift.metadata_response undef, %swift.type* [[RES]], 0 +// CHECK-NEXT: [[T1:%.*]] = insertvalue %swift.metadata_response [[T0]], i64 0, 1 +// CHECK-NEXT: ret %swift.metadata_response [[T1]] -// CHECK-LABEL: define linkonce_odr hidden %swift.type* @"$S12typemetadata1SV_AA1CCtMa"() +// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$S12typemetadata1SV_AA1CCtMa" +// CHECK-SAME: ([[INT]]) // CHECK: [[T0:%.*]] = load %swift.type*, %swift.type** @"$S12typemetadata1SV_AA1CCtML", align 8 // CHECK-NEXT: [[T1:%.*]] = icmp eq %swift.type* [[T0]], null // CHECK-NEXT: br i1 [[T1]] -// CHECK: [[T0:%.*]] = call %swift.type* @"$S12typemetadata1CCMa"() +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S12typemetadata1CCMa"([[INT]] 0) +// CHECK: [[T0:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[T1:%.*]] = call %swift.type* @swift_getTupleTypeMetadata2(%swift.type* {{.*}} @"$S12typemetadata1SVMf", {{.*}} %swift.type* [[T0]], i8* null, i8** null) // CHECK-NEXT: store atomic %swift.type* [[T1]], %swift.type** @"$S12typemetadata1SV_AA1CCtML" release, align 8 // CHECK-NEXT: br label // CHECK: [[RES:%.*]] = phi -// CHECK-NEXT: ret %swift.type* [[RES]] +// CHECK-NEXT: [[T0:%.*]] = insertvalue %swift.metadata_response undef, %swift.type* [[RES]], 0 +// CHECK-NEXT: [[T1:%.*]] = insertvalue %swift.metadata_response [[T0]], i64 0, 1 +// CHECK-NEXT: ret %swift.metadata_response [[T1]] - -// OSIZE: define hidden %swift.type* @"$S12typemetadata1CCMa"() [[ATTR:#[0-9]+]] { +// OSIZE: define hidden swiftcc %swift.metadata_response @"$S12typemetadata1CCMa" +// OSIZE-SAME: ([[INT]]) [[ATTR:#[0-9]+]] { // OSIZE: [[ATTR]] = {{{.*}}noinline diff --git a/test/IRGen/unconditional_checked_cast.sil b/test/IRGen/unconditional_checked_cast.sil index fe9bafef60e..3f7fa7a590d 100644 --- a/test/IRGen/unconditional_checked_cast.sil +++ b/test/IRGen/unconditional_checked_cast.sil @@ -14,7 +14,8 @@ sil_vtable D {} // CHECK: entry: // CHECK-NEXT: [[INPUTPTR:%[0-9]+]] = load %T26unconditional_checked_cast1CC*, %T26unconditional_checked_cast1CC** [[INPUTPTRPTR:%[0-9]+]], align 8 // CHECK-NEXT: [[I8INPUTPTR:%[0-9]+]] = bitcast %T26unconditional_checked_cast1CC* [[INPUTPTR]] to i8* -// CHECK-NEXT: [[T0:%.*]] = call %swift.type* @"$S26unconditional_checked_cast1DCMa"() +// CHECK-NEXT: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S26unconditional_checked_cast1DCMa"(i64 0) +// CHECK-NEXT: [[T0:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK-NEXT: [[T1:%.*]] = bitcast %swift.type* [[T0]] to i8* // CHECK-NEXT: [[I8RESULTPTR:%.*]] = call i8* @swift_dynamicCastClassUnconditional(i8* [[I8INPUTPTR]], i8* [[T1]]) // CHECK-NEXT: [[DOWNCASTINPUTPTR:%[0-9]+]] = bitcast i8* [[I8RESULTPTR]] to %T26unconditional_checked_cast1DC* diff --git a/test/IRGen/vtable_multi_file.swift b/test/IRGen/vtable_multi_file.swift index c8d7ed6c39f..ef7b8e92cc0 100644 --- a/test/IRGen/vtable_multi_file.swift +++ b/test/IRGen/vtable_multi_file.swift @@ -6,7 +6,8 @@ func markUsed(_ t: T) {} // CHECK-LABEL: define hidden swiftcc void @"$S17vtable_multi_file36baseClassVtablesIncludeImplicitInitsyyF"() {{.*}} { func baseClassVtablesIncludeImplicitInits() { - // CHECK: [[T0:%.*]] = call %swift.type* @"$S17vtable_multi_file8SubclassCMa"() + // CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S17vtable_multi_file8SubclassCMa"(i64 0) + // CHECK: [[T0:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[T1:%.*]] = bitcast %swift.type* [[T0]] to { %swift.bridge*, i64 } (%swift.type*)** // CHECK: [[T2:%.*]] = getelementptr inbounds { %swift.bridge*, i64 } (%swift.type*)*, { %swift.bridge*, i64 } (%swift.type*)** [[T1]], i64 11 // CHECK: load { %swift.bridge*, i64 } (%swift.type*)*, { %swift.bridge*, i64 } (%swift.type*)** [[T2]] diff --git a/test/IRGen/weak_import_native.swift b/test/IRGen/weak_import_native.swift index 3b186b7023f..cfe02e5a6d8 100644 --- a/test/IRGen/weak_import_native.swift +++ b/test/IRGen/weak_import_native.swift @@ -138,13 +138,13 @@ func testProtocolGeneric(_ type: Impl.Type) { func testWeakTypes() -> [Any.Type] { // FIXME: These should be weak. - // CHECK-DAG: declare %swift.type* @"$S25weak_import_native_helper5WeakSVMa"() - // CHECK-DAG: declare %swift.type* @"$S25weak_import_native_helper5WeakEOMa"() - // CHECK-DAG: declare %swift.type* @"$S25weak_import_native_helper5WeakCCMa"() + // CHECK-DAG: declare swiftcc %swift.metadata_response @"$S25weak_import_native_helper5WeakSVMa" + // CHECK-DAG: declare swiftcc %swift.metadata_response @"$S25weak_import_native_helper5WeakEOMa" + // CHECK-DAG: declare swiftcc %swift.metadata_response @"$S25weak_import_native_helper5WeakCCMa" // CHECK-DAG: @"$S25weak_import_native_helper5WeakPMp" = extern_weak global %swift.protocol - // CHECK-DAG: declare %swift.type* @"$S25weak_import_native_helper8GenericSVMa" - // CHECK-DAG: declare %swift.type* @"$S25weak_import_native_helper8GenericEOMa" - // CHECK-DAG: declare %swift.type* @"$S25weak_import_native_helper8GenericCCMa" + // CHECK-DAG: declare swiftcc %swift.metadata_response @"$S25weak_import_native_helper8GenericSVMa" + // CHECK-DAG: declare swiftcc %swift.metadata_response @"$S25weak_import_native_helper8GenericEOMa" + // CHECK-DAG: declare swiftcc %swift.metadata_response @"$S25weak_import_native_helper8GenericCCMa" return [WeakS.self, WeakE.self, WeakC.self, WeakP.self, GenericS.self, GenericE.self, GenericC.self] } diff --git a/test/IRGen/witness_method.sil b/test/IRGen/witness_method.sil index 561e57ef2cd..56f8ea9d82d 100644 --- a/test/IRGen/witness_method.sil +++ b/test/IRGen/witness_method.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s -DINT=i%target-ptrsize // REQUIRES: CPU=i386 || CPU=x86_64 @@ -64,7 +64,8 @@ struct SyncUp : Synergy { // CHECK-LABEL: define{{( protected)?}} swiftcc void @testGenericWitnessMethod(%swift.opaque* noalias nocapture sret, %T14witness_method6SyncUpV* noalias nocapture, %swift.type* %T) // CHECK: entry: -// CHECK: [[METADATA:%.*]] = call %swift.type* @"$S14witness_method6SyncUpVMa"(%swift.type* %T) +// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S14witness_method6SyncUpVMa"([[INT]] 0, %swift.type* %T) +// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // CHECK: [[WTABLE:%.*]] = call i8** @"$S14witness_method6SyncUpVyxGAA7SynergyAAWa"(%swift.type* [[METADATA]], i8*** undef) // CHECK: [[WITNESS_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[WTABLE]], i32 2 // CHECK: [[WITNESS_FN:%.*]] = load i8*, i8** [[WITNESS_ADDR]] diff --git a/test/IRGen/witness_table_indirect_conformances.swift b/test/IRGen/witness_table_indirect_conformances.swift index 26669d3f551..41fcf412849 100644 --- a/test/IRGen/witness_table_indirect_conformances.swift +++ b/test/IRGen/witness_table_indirect_conformances.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir -disable-objc-attr-requires-foundation-module -swift-version 4 | %FileCheck %s +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir -disable-objc-attr-requires-foundation-module -swift-version 4 | %FileCheck %s -DINT=i%target-ptrsize protocol P1 { associatedtype AssocP1 @@ -32,7 +32,7 @@ struct Z: P2 { // CHECK: @"$S35witness_table_indirect_conformances1WVAA2P3AAWP" = hidden constant [5 x i8*] [ // CHECK-SAME: @"$S35witness_table_indirect_conformances1WVAA2P3AAMc" -// CHECK-SAME: i8* bitcast (%swift.type* ()* @"$S35witness_table_indirect_conformances1ZVMa" to i8*), i8* bitcast (i8** ()* @"$S35witness_table_indirect_conformances1ZVAA2P2AAWa" to i8*), +// CHECK-SAME: i8* bitcast (%swift.metadata_response ([[INT]])* @"$S35witness_table_indirect_conformances1ZVMa" to i8*), i8* bitcast (i8** ()* @"$S35witness_table_indirect_conformances1ZVAA2P2AAWa" to i8*), // CHECK-SAME: i8* bitcast (i8** ()* @"$S35witness_table_indirect_conformances1YVAA1QAAWa" to i8*), // CHECK-SAME: i8* bitcast (void (%T35witness_table_indirect_conformances1ZV*, %T35witness_table_indirect_conformances1WV*, %swift.type*, i8**)* @"$S35witness_table_indirect_conformances1WVAA2P3A2aDP08getAssocE00gE0QzyFTW" to i8*)] struct W: P3 { @@ -49,6 +49,7 @@ struct W: P3 { // CHECK-NEXT: entry: // CHECK: ret i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @"$S35witness_table_indirect_conformances1ZVAA2P2AAWP", i32 0, i32 0) -// CHECK-LABEL: define hidden %swift.type* @"$S35witness_table_indirect_conformances1ZVMa"() +// CHECK-LABEL: define hidden swiftcc %swift.metadata_response @"$S35witness_table_indirect_conformances1ZVMa" +// CHECK-SAME: ([[INT]]) // CHECK-NEXT: entry: -// CHECK-NEXT: ret %swift.type* bitcast {{.*}} @"$S35witness_table_indirect_conformances1ZVMf", i32 0, i32 1) to %swift.type* +// CHECK-NEXT: ret %swift.metadata_response { %swift.type* bitcast {{.*}} @"$S35witness_table_indirect_conformances1ZVMf", i32 0, i32 1) to %swift.type*), [[INT]] 0 } diff --git a/test/IRGen/witness_table_objc_associated_type.swift b/test/IRGen/witness_table_objc_associated_type.swift index 6a131480c71..567e3dd18af 100644 --- a/test/IRGen/witness_table_objc_associated_type.swift +++ b/test/IRGen/witness_table_objc_associated_type.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck %s +// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck %s -DINT=i%target-ptrsize protocol A {} @@ -20,7 +20,7 @@ struct SB: B { func foo() {} } // CHECK-LABEL: @"$S34witness_table_objc_associated_type2SBVAA1BAAWP" = hidden constant [4 x i8*] [ -// CHECK: i8* bitcast (%swift.type* ()* @"$S34witness_table_objc_associated_type2SAVMa" to i8*) +// CHECK: i8* bitcast (%swift.metadata_response ([[INT]])* @"$S34witness_table_objc_associated_type2SAVMa" to i8*) // CHECK: i8* bitcast (i8** ()* @"$S34witness_table_objc_associated_type2SAVAA1AAAWa" to i8*) // CHECK: i8* bitcast {{.*}} @"$S34witness_table_objc_associated_type2SBVAA1BA2aDP3fooyyFTW" // CHECK: ] @@ -31,7 +31,7 @@ struct SO: C { func foo() {} } // CHECK-LABEL: @"$S34witness_table_objc_associated_type2SOVAA1CAAWP" = hidden constant [3 x i8*] [ -// CHECK: i8* bitcast (%swift.type* ()* @"$S34witness_table_objc_associated_type2COCMa" to i8*) +// CHECK: i8* bitcast (%swift.metadata_response ([[INT]])* @"$S34witness_table_objc_associated_type2COCMa" to i8*) // CHECK: i8* bitcast {{.*}} @"$S34witness_table_objc_associated_type2SOVAA1CA2aDP3fooyyFTW" // CHECK: ] diff --git a/test/IRGen/yield_once_big.sil b/test/IRGen/yield_once_big.sil index 91f9c33a438..a88535d3834 100644 --- a/test/IRGen/yield_once_big.sil +++ b/test/IRGen/yield_once_big.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -emit-ir -disable-llvm-optzns %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize +// RUN: %target-swift-frontend -emit-ir -disable-llvm-optzns %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -DINT=i%target-ptrsize import Builtin import Swift @@ -96,7 +96,8 @@ entry(%flag : $Builtin.Int1): // CHECK-NEXT: [[BUFFER:%.*]] = getelementptr inbounds {{\[}}[[BUFFER_SIZE]] x i8], {{\[}}[[BUFFER_SIZE]] x i8]* [[T0]], i32 0, i32 0 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 [[BUFFER_SIZE]], i8* [[BUFFER]]) - // CHECK-NEXT: [[SUBCLASS:%.*]] = call %swift.type* @"$S14yield_once_big12SomeSubclassCMa"() + // CHECK-NEXT: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S14yield_once_big12SomeSubclassCMa"([[INT]] 0) + // CHECK-NEXT: [[SUBCLASS:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // Prepare the continuation function pointer to block analysis. // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.coro.prepare.retcon(i8* bitcast ([[ORIG_CORO_T:.*]] @test_simple to i8*)) diff --git a/test/IRGen/yield_once_biggish.sil b/test/IRGen/yield_once_biggish.sil index 47ba598dd43..4955682aa98 100644 --- a/test/IRGen/yield_once_biggish.sil +++ b/test/IRGen/yield_once_biggish.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -emit-ir -disable-llvm-optzns %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize +// RUN: %target-swift-frontend -emit-ir -disable-llvm-optzns %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -DINT=i%target-ptrsize // i386 uses a scalar result count of 3 instead of 4, so this test would need // to be substantially different to test the functionality there. It's easier @@ -105,7 +105,8 @@ entry(%flag : $Builtin.Int1): // CHECK-NEXT: [[BUFFER:%.*]] = getelementptr inbounds {{\[}}[[BUFFER_SIZE]] x i8], {{\[}}[[BUFFER_SIZE]] x i8]* [[T0]], i32 0, i32 0 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 [[BUFFER_SIZE]], i8* [[BUFFER]]) - // CHECK-NEXT: [[SUBCLASS:%.*]] = call %swift.type* @"$S18yield_once_biggish12SomeSubclassCMa"() + // CHECK-NEXT: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S18yield_once_biggish12SomeSubclassCMa"([[INT]] 0) + // CHECK-NEXT: [[SUBCLASS:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // Prepare the continuation function pointer to block analysis. // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.coro.prepare.retcon(i8* bitcast ([[ORIG_CORO_T:.*]] @test_simple to i8*)) diff --git a/test/IRGen/yield_once_indirect.sil b/test/IRGen/yield_once_indirect.sil index 4f023965dd3..7b325df8775 100644 --- a/test/IRGen/yield_once_indirect.sil +++ b/test/IRGen/yield_once_indirect.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -emit-ir -disable-llvm-optzns %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize +// RUN: %target-swift-frontend -emit-ir -disable-llvm-optzns %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -DINT=i%target-ptrsize import Builtin import Swift @@ -94,7 +94,8 @@ entry(%flag : $Builtin.Int1): // CHECK-NEXT: [[BUFFER:%.*]] = getelementptr inbounds {{\[}}[[BUFFER_SIZE]] x i8], {{\[}}[[BUFFER_SIZE]] x i8]* [[T0]], i32 0, i32 0 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 [[BUFFER_SIZE]], i8* [[BUFFER]]) - // CHECK-NEXT: [[SUBCLASS:%.*]] = call %swift.type* @"$S19yield_once_indirect12SomeSubclassCMa"() + // CHECK-NEXT: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$S19yield_once_indirect12SomeSubclassCMa"([[INT]] 0) + // CHECK-NEXT: [[SUBCLASS:%.*]] = extractvalue %swift.metadata_response [[TMP]], 0 // Prepare the continuation function pointer to block analysis. // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.coro.prepare.retcon(i8* bitcast ([[ORIG_CORO_T:.*]] @test_simple to i8*)) diff --git a/test/Inputs/conditional_conformance_basic_conformances.swift b/test/Inputs/conditional_conformance_basic_conformances.swift index 7b0fc622852..4e26eeffd7e 100644 --- a/test/Inputs/conditional_conformance_basic_conformances.swift +++ b/test/Inputs/conditional_conformance_basic_conformances.swift @@ -50,7 +50,8 @@ public func single_generic(_: T.Type) { // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S42conditional_conformance_basic_conformances14single_genericyyxmAA2P2RzlF"(%swift.type*, %swift.type* %T, i8** %T.P2) // CHECK-NEXT: entry: // CHECK-NEXT: %conditional.requirement.buffer = alloca [1 x i8**], align 8 -// CHECK-NEXT: [[Single_TYPE:%.*]] = call %swift.type* @"$S42conditional_conformance_basic_conformances6SingleVMa"(%swift.type* %T) +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S42conditional_conformance_basic_conformances6SingleVMa"(i64 0, %swift.type* %T) +// CHECK-NEXT: [[Single_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [1 x i8**], [1 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[T_P2_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 // CHECK-NEXT: store i8** %T.P2, i8*** [[T_P2_PTR]], align 8 @@ -73,7 +74,8 @@ public func single_concrete() { } // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S42conditional_conformance_basic_conformances15single_concreteyyF"() // CHECK-NEXT: entry: -// CHECK-NEXT: [[Single_TYPE:%.*]] = call %swift.type* @"$S42conditional_conformance_basic_conformances6SingleVyAA4IsP2VGMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S42conditional_conformance_basic_conformances6SingleVyAA4IsP2VGMa"(i64 0) +// CHECK-NEXT: [[Single_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[Single_P1:%.*]] = call i8** @"$S42conditional_conformance_basic_conformances6SingleVyAA4IsP2VGACyxGAA2P1A2A0G0RzlWl"() // CHECK-NEXT: call swiftcc void @"$S42conditional_conformance_basic_conformances8takes_p1yyxmAA2P1RzlF"(%swift.type* [[Single_TYPE]], %swift.type* [[Single_TYPE]], i8** [[Single_P1]]) // CHECK-NEXT: ret void @@ -90,7 +92,8 @@ public func single_concrete() { // CHECK-NEXT: br i1 [[IS_NULL]], label %cacheIsNull, label %cont // CHECK: cacheIsNull: -// CHECK-NEXT: [[Single_TYPE:%.*]] = call %swift.type* @"$S42conditional_conformance_basic_conformances6SingleVyAA4IsP2VGMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S42conditional_conformance_basic_conformances6SingleVyAA4IsP2VGMa"(i64 0) +// CHECK-NEXT: [[Single_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [1 x i8**], [1 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[A_P2_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 @@ -101,8 +104,8 @@ public func single_concrete() { // CHECK-NEXT: br label %cont // CHECK: cont: -// CHECK-NEXT: %6 = phi i8** [ [[CACHE]], %entry ], [ [[Single_P1]], %cacheIsNull ] -// CHECK-NEXT: ret i8** %6 +// CHECK-NEXT: [[T0:%.*]] = phi i8** [ [[CACHE]], %entry ], [ [[Single_P1]], %cacheIsNull ] +// CHECK-NEXT: ret i8** [[T0]] // CHECK-NEXT: } @@ -168,7 +171,8 @@ public func double_generic_generic(_: U.Type, _: V.Type) { // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S42conditional_conformance_basic_conformances015double_generic_F0yyxm_q_mtAA2P2RzAA2P3R_r0_lF"(%swift.type*, %swift.type*, %swift.type* %U, %swift.type* %V, i8** %U.P2, i8** %V.P3) // CHECK-NEXT: entry: // CHECK-NEXT: %conditional.requirement.buffer = alloca [2 x i8**], align 8 -// CHECK-NEXT: [[Double_TYPE:%.*]] = call %swift.type* @"$S42conditional_conformance_basic_conformances6DoubleVMa"(%swift.type* %U, %swift.type* %V) +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S42conditional_conformance_basic_conformances6DoubleVMa"(i64 0, %swift.type* %U, %swift.type* %V) +// CHECK-NEXT: [[Double_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [2 x i8**], [2 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[B_P2_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 @@ -196,7 +200,8 @@ public func double_generic_concrete(_: X.Type) { // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S42conditional_conformance_basic_conformances23double_generic_concreteyyxmAA2P2RzlF"(%swift.type*, %swift.type* %X, i8** %X.P2) // CHECK-NEXT: entry: // CHECK-NEXT: %conditional.requirement.buffer = alloca [2 x i8**], align 8 -// CHECK-NEXT: [[Double_TYPE:%.*]] = call %swift.type* @"$S42conditional_conformance_basic_conformances6DoubleVMa"(%swift.type* %X, %swift.type* bitcast (i64* getelementptr inbounds (<{ i8**, i64, <{ {{.*}} }>* }>, <{ {{.*}} }>* @"$S42conditional_conformance_basic_conformances4IsP3VMf", i32 0, i32 1) to %swift.type*)) +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S42conditional_conformance_basic_conformances6DoubleVMa"(i64 0, %swift.type* %X, %swift.type* bitcast (i64* getelementptr inbounds (<{ i8**, i64, <{ {{.*}} }>* }>, <{ {{.*}} }>* @"$S42conditional_conformance_basic_conformances4IsP3VMf", i32 0, i32 1) to %swift.type*)) +// CHECK-NEXT: [[Double_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [2 x i8**], [2 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[B_P2_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 @@ -204,7 +209,7 @@ public func double_generic_concrete(_: X.Type) { // CHECK-NEXT: [[C_P3_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 1 // CHECK-NEXT: store i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @"$S42conditional_conformance_basic_conformances4IsP3VAA0F0AAWP", i32 0, i32 0), i8*** [[C_P3_PTR]], align 8 -// CHECK-NEXT: [[Double_P1:%.*]] = call i8** @"$S42conditional_conformance_basic_conformances6DoubleVyxq_GAA2P1A2A2P2RzAA2P3R_rlWa"(%swift.type* %1, i8*** [[CONDITIONAL_REQUIREMENTS]]) +// CHECK-NEXT: [[Double_P1:%.*]] = call i8** @"$S42conditional_conformance_basic_conformances6DoubleVyxq_GAA2P1A2A2P2RzAA2P3R_rlWa"(%swift.type* [[Double_TYPE]], i8*** [[CONDITIONAL_REQUIREMENTS]]) // CHECK-NEXT: call swiftcc void @"$S42conditional_conformance_basic_conformances8takes_p1yyxmAA2P1RzlF"(%swift.type* [[Double_TYPE]], %swift.type* [[Double_TYPE]], i8** [[Double_P1]]) // CHECK-NEXT: ret void // CHECK-NEXT: } @@ -214,7 +219,8 @@ public func double_concrete_concrete() { } // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S42conditional_conformance_basic_conformances016double_concrete_F0yyF"() // CHECK-NEXT: entry: -// CHECK-NEXT: [[Double_TYPE:%.*]] = call %swift.type* @"$S42conditional_conformance_basic_conformances6DoubleVyAA4IsP2VAA0F2P3VGMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S42conditional_conformance_basic_conformances6DoubleVyAA4IsP2VAA0F2P3VGMa"(i64 0) +// CHECK-NEXT: [[Double_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[Double_P1:%.*]] = call i8** @"$S42conditional_conformance_basic_conformances6DoubleVyAA4IsP2VAA0F2P3VGACyxq_GAA2P1A2A0G0RzAA0H0R_rlWl"() // CHECK-NEXT: call swiftcc void @"$S42conditional_conformance_basic_conformances8takes_p1yyxmAA2P1RzlF"(%swift.type* [[Double_TYPE]], %swift.type* [[Double_TYPE]], i8** [[Double_P1]]) // CHECK-NEXT: ret void @@ -230,7 +236,8 @@ public func double_concrete_concrete() { // CHECK-NEXT: br i1 [[IS_NULL]], label %cacheIsNull, label %cont // CHECK: cacheIsNull: -// CHECK-NEXT: [[Double_TYPE:%.*]] = call %swift.type* @"$S42conditional_conformance_basic_conformances6DoubleVyAA4IsP2VAA0F2P3VGMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S42conditional_conformance_basic_conformances6DoubleVyAA4IsP2VAA0F2P3VGMa"(i64 0) +// CHECK-NEXT: [[Double_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [2 x i8**], [2 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[B_P2_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 @@ -243,8 +250,8 @@ public func double_concrete_concrete() { // CHECK-NEXT: br label %cont // CHECK: cont: -// CHECK-NEXT: %7 = phi i8** [ [[CACHE]], %entry ], [ [[Double_P1]], %cacheIsNull ] -// CHECK-NEXT: ret i8** %7 +// CHECK-NEXT: [[T0:%.*]] = phi i8** [ [[CACHE]], %entry ], [ [[Double_P1]], %cacheIsNull ] +// CHECK-NEXT: ret i8** [[T0]] // CHECK-NEXT: } diff --git a/test/Inputs/conditional_conformance_recursive.swift b/test/Inputs/conditional_conformance_recursive.swift index b166374aa39..7cb35ba2b3f 100644 --- a/test/Inputs/conditional_conformance_recursive.swift +++ b/test/Inputs/conditional_conformance_recursive.swift @@ -24,7 +24,7 @@ extension Wrapper: P3 where T: P3 { } // CHECK: call i8** @"$S33conditional_conformance_recursive7WrapperVyxGAA2P2A2aERzrlWa" // associated type metadata accessor for B in Wrapper: P2 -// CHECK-LABEL: define internal %swift.type* @"$S33conditional_conformance_recursive7WrapperVyxGAA2P2A2aERzrl1BWt" +// CHECK-LABEL: define internal swiftcc %swift.metadata_response @"$S33conditional_conformance_recursive7WrapperVyxGAA2P2A2aERzrl1BWt" // CHECK: [[T_TO_P2_PTR:%.*]] = getelementptr inbounds i8*, i8** [[WRAPPER_T_TO_P2:%.*]], i32 -1 // CHECK: [[T_TO_P2_VAL:%.*]] = load i8*, i8** [[T_TO_P2_PTR]] // CHECK: [[T_TO_P2:%.*]] = bitcast i8* [[T_TO_P2_VAL]] to i8** @@ -36,12 +36,16 @@ extension Wrapper: P3 where T: P3 { } // CHECK: [[T_TYPE:%.*]] = load %swift.type*, %swift.type** [[T_TYPE_PTR]] // CHECK: [[T_B_TYPE_ACCESSOR_PTR_GEP:%.*]] = getelementptr inbounds i8*, i8** [[T_TO_P1]], i32 1 // CHECK: [[T_B_TYPE_ACCESSOR_PTR:%.*]] = load i8*, i8** [[T_B_TYPE_ACCESSOR_PTR_GEP]], align 8 -// CHECK: [[T_B_TYPE_ACCESSOR:%.*]] = bitcast i8* [[T_B_TYPE_ACCESSOR_PTR]] to %swift.type* (%swift.type*, i8**)* -// CHECK: [[T_A_TYPE:%.*]] = call %swift.type* [[T_B_TYPE_ACCESSOR]](%swift.type* [[T_TYPE]], i8** [[T_TO_P1]]) -// CHECK: ret %swift.type* [[T_A_TYPE]] +// CHECK: [[T_B_TYPE_ACCESSOR:%.*]] = bitcast i8* [[T_B_TYPE_ACCESSOR_PTR]] to %swift.metadata_response (i64, %swift.type*, i8**)* +// CHECK: [[T_A_TYPE:%.*]] = call swiftcc %swift.metadata_response [[T_B_TYPE_ACCESSOR]](i64 %0, %swift.type* [[T_TYPE]], i8** [[T_TO_P1]]) +// CHECK: [[T0:%.*]] = extractvalue %swift.metadata_response [[T_A_TYPE]], 0 +// CHECK: [[T1:%.*]] = extractvalue %swift.metadata_response [[T_A_TYPE]], 1 +// CHECK: [[T2:%.*]] = insertvalue %swift.metadata_response undef, %swift.type* [[T0]], 0 +// CHECK: [[T3:%.*]] = insertvalue %swift.metadata_response [[T2]], i64 [[T1]], 1 +// CHECK: ret %swift.metadata_response [[T3]] // associated type witness table accessor for A : P2 in Wrapper: P2 -// CHECK-LABEL: define internal i8** @"$S33conditional_conformance_recursive7WrapperVyxGAA2P2A2aERzrl1A_AaEPWT" +// CHECK-LABEL: define internal swiftcc i8** @"$S33conditional_conformance_recursive7WrapperVyxGAA2P2A2aERzrl1A_AaEPWT" // CHECK: [[CONDITIONAL_REQ_BUFFER:%.*]] = alloca [1 x i8**] // CHECK: [[FIRST_REQ:%.*]] = getelementptr inbounds [1 x i8**], [1 x i8**]* [[CONDITIONAL_REQ_BUFFER]] // CHECK: call i8** @"$S33conditional_conformance_recursive7WrapperVyxGAA2P2A2aERzrlWa"(%swift.type* [[WRAPPER_TO_A:%.*]], i8*** [[FIRST_REQ]]) diff --git a/test/Inputs/conditional_conformance_subclass.swift b/test/Inputs/conditional_conformance_subclass.swift index a10592e3f4b..7dd34c6b67f 100644 --- a/test/Inputs/conditional_conformance_subclass.swift +++ b/test/Inputs/conditional_conformance_subclass.swift @@ -50,7 +50,8 @@ public func subclassgeneric_generic(_: T.Type) { // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S32conditional_conformance_subclass23subclassgeneric_genericyyxmAA2P2RzlF"(%swift.type*, %swift.type* %T, i8** %T.P2) // CHECK-NEXT: entry: // CHECK-NEXT: %conditional.requirement.buffer = alloca [1 x i8**], align 8 -// CHECK-NEXT: [[SubclassGeneric_TYPE:%.*]] = call %swift.type* @"$S32conditional_conformance_subclass15SubclassGenericCMa"(%swift.type* %T) +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S32conditional_conformance_subclass15SubclassGenericCMa"(i64 0, %swift.type* %T) +// CHECK-NEXT: [[SubclassGeneric_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [1 x i8**], [1 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[T_P2_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 // CHECK-NEXT: store i8** %T.P2, i8*** [[T_P2_PTR]], align 8 @@ -73,7 +74,8 @@ public func subclassgeneric_concrete() { // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S32conditional_conformance_subclass24subclassgeneric_concreteyyF"() // CHECK-NEXT: entry: -// CHECK-NEXT: [[SubclassGeneric_TYPE:%.*]] = call %swift.type* @"$S32conditional_conformance_subclass15SubclassGenericCyAA4IsP2VGMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S32conditional_conformance_subclass15SubclassGenericCyAA4IsP2VGMa"(i64 0) +// CHECK-NEXT: [[SubclassGeneric_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[Base_P1:%.*]] = call i8** @"$S32conditional_conformance_subclass15SubclassGenericCyAA4IsP2VGAA4BaseCyxGAA2P1A2A0G0RzlWl"() // CHECK-NEXT: call swiftcc void @"$S32conditional_conformance_subclass8takes_p1yyxmAA2P1RzlF"(%swift.type* [[SubclassGeneric_TYPE]], %swift.type* [[SubclassGeneric_TYPE]], i8** [[Base_P1]]) // CHECK-NEXT: ret void @@ -89,7 +91,8 @@ public func subclassgeneric_concrete() { // CHECK-NEXT: br i1 [[IS_NULL]], label %cacheIsNull, label %cont // CHECK: cacheIsNull: -// CHECK-NEXT: [[SubclassGeneric_TYPE:%.*]] = call %swift.type* @"$S32conditional_conformance_subclass15SubclassGenericCyAA4IsP2VGMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S32conditional_conformance_subclass15SubclassGenericCyAA4IsP2VGMa"(i64 0) +// CHECK-NEXT: [[SubclassGeneric_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [1 x i8**], [1 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[A_P2_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 // CHECK-NEXT: store i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @"$S32conditional_conformance_subclass4IsP2VAA0E0AAWP", i32 0, i32 0), i8*** [[A_P2_PTR]], align 8 @@ -98,8 +101,8 @@ public func subclassgeneric_concrete() { // CHECK-NEXT: br label %cont // CHECK: cont: -// CHECK-NEXT: %6 = phi i8** [ [[CACHE]], %entry ], [ [[Base_P1]], %cacheIsNull ] -// CHECK-NEXT: ret i8** %6 +// CHECK-NEXT: [[T0:%.*]] = phi i8** [ [[CACHE]], %entry ], [ [[Base_P1]], %cacheIsNull ] +// CHECK-NEXT: ret i8** [[T0]] // CHECK-NEXT: } public func subclassconcrete() { @@ -108,7 +111,8 @@ public func subclassconcrete() { // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S32conditional_conformance_subclass16subclassconcreteyyF"() // CHECK-NEXT: entry: -// CHECK-NEXT: [[SubclassConcrete_TYPE:%.*]] = call %swift.type* @"$S32conditional_conformance_subclass16SubclassConcreteCMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S32conditional_conformance_subclass16SubclassConcreteCMa"(i64 0) +// CHECK-NEXT: [[SubclassConcrete_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[SubclassConcrete_P1:%.*]] = call i8** @"$S32conditional_conformance_subclass16SubclassConcreteCAA4BaseCyxGAA2P1A2A2P2RzlWl"() // CHECK-NEXT: call swiftcc void @"$S32conditional_conformance_subclass8takes_p1yyxmAA2P1RzlF"(%swift.type* [[SubclassConcrete_TYPE]], %swift.type* [[SubclassConcrete_TYPE]], i8** [[SubclassConcrete_P1]]) // CHECK-NEXT: ret void @@ -122,7 +126,8 @@ public func subclassconcrete() { // CHECK-NEXT: br i1 [[IS_NULL]], label %cacheIsNull, label %cont // CHECK: cacheIsNull: -// CHECK-NEXT: [[SubclassConcrete_TYPE:%.*]] = call %swift.type* @"$S32conditional_conformance_subclass16SubclassConcreteCMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S32conditional_conformance_subclass16SubclassConcreteCMa"(i64 0) +// CHECK-NEXT: [[SubclassConcrete_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [1 x i8**], [1 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[A_P2_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 // CHECK-NEXT: store i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @"$S32conditional_conformance_subclass4IsP2VAA0E0AAWP", i32 0, i32 0), i8*** [[A_P2_PTR]], align 8 @@ -131,8 +136,8 @@ public func subclassconcrete() { // CHECK-NEXT: br label %cont // CHECK: cont: -// CHECK-NEXT: %6 = phi i8** [ [[CACHE]], %entry ], [ [[Base_P1]], %cacheIsNull ] -// CHECK-NEXT: ret i8** %6 +// CHECK-NEXT: [[T0:%.*]] = phi i8** [ [[CACHE]], %entry ], [ [[Base_P1]], %cacheIsNull ] +// CHECK-NEXT: ret i8** [[T0]] // CHECK-NEXT: } public func subclassgenericconcrete() { @@ -141,7 +146,8 @@ public func subclassgenericconcrete() { // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S32conditional_conformance_subclass23subclassgenericconcreteyyF"() // CHECK-NEXT: entry: -// CHECK-NEXT: [[SubclassGenericConcrete_TYPE:%.*]] = call %swift.type* @"$S32conditional_conformance_subclass23SubclassGenericConcreteCMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S32conditional_conformance_subclass23SubclassGenericConcreteCMa"(i64 0) +// CHECK-NEXT: [[SubclassGenericConcrete_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[SubclassGenericConcrete_P1:%.*]] = call i8** @"$S32conditional_conformance_subclass23SubclassGenericConcreteCAA4BaseCyxGAA2P1A2A2P2RzlWl"() // CHECK-NEXT: call swiftcc void @"$S32conditional_conformance_subclass8takes_p1yyxmAA2P1RzlF"(%swift.type* [[SubclassGenericConcrete_TYPE]], %swift.type* [[SubclassGenericConcrete_TYPE]], i8** [[SubclassGenericConcrete_P1]]) // CHECK-NEXT: ret void @@ -155,7 +161,8 @@ public func subclassgenericconcrete() { // CHECK-NEXT: br i1 [[IS_NULL]], label %cacheIsNull, label %cont // CHECK: cacheIsNull: -// CHECK-NEXT: [[SubclassGenericConcrete_TYPE:%.*]] = call %swift.type* @"$S32conditional_conformance_subclass23SubclassGenericConcreteCMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S32conditional_conformance_subclass23SubclassGenericConcreteCMa"(i64 0) +// CHECK-NEXT: [[SubclassGenericConcrete_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [1 x i8**], [1 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[A_P2_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 // CHECK-NEXT: store i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @"$S32conditional_conformance_subclass4IsP2VAA0E0AAWP", i32 0, i32 0), i8*** [[A_P2_PTR]], align 8 @@ -164,8 +171,8 @@ public func subclassgenericconcrete() { // CHECK-NEXT: br label %cont // CHECK: cont: -// CHECK-NEXT: %6 = phi i8** [ [[CACHE]], %entry ], [ [[Base_P1]], %cacheIsNull ] -// CHECK-NEXT: ret i8** %6 +// CHECK-NEXT: [[T0:%.*]] = phi i8** [ [[CACHE]], %entry ], [ [[Base_P1]], %cacheIsNull ] +// CHECK-NEXT: ret i8** [[T0]] // CHECK-NEXT: } diff --git a/test/Inputs/conditional_conformance_with_assoc.swift b/test/Inputs/conditional_conformance_with_assoc.swift index a8fc39a4692..4575cae75d4 100644 --- a/test/Inputs/conditional_conformance_with_assoc.swift +++ b/test/Inputs/conditional_conformance_with_assoc.swift @@ -112,7 +112,8 @@ public func generic_generic(_: T.Type, _: U.Type) // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S34conditional_conformance_with_assoc08generic_E0yyxm_q_mtAA2P2RzAA2P3R_AaC3AT2RpzAadE_AeaCP3AT3RPzr0_lF"(%swift.type*, %swift.type*, %swift.type* %T, %swift.type* %U, i8** %T.P2, i8** %U.P3, i8** %T.AT2.P2, i8** %T.AT2.AT2.AT3.P3) // CHECK-NEXT: entry: // CHECK-NEXT: %conditional.requirement.buffer = alloca [3 x i8**], align 8 -// CHECK-NEXT: [[Double_TYPE:%.*]] = call %swift.type* @"$S34conditional_conformance_with_assoc6DoubleVMa"(%swift.type* %T, %swift.type* %U, i8** %T.P2) +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S34conditional_conformance_with_assoc6DoubleVMa"(i64 0, %swift.type* %T, %swift.type* %U, i8** %T.P2) +// CHECK-NEXT: [[Double_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [3 x i8**], [3 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[C_P3_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 @@ -135,7 +136,8 @@ public func generic_concrete(_: T.Type) // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S34conditional_conformance_with_assoc16generic_concreteyyxmAA2P2RzAaC3AT2RpzAA2P3AD_AdaCP3AT3RPzlF"(%swift.type*, %swift.type* %T, i8** %T.P2, i8** %T.AT2.P2, i8** %T.AT2.AT2.AT3.P3) // CHECK-NEXT: entry: // CHECK-NEXT: %conditional.requirement.buffer = alloca [3 x i8**], align 8 -// CHECK-NEXT: [[Double_TYPE:%.*]] = call %swift.type* @"$S34conditional_conformance_with_assoc6DoubleVMa"(%swift.type* %T, %swift.type* bitcast (i64* getelementptr inbounds (<{ i8**, i64, <{ {{.*}} }>* }>, <{ {{.*}} }>* @"$S34conditional_conformance_with_assoc4IsP3VMf", i32 0, i32 1) to %swift.type*), i8** %T.P2) +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S34conditional_conformance_with_assoc6DoubleVMa"(i64 0, %swift.type* %T, %swift.type* bitcast (i64* getelementptr inbounds (<{ i8**, i64, <{ {{.*}} }>* }>, <{ {{.*}} }>* @"$S34conditional_conformance_with_assoc4IsP3VMf", i32 0, i32 1) to %swift.type*), i8** %T.P2) +// CHECK-NEXT: [[Double_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [3 x i8**], [3 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[C_P3_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 @@ -160,7 +162,8 @@ public func concrete_generic(_: U.Type) // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S34conditional_conformance_with_assoc16concrete_genericyyxmAA2P3RzlF"(%swift.type*, %swift.type* %U, i8** %U.P3) // CHECK-NEXT: entry: // CHECK-NEXT: %conditional.requirement.buffer = alloca [3 x i8**], align 8 -// CHECK-NEXT: [[Double_TYPE:%.*]] = call %swift.type* @"$S34conditional_conformance_with_assoc6DoubleVMa"(%swift.type* bitcast (i64* getelementptr inbounds (<{ {{.*}} }>, <{ {{.*}} }>* @"$S34conditional_conformance_with_assoc8IsAlsoP2VMf", i32 0, i32 1) to %swift.type*), %swift.type* %U, i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @"$S34conditional_conformance_with_assoc8IsAlsoP2VAA0G0AAWP", i32 0, i32 0)) +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S34conditional_conformance_with_assoc6DoubleVMa"(i64 0, %swift.type* bitcast (i64* getelementptr inbounds (<{ {{.*}} }>, <{ {{.*}} }>* @"$S34conditional_conformance_with_assoc8IsAlsoP2VMf", i32 0, i32 1) to %swift.type*), %swift.type* %U, i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @"$S34conditional_conformance_with_assoc8IsAlsoP2VAA0G0AAWP", i32 0, i32 0)) +// CHECK-NEXT: [[Double_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [3 x i8**], [3 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[C_P3_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 // CHECK-NEXT: store i8** %U.P3, i8*** [[C_P3_PTR]], align 8 @@ -180,9 +183,10 @@ public func concrete_concrete() { // CHECK-LABEL: define{{( protected)?}} swiftcc void @"$S34conditional_conformance_with_assoc09concrete_E0yyF"() // CHECK-NEXT: entry: -// CHECK-NEXT: %0 = call %swift.type* @"$S34conditional_conformance_with_assoc6DoubleVyAA8IsAlsoP2VAA0F2P3VGMa"() -// CHECK-NEXT: %1 = call i8** @"$S34conditional_conformance_with_assoc6DoubleVyAA8IsAlsoP2VAA0F2P3VGACyxq_GAA2P1A2A0I0R_AA0H03AT2RpzAakM_AmaLP3AT3RPzrlWl"() -// CHECK-NEXT: call swiftcc void @"$S34conditional_conformance_with_assoc8takes_p1yyxmAA2P1RzlF"(%swift.type* %0, %swift.type* %0, i8** %1) +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S34conditional_conformance_with_assoc6DoubleVyAA8IsAlsoP2VAA0F2P3VGMa"(i64 0) +// CHECK-NEXT: [[X:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 +// CHECK-NEXT: [[Z:%.*]] = call i8** @"$S34conditional_conformance_with_assoc6DoubleVyAA8IsAlsoP2VAA0F2P3VGACyxq_GAA2P1A2A0I0R_AA0H03AT2RpzAakM_AmaLP3AT3RPzrlWl"() +// CHECK-NEXT: call swiftcc void @"$S34conditional_conformance_with_assoc8takes_p1yyxmAA2P1RzlF"(%swift.type* [[X]], %swift.type* [[X]], i8** [[Z]]) // CHECK-NEXT: ret void // CHECK-NEXT: } @@ -196,7 +200,8 @@ public func concrete_concrete() { // CHECK-NEXT: br i1 [[IS_NULL]], label %cacheIsNull, label %cont // CHECK: cacheIsNull: -// CHECK-NEXT: [[Double_TYPE:%.*]] = call %swift.type* @"$S34conditional_conformance_with_assoc6DoubleVyAA8IsAlsoP2VAA0F2P3VGMa"() +// CHECK-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$S34conditional_conformance_with_assoc6DoubleVyAA8IsAlsoP2VAA0F2P3VGMa"(i64 0) +// CHECK-NEXT: [[Double_TYPE:%.*]] = extractvalue %swift.metadata_response [[T0]], 0 // CHECK-NEXT: [[CONDITIONAL_REQUIREMENTS:%.*]] = getelementptr inbounds [3 x i8**], [3 x i8**]* %conditional.requirement.buffer, i32 0, i32 0 // CHECK-NEXT: [[C_P3_PTR:%.*]] = getelementptr inbounds i8**, i8*** [[CONDITIONAL_REQUIREMENTS]], i32 0 // CHECK-NEXT: store i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @"$S34conditional_conformance_with_assoc4IsP3VAA0F0AAWP", i32 0, i32 0), i8*** [[C_P3_PTR]], align 8 @@ -209,8 +214,8 @@ public func concrete_concrete() { // CHECK-NEXT: br label %cont // CHECK: cont: -// CHECK-NEXT: %8 = phi i8** [ [[CACHE]], %entry ], [ [[Double_P1]], %cacheIsNull ] -// CHECK-NEXT: ret i8** %8 +// CHECK-NEXT: [[T0:%.*]] = phi i8** [ [[CACHE]], %entry ], [ [[Double_P1]], %cacheIsNull ] +// CHECK-NEXT: ret i8** [[T0]] // CHECK-NEXT: } diff --git a/test/Interpreter/SDK/archive_attributes.swift b/test/Interpreter/SDK/archive_attributes.swift index f9098cfae06..a64e39645ad 100644 --- a/test/Interpreter/SDK/archive_attributes.swift +++ b/test/Interpreter/SDK/archive_attributes.swift @@ -182,8 +182,10 @@ main() // CHECK-IR-LABEL: define {{.*}} @_swift_eager_class_initialization // CHECK-IR-NEXT: entry: // CHECK-IR-NEXT: call {{.*}}IntClassCMa +// CHECK-IR-NEXT: extractvalue // CHECK-IR-NEXT: call void asm // CHECK-IR-NEXT: call {{.*}}DoubleClassCMa +// CHECK-IR-NEXT: extractvalue // CHECK-IR-NEXT: call void asm // CHECK-IR-NEXT: ret diff --git a/test/multifile/require-layout-generic-arg-closure.swift b/test/multifile/require-layout-generic-arg-closure.swift index f7613e89ef2..33ac1b2580b 100644 --- a/test/multifile/require-layout-generic-arg-closure.swift +++ b/test/multifile/require-layout-generic-arg-closure.swift @@ -12,7 +12,7 @@ // FILE1: [[T2:%.*]] = bitcast %swift.type* [[TYPEMETADATA]] to %swift.type** // FILE1: [[T_PTR:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[T2]], i64 16 // FILE1: [[T:%.*]] = load %swift.type*, %swift.type** [[T_PTR]] -// FILE1: call %swift.type* @"$S4test3SubCMa"(%swift.type* [[T]]) +// FILE1: call swiftcc %swift.metadata_response @"$S4test3SubCMa"(i64 0, %swift.type* [[T]]) public func requestType2(x: T) { requestTypeThrough(closure: { x in print(x) }, arg: x)