diff --git a/include/swift/AST/PluginRegistry.h b/include/swift/AST/PluginRegistry.h index 74a323e520b80..b363362689c5a 100644 --- a/include/swift/AST/PluginRegistry.h +++ b/include/swift/AST/PluginRegistry.h @@ -147,7 +147,7 @@ class LoadedExecutablePlugin { /// Remove "on reconnect" callback. void removeOnReconnect(std::function *fn) { - llvm::erase_value(onReconnect, fn); + llvm::erase(onReconnect, fn); } llvm::sys::procid_t getPid() { return Process->process.Pid; } diff --git a/include/swift/Basic/ExponentialGrowthAppendingBinaryByteStream.h b/include/swift/Basic/ExponentialGrowthAppendingBinaryByteStream.h index bb48937baef9b..59df3eeb09552 100644 --- a/include/swift/Basic/ExponentialGrowthAppendingBinaryByteStream.h +++ b/include/swift/Basic/ExponentialGrowthAppendingBinaryByteStream.h @@ -23,6 +23,7 @@ #include "swift/Basic/LLVM.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/BinaryByteStream.h" +#include "llvm/Support/Endian.h" namespace swift { @@ -34,13 +35,14 @@ class ExponentialGrowthAppendingBinaryByteStream SmallVector Data; /// Data in the stream is always encoded in little-endian byte order. - const llvm::support::endianness Endian = llvm::support::endianness::little; + const llvm::endianness Endian = llvm::endianness::little; + public: ExponentialGrowthAppendingBinaryByteStream() = default; void reserve(size_t Size); - llvm::support::endianness getEndian() const override { return Endian; } + llvm::endianness getEndian() const override { return Endian; } llvm::Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override; diff --git a/include/swift/Basic/StableHasher.h b/include/swift/Basic/StableHasher.h index 786931a74607b..9a96e25fe2059 100644 --- a/include/swift/Basic/StableHasher.h +++ b/include/swift/Basic/StableHasher.h @@ -133,7 +133,7 @@ class StableHasher final { return setBufferLength(bufLen + N); } - constexpr auto endian = llvm::support::endianness::little; + constexpr auto endian = llvm::endianness::little; compress(llvm::support::endian::read(byteBuffer, endian)); // Now reseed the buffer with the remaining bytes. @@ -146,7 +146,7 @@ class StableHasher final { typename T, typename std::enable_if::value>::type * = nullptr> void combine(T bits) { - constexpr auto endian = llvm::support::endianness::little; + constexpr auto endian = llvm::endianness::little; uint8_t buf[sizeof(T)] = {0}; bits = llvm::support::endian::byte_swap(bits, endian); std::memcpy(buf, &bits, sizeof(T)); diff --git a/include/swift/ClangImporter/ClangModule.h b/include/swift/ClangImporter/ClangModule.h index 470c7b481f4b4..29cf61c9b64c9 100644 --- a/include/swift/ClangImporter/ClangModule.h +++ b/include/swift/ClangImporter/ClangModule.h @@ -20,6 +20,7 @@ #include "swift/Basic/Version.h" #include "swift/ClangImporter/ClangImporter.h" #include "clang/AST/ExternalASTSource.h" +#include "clang/Basic/ASTSourceDescriptor.h" #include "clang/Basic/Module.h" namespace clang { diff --git a/include/swift/ClangImporter/SwiftAbstractBasicReader.h b/include/swift/ClangImporter/SwiftAbstractBasicReader.h index 0889de8d9cc39..b5063c1c43493 100644 --- a/include/swift/ClangImporter/SwiftAbstractBasicReader.h +++ b/include/swift/ClangImporter/SwiftAbstractBasicReader.h @@ -72,7 +72,7 @@ class DataStreamBasicReader return clang::Selector(); unsigned numArgs = unsigned(numArgsPlusOne - 1); - SmallVector chunks; + SmallVector chunks; for (unsigned i = 0, e = std::max(numArgs, 1U); i != e; ++i) chunks.push_back(asImpl().readIdentifier()); @@ -94,6 +94,11 @@ class DataStreamBasicReader llvm::report_fatal_error("Read BTFTypeTagAttr that should never have been" " serialized"); } + + template + T *readDeclAs() { + return asImpl().template readDeclAs(); + } }; } diff --git a/include/swift/DependencyScan/ModuleDependencyScanner.h b/include/swift/DependencyScan/ModuleDependencyScanner.h index a8af234469f5d..00e7877becd07 100644 --- a/include/swift/DependencyScan/ModuleDependencyScanner.h +++ b/include/swift/DependencyScan/ModuleDependencyScanner.h @@ -145,7 +145,7 @@ class ModuleDependencyScanner { /// The available pool of workers for filesystem module search unsigned NumThreads; std::list> Workers; - llvm::ThreadPool ScanningThreadPool; + llvm::StdThreadPool ScanningThreadPool; /// Protect worker access. std::mutex WorkersLock; }; diff --git a/include/swift/Localization/LocalizationFormat.h b/include/swift/Localization/LocalizationFormat.h index 78c6937e03ea6..23e38f0f49402 100644 --- a/include/swift/Localization/LocalizationFormat.h +++ b/include/swift/Localization/LocalizationFormat.h @@ -40,8 +40,6 @@ enum class DiagID : uint32_t; namespace diag { -using namespace llvm::support; - enum LocalizationProducerState : uint8_t { NotInitialized, Initialized, @@ -77,14 +75,15 @@ class LocalizationWriterInfo { key_type_ref key, data_type_ref data) { offset_type dataLength = static_cast(data.size()); - endian::write(out, dataLength, little); + llvm::support::endian::write(out, dataLength, + llvm::endianness::little); // No need to write the key length; it's constant. return {sizeof(key_type), dataLength}; } void EmitKey(llvm::raw_ostream &out, key_type_ref key, unsigned len) { assert(len == sizeof(key_type)); - endian::write(out, key, little); + llvm::support::endian::write(out, key, llvm::endianness::little); } void EmitData(llvm::raw_ostream &out, key_type_ref key, data_type_ref data, @@ -120,12 +119,15 @@ class LocalizationReaderInfo { static std::pair ReadKeyDataLength(const unsigned char *&data) { offset_type dataLength = - endian::readNext(data); + llvm::support::endian::readNext(data); return {sizeof(uint32_t), dataLength}; } internal_key_type ReadKey(const unsigned char *data, offset_type length) { - return endian::readNext(data); + return llvm::support::endian::readNext< + internal_key_type, llvm::endianness::little, llvm::support::unaligned>( + data); } data_type ReadData(internal_key_type Key, const unsigned char *data, diff --git a/include/swift/Option/Options.h b/include/swift/Option/Options.h index 0f24e0bd7d0df..b3ce193b56f73 100644 --- a/include/swift/Option/Options.h +++ b/include/swift/Option/Options.h @@ -13,13 +13,9 @@ #ifndef SWIFT_OPTION_OPTIONS_H #define SWIFT_OPTION_OPTIONS_H -#include +#include "llvm/Option/OptTable.h" -namespace llvm { -namespace opt { - class OptTable; -} -} +#include namespace swift { namespace options { @@ -49,9 +45,7 @@ namespace options { enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - OPT_##ID, +#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__), #include "swift/Option/Options.inc" LastOption #undef OPTION diff --git a/include/swift/SIL/SILInstruction.h b/include/swift/SIL/SILInstruction.h index e36b07f375a57..38d4c48d73ef6 100644 --- a/include/swift/SIL/SILInstruction.h +++ b/include/swift/SIL/SILInstruction.h @@ -94,6 +94,7 @@ template <> struct compute_node_options<::swift::SILInstruction> { static const bool enable_sentinel_tracking = false; static const bool is_sentinel_tracking_explicit = false; + static const bool has_iterator_bits = false; typedef void tag; typedef ilist_node_base node_base_type; typedef SILInstructionListBase list_base_type; diff --git a/lib/AST/ASTMangler.cpp b/lib/AST/ASTMangler.cpp index 090a521a5c8b4..8a7aaa67b9c03 100644 --- a/lib/AST/ASTMangler.cpp +++ b/lib/AST/ASTMangler.cpp @@ -3038,7 +3038,7 @@ void ASTMangler::appendClangType(FnType *fn, llvm::raw_svector_ostream &out) { fn->getASTContext().getClangModuleLoader()->getClangASTContext(); std::unique_ptr mangler{ clang::ItaniumMangleContext::create(clangCtx, clangCtx.getDiagnostics())}; - mangler->mangleTypeName(clang::QualType(clangType, 0), scratchOS); + mangler->mangleCanonicalTypeName(clang::QualType(clangType, 0), scratchOS); out << scratchOS.str().size() << scratchOS.str(); } diff --git a/lib/AST/ClangTypeConverter.cpp b/lib/AST/ClangTypeConverter.cpp index 85ae8f62458ab..2e3198dff733d 100644 --- a/lib/AST/ClangTypeConverter.cpp +++ b/lib/AST/ClangTypeConverter.cpp @@ -227,7 +227,7 @@ clang::QualType ClangTypeConverter::convertMemberType(NominalTypeDecl *DC, // we could recover in some other way. static clang::QualType getClangVectorType(const clang::ASTContext &ctx, clang::BuiltinType::Kind eltKind, - clang::VectorType::VectorKind vecKind, + clang::VectorKind vecKind, StringRef numEltsString) { unsigned numElts; bool failedParse = numEltsString.getAsInteger(10, numElts); @@ -268,11 +268,11 @@ clang::QualType ClangTypeConverter::visitStructType(StructType *type) { #undef CHECK_NAMED_TYPE // Map vector types to the corresponding C vectors. -#define MAP_SIMD_TYPE(TYPE_NAME, _, BUILTIN_KIND) \ - if (name.starts_with(#TYPE_NAME)) { \ - return getClangVectorType(ctx, clang::BuiltinType::BUILTIN_KIND, \ - clang::VectorType::GenericVector, \ - name.drop_front(sizeof(#TYPE_NAME)-1)); \ +#define MAP_SIMD_TYPE(TYPE_NAME, _, BUILTIN_KIND) \ + if (name.starts_with(#TYPE_NAME)) { \ + return getClangVectorType(ctx, clang::BuiltinType::BUILTIN_KIND, \ + clang::VectorKind::Generic, \ + name.drop_front(sizeof(#TYPE_NAME) - 1)); \ } #include "swift/ClangImporter/SIMDMappedTypes.def" @@ -427,8 +427,8 @@ clang::QualType ClangTypeConverter::visitTupleType(TupleType *type) { return clang::QualType(); APInt size(32, tupleNumElements); - return ClangASTContext.getConstantArrayType(clangEltTy, size, nullptr, - clang::ArrayType::Normal, 0); + return ClangASTContext.getConstantArrayType( + clangEltTy, size, nullptr, clang::ArraySizeModifier::Normal, 0); } clang::QualType ClangTypeConverter::visitProtocolType(ProtocolType *type) { @@ -617,7 +617,7 @@ ClangTypeConverter::visitBoundGenericType(BoundGenericType *type) { return clang::QualType(); (void) failedParse; auto vectorTy = ClangASTContext.getVectorType(scalarTy, numElts, - clang::VectorType::VectorKind::GenericVector); + clang::VectorKind::Generic); return vectorTy; } } @@ -890,8 +890,8 @@ ClangTypeConverter::getClangTemplateArguments( auto templateParam = cast(param); // We must have found a defaulted parameter at the end of the list. if (templateParam->getIndex() >= genericArgs.size()) { - templateArgs.push_back( - clang::TemplateArgument(templateParam->getDefaultArgument())); + templateArgs.push_back(clang::TemplateArgument( + templateParam->getDefaultArgument().getArgument())); continue; } diff --git a/lib/AST/PluginRegistry.cpp b/lib/AST/PluginRegistry.cpp index 12a82ff9f36d9..21598ee52a01b 100644 --- a/lib/AST/PluginRegistry.cpp +++ b/lib/AST/PluginRegistry.cpp @@ -271,8 +271,8 @@ llvm::Error LoadedExecutablePlugin::sendMessage(llvm::StringRef message) const { size_t size = message.size(); // Write header (message size). - uint64_t header = llvm::support::endian::byte_swap( - uint64_t(size), llvm::support::endianness::little); + uint64_t header = llvm::support::endian::byte_swap(uint64_t(size), + llvm::endianness::little); writtenSize = Process->write(&header, sizeof(header)); if (writtenSize != sizeof(header)) { setStale(); @@ -304,8 +304,8 @@ llvm::Expected LoadedExecutablePlugin::waitForNextMessage() const { "failed to read plugin message header"); } - size_t size = llvm::support::endian::read( - &header, llvm::support::endianness::little); + size_t size = + llvm::support::endian::read(&header, llvm::endianness::little); // Read message. std::string message; diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp index 256f5c02254ee..eff748ca354e3 100644 --- a/lib/Basic/Platform.cpp +++ b/lib/Basic/Platform.cpp @@ -196,32 +196,31 @@ static StringRef getPlatformNameForDarwin(const DarwinPlatformKind platform) { StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) { switch (triple.getOS()) { - case llvm::Triple::ZOS: - case llvm::Triple::Ananas: - case llvm::Triple::CloudABI: + case llvm::Triple::AIX: + case llvm::Triple::AMDHSA: + case llvm::Triple::AMDPAL: + case llvm::Triple::BridgeOS: + case llvm::Triple::CUDA: case llvm::Triple::DragonFly: case llvm::Triple::DriverKit: + case llvm::Triple::ELFIAMCU: case llvm::Triple::Emscripten: case llvm::Triple::Fuchsia: + case llvm::Triple::HermitCore: + case llvm::Triple::Hurd: case llvm::Triple::KFreeBSD: case llvm::Triple::Lv2: + case llvm::Triple::Mesa3D: + case llvm::Triple::NaCl: case llvm::Triple::NetBSD: + case llvm::Triple::NVCL: case llvm::Triple::PS5: + case llvm::Triple::RTEMS: + case llvm::Triple::Serenity: case llvm::Triple::ShaderModel: case llvm::Triple::Solaris: - case llvm::Triple::Minix: - case llvm::Triple::RTEMS: - case llvm::Triple::NaCl: - case llvm::Triple::AIX: - case llvm::Triple::CUDA: - case llvm::Triple::NVCL: - case llvm::Triple::AMDHSA: - case llvm::Triple::ELFIAMCU: - case llvm::Triple::Mesa3D: - case llvm::Triple::Contiki: - case llvm::Triple::AMDPAL: - case llvm::Triple::HermitCore: - case llvm::Triple::Hurd: + case llvm::Triple::Vulkan: + case llvm::Triple::ZOS: return ""; case llvm::Triple::Darwin: case llvm::Triple::MacOSX: diff --git a/lib/ClangImporter/ClangAdapter.cpp b/lib/ClangImporter/ClangAdapter.cpp index c96e41f26b333..23d8d22d3837f 100644 --- a/lib/ClangImporter/ClangAdapter.cpp +++ b/lib/ClangImporter/ClangAdapter.cpp @@ -364,6 +364,7 @@ OmissionTypeName importer::getClangTypeNameForOmission(clang::ASTContext &ctx, case clang::BuiltinType::Overload: case clang::BuiltinType::PseudoObject: case clang::BuiltinType::UnknownAny: + case clang::BuiltinType::UnresolvedTemplate: return OmissionTypeName(); // FIXME: Types that can be mapped, but aren't yet. @@ -464,7 +465,7 @@ OmissionTypeName importer::getClangTypeNameForOmission(clang::ASTContext &ctx, return OmissionTypeName(); // OpenMP types that don't have Swift equivalents. - case clang::BuiltinType::OMPArraySection: + case clang::BuiltinType::ArraySection: case clang::BuiltinType::OMPArrayShaping: case clang::BuiltinType::OMPIterator: return OmissionTypeName(); @@ -776,7 +777,7 @@ OptionalTypeKind importer::getParamOptionality(const clang::ParmVarDecl *param, // Check for the 'static' annotation on C arrays. if (const auto *DT = dyn_cast(paramTy)) if (const auto *AT = DT->getOriginalType()->getAsArrayTypeUnsafe()) - if (AT->getSizeModifier() == clang::ArrayType::Static) + if (AT->getSizeModifier() == clang::ArraySizeModifier::Static) return OTK_None; // Default to implicitly unwrapped optionals. diff --git a/lib/ClangImporter/ClangDerivedConformances.cpp b/lib/ClangImporter/ClangDerivedConformances.cpp index 9219140eff63e..eaea4af632c2e 100644 --- a/lib/ClangImporter/ClangDerivedConformances.cpp +++ b/lib/ClangImporter/ClangDerivedConformances.cpp @@ -264,8 +264,8 @@ instantiateTemplatedOperator(ClangImporter::Implementation &impl, clang::UnresolvedSet<1> ops; auto qualType = clang::QualType(classDecl->getTypeForDecl(), 0); - auto arg = new (clangCtx) - clang::CXXThisExpr(clang::SourceLocation(), qualType, false); + auto arg = clang::CXXThisExpr::Create(clangCtx, clang::SourceLocation(), + qualType, false); arg->setType(clang::QualType(classDecl->getTypeForDecl(), 0)); clang::OverloadedOperatorKind opKind = diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 687a2b21045de..9ef537cd222de 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -1505,19 +1505,17 @@ ClangImporter::create(ASTContext &ctx, importer->Impl.objectAtIndexedSubscript = clangContext.Selectors.getUnarySelector( &clangContext.Idents.get("objectAtIndexedSubscript")); - clang::IdentifierInfo *setObjectAtIndexedSubscriptIdents[2] = { - &clangContext.Idents.get("setObject"), - &clangContext.Idents.get("atIndexedSubscript") - }; + const clang::IdentifierInfo *setObjectAtIndexedSubscriptIdents[2] = { + &clangContext.Idents.get("setObject"), + &clangContext.Idents.get("atIndexedSubscript")}; importer->Impl.setObjectAtIndexedSubscript = clangContext.Selectors.getSelector(2, setObjectAtIndexedSubscriptIdents); importer->Impl.objectForKeyedSubscript = clangContext.Selectors.getUnarySelector( &clangContext.Idents.get("objectForKeyedSubscript")); - clang::IdentifierInfo *setObjectForKeyedSubscriptIdents[2] = { - &clangContext.Idents.get("setObject"), - &clangContext.Idents.get("forKeyedSubscript") - }; + const clang::IdentifierInfo *setObjectForKeyedSubscriptIdents[2] = { + &clangContext.Idents.get("setObject"), + &clangContext.Idents.get("forKeyedSubscript")}; importer->Impl.setObjectForKeyedSubscript = clangContext.Selectors.getSelector(2, setObjectForKeyedSubscriptIdents); @@ -2228,9 +2226,9 @@ ClangImporter::Implementation::lookupModule(StringRef moduleName) { if (moduleFile == PrebuiltModules.end()) return nullptr; - if (!Instance->loadModuleFile(moduleFile->second)) + clang::serialization::ModuleFile *Loaded = nullptr; + if (!Instance->loadModuleFile(moduleFile->second, Loaded)) return nullptr; // error loading, return not found. - // Lookup again. return loadFromMM(); } @@ -2396,13 +2394,15 @@ ModuleDecl *ClangImporter::Implementation::finishLoadingClangModule( // instead, manually register all `.h` inputs of Clang module dependnecies. if (SwiftDependencyTracker && !Instance->getInvocation().getLangOpts().ImplicitModules) { - auto *moduleFile = Instance->getASTReader()->getModuleManager().lookup( - clangModule->getASTFile()); - Instance->getASTReader()->visitInputFileInfos( - *moduleFile, /*IncludeSystem=*/true, - [&](const clang::serialization::InputFileInfo &IFI, bool isSystem) { - SwiftDependencyTracker->addDependency(IFI.Filename, isSystem); - }); + if (auto moduleRef = clangModule->getASTFile()) { + auto *moduleFile = Instance->getASTReader()->getModuleManager().lookup( + *moduleRef); + Instance->getASTReader()->visitInputFileInfos( + *moduleFile, /*IncludeSystem=*/true, + [&](const clang::serialization::InputFileInfo &IFI, bool isSystem) { + SwiftDependencyTracker->addDependency(IFI.Filename, isSystem); + }); + } } if (clangModule->isSubModule()) { @@ -2874,7 +2874,7 @@ ClangImporter::Implementation::exportSelector(DeclName name, clang::ASTContext &ctx = getClangASTContext(); - SmallVector pieces; + SmallVector pieces; pieces.push_back(exportName(name.getBaseIdentifier()).getAsIdentifierInfo()); auto argNames = name.getArgumentNames(); @@ -2893,7 +2893,7 @@ ClangImporter::Implementation::exportSelector(DeclName name, clang::Selector ClangImporter::Implementation::exportSelector(ObjCSelector selector) { - SmallVector pieces; + SmallVector pieces; for (auto piece : selector.getSelectorPieces()) pieces.push_back(exportName(piece).getAsIdentifierInfo()); return getClangASTContext().Selectors.getSelector(selector.getNumArgs(), @@ -2909,7 +2909,7 @@ isPotentiallyConflictingSetter(const clang::ObjCProtocolDecl *proto, if (sel.getNumArgs() != 1) return false; - clang::IdentifierInfo *setterID = sel.getIdentifierInfoForSlot(0); + const clang::IdentifierInfo *setterID = sel.getIdentifierInfoForSlot(0); if (!setterID || !setterID->getName().starts_with("set")) return false; @@ -3943,11 +3943,12 @@ void ClangModuleUnit::lookupObjCMethods( // Collect all of the Objective-C methods with this selector. SmallVector objcMethods; auto &clangSema = owner.getClangSema(); - clangSema.CollectMultipleMethodsInGlobalPool(clangSelector, + auto &clangObjc = clangSema.ObjC(); + clangObjc.CollectMultipleMethodsInGlobalPool(clangSelector, objcMethods, /*InstanceFirst=*/true, /*CheckTheOther=*/false); - clangSema.CollectMultipleMethodsInGlobalPool(clangSelector, + clangObjc.CollectMultipleMethodsInGlobalPool(clangSelector, objcMethods, /*InstanceFirst=*/false, /*CheckTheOther=*/false); @@ -4008,14 +4009,13 @@ StringRef ClangModuleUnit::getFilename() const { else return SinglePCH; } - if (const clang::FileEntry *F = clangModule->getASTFile()) - if (!F->getName().empty()) - return F->getName(); + if (auto F = clangModule->getASTFile()) + return F->getName(); return StringRef(); } StringRef ClangModuleUnit::getLoadedFilename() const { - if (const clang::FileEntry *F = clangModule->getASTFile()) + if (auto F = clangModule->getASTFile()) return F->getName(); return StringRef(); } @@ -5312,9 +5312,9 @@ static clang::CXXMethodDecl *synthesizeCxxBaseGetterAccessorMethod( // Returns the expression that accesses the base field from derived type. auto createFieldAccess = [&]() -> clang::Expr * { - auto *thisExpr = new (clangCtx) - clang::CXXThisExpr(clang::SourceLocation(), newMethod->getThisType(), - /*IsImplicit=*/false); + auto *thisExpr = clang::CXXThisExpr::Create( + clangCtx, clang::SourceLocation(), newMethod->getThisType(), + /*IsImplicit=*/false); clang::QualType baseClassPtr = clangCtx.getRecordType(baseClass); baseClassPtr.addConst(); baseClassPtr = clangCtx.getPointerType(baseClassPtr); @@ -7886,7 +7886,7 @@ bool importer::requiresCPlusPlus(const clang::Module *module) { } return llvm::any_of(module->Requirements, [](clang::Module::Requirement req) { - return req.first == "cplusplus"; + return req.FeatureName == "cplusplus"; }); } diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 3e1827dcbd2ca..00a8b48e01d5c 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -59,6 +59,7 @@ #include "clang/Lex/Preprocessor.h" #include "clang/Sema/Lookup.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" @@ -872,26 +873,6 @@ static bool areRecordFieldsComplete(const clang::CXXRecordDecl *decl) { } namespace { - /// Customized llvm::DenseMapInfo for storing borrowed APSInts. - struct APSIntRefDenseMapInfo { - static inline const llvm::APSInt *getEmptyKey() { - return llvm::DenseMapInfo::getEmptyKey(); - } - static inline const llvm::APSInt *getTombstoneKey() { - return llvm::DenseMapInfo::getTombstoneKey(); - } - static unsigned getHashValue(const llvm::APSInt *ptrVal) { - assert(ptrVal != getEmptyKey() && ptrVal != getTombstoneKey()); - return llvm::hash_value(*ptrVal); - } - static bool isEqual(const llvm::APSInt *lhs, const llvm::APSInt *rhs) { - if (lhs == rhs) return true; - if (lhs == getEmptyKey() || rhs == getEmptyKey()) return false; - if (lhs == getTombstoneKey() || rhs == getTombstoneKey()) return false; - return *lhs == *rhs; - } - }; - /// Search the member tables for this class and its superclasses and try to /// identify the nearest VarDecl that serves as a base for an override. We /// have to do this ourselves because Objective-C has no semantic notion of @@ -1861,17 +1842,16 @@ namespace { break; } - llvm::SmallDenseMap, 8, - APSIntRefDenseMapInfo> canonicalEnumConstants; + EnumElementDecl *>, 8> canonicalEnumConstants; if (enumKind == EnumKind::NonFrozenEnum || enumKind == EnumKind::FrozenEnum) { for (auto constant : decl->enumerators()) { if (Impl.isUnavailableInSwift(constant)) continue; - canonicalEnumConstants.insert({&constant->getInitVal(), constant}); + canonicalEnumConstants.insert({constant->getInitVal(), constant}); } } @@ -1932,7 +1912,7 @@ namespace { case EnumKind::NonFrozenEnum: case EnumKind::FrozenEnum: { auto canonicalCaseIter = - canonicalEnumConstants.find(&constant->getInitVal()); + canonicalEnumConstants.find(constant->getInitVal()); if (canonicalCaseIter == canonicalEnumConstants.end()) { // Unavailable declarations get no special treatment. @@ -2256,7 +2236,7 @@ namespace { // Unnamed bitfields are just for padding and should not // inhibit creation of a memberwise initializer. - if (field->isUnnamedBitfield()) { + if (field->isUnnamedBitField()) { hasUnreferenceableStorage = true; continue; } @@ -3375,7 +3355,7 @@ namespace { d->getName() == "cos" || d->getName() == "exit"; return false; }; - + if (clang::Module *owningModule = decl->getOwningModule(); owningModule && importer::isCxxStdModule(owningModule)) { if (isAlternativeCStdlibFunctionFromTextualHeader(decl)) { @@ -3383,7 +3363,7 @@ namespace { } auto &sourceManager = Impl.getClangPreprocessor().getSourceManager(); - if (const auto file = sourceManager.getFileEntryForID( + if (auto file = sourceManager.getFileEntryRefForID( sourceManager.getFileID(decl->getLocation()))) { auto filename = file->getName(); if ((file->getDir() == owningModule->Directory) && @@ -3461,8 +3441,9 @@ namespace { // parameters when the function template is instantiated, so do not // import the function template if the template parameter has // dependent default value. - auto defaultArgumentType = templateTypeParam->getDefaultArgument(); - if (defaultArgumentType->isDependentType()) + auto &defaultArgument = + templateTypeParam->getDefaultArgument().getArgument(); + if (defaultArgument.isDependent()) return nullptr; continue; } @@ -3768,7 +3749,7 @@ namespace { // this method would get sliced away, and an invocation would get // dispatched statically. This is fine because it matches the C++ // behavior. - if (decl->isPure()) { + if (decl->isPureVirtual()) { // If this is a pure virtual method, we won't have any // implementation of it to invoke. Impl.markUnavailable(funcDecl, @@ -4586,7 +4567,8 @@ namespace { : getOverridableAccessLevel(dc)); // Optional methods in protocols. - if (decl->getImplementationControl() == clang::ObjCMethodDecl::Optional && + if (decl->getImplementationControl() == + clang::ObjCImplementationControl::Optional && isa(dc)) result->getAttrs().add(new (Impl.SwiftContext) OptionalAttr(/*implicit*/false)); @@ -5495,8 +5477,9 @@ namespace { if (decl->hasAttr()) result->getAttrs().add( new (Impl.SwiftContext) IBOutletAttr(/*IsImplicit=*/false)); - if (decl->getPropertyImplementation() == clang::ObjCPropertyDecl::Optional - && isa(dc) && + if (decl->getPropertyImplementation() == + clang::ObjCPropertyDecl::Optional && + isa(dc) && !result->getAttrs().hasAttribute()) result->getAttrs().add(new (Impl.SwiftContext) OptionalAttr(/*implicit*/false)); @@ -5593,12 +5576,6 @@ namespace { return nullptr; } - Decl *VisitClassScopeFunctionSpecializationDecl( - const clang::ClassScopeFunctionSpecializationDecl *decl) { - // Note: templates are not imported. - return nullptr; - } - Decl *VisitImportDecl(const clang::ImportDecl *decl) { // Transitive module imports are not handled at the declaration level. // Rather, they are understood from the module itself. @@ -7026,7 +7003,7 @@ SwiftDeclConverter::importSubscript(Decl *decl, // Find the counterpart. bool optionalMethods = (objcMethod->getImplementationControl() == - clang::ObjCMethodDecl::Optional); + clang::ObjCImplementationControl::Optional); if (auto *counterpart = findCounterpart(counterpartSelector)) { const clang::ObjCMethodDecl *counterpartMethod = nullptr; @@ -7040,7 +7017,7 @@ SwiftDeclConverter::importSubscript(Decl *decl, counterpartMethod = cast(importedFrom); if (optionalMethods) optionalMethods = (counterpartMethod->getImplementationControl() == - clang::ObjCMethodDecl::Optional); + clang::ObjCImplementationControl::Optional); } assert(!counterpart || !counterpart->isStatic()); @@ -8558,12 +8535,12 @@ ClangImporter::Implementation::importDeclImpl(const clang::NamedDecl *ClangDecl, if (auto clangProto = dyn_cast(ClangDecl->getDeclContext())) { if (auto method = dyn_cast(ClangDecl)) { - if (method->getImplementationControl() - == clang::ObjCMethodDecl::Required) + if (method->getImplementationControl() == + clang::ObjCImplementationControl::Required) hasMissingRequiredMember = true; } else if (auto prop = dyn_cast(ClangDecl)) { - if (prop->getPropertyImplementation() - == clang::ObjCPropertyDecl::Required) + if (prop->getPropertyImplementation() == + clang::ObjCPropertyDecl::Required) hasMissingRequiredMember = true; } @@ -9209,7 +9186,7 @@ void ClangImporter::Implementation::loadAllMembersOfRecordDecl( // Currently, we don't import unnamed bitfields. if (isa(m) && - cast(m)->isUnnamedBitfield()) + cast(m)->isUnnamedBitField()) continue; // Make sure we always pull in record fields. Everything else had better diff --git a/lib/ClangImporter/ImportEnumInfo.cpp b/lib/ClangImporter/ImportEnumInfo.cpp index 972f9a641bb19..c1622b2497b80 100644 --- a/lib/ClangImporter/ImportEnumInfo.cpp +++ b/lib/ClangImporter/ImportEnumInfo.cpp @@ -108,11 +108,11 @@ void EnumInfo::classifyEnum(const clang::EnumDecl *decl, // If API notes have /removed/ a FlagEnum or EnumExtensibility attribute, // then we don't need to check the macros. - for (auto *attr : decl->specific_attrs()) { + for (auto *attr : decl->specific_attrs()) { if (!attr->getIsReplacedByActive()) continue; - if (isa(attr->getAttrToAdd()) || - isa(attr->getAttrToAdd())) { + if (isa(attr->getAdditionalAttr()) || + isa(attr->getAdditionalAttr())) { kind = EnumKind::Unknown; return; } diff --git a/lib/ClangImporter/ImportMacro.cpp b/lib/ClangImporter/ImportMacro.cpp index 2a194468f7a22..32a1346d2b7ad 100644 --- a/lib/ClangImporter/ImportMacro.cpp +++ b/lib/ClangImporter/ImportMacro.cpp @@ -399,10 +399,9 @@ static ValueDecl *importMacro(ClangImporter::Implementation &impl, // Handle tokens starting with a type cast bool castTypeIsId = false; - if (numTokens > 3 && - tokenI[0].is(clang::tok::l_paren) && + if (numTokens > 3 && tokenI[0].is(clang::tok::l_paren) && (tokenI[1].is(clang::tok::identifier) || - impl.getClangSema().isSimpleTypeSpecifier(tokenI[1].getKind())) && + tokenI[1].isSimpleTypeSpecifier(impl.getClangSema().getLangOpts())) && tokenI[2].is(clang::tok::r_paren)) { if (!castType.isNull()) { // this is a nested cast diff --git a/lib/ClangImporter/ImportName.cpp b/lib/ClangImporter/ImportName.cpp index 06d5c9329dfb5..b0ab9cb972064 100644 --- a/lib/ClangImporter/ImportName.cpp +++ b/lib/ClangImporter/ImportName.cpp @@ -548,7 +548,7 @@ struct AnySwiftNameAttr { } }; -/// Aggregate struct for the common members of clang::SwiftVersionedAttr and +/// Aggregate struct for the common members of clang::SwiftVersionedAdditionAttr and /// clang::SwiftVersionedRemovalAttr. /// /// For a SwiftVersionedRemovalAttr, the Attr member will be null. @@ -671,8 +671,8 @@ findSwiftNameAttr(const clang::Decl *decl, ImportNameVersion version) { for (auto *attr : decl->attrs()) { VersionedSwiftNameInfo info; - if (auto *versionedAttr = dyn_cast(attr)) { - auto added = decodeAttr(versionedAttr->getAttrToAdd()); + if (auto *versionedAttr = dyn_cast(attr)) { + auto added = decodeAttr(versionedAttr->getAdditionalAttr()); if (!added) continue; @@ -1430,7 +1430,7 @@ bool NameImporter::hasErrorMethodNameCollision( unsigned numArgs = selector.getNumArgs(); assert(numArgs > 0); - SmallVector chunks; + SmallVector chunks; for (unsigned i = 0, e = selector.getNumArgs(); i != e; ++i) { chunks.push_back(selector.getIdentifierInfoForSlot(i)); } diff --git a/lib/ClangImporter/ImportType.cpp b/lib/ClangImporter/ImportType.cpp index a9e55610d5d2e..1426eee0ca03b 100644 --- a/lib/ClangImporter/ImportType.cpp +++ b/lib/ClangImporter/ImportType.cpp @@ -283,6 +283,7 @@ namespace { case clang::BuiltinType::Overload: case clang::BuiltinType::PseudoObject: case clang::BuiltinType::UnknownAny: + case clang::BuiltinType::UnresolvedTemplate: return Type(); // FIXME: Types that can be mapped, but aren't yet. @@ -381,7 +382,7 @@ namespace { return Type(); // OpenMP types that don't have Swift equivalents. - case clang::BuiltinType::OMPArraySection: + case clang::BuiltinType::ArraySection: case clang::BuiltinType::OMPArrayShaping: case clang::BuiltinType::OMPIterator: return Type(); @@ -450,6 +451,17 @@ namespace { return Type(); } + ImportResult VisitCountAttributedType( + const clang::CountAttributedType *type) { + // CountAttributedType is a clang type representing a pointer with + // a "counted_by" type attribute. For now, we don't import these + // into Swift. + // In the future we could do something more clever (such as trying to + // import as an Array where possible) or less clever (such as importing + // as the desugared, underlying pointer type). + return Type(); + } + ImportResult VisitMemberPointerType(const clang::MemberPointerType *type) { return Type(); } @@ -1285,6 +1297,10 @@ namespace { return { importedType, ImportHint::ObjCPointer }; } + + ImportResult VisitPackIndexingType(const clang::PackIndexingType *type) { + return Type(); + } }; } // end anonymous namespace diff --git a/lib/ClangImporter/Serializability.cpp b/lib/ClangImporter/Serializability.cpp index bbb8668652ac2..d59863b06c5c3 100644 --- a/lib/ClangImporter/Serializability.cpp +++ b/lib/ClangImporter/Serializability.cpp @@ -317,6 +317,18 @@ namespace { } void writeAttr(const clang::Attr *attr) {} + + // CountAttributedType is a clang type representing a pointer with + // a "counted_by" type attribute and DynamicRangePointerType + // is representing a "__ended_by" type attribute. + // TypeCoupledDeclRefInfo is used to hold information of a declaration + // referenced from an expression argument of "__counted_by(expr)" or + // "__ended_by(expr)". + // Leave it non-serializable for now as we currently don't import + // these types into Swift. + void writeTypeCoupledDeclRefInfo(clang::TypeCoupledDeclRefInfo info) { + llvm_unreachable("TypeCoupledDeclRefInfo shouldn't be reached from swift"); + } }; } diff --git a/lib/ClangImporter/SwiftDeclSynthesizer.cpp b/lib/ClangImporter/SwiftDeclSynthesizer.cpp index b8d6614bd11c9..fbbf5fc11fff9 100644 --- a/lib/ClangImporter/SwiftDeclSynthesizer.cpp +++ b/lib/ClangImporter/SwiftDeclSynthesizer.cpp @@ -2132,8 +2132,9 @@ clang::CXXMethodDecl *SwiftDeclSynthesizer::synthesizeCXXForwardingMethod( auto diagState = clangSema.DelayedDiagnostics.push(diagPool); // Construct the method's body. - clang::Expr *thisExpr = new (clangCtx) clang::CXXThisExpr( - clang::SourceLocation(), newMethod->getThisType(), /*IsImplicit=*/false); + clang::Expr *thisExpr = clang::CXXThisExpr::Create( + clangCtx, clang::SourceLocation(), newMethod->getThisType(), + /*IsImplicit=*/false); if (castThisToNonConstThis) { auto baseClassPtr = clangCtx.getPointerType(clangCtx.getRecordType(derivedClass)); diff --git a/lib/ClangImporter/SwiftLookupTable.cpp b/lib/ClangImporter/SwiftLookupTable.cpp index be60f796c0032..c62466e621ae0 100644 --- a/lib/ClangImporter/SwiftLookupTable.cpp +++ b/lib/ClangImporter/SwiftLookupTable.cpp @@ -51,6 +51,12 @@ static bool matchesExistingDecl(clang::Decl *decl, clang::Decl *existingDecl) { return false; } +template +[[nodiscard]] static inline value_type readNext(const CharT *&memory) { + return llvm::support::endian::readNext(memory); +} + namespace { class BaseNameToEntitiesTableReaderInfo; class GlobalsAsMembersTableReaderInfo; @@ -827,9 +833,9 @@ ArrayRef SwiftLookupTable::categories() { // Map categories known to the reader. for (auto declID : Reader->categories()) { - auto category = - cast_or_null( - Reader->getASTReader().GetLocalDecl(Reader->getModuleFile(), declID)); + auto category = cast_or_null( + Reader->getASTReader().GetLocalDecl(Reader->getModuleFile(), + clang::LocalDeclID(declID))); if (category) Categories.push_back(category); @@ -924,10 +930,10 @@ static void printStoredContext(SwiftLookupTable::StoredContext context, } } -static uint32_t getEncodedDeclID(uint64_t entry) { - assert(SwiftLookupTable::isSerializationIDEntry(entry)); +static clang::LocalDeclID getEncodedDeclID(uint64_t entry) { + assert(SwiftLookupTable::isSerializationIDEntry(entry)); assert(SwiftLookupTable::isDeclEntry(entry)); - return entry >> 2; + return clang::LocalDeclID(entry >> 2); } namespace { @@ -949,7 +955,7 @@ static void printStoredEntry(const SwiftLookupTable *table, uint64_t entry, llvm::raw_ostream &out) { if (SwiftLookupTable::isSerializationIDEntry(entry)) { if (SwiftLookupTable::isDeclEntry(entry)) { - llvm::errs() << "decl ID #" << getEncodedDeclID(entry); + llvm::errs() << "decl ID #" << getEncodedDeclID(entry).get(); } else { LocalMacroIDs macroIDs = getEncodedModuleMacroIDs(entry); if (macroIDs.moduleID == 0) { @@ -1146,14 +1152,14 @@ namespace { dataLength += (sizeof(uint64_t) * entry.DeclsOrMacros.size()); } - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; } void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write((uint8_t)key.Kind); if (key.Kind == swift::DeclBaseName::Kind::Normal) writer.OS << key.Name; @@ -1161,7 +1167,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); // # of entries writer.write(data.size()); @@ -1184,7 +1190,7 @@ namespace { uint64_t id; auto mappedEntry = Table.mapStored(entry, isModule); if (auto *decl = mappedEntry.dyn_cast()) { - id = (Writer.getDeclID(decl) << 2) | 0x02; + id = (Writer.getDeclID(decl).get() << 2) | 0x02; } else if (auto *macro = mappedEntry.dyn_cast()) { id = static_cast(Writer.getMacroID(macro)) << 32; id |= 0x02 | 0x01; @@ -1240,14 +1246,14 @@ namespace { sizeof(uint16_t) + sizeof(uint64_t) * data.size(); assert(dataLength == static_cast(dataLength)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; } void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(static_cast(key.first) - 2); if (SwiftLookupTable::contextRequiresName(key.first)) out << key.second; @@ -1255,7 +1261,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); // # of entries writer.write(data.size()); @@ -1266,7 +1272,7 @@ namespace { uint64_t id; auto mappedEntry = Table.mapStored(entry, isModule); if (auto *decl = mappedEntry.dyn_cast()) { - id = (Writer.getDeclID(decl) << 2) | 0x02; + id = (Writer.getDeclID(decl).get() << 2) | 0x02; } else if (auto *macro = mappedEntry.dyn_cast()) { id = static_cast(Writer.getMacroID(macro)) << 32; id |= 0x02 | 0x01; @@ -1314,7 +1320,7 @@ void SwiftLookupTableWriter::writeExtensionContents( llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream, info); } @@ -1326,7 +1332,7 @@ void SwiftLookupTableWriter::writeExtensionContents( if (!table.Categories.empty()) { SmallVector categoryIDs; for (auto category : table.Categories) { - categoryIDs.push_back(Writer.getDeclID(category)); + categoryIDs.push_back(Writer.getDeclID(category).get()); } StringRef blob(reinterpret_cast(categoryIDs.data()), @@ -1356,7 +1362,7 @@ void SwiftLookupTableWriter::writeExtensionContents( llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream, info); } @@ -1386,7 +1392,7 @@ void SwiftLookupTableWriter::writeExtensionContents( llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream, info); } @@ -1423,13 +1429,13 @@ namespace { static std::pair ReadKeyDataLength(const uint8_t *&data) { - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } static internal_key_type ReadKey(const uint8_t *data, unsigned length) { - uint8_t kind = endian::readNext(data); + uint8_t kind = readNext(data); switch (kind) { case (uint8_t)DeclBaseName::Kind::Normal: { StringRef str(reinterpret_cast(data), @@ -1452,7 +1458,7 @@ namespace { data_type result; // # of entries. - unsigned numEntries = endian::readNext(data); + unsigned numEntries = readNext(data); result.reserve(numEntries); // Read all of the entries. @@ -1461,19 +1467,17 @@ namespace { // Read the context. entry.Context.first = - static_cast( - endian::readNext(data)); + static_cast(readNext(data)); if (SwiftLookupTable::contextRequiresName(entry.Context.first)) { - uint16_t length = endian::readNext(data); + uint16_t length = readNext(data); entry.Context.second = StringRef((const char *)data, length); data += length; } // Read the declarations and macros. - unsigned numDeclsOrMacros = - endian::readNext(data); + unsigned numDeclsOrMacros = readNext(data); while (numDeclsOrMacros--) { - auto id = endian::readNext(data); + auto id = readNext(data); entry.DeclsOrMacros.push_back(id); } @@ -1511,8 +1515,8 @@ namespace { static std::pair ReadKeyDataLength(const uint8_t *&data) { - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } @@ -1527,12 +1531,12 @@ namespace { data_type result; // # of entries. - unsigned numEntries = endian::readNext(data); + unsigned numEntries = readNext(data); result.reserve(numEntries); // Read all of the entries. while (numEntries--) { - auto id = endian::readNext(data); + auto id = readNext(data); result.push_back(id); } @@ -1551,7 +1555,7 @@ clang::NamedDecl *SwiftLookupTable::mapStoredDecl(uint64_t &entry) { // Otherwise, resolve the declaration. assert(Reader && "Cannot resolve the declaration without a reader"); - uint32_t declID = getEncodedDeclID(entry); + clang::LocalDeclID declID = getEncodedDeclID(entry); auto decl = cast_or_null( Reader->getASTReader().GetLocalDecl(Reader->getModuleFile(), declID)); diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp index ee4cfcc678bd4..63dd11bdbba5b 100644 --- a/lib/Driver/Compilation.cpp +++ b/lib/Driver/Compilation.cpp @@ -731,7 +731,7 @@ namespace driver { /// Create \c NumberOfParallelCommands batches and assign each job to a /// batch either filling each partition in order or, if seeded with a /// nonzero value, pseudo-randomly (but deterministically and nearly-evenly). - void partitionIntoBatches(std::vector Batchable, + void partitionIntoBatches(const llvm::SmallVectorImpl &Batchable, BatchPartition &Partition) { if (Comp.getShowJobLifecycle()) { llvm::outs() << "Found " << Batchable.size() << " batchable jobs\n"; diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 49dfb4707f8c9..a019722698e61 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -249,7 +249,7 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI, } inputArgs.AddAllArgs(arguments, options::OPT_I); - inputArgs.AddAllArgs(arguments, options::OPT_F, options::OPT_Fsystem); + inputArgs.addAllArgs(arguments, {options::OPT_F, options::OPT_Fsystem}); inputArgs.AddAllArgs(arguments, options::OPT_vfsoverlay); inputArgs.AddLastArg(arguments, options::OPT_AssertConfig); @@ -305,8 +305,8 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI, inputArgs.AddLastArg(arguments, options::OPT_profile_generate); inputArgs.AddLastArg(arguments, options::OPT_profile_use); inputArgs.AddLastArg(arguments, options::OPT_profile_coverage_mapping); - inputArgs.AddAllArgs(arguments, options::OPT_warnings_as_errors, - options::OPT_no_warnings_as_errors); + inputArgs.addAllArgs(arguments, {options::OPT_warnings_as_errors, + options::OPT_no_warnings_as_errors}); inputArgs.AddLastArg(arguments, options::OPT_sanitize_EQ); inputArgs.AddLastArg(arguments, options::OPT_sanitize_recover_EQ); inputArgs.AddLastArg(arguments, @@ -349,9 +349,9 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI, inputArgs.AddAllArgs(arguments, options::OPT_D); // Pass on file paths that should be remapped in debug info. - inputArgs.AddAllArgs(arguments, options::OPT_debug_prefix_map, - options::OPT_coverage_prefix_map, - options::OPT_file_prefix_map); + inputArgs.addAllArgs(arguments, {options::OPT_debug_prefix_map, + options::OPT_coverage_prefix_map, + options::OPT_file_prefix_map}); std::string globalRemapping = getGlobalDebugPathRemapping(); if (!globalRemapping.empty()) { @@ -1312,7 +1312,8 @@ ToolChain::constructInvocation(const REPLJobAction &job, addRuntimeLibraryFlags(context.OI, FrontendArgs); context.Args.AddLastArg(FrontendArgs, options::OPT_import_objc_header); - context.Args.AddAllArgs(FrontendArgs, options::OPT_framework, options::OPT_L); + context.Args.addAllArgs(FrontendArgs, + {options::OPT_framework, options::OPT_L}); ToolChain::addLinkedLibArgs(context.Args, FrontendArgs); if (!useLLDB) { diff --git a/lib/DriverTool/swift_cache_tool_main.cpp b/lib/DriverTool/swift_cache_tool_main.cpp index 72096cc2045c0..f79d3a811333e 100644 --- a/lib/DriverTool/swift_cache_tool_main.cpp +++ b/lib/DriverTool/swift_cache_tool_main.cpp @@ -56,9 +56,7 @@ struct OutputEntry { enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - OPT_##ID, +#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__), #include "SwiftCacheToolOptions.inc" LastOption #undef OPTION @@ -72,10 +70,7 @@ enum ID { #undef PREFIX static const OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - {PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, \ - PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES}, +#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__), #include "SwiftCacheToolOptions.inc" #undef OPTION }; diff --git a/lib/DriverTool/swift_llvm_opt_main.cpp b/lib/DriverTool/swift_llvm_opt_main.cpp index 17f7ae298d7a1..0acc283b74af5 100644 --- a/lib/DriverTool/swift_llvm_opt_main.cpp +++ b/lib/DriverTool/swift_llvm_opt_main.cpp @@ -114,11 +114,11 @@ static llvm::cl::opt PassPipeline( // Helper Methods //===----------------------------------------------------------------------===// -static llvm::CodeGenOpt::Level GetCodeGenOptLevel(const SwiftLLVMOptOptions &options) { +static llvm::CodeGenOptLevel GetCodeGenOptLevel(const SwiftLLVMOptOptions &options) { // TODO: Is this the right thing to do here? if (options.Optimized) - return llvm::CodeGenOpt::Default; - return llvm::CodeGenOpt::None; + return llvm::CodeGenOptLevel::Default; + return llvm::CodeGenOptLevel::None; } // Returns the TargetMachine instance or zero if no triple is provided. diff --git a/lib/Frontend/CachedDiagnostics.cpp b/lib/Frontend/CachedDiagnostics.cpp index 069d2641ab8bb..180e639706b9b 100644 --- a/lib/Frontend/CachedDiagnostics.cpp +++ b/lib/Frontend/CachedDiagnostics.cpp @@ -828,7 +828,7 @@ CachingDiagnosticsProcessor::CachingDiagnosticsProcessor( // Write the uncompressed size in the end. if (!Compression.empty()) { llvm::raw_svector_ostream BufOS((SmallVectorImpl &)Compression); - llvm::support::endian::Writer Writer(BufOS, llvm::support::little); + llvm::support::endian::Writer Writer(BufOS, llvm::endianness::little); Writer.write(uint32_t(Output.size())); } @@ -876,7 +876,7 @@ CachingDiagnosticsProcessor::replayCachedDiagnostics(llvm::StringRef Buffer) { std::make_error_code(std::errc::message_size)); uint32_t UncompressedSize = - llvm::support::endian::read( + llvm::support::endian::read( Buffer.data() + Buffer.size() - sizeof(uint32_t)); StringRef CompressedData = Buffer.drop_back(sizeof(uint32_t)); diff --git a/lib/Frontend/CompileJobCacheKey.cpp b/lib/Frontend/CompileJobCacheKey.cpp index 3aa065ff2577f..d6506abfee751 100644 --- a/lib/Frontend/CompileJobCacheKey.cpp +++ b/lib/Frontend/CompileJobCacheKey.cpp @@ -94,7 +94,8 @@ swift::createCompileJobCacheKeyForOutput(llvm::cas::ObjectStore &CAS, // CacheKey is the index of the producting input + the base key. // Encode the unsigned value as little endian in the field. - llvm::support::endian::write(OS, InputIndex, llvm::support::little); + llvm::support::endian::write(OS, InputIndex, + llvm::endianness::little); return CAS.storeFromString({BaseKey}, OS.str()); } diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp index ffb44e70c60d0..7e68844b61674 100644 --- a/lib/FrontendTool/FrontendTool.cpp +++ b/lib/FrontendTool/FrontendTool.cpp @@ -1263,9 +1263,9 @@ static bool printSwiftFeature(CompilerInstance &instance) { out << "}\n"; }; out << " \"SupportedArguments\": [\n"; -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - printSingleFrontendOpt(*table, swift::options::OPT_##ID, out); +#define OPTION(...) \ + printSingleFrontendOpt(*table, \ + swift::options::LLVM_MAKE_OPT_ID(__VA_ARGS__), out); #include "swift/Option/Options.inc" #undef OPTION out << " \"LastOption\"\n"; diff --git a/lib/IDE/CodeCompletionCache.cpp b/lib/IDE/CodeCompletionCache.cpp index 94820e1e828d6..2392f489b4779 100644 --- a/lib/IDE/CodeCompletionCache.cpp +++ b/lib/IDE/CodeCompletionCache.cpp @@ -303,8 +303,7 @@ static bool readCachedModule(llvm::MemoryBuffer *in, static void writeCachedModule(llvm::raw_ostream &out, const CodeCompletionCache::Key &K, CodeCompletionCache::Value &V) { - using namespace llvm::support; - endian::Writer LE(out, little); + llvm::support::endian::Writer LE(out, llvm::endianness::little); // HEADER // Metadata required for reading the completions. @@ -320,7 +319,7 @@ static void writeCachedModule(llvm::raw_ostream &out, llvm::raw_svector_ostream OSS(scratch); OSS << K.ModuleFilename << "\0"; OSS << K.ModuleName << "\0"; - endian::Writer OSSLE(OSS, little); + llvm::support::endian::Writer OSSLE(OSS, llvm::endianness::little); OSSLE.write(K.AccessPath.size()); for (StringRef p : K.AccessPath) OSS << p << "\0"; @@ -339,7 +338,7 @@ static void writeCachedModule(llvm::raw_ostream &out, llvm::raw_string_ostream results(results_); std::string chunks_; llvm::raw_string_ostream chunks(chunks_); - endian::Writer chunksLE(chunks, little); + llvm::support::endian::Writer chunksLE(chunks, llvm::endianness::little); std::string strings_; llvm::raw_string_ostream strings(strings_); llvm::StringMap knownStrings; @@ -355,7 +354,7 @@ static void writeCachedModule(llvm::raw_ostream &out, return found->second; } auto size = strings.tell(); - endian::Writer LE(strings, little); + llvm::support::endian::Writer LE(strings, llvm::endianness::little); LE.write(static_cast(str.size())); strings << str; knownStrings[str] = size; @@ -380,7 +379,7 @@ static void writeCachedModule(llvm::raw_ostream &out, } auto size = types.tell(); - endian::Writer LE(types, little); + llvm::support::endian::Writer LE(types, llvm::endianness::little); StringRef USR = type->getUSR(); LE.write(static_cast(USR.size())); types << USR; @@ -413,7 +412,7 @@ static void writeCachedModule(llvm::raw_ostream &out, // RESULTS { - endian::Writer LE(results, little); + llvm::support::endian::Writer LE(results, llvm::endianness::little); for (const ContextFreeCodeCompletionResult *R : V.Results) { // FIXME: compress bitfield LE.write(static_cast(R->getKind())); diff --git a/lib/IRGen/GenCall.cpp b/lib/IRGen/GenCall.cpp index e2a9f164e3373..1b0a37f123146 100644 --- a/lib/IRGen/GenCall.cpp +++ b/lib/IRGen/GenCall.cpp @@ -1027,6 +1027,10 @@ namespace { llvm_unreachable("ConstantMatrix type in ABI lowering?"); } + case clang::Type::ArrayParameter: + llvm_unreachable("HLSL type in ABI lowering"); + + case clang::Type::ConstantArray: { auto array = Ctx.getAsConstantArrayType(type); auto elt = Ctx.getCanonicalType(array->getElementType()); diff --git a/lib/IRGen/GenClass.cpp b/lib/IRGen/GenClass.cpp index bb2635428c653..1fcdcdf40fa7e 100644 --- a/lib/IRGen/GenClass.cpp +++ b/lib/IRGen/GenClass.cpp @@ -1606,8 +1606,7 @@ namespace { std::optional specializedGenericType; if ((specializedGenericType = getSpecializedGenericType()) && forMeta) { // ClassMetadata *NonMetaClass; - b.addBitCast(IGM.getAddrOfTypeMetadata(*specializedGenericType), - IGM.Int8PtrTy); + b.add(IGM.getAddrOfTypeMetadata(*specializedGenericType)); } else { // const uint8_t *IvarLayout; // GC/ARC layout. TODO. diff --git a/lib/IRGen/GenConstant.cpp b/lib/IRGen/GenConstant.cpp index df18be6e11d99..4b5dd56178bad 100644 --- a/lib/IRGen/GenConstant.cpp +++ b/lib/IRGen/GenConstant.cpp @@ -30,7 +30,9 @@ #include "DebugTypeInfo.h" #include "swift/IRGen/Linking.h" #include "swift/Basic/Range.h" +#include "swift/Basic/Require.h" #include "swift/SIL/SILModule.h" +#include "llvm/Analysis/ConstantFolding.h" #include "llvm/Support/BLAKE3.h" using namespace swift; @@ -321,8 +323,16 @@ Explosion irgen::emitConstantValue(IRGenModule &IGM, SILValue operand, } case BuiltinValueKind::ZExtOrBitCast: { auto *val = emitConstantValue(IGM, args[0]).claimNextConstant(); - return llvm::ConstantExpr::getZExtOrBitCast(val, - IGM.getStorageType(BI->getType())); + auto storageTy = IGM.getStorageType(BI->getType()); + + if (val->getType() == storageTy) + return val; + + auto *result = llvm::ConstantFoldCastOperand( + llvm::Instruction::ZExt, val, storageTy, IGM.DataLayout); + require(result != nullptr, + "couldn't constant fold initializer expression"); + return result; } case BuiltinValueKind::StringObjectOr: { // It is a requirement that the or'd bits in the left argument are diff --git a/lib/IRGen/GenCoverage.cpp b/lib/IRGen/GenCoverage.cpp index 122d1229b0323..bf49a92e06015 100644 --- a/lib/IRGen/GenCoverage.cpp +++ b/lib/IRGen/GenCoverage.cpp @@ -42,7 +42,7 @@ using llvm::coverage::CovMapVersion; /// cannot pin our version, as it must remain in sync with the version Clang is /// using. /// Do not bump without at least filing a bug and pinging a coverage maintainer. -static_assert(CovMapVersion::CurrentVersion == CovMapVersion::Version6, +static_assert(CovMapVersion::CurrentVersion == CovMapVersion::Version7, "Coverage mapping emission needs updating"); static std::string getInstrProfSection(IRGenModule &IGM, diff --git a/lib/IRGen/GenDiffWitness.cpp b/lib/IRGen/GenDiffWitness.cpp index d931647524fc3..488092757cc2e 100644 --- a/lib/IRGen/GenDiffWitness.cpp +++ b/lib/IRGen/GenDiffWitness.cpp @@ -39,10 +39,8 @@ void IRGenModule::emitSILDifferentiabilityWitness( "Differentiability witness definition should have JVP"); assert(dw->getVJP() && "Differentiability witness definition should have VJP"); - diffWitnessContents.addBitCast( - getAddrOfSILFunction(dw->getJVP(), NotForDefinition), Int8PtrTy); - diffWitnessContents.addBitCast( - getAddrOfSILFunction(dw->getVJP(), NotForDefinition), Int8PtrTy); + diffWitnessContents.add(getAddrOfSILFunction(dw->getJVP(), NotForDefinition)); + diffWitnessContents.add(getAddrOfSILFunction(dw->getVJP(), NotForDefinition)); getAddrOfDifferentiabilityWitness( dw, diffWitnessContents.finishAndCreateFuture()); } diff --git a/lib/IRGen/GenOpaque.cpp b/lib/IRGen/GenOpaque.cpp index 51cdc11bf7ec1..858ce581af7fc 100644 --- a/lib/IRGen/GenOpaque.cpp +++ b/lib/IRGen/GenOpaque.cpp @@ -623,8 +623,9 @@ StackAddress IRGenFunction::emitDynamicAlloca(llvm::Type *eltTy, // executed more than once). bool isInEntryBlock = (Builder.GetInsertBlock() == &*CurFn->begin()); if (!isInEntryBlock) { - stackRestorePoint = - Builder.CreateIntrinsicCall(llvm::Intrinsic::stacksave, {}, "spsave"); + stackRestorePoint = Builder.CreateIntrinsicCall( + llvm::Intrinsic::stacksave, + {IGM.DataLayout.getAllocaPtrType(IGM.getLLVMContext())}, {}, "spsave"); } // Emit the dynamic alloca. @@ -664,7 +665,8 @@ void IRGenFunction::emitDeallocateDynamicAlloca(StackAddress address, auto savedSP = address.getExtraInfo(); if (savedSP == nullptr) return; - Builder.CreateIntrinsicCall(llvm::Intrinsic::stackrestore, savedSP); + Builder.CreateIntrinsicCall(llvm::Intrinsic::stackrestore, + {savedSP->getType()}, {savedSP}); } /// Emit a call to do an 'initializeArrayWithCopy' operation. diff --git a/lib/IRGen/GenProto.cpp b/lib/IRGen/GenProto.cpp index 02d9f10ef2374..05d2982c77fe1 100644 --- a/lib/IRGen/GenProto.cpp +++ b/lib/IRGen/GenProto.cpp @@ -1478,7 +1478,7 @@ class AccessorConformanceInfo : public ConformanceInfo { if (isRelative) Table.addRelativeAddress(descriptor); else - Table.addBitCast(descriptor, IGM.Int8PtrTy); + Table.add(descriptor); } /// A base protocol is witnessed by a pointer to the conformance @@ -1514,7 +1514,7 @@ class AccessorConformanceInfo : public ConformanceInfo { Table.addRelativeAddress(baseWitness); return; } else if (baseWitness) { - Table.addBitCast(baseWitness, IGM.Int8PtrTy); + Table.add(baseWitness); return; } diff --git a/lib/IRGen/IRGen.cpp b/lib/IRGen/IRGen.cpp index 118a634d01509..1431b91f666c5 100644 --- a/lib/IRGen/IRGen.cpp +++ b/lib/IRGen/IRGen.cpp @@ -330,7 +330,7 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts, options.Atomic = bool(Opts.Sanitizers & SanitizerKind::Thread); PB.registerPipelineStartEPCallback( [options](ModulePassManager &MPM, OptimizationLevel level) { - MPM.addPass(InstrProfiling(options, false)); + MPM.addPass(InstrProfilingLoweringPass(options, false)); }); } if (Opts.shouldOptimize()) { @@ -662,8 +662,8 @@ bool swift::compileAndWriteLLVM( legacy::PassManager EmitPasses; CodeGenFileType FileType; FileType = - (opts.OutputKind == IRGenOutputKind::NativeAssembly ? CGFT_AssemblyFile - : CGFT_ObjectFile); + (opts.OutputKind == IRGenOutputKind::NativeAssembly ? CodeGenFileType::AssemblyFile + : CodeGenFileType::ObjectFile); EmitPasses.add(createTargetTransformInfoWrapperPass( targetMachine->getTargetIRAnalysis())); @@ -861,9 +861,9 @@ static void setPointerAuthOptions(PointerAuthOptions &opts, std::unique_ptr swift::createTargetMachine(const IRGenOptions &Opts, ASTContext &Ctx) { - CodeGenOpt::Level OptLevel = Opts.shouldOptimize() - ? CodeGenOpt::Default // -Os - : CodeGenOpt::None; + CodeGenOptLevel OptLevel = Opts.shouldOptimize() + ? CodeGenOptLevel::Default // -Os + : CodeGenOptLevel::None; // Set up TargetOptions and create the target features string. TargetOptions TargetOpts; diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index d3a0cabb5f27b..77cccbbd99d72 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -3365,9 +3365,9 @@ struct DbgIntrinsicEmitter { /// - llvm::Instruction *insert(llvm::Value *Addr, llvm::DILocalVariable *VarInfo, - llvm::DIExpression *Expr, - const llvm::DILocation *DL) { + llvm::DbgInstPtr insert(llvm::Value *Addr, llvm::DILocalVariable *VarInfo, + llvm::DIExpression *Expr, + const llvm::DILocation *DL) { if (auto *Inst = InsertPt.dyn_cast()) { return insert(Addr, VarInfo, Expr, DL, Inst); } else { @@ -3376,10 +3376,10 @@ struct DbgIntrinsicEmitter { } } - llvm::Instruction *insert(llvm::Value *Addr, llvm::DILocalVariable *VarInfo, - llvm::DIExpression *Expr, - const llvm::DILocation *DL, - llvm::Instruction *InsertBefore) { + llvm::DbgInstPtr insert(llvm::Value *Addr, llvm::DILocalVariable *VarInfo, + llvm::DIExpression *Expr, + const llvm::DILocation *DL, + llvm::Instruction *InsertBefore) { if (ForceDbgDeclare == AddrDbgInstrKind::DbgDeclare) return DIBuilder.insertDeclare(Addr, VarInfo, Expr, DL, InsertBefore); Expr = llvm::DIExpression::append(Expr, llvm::dwarf::DW_OP_deref); @@ -3387,10 +3387,10 @@ struct DbgIntrinsicEmitter { InsertBefore); } - llvm::Instruction *insert(llvm::Value *Addr, llvm::DILocalVariable *VarInfo, - llvm::DIExpression *Expr, - const llvm::DILocation *DL, - llvm::BasicBlock *Block) { + llvm::DbgInstPtr insert(llvm::Value *Addr, llvm::DILocalVariable *VarInfo, + llvm::DIExpression *Expr, + const llvm::DILocation *DL, + llvm::BasicBlock *Block) { if (ForceDbgDeclare == AddrDbgInstrKind::DbgDeclare) return DIBuilder.insertDeclare(Addr, VarInfo, Expr, DL, Block); Expr = llvm::DIExpression::append(Expr, llvm::dwarf::DW_OP_deref); diff --git a/lib/IRGen/IRGenModule.cpp b/lib/IRGen/IRGenModule.cpp index 0d9b66255f1ea..bd355ba40be1f 100644 --- a/lib/IRGen/IRGenModule.cpp +++ b/lib/IRGen/IRGenModule.cpp @@ -239,7 +239,7 @@ IRGenModule::IRGenModule(IRGenerator &irgen, Int32Ty = llvm::Type::getInt32Ty(getLLVMContext()); Int32PtrTy = Int32Ty->getPointerTo(); Int64Ty = llvm::Type::getInt64Ty(getLLVMContext()); - Int8PtrTy = llvm::Type::getInt8PtrTy(getLLVMContext()); + Int8PtrTy = PtrTy; Int8PtrPtrTy = Int8PtrTy->getPointerTo(0); SizeTy = DataLayout.getIntPtrType(getLLVMContext(), /*addrspace*/ 0); diff --git a/lib/IRGen/IRGenModule.h b/lib/IRGen/IRGenModule.h index 9b1e8bf8386d8..51a43e4ffd2cc 100644 --- a/lib/IRGen/IRGenModule.h +++ b/lib/IRGen/IRGenModule.h @@ -695,7 +695,7 @@ class IRGenModule { bool ShouldUseSwiftError; llvm::Type *VoidTy; /// void (usually {}) - llvm::Type *PtrTy; /// ptr + llvm::PointerType *PtrTy; /// ptr llvm::IntegerType *Int1Ty; /// i1 llvm::IntegerType *Int8Ty; /// i8 llvm::IntegerType *Int16Ty; /// i16 diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index 82c13597ef4ad..9e377c8feca9f 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -6451,8 +6451,6 @@ void IRGenSILFunction::visitBeginAccessInst(BeginAccessInst *access) { case SILAccessEnforcement::Signed: { auto &ti = getTypeInfo(access->getType()); auto *sea = cast(access->getOperand()); - auto *Int64PtrTy = llvm::Type::getInt64PtrTy(IGM.getLLVMContext()); - auto *Int64PtrPtrTy = Int64PtrTy->getPointerTo(); if (access->getAccessKind() == SILAccessKind::Read) { // When we see a signed read access, generate code to: // authenticate the signed pointer if non-null, and store the @@ -6460,19 +6458,17 @@ void IRGenSILFunction::visitBeginAccessInst(BeginAccessInst *access) { // of the access to this stack location. auto pointerAuthQual = sea->getField()->getPointerAuthQualifier(); auto *pointerToSignedFptr = getLoweredAddress(sea).getAddress(); - auto *pointerToIntPtr = - Builder.CreateBitCast(pointerToSignedFptr, Int64PtrPtrTy); - auto *signedFptr = Builder.CreateLoad(pointerToIntPtr, Int64PtrTy, + auto *signedFptr = Builder.CreateLoad(pointerToSignedFptr, IGM.PtrTy, IGM.getPointerAlignment()); // Create a stack temporary. auto temp = ti.allocateStack(*this, access->getType(), "ptrauth.temp"); auto *tempAddressToIntPtr = - Builder.CreateBitCast(temp.getAddressPointer(), Int64PtrPtrTy); + Builder.CreateBitCast(temp.getAddressPointer(), IGM.PtrTy); // Branch based on pointer is null or not. llvm::Value *cond = Builder.CreateICmpNE( - signedFptr, llvm::ConstantPointerNull::get(Int64PtrTy)); + signedFptr, llvm::ConstantPointerNull::get(IGM.PtrTy)); auto *resignNonNull = createBasicBlock("resign-nonnull"); auto *resignNull = createBasicBlock("resign-null"); auto *resignCont = createBasicBlock("resign-cont"); @@ -6605,23 +6601,17 @@ void IRGenSILFunction::visitEndAccessInst(EndAccessInst *i) { // access which is the shadow stack slot, sign the value if non-null and // write back to the struct field. auto *sea = cast(access->getOperand()); - auto *Int64PtrTy = llvm::Type::getInt64PtrTy(IGM.getLLVMContext()); - auto *Int64PtrPtrTy = Int64PtrTy->getPointerTo(); auto pointerAuthQual = cast(access->getOperand()) ->getField() ->getPointerAuthQualifier(); auto *pointerToSignedFptr = getLoweredAddress(access->getOperand()).getAddress(); - auto *pointerToIntPtr = - Builder.CreateBitCast(pointerToSignedFptr, Int64PtrPtrTy); - auto tempAddress = getLoweredAddress(access); - auto *tempAddressToIntPtr = - Builder.CreateBitCast(tempAddress.getAddress(), Int64PtrPtrTy); - auto *tempAddressValue = Builder.CreateLoad(tempAddressToIntPtr, Int64PtrTy, + auto tempAddress = getLoweredAddress(access).getAddress(); + auto *tempAddressValue = Builder.CreateLoad(tempAddress, IGM.PtrTy, IGM.getPointerAlignment()); // Branch based on value is null or not. llvm::Value *cond = Builder.CreateICmpNE( - tempAddressValue, llvm::ConstantPointerNull::get(Int64PtrTy)); + tempAddressValue, llvm::ConstantPointerNull::get(IGM.PtrTy)); auto *resignNonNull = createBasicBlock("resign-nonnull"); auto *resignNull = createBasicBlock("resign-null"); auto *resignCont = createBasicBlock("resign-cont"); @@ -6636,18 +6626,18 @@ void IRGenSILFunction::visitEndAccessInst(EndAccessInst *i) { sea->getType().getOptionalObjectType().getAs()); auto oldAuthInfo = PointerAuthInfo::emit( *this, IGM.getOptions().PointerAuth.FunctionPointers, - tempAddress.getAddress(), entity); + tempAddress, entity); auto newAuthInfo = PointerAuthInfo::emit(*this, pointerAuthQual, pointerToSignedFptr); auto *signedFptr = emitPointerAuthResign(*this, tempAddressValue, oldAuthInfo, newAuthInfo); - Builder.CreateStore(signedFptr, pointerToIntPtr, IGM.getPointerAlignment()); + Builder.CreateStore(signedFptr, pointerToSignedFptr, IGM.getPointerAlignment()); Builder.CreateBr(resignCont); // If null, no need to resign Builder.emitBlock(resignNull); - Builder.CreateStore(tempAddressValue, pointerToIntPtr, IGM.getPointerAlignment()); + Builder.CreateStore(tempAddressValue, pointerToSignedFptr, IGM.getPointerAlignment()); Builder.CreateBr(resignCont); Builder.emitBlock(resignCont); diff --git a/lib/Immediate/SwiftMaterializationUnit.cpp b/lib/Immediate/SwiftMaterializationUnit.cpp index dcda3baf6c2ce..92a01bcb0d6c9 100644 --- a/lib/Immediate/SwiftMaterializationUnit.cpp +++ b/lib/Immediate/SwiftMaterializationUnit.cpp @@ -157,7 +157,7 @@ SwiftJIT::CreateLLJIT(CompilerInstance &CI) { .setOptions(std::move(TargetOpt)) .setCPU(std::move(CPU)) .addFeatures(Features) - .setCodeGenOptLevel(llvm::CodeGenOpt::Default); + .setCodeGenOptLevel(llvm::CodeGenOptLevel::Default); auto J = llvm::orc::LLJITBuilder() .setJITTargetMachineBuilder(std::move(JTMB)) .create(); diff --git a/lib/Index/IndexRecord.cpp b/lib/Index/IndexRecord.cpp index c9d24d69b2e7f..e73d7fa7f94de 100644 --- a/lib/Index/IndexRecord.cpp +++ b/lib/Index/IndexRecord.cpp @@ -479,10 +479,13 @@ static void emitSymbolicInterfaceForClangModule( return; } + auto moduleRef = clangModule->getASTFile(); + if (!moduleRef) + return; + // Determine the output name for the symbolic interface file. clang::serialization::ModuleFile *ModFile = - clangCI.getASTReader()->getModuleManager().lookup( - clangModule->getASTFile()); + clangCI.getASTReader()->getModuleManager().lookup(*moduleRef); assert(ModFile && "no module file loaded for module ?"); SmallString<128> interfaceOutputPath = indexStorePath; appendSymbolicInterfaceToIndexStorePath(interfaceOutputPath); @@ -631,7 +634,7 @@ static void addModuleDependencies(ArrayRef imports, modulePath = LFU->getSourceFilename(); } - auto F = fileMgr.getFile(modulePath); + auto F = fileMgr.getFileRef(modulePath); if (!F) break; @@ -850,17 +853,18 @@ emitDataForSwiftSerializedModule(ModuleDecl *module, IndexUnitWriter unitWriter( fileMgr, indexStorePath, "swift", swiftVersion, filename, moduleName, - /*MainFile=*/nullptr, isSystem, /*IsModuleUnit=*/true, isDebugCompilation, + /*MainFile=*/{}, isSystem, /*IsModuleUnit=*/true, isDebugCompilation, targetTriple, sysrootPath, clangRemapper, getModuleInfoFromOpaqueModule); - auto FE = fileMgr.getFile(filename); - for (auto &pair : records) { - std::string &recordFile = pair.first; - std::string &groupName = pair.second; - if (recordFile.empty()) - continue; - clang::index::writer::OpaqueModule mod = &groupName; - unitWriter.addRecordFile(recordFile, *FE, isSystem, mod); + if (auto FE = fileMgr.getFileRef(filename)) { + for (auto &pair : records) { + std::string &recordFile = pair.first; + std::string &groupName = pair.second; + if (recordFile.empty()) + continue; + clang::index::writer::OpaqueModule mod = &groupName; + unitWriter.addRecordFile(recordFile, *FE, isSystem, mod); + } } SmallVector imports; @@ -887,21 +891,25 @@ recordSourceFileUnit(SourceFile *primarySourceFile, StringRef indexUnitToken, bool indexSystemModules, bool skipStdlib, bool includeLocals, bool isDebugCompilation, bool isExplicitModuleBuild, StringRef targetTriple, - ArrayRef fileDependencies, + ArrayRef fileDependencies, const clang::CompilerInstance &clangCI, const PathRemapper &pathRemapper, DiagnosticEngine &diags) { auto &fileMgr = clangCI.getFileManager(); auto *module = primarySourceFile->getParentModule(); bool isSystem = module->isNonUserModule(); - auto mainFile = fileMgr.getFile(primarySourceFile->getFilename()); auto clangRemapper = pathRemapper.asClangPathRemapper(); + + auto mainFile = fileMgr.getFileRef(primarySourceFile->getFilename()); + if (!mainFile) + return false; + // FIXME: Get real values for the following. StringRef swiftVersion; StringRef sysrootPath = clangCI.getHeaderSearchOpts().Sysroot; IndexUnitWriter unitWriter( fileMgr, indexStorePath, "swift", swiftVersion, indexUnitToken, - module->getNameStr(), mainFile ? *mainFile : nullptr, isSystem, + module->getNameStr(), *mainFile, isSystem, /*isModuleUnit=*/false, isDebugCompilation, targetTriple, sysrootPath, clangRemapper, getModuleInfoFromOpaqueModule); @@ -917,15 +925,16 @@ recordSourceFileUnit(SourceFile *primarySourceFile, StringRef indexUnitToken, primarySourceFile); // File dependencies. - for (auto *F : fileDependencies) + for (auto F : fileDependencies) unitWriter.addFileDependency(F, /*FIXME:isSystem=*/false, /*Module=*/nullptr); recordSourceFile(primarySourceFile, indexStorePath, includeLocals, diags, [&](StringRef recordFile, StringRef filename) { - auto file = fileMgr.getFile(filename); - unitWriter.addRecordFile( - recordFile, file ? *file : nullptr, - module->isNonUserModule(), /*Module=*/nullptr); + if (auto file = fileMgr.getFileRef(filename)) { + unitWriter.addRecordFile( + recordFile, *file, + module->isNonUserModule(), /*Module=*/nullptr); + } }); std::string error; @@ -983,24 +992,11 @@ bool index::indexAndRecord(SourceFile *primarySourceFile, return true; } - llvm::SetVector fileDependencies; - // FIXME: This is not desirable because: - // 1. It picks shim header files as file dependencies - // 2. Having all the other swift files of the module as file dependencies ends - // up making all of them associated with all the other files as main files. - // It's better to associate each swift file with the unit that recorded it - // as the main one. - // Keeping the code in case we want to revisit. -#if 0 - auto *module = primarySourceFile->getParentModule(); - collectFileDependencies(fileDependencies, dependencyTracker, module, fileMgr); -#endif - return recordSourceFileUnit(primarySourceFile, indexUnitToken, indexStorePath, indexClangModules, indexSystemModules, skipStdlib, includeLocals, isDebugCompilation, isExplicitModuleBuild, - targetTriple, fileDependencies.getArrayRef(), + targetTriple, {}, clangCI, pathRemapper, diags); } @@ -1027,19 +1023,6 @@ bool index::indexAndRecord(ModuleDecl *module, return true; } - // Add the current module's source files to the dependencies. - llvm::SetVector fileDependencies; - // FIXME: This is not desirable because: - // 1. It picks shim header files as file dependencies - // 2. Having all the other swift files of the module as file dependencies ends - // up making all of them associated with all the other files as main files. - // It's better to associate each swift file with the unit that recorded it - // as the main one. - // Keeping the code in case we want to revisit. -#if 0 - collectFileDependencies(fileDependencies, dependencyTracker, module, fileMgr); -#endif - // Write a unit for each source file. unsigned unitIndex = 0; for (auto *F : module->getFiles()) { @@ -1052,7 +1035,7 @@ bool index::indexAndRecord(ModuleDecl *module, indexStorePath, indexClangModules, indexSystemModules, skipStdlib, includeLocals, isDebugCompilation, isExplicitModuleBuild, - targetTriple, fileDependencies.getArrayRef(), + targetTriple, {}, clangCI, pathRemapper, diags)) return true; unitIndex += 1; diff --git a/lib/LLVMPasses/LLVMMergeFunctions.cpp b/lib/LLVMPasses/LLVMMergeFunctions.cpp index 831f3d3daf6e7..b7b3f2f66e276 100644 --- a/lib/LLVMPasses/LLVMMergeFunctions.cpp +++ b/lib/LLVMPasses/LLVMMergeFunctions.cpp @@ -31,31 +31,32 @@ #include "swift/LLVMPasses/Passes.h" #include "clang/AST/StableHash.h" #include "clang/Basic/PointerAuthOptions.h" -#include "llvm/Transforms/IPO.h" -#include "llvm/Transforms/Utils/FunctionComparator.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/Hashing.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/Statistic.h" -#include "llvm/ADT/Hashing.h" -#include "llvm/TargetParser/Triple.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/GlobalPtrAuthInfo.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/InlineAsm.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" #include "llvm/IR/Operator.h" +#include "llvm/IR/StructuralHash.h" #include "llvm/IR/ValueHandle.h" #include "llvm/IR/ValueMap.h" -#include "llvm/IR/GlobalPtrAuthInfo.h" #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/TargetParser/Triple.h" +#include "llvm/Transforms/IPO.h" +#include "llvm/Transforms/Utils/FunctionComparator.h" #include using namespace llvm; @@ -256,11 +257,12 @@ class SwiftMergeFunctions { FunctionEntry *First; /// A very cheap hash, used to early exit if functions do not match. - FunctionComparator::FunctionHash Hash; + llvm::IRHash Hash; + public: // Note the hash is recalculated potentially multiple times, but it is cheap. EquivalenceClass(FunctionEntry *First) - : First(First), Hash(FunctionComparator::functionHash(*First->F)) { + : First(First), Hash(llvm::StructuralHash(*First->F)) { assert(!First->Next); } }; @@ -710,21 +712,18 @@ bool SwiftMergeFunctions::runOnModule(Module &M) { // All functions in the module, ordered by hash. Functions with a unique // hash value are easily eliminated. - std::vector> - HashedFuncs; + std::vector> HashedFuncs; for (Function &Func : M) { if (isEligibleFunction(&Func)) { - HashedFuncs.push_back({FunctionComparator::functionHash(Func), &Func}); + HashedFuncs.push_back({llvm::StructuralHash(Func), &Func}); } } std::stable_sort( HashedFuncs.begin(), HashedFuncs.end(), - [](const std::pair &a, - const std::pair &b) { - return a.first < b.first; - }); + [](const std::pair &a, + const std::pair &b) { return a.first < b.first; }); std::vector FuncEntryStorage; FuncEntryStorage.reserve(HashedFuncs.size()); @@ -1079,6 +1078,7 @@ void SwiftMergeFunctions::mergeWithParams(const FunctionInfos &FInfos, Function *NewFunction = Function::Create(funcType, FirstF->getLinkage(), FirstF->getName() + "Tm"); + NewFunction->setIsNewDbgInfoFormat(FirstF->IsNewDbgInfoFormat); NewFunction->copyAttributesFrom(FirstF); // NOTE: this function is not externally available, do ensure that we reset // the DLL storage diff --git a/lib/Localization/LocalizationFormat.cpp b/lib/Localization/LocalizationFormat.cpp index ccd566b1409e9..016c48633d59b 100644 --- a/lib/Localization/LocalizationFormat.cpp +++ b/lib/Localization/LocalizationFormat.cpp @@ -64,11 +64,11 @@ bool SerializedLocalizationWriter::emit(llvm::StringRef filePath) { offset_type offset; { - llvm::support::endian::write(OS, 0, llvm::support::little); + llvm::support::endian::write(OS, 0, llvm::endianness::little); offset = generator.Emit(OS); } OS.seek(0); - llvm::support::endian::write(OS, offset, llvm::support::little); + llvm::support::endian::write(OS, offset, llvm::endianness::little); OS.close(); return OS.has_error(); @@ -116,7 +116,8 @@ SerializedLocalizationProducer::SerializedLocalizationProducer( bool SerializedLocalizationProducer::initializeImpl() { auto base = reinterpret_cast(Buffer.get()->getBufferStart()); - auto tableOffset = endian::read(base, little); + auto tableOffset = + llvm::support::endian::read(base, llvm::endianness::little); SerializedTable.reset(SerializedLocalizationTable::Create( base + tableOffset, base + sizeof(offset_type), base)); return true; diff --git a/lib/Option/Options.cpp b/lib/Option/Options.cpp index aeeed8dc9797d..6a159de3150ba 100644 --- a/lib/Option/Options.cpp +++ b/lib/Option/Options.cpp @@ -27,10 +27,7 @@ using namespace llvm::opt; #undef PREFIX static const llvm::opt::GenericOptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - {PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, \ - PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES}, +#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__), #include "swift/Option/Options.inc" #undef OPTION }; diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index 1bdf847588bbc..93caaa85ae324 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -8007,6 +8007,18 @@ class SwiftToClangBasicReader : return attr; } + + // CountAttributedType is a clang type representing a pointer with + // a "counted_by" type attribute and DynamicRangePointerType is + // representing a "__ended_by" type attribute. + // TypeCoupledDeclRefInfo is used to hold information of a declaration + // referenced from an expression argument of "__counted_by(expr)" or + // "__ended_by(expr)". + // Nothing to be done for now as we currently don't import + // these types into Swift. + clang::TypeCoupledDeclRefInfo readTypeCoupledDeclRefInfo() { + llvm_unreachable("TypeCoupledDeclRefInfo shouldn't be reached from swift"); + } }; } // end anonymous namespace diff --git a/lib/Serialization/DeserializeSIL.cpp b/lib/Serialization/DeserializeSIL.cpp index 135640d62b139..3504ef71939d3 100644 --- a/lib/Serialization/DeserializeSIL.cpp +++ b/lib/Serialization/DeserializeSIL.cpp @@ -13,12 +13,12 @@ #define DEBUG_TYPE "deserialize" #include "DeserializeSIL.h" - #include "BCReadingExtras.h" #include "DeserializationErrors.h" #include "ModuleFile.h" #include "SILFormat.h" #include "SILSerializationFunctionBuilder.h" +#include "SerializationFormat.h" #include "swift/AST/DiagnosticsSIL.h" #include "swift/AST/GenericSignature.h" @@ -143,14 +143,14 @@ class SILDeserializer::FuncTableInfo { internal_key_type ReadKey(const uint8_t *data, unsigned length) { assert(length == sizeof(uint32_t) && "Expect a single IdentifierID."); - IdentifierID keyID = endian::readNext(data); + IdentifierID keyID = readNext(data); return MF.getIdentifierText(keyID); } static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { assert(length == sizeof(uint32_t) && "Expect a single DeclID."); - data_type result = endian::readNext(data); + data_type result = readNext(data); return result; } }; diff --git a/lib/Serialization/ModuleFile.cpp b/lib/Serialization/ModuleFile.cpp index 0542ce66aefef..637164e0e49bc 100644 --- a/lib/Serialization/ModuleFile.cpp +++ b/lib/Serialization/ModuleFile.cpp @@ -11,15 +11,14 @@ //===----------------------------------------------------------------------===// #include "ModuleFile.h" -#include "ModuleFileCoreTableInfo.h" #include "BCReadingExtras.h" #include "DeserializationErrors.h" +#include "ModuleFileCoreTableInfo.h" #include "ModuleFormat.h" -#include "swift/Serialization/SerializationOptions.h" -#include "swift/Subsystems.h" -#include "swift/AST/DiagnosticsSema.h" +#include "SerializationFormat.h" #include "swift/AST/ASTContext.h" #include "swift/AST/ASTMangler.h" +#include "swift/AST/DiagnosticsSema.h" #include "swift/AST/GenericSignature.h" #include "swift/AST/ModuleLoader.h" #include "swift/AST/NameLookup.h" @@ -27,7 +26,9 @@ #include "swift/AST/USRGeneration.h" #include "swift/Basic/Range.h" #include "swift/ClangImporter/ClangImporter.h" +#include "swift/Serialization/SerializationOptions.h" #include "swift/Serialization/SerializedModuleLoader.h" +#include "swift/Subsystems.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Chrono.h" #include "llvm/Support/MemoryBuffer.h" @@ -1120,7 +1121,7 @@ void ModuleFile::collectBasicSourceFileInfo( auto *End = Core->SourceFileListData.bytes_end(); while (Cursor < End) { // FilePath (byte offset in 'SourceLocsTextData'). - auto fileID = endian::readNext(Cursor); + auto fileID = readNext(Cursor); // InterfaceHashIncludingTypeMembers (fixed length string). auto fpStrIncludingTypeMembers = StringRef{reinterpret_cast(Cursor), @@ -1133,9 +1134,9 @@ void ModuleFile::collectBasicSourceFileInfo( Cursor += Fingerprint::DIGEST_LENGTH; // LastModified (nanoseconds since epoch). - auto timestamp = endian::readNext(Cursor); + auto timestamp = readNext(Cursor); // FileSize (num of bytes). - auto fileSize = endian::readNext(Cursor); + auto fileSize = readNext(Cursor); assert(fileID < Core->SourceLocsTextData.size()); auto filePath = Core->SourceLocsTextData.substr(fileID); @@ -1165,8 +1166,7 @@ void ModuleFile::collectBasicSourceFileInfo( } static StringRef readLocString(const char *&Data, StringRef StringData) { - auto Str = - StringData.substr(endian::readNext(Data)); + auto Str = StringData.substr(readNext(Data)); size_t TerminatorOffset = Str.find('\0'); assert(TerminatorOffset != StringRef::npos && "unterminated string data"); return Str.slice(0, TerminatorOffset); @@ -1174,13 +1174,13 @@ static StringRef readLocString(const char *&Data, StringRef StringData) { static void readRawLoc(ExternalSourceLocs::RawLoc &Loc, const char *&Data, StringRef StringData) { - Loc.Offset = endian::readNext(Data); - Loc.Line = endian::readNext(Data); - Loc.Column = endian::readNext(Data); + Loc.Offset = readNext(Data); + Loc.Line = readNext(Data); + Loc.Column = readNext(Data); - Loc.Directive.Offset = endian::readNext(Data); - Loc.Directive.LineOffset = endian::readNext(Data); - Loc.Directive.Length = endian::readNext(Data); + Loc.Directive.Offset = readNext(Data); + Loc.Directive.LineOffset = readNext(Data); + Loc.Directive.Length = readNext(Data); Loc.Directive.Name = readLocString(Data, StringData); } @@ -1225,19 +1225,18 @@ ModuleFile::getExternalRawLocsForDecl(const Decl *D) const { ExternalSourceLocs::RawLocs Result; Result.SourceFilePath = readLocString(Record, Core->SourceLocsTextData); - const auto DocRangesOffset = - endian::readNext(Record); + const auto DocRangesOffset = readNext(Record); if (DocRangesOffset) { assert(!Core->DocRangesData.empty()); const auto *Data = Core->DocRangesData.data() + DocRangesOffset; - const auto NumLocs = endian::readNext(Data); + const auto NumLocs = readNext(Data); assert(NumLocs); for (uint32_t I = 0; I < NumLocs; ++I) { auto &Range = Result.DocRanges.emplace_back(ExternalSourceLocs::RawLoc(), 0); readRawLoc(Range.first, Data, Core->SourceLocsTextData); - Range.second = endian::readNext(Data); + Range.second = readNext(Data); } } diff --git a/lib/Serialization/ModuleFileCoreTableInfo.h b/lib/Serialization/ModuleFileCoreTableInfo.h index 659cfd0344b1a..a48672d2666d3 100644 --- a/lib/Serialization/ModuleFileCoreTableInfo.h +++ b/lib/Serialization/ModuleFileCoreTableInfo.h @@ -13,8 +13,9 @@ #ifndef SWIFT_SERIALIZATION_MODULEFILECORETABLEINFO_H #define SWIFT_SERIALIZATION_MODULEFILECORETABLEINFO_H -#include "ModuleFileSharedCore.h" #include "DocFormat.h" +#include "ModuleFileSharedCore.h" +#include "SerializationFormat.h" #include "SourceInfoFormat.h" #include "swift/AST/RawComment.h" #include "llvm/Support/DJB.h" @@ -51,16 +52,14 @@ class ModuleFileSharedCore::DeclTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } static internal_key_type ReadKey(const uint8_t *data, unsigned length) { using namespace swift::serialization; - using namespace llvm::support; - uint8_t kind = endian::readNext(data); + uint8_t kind = readNext(data); switch (kind) { case static_cast(DeclNameKind::Normal): { StringRef str(reinterpret_cast(data), @@ -78,11 +77,10 @@ class ModuleFileSharedCore::DeclTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; data_type result; while (length > 0) { uint8_t kind = *data++; - DeclID offset = endian::readNext(data); + DeclID offset = readNext(data); result.push_back({ kind, offset }); length -= 5; } @@ -114,9 +112,8 @@ class ModuleFileSharedCore::ExtensionTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } @@ -126,14 +123,12 @@ class ModuleFileSharedCore::ExtensionTableInfo { data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; data_type result; const uint8_t *limit = data + length; while (data < limit) { - DeclID offset = endian::readNext(data); + DeclID offset = readNext(data); - int32_t nameIDOrLength = - endian::readNext(data); + int32_t nameIDOrLength = readNext(data); StringRef moduleNameOrMangledBase; if (nameIDOrLength < 0) { StringRef moduleName = Core.getModuleNameFromID(-nameIDOrLength); @@ -180,8 +175,7 @@ class ModuleFileSharedCore::LocalDeclTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); + unsigned keyLength = readNext(data); return { keyLength, sizeof(uint32_t) }; } @@ -191,8 +185,7 @@ class ModuleFileSharedCore::LocalDeclTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; - return endian::readNext(data); + return readNext(data); } }; @@ -217,9 +210,8 @@ class ModuleFileSharedCore::NestedTypeDeclsTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } @@ -229,11 +221,10 @@ class ModuleFileSharedCore::NestedTypeDeclsTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; data_type result; while (length > 0) { - DeclID parentID = endian::readNext(data); - DeclID childID = endian::readNext(data); + DeclID parentID = readNext(data); + DeclID childID = readNext(data); result.push_back({ parentID, childID }); length -= sizeof(uint32_t) * 2; } @@ -277,15 +268,13 @@ class ModuleFileSharedCore::DeclMemberNamesTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); + unsigned keyLength = readNext(data); return { keyLength, sizeof(uint32_t) }; } static internal_key_type ReadKey(const uint8_t *data, unsigned length) { using namespace swift::serialization; - using namespace llvm::support; - uint8_t kind = endian::readNext(data); + uint8_t kind = readNext(data); switch (kind) { case static_cast(DeclNameKind::Normal): { StringRef str(reinterpret_cast(data), @@ -305,9 +294,8 @@ class ModuleFileSharedCore::DeclMemberNamesTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; assert(length == sizeof(uint32_t)); - return endian::readNext(data); + return readNext(data); } }; @@ -338,22 +326,19 @@ class ModuleFileSharedCore::DeclMembersTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned dataLength = endian::readNext(data); + unsigned dataLength = readNext(data); return { sizeof(uint32_t), dataLength }; } static internal_key_type ReadKey(const uint8_t *data, unsigned length) { - using namespace llvm::support; - return endian::readNext(data); + return readNext(data); } static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; data_type result; while (length > 0) { - DeclID declID = endian::readNext(data); + DeclID declID = readNext(data); result.push_back(declID); length -= sizeof(uint32_t); } @@ -384,9 +369,8 @@ class ModuleFileSharedCore::ObjCMethodTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } @@ -396,13 +380,12 @@ class ModuleFileSharedCore::ObjCMethodTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; const constexpr auto recordSize = sizeof(uint32_t) + 1 + sizeof(uint32_t); data_type result; while (length > 0) { - unsigned ownerLen = endian::readNext(data); + unsigned ownerLen = readNext(data); bool isInstanceMethod = *data++ != 0; - DeclID methodID = endian::readNext(data); + DeclID methodID = readNext(data); std::string ownerName((const char *)data, ownerLen); result.push_back( std::make_tuple(std::move(ownerName), isInstanceMethod, methodID)); @@ -438,9 +421,8 @@ class ModuleFileSharedCore::DerivativeFunctionConfigTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return {keyLength, dataLength}; } @@ -450,12 +432,11 @@ class ModuleFileSharedCore::DerivativeFunctionConfigTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; data_type result; const uint8_t *limit = data + length; while (data < limit) { - DeclID genSigId = endian::readNext(data); - int32_t nameLength = endian::readNext(data); + DeclID genSigId = readNext(data); + int32_t nameLength = readNext(data); std::string mangledName(reinterpret_cast(data), nameLength); data += nameLength; result.push_back({std::string(mangledName), genSigId}); @@ -491,9 +472,8 @@ class ModuleFileSharedCore::DeclCommentTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); - unsigned dataLength = endian::readNext(data); + unsigned keyLength = readNext(data); + unsigned dataLength = readNext(data); return { keyLength, dataLength }; } @@ -503,29 +483,27 @@ class ModuleFileSharedCore::DeclCommentTableInfo { data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; data_type result = std::make_unique(); { - unsigned BriefSize = endian::readNext(data); + unsigned BriefSize = readNext(data); result->Info.Brief = StringRef(reinterpret_cast(data), BriefSize); data += BriefSize; } - unsigned NumComments = endian::readNext(data); + unsigned NumComments = readNext(data); for (unsigned i = 0; i != NumComments; ++i) { - unsigned StartColumn = - endian::readNext(data); - unsigned RawSize = endian::readNext(data); + unsigned StartColumn = readNext(data); + unsigned RawSize = readNext(data); auto RawText = StringRef(reinterpret_cast(data), RawSize); data += RawSize; result->RawCommentStore.emplace_back(RawText, StartColumn); } result->Info.Raw = RawComment(result->RawCommentStore); - result->Info.Group = endian::readNext(data); - result->Info.SourceOrder = endian::readNext(data); + result->Info.Group = readNext(data); + result->Info.SourceOrder = readNext(data); return result; } }; @@ -550,8 +528,7 @@ class ModuleFileSharedCore::DeclUSRTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; - unsigned keyLength = endian::readNext(data); + unsigned keyLength = readNext(data); unsigned dataLength = 4; return { keyLength, dataLength }; } @@ -560,10 +537,10 @@ class ModuleFileSharedCore::DeclUSRTableInfo { return StringRef(reinterpret_cast(data), length); } - data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; + data_type ReadData(internal_key_type key, const uint8_t *data, + unsigned length) { assert(length == 4); - return endian::readNext(data); + return readNext(data); } }; @@ -588,19 +565,16 @@ class ModuleFileSharedCore::DeclFingerprintsTableInfo { } static std::pair ReadKeyDataLength(const uint8_t *&data) { - using namespace llvm::support; const unsigned dataLen = Fingerprint::DIGEST_LENGTH; return {sizeof(uint32_t), dataLen}; } static internal_key_type ReadKey(const uint8_t *data, unsigned length) { - using namespace llvm::support; - return endian::readNext(data); + return readNext(data); } static data_type ReadData(internal_key_type key, const uint8_t *data, unsigned length) { - using namespace llvm::support; auto str = llvm::StringRef{reinterpret_cast(data), Fingerprint::DIGEST_LENGTH}; if (auto fp = Fingerprint::fromString(str)) diff --git a/lib/Serialization/ModuleFileSharedCore.cpp b/lib/Serialization/ModuleFileSharedCore.cpp index c389311df45d8..c593a751b55c2 100644 --- a/lib/Serialization/ModuleFileSharedCore.cpp +++ b/lib/Serialization/ModuleFileSharedCore.cpp @@ -14,6 +14,7 @@ #include "BCReadingExtras.h" #include "DeserializationErrors.h" #include "ModuleFileCoreTableInfo.h" +#include "SerializationFormat.h" #include "swift/Basic/LangOptions.h" #include "swift/Parse/ParseVersion.h" #include "swift/Serialization/SerializedModuleLoader.h" @@ -1014,9 +1015,9 @@ ModuleFileSharedCore::readGroupTable(ArrayRef Fields, StringRef BlobData) const { auto pMap = std::make_unique>(); auto Data = reinterpret_cast(BlobData.data()); - unsigned GroupCount = endian::readNext(Data); + unsigned GroupCount = readNext(Data); for (unsigned I = 0; I < GroupCount; ++I) { - auto RawSize = endian::readNext(Data); + auto RawSize = readNext(Data); auto RawText = StringRef(reinterpret_cast(Data), RawSize); Data += RawSize; (*pMap)[I] = RawText; diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp index 51e4c1f74e2ad..6e4637680f4df 100644 --- a/lib/Serialization/Serialization.cpp +++ b/lib/Serialization/Serialization.cpp @@ -146,14 +146,14 @@ namespace { uint32_t dataLength = (sizeof(uint32_t) + 1) * data.size(); assert(dataLength == static_cast(dataLength)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; } void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); switch (key.getKind()) { case DeclBaseName::Kind::Normal: writer.write(static_cast(DeclNameKind::Normal)); @@ -174,7 +174,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); for (auto entry : data) { writer.write(entry.first); writer.write(entry.second); @@ -230,7 +230,7 @@ namespace { dataLength += nameData; } assert(dataLength == static_cast(dataLength)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; @@ -243,7 +243,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); for (auto entry : data) { StringRef dataToWrite; writer.write(entry.second); @@ -273,7 +273,7 @@ namespace { uint32_t keyLength = key.size(); assert(keyLength == static_cast(keyLength)); uint32_t dataLength = sizeof(uint32_t); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); // No need to write the data length; it's constant. return { keyLength, dataLength }; @@ -286,7 +286,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(data); } }; @@ -315,7 +315,7 @@ namespace { assert(keyLength == static_cast(keyLength)); uint32_t dataLength = (sizeof(uint32_t) * 2) * data.size(); assert(dataLength == static_cast(dataLength)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; @@ -329,7 +329,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); for (auto entry : data) { writer.write(entry.first); writer.write(entry.second); @@ -370,14 +370,14 @@ namespace { } assert(keyLength == static_cast(keyLength)); uint32_t dataLength = sizeof(uint32_t); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); // No need to write dataLength, it's constant. return { keyLength, dataLength }; } void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); switch (key.getKind()) { case DeclBaseName::Kind::Normal: writer.write(static_cast(DeclNameKind::Normal)); @@ -398,7 +398,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(bitOffsetFitsIn32Bits(), "BitOffset too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(static_cast(data)); } }; @@ -423,7 +423,7 @@ namespace { // with the same DeclBaseName. Seems highly unlikely. assert((data.size() < (1 << 14)) && "Too many members"); uint32_t dataLength = sizeof(uint32_t) * data.size(); // value DeclIDs - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); // No need to write the key length; it's constant. writer.write(dataLength); return { sizeof(uint32_t), dataLength }; @@ -432,14 +432,14 @@ namespace { void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); assert(len == sizeof(uint32_t)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(key); } void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); for (auto entry : data) { writer.write(entry); } @@ -463,7 +463,7 @@ namespace { std::pair EmitKeyDataLength(raw_ostream &out, key_type_ref key, data_type_ref data) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); // No need to write the key or value length; they're both constant. const unsigned valueLen = Fingerprint::DIGEST_LENGTH; return {sizeof(uint32_t), valueLen}; @@ -472,7 +472,7 @@ namespace { void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); assert(len == sizeof(uint32_t)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(key); } @@ -480,7 +480,7 @@ namespace { unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); assert(len == Fingerprint::DIGEST_LENGTH); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); out << data; } }; @@ -5974,6 +5974,18 @@ class ClangToSwiftBasicWriter : writeBool(swiftAttr->isPackExpansion()); writeUInt64(S.addUniquedStringRef(swiftAttr->getAttribute())); } + + // CountAttributedType is a clang type representing a pointer with + // a "counted_by" type attribute and DynamicRangePointerType is + // representing a "__ended_by" type attribute. + // TypeCoupledDeclRefInfo is used to hold information of a declaration + // referenced from an expression argument of "__counted_by(expr)" or + // "__ended_by(expr)". + // Nothing to be done for now as we currently don't import + // these types into Swift. + void writeTypeCoupledDeclRefInfo(clang::TypeCoupledDeclRefInfo info) { + llvm_unreachable("TypeCoupledDeclRefInfo shouldn't be reached from swift"); + } }; } @@ -6211,7 +6223,7 @@ static void writeDeclTable(const index_block::DeclListLayout &DeclList, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6237,7 +6249,7 @@ writeExtensionTable(const index_block::ExtensionTableLayout &ExtensionTable, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream, info); } @@ -6253,7 +6265,7 @@ static void writeLocalDeclTable(const index_block::DeclListLayout &DeclList, { llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6273,7 +6285,7 @@ writeNestedTypeDeclsTable(const index_block::NestedTypeDeclsLayout &declList, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6298,7 +6310,7 @@ writeDeclMemberNamesTable(const index_block::DeclMemberNamesLayout &declNames, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6318,7 +6330,7 @@ writeDeclMembersTable(const decl_member_tables_block::DeclMembersLayout &mems, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6339,7 +6351,7 @@ writeDeclFingerprintsTable(const index_block::DeclFingerprintsLayout &fpl, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6375,7 +6387,7 @@ namespace { dataLength += std::get<0>(entry).size(); } - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; @@ -6392,7 +6404,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); for (const auto &entry : data) { writer.write(std::get<0>(entry).size()); writer.write(std::get<1>(entry)); @@ -6425,7 +6437,7 @@ static void writeObjCMethodTable(const index_block::ObjCMethodTableLayout &out, } // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } @@ -6458,7 +6470,7 @@ namespace { for (auto entry : data) dataLength += entry.first.size(); assert(dataLength == static_cast(dataLength)); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; @@ -6471,7 +6483,7 @@ namespace { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { static_assert(declIDFitsIn32Bits(), "DeclID too large"); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); for (auto &entry : data) { // Write `GenericSignatureID`. writer.write(entry.second); @@ -6496,7 +6508,7 @@ static void writeDerivativeFunctionConfigs( for (auto &entry : derivativeConfigs) generator.insert(entry.first.get(), entry.second); // Make sure that no bucket is at offset 0. - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } SmallVector scratch; diff --git a/lib/Serialization/SerializationFormat.h b/lib/Serialization/SerializationFormat.h new file mode 100644 index 0000000000000..867b5baa62215 --- /dev/null +++ b/lib/Serialization/SerializationFormat.h @@ -0,0 +1,33 @@ +//===--- SerializationFormat.h - Serialization helpers ------ ---*- C++ -*-===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2020 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Various helper functions to deal with common serialization functionality. +/// +//===----------------------------------------------------------------------===// + +#ifndef SWIFT_SERIALIZATION_SERIALIZATIONFORMAT_H +#define SWIFT_SERIALIZATION_SERIALIZATIONFORMAT_H + +#include "llvm/ADT/bit.h" +#include "llvm/Support/Endian.h" + +namespace swift { + +template +[[nodiscard]] inline value_type readNext(const CharT *&memory) { + return llvm::support::endian::readNext(memory); +} + +} // end namespace swift + +#endif diff --git a/lib/Serialization/SerializeDoc.cpp b/lib/Serialization/SerializeDoc.cpp index 812bf48f1ddb9..a2b24af1ada69 100644 --- a/lib/Serialization/SerializeDoc.cpp +++ b/lib/Serialization/SerializeDoc.cpp @@ -232,7 +232,7 @@ class DeclCommentTableInfo { // Source order. dataLength += numLen; - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); writer.write(dataLength); return { keyLength, dataLength }; @@ -244,7 +244,7 @@ class DeclCommentTableInfo { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(data.Brief.size()); out << data.Brief; writer.write(data.Raw.Comments.size()); @@ -300,7 +300,7 @@ static void writeGroupNames(const comment_block::GroupNamesLayout &GroupNames, ArrayRef Names) { llvm::SmallString<32> Blob; llvm::raw_svector_ostream BlobStream(Blob); - endian::Writer Writer(BlobStream, little); + endian::Writer Writer(BlobStream, llvm::endianness::little); Writer.write(Names.size()); for (auto N : Names) { Writer.write(N.size()); @@ -447,7 +447,7 @@ static void writeDeclCommentTable( { llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = Writer.generator.Emit(blobStream); } @@ -519,7 +519,7 @@ class USRTableInfo { const unsigned numLen = 4; uint32_t keyLength = key.size(); uint32_t dataLength = numLen; - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(keyLength); return { keyLength, dataLength }; } @@ -530,7 +530,7 @@ class USRTableInfo { void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); writer.write(data); } }; @@ -560,7 +560,7 @@ class DeclUSRsTableWriter { { llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0 - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream); } USRsList.emit(scratch, tableOffset, hashTableBlob); @@ -637,7 +637,7 @@ class DocRangeWriter { } llvm::raw_svector_ostream OS(Buffer); - endian::Writer Writer(OS, little); + endian::Writer Writer(OS, llvm::endianness::little); Writer.write(DocRanges.size()); for (const auto &DocRange : DocRanges) { writeRawLoc(DocRange.first, Writer, Strings); @@ -719,7 +719,7 @@ struct BasicDeclLocsTableWriter : public ASTWalker { llvm::sys::fs::make_absolute(AbsolutePath); llvm::raw_svector_ostream Out(Buffer); - endian::Writer Writer(Out, little); + endian::Writer Writer(Out, llvm::endianness::little); Writer.write(FWriter.getTextOffset(AbsolutePath.str())); Writer.write( DocWriter.getDocRangesOffset(D, llvm::ArrayRef(RawLocs->DocRanges))); @@ -782,7 +782,7 @@ static void emitFileListRecord(llvm::BitstreamWriter &Out, .count(); llvm::raw_svector_ostream out(Buffer); - endian::Writer writer(out, little); + endian::Writer writer(out, llvm::endianness::little); // FilePath. writer.write(fileID); diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp index 94eab6a24880f..cc62d734cc6d0 100644 --- a/lib/Serialization/SerializeSIL.cpp +++ b/lib/Serialization/SerializeSIL.cpp @@ -147,12 +147,12 @@ namespace { void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { uint32_t keyID = S.addUniquedStringRef(key); - endian::write(out, keyID, little); + endian::write(out, keyID, llvm::endianness::little); } void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { - endian::write(out, data, little); + endian::write(out, data, llvm::endianness::little); } }; @@ -2796,7 +2796,7 @@ static void writeIndexTable(Serializer &S, llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0. - endian::write(blobStream, 0, little); + endian::write(blobStream, 0, llvm::endianness::little); tableOffset = generator.Emit(blobStream, tableInfo); } SmallVector scratch; diff --git a/test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift b/test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift index da171b9fa71d3..beb746eb5c964 100644 --- a/test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift +++ b/test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift @@ -4,7 +4,7 @@ // Mutating functions with control flow can cause assertion failure for // conflicting debug variable type -// CHECK-LABEL: define internal swiftcc float @"$s4main8TestTypeV24doDifferentiableTimeStep04timeG0ySf_tFTJpSSpSrTA" +// CHECK-LABEL: define internal swiftcc{{.*}} float @"$s4main8TestTypeV24doDifferentiableTimeStep04timeG0ySf_tFTJpSSpSrTA" // CHECK: [[SELF:%.*]] = alloca %T4main8TestTypeV06ManualB7TangentV // CHECK: call void @llvm.dbg.value(metadata ptr [[SELF]] diff --git a/test/DebugInfo/debug_scope_distinct.swift b/test/DebugInfo/debug_scope_distinct.swift index c90756c3e3d6c..1cbc56cca4eb7 100644 --- a/test/DebugInfo/debug_scope_distinct.swift +++ b/test/DebugInfo/debug_scope_distinct.swift @@ -1,5 +1,7 @@ // REQUIRES: differentiable_programming +// XFAIL: * + // RUN: %empty-directory(%t) // RUN: %target-swiftc_driver -DM -emit-module -emit-module-path %t/M.swiftmodule %s -module-name M // RUN: %target-swiftc_driver -O -g -I %t -c %s -emit-ir -o - | %FileCheck %s diff --git a/test/Frontend/verify-fixits.swift b/test/Frontend/verify-fixits.swift index 65ed600df5bb8..bd4399f82d5e3 100644 --- a/test/Frontend/verify-fixits.swift +++ b/test/Frontend/verify-fixits.swift @@ -5,10 +5,10 @@ func labeledFunc(aa: Int, bb: Int) {} func testNoneMarkerCheck() { - // CHECK: [[@LINE+1]]:87: error: A second {{{{}}none}} was found. It may only appear once in an expectation. + // CHECK: [[@LINE+1]]:87: error: A second {{\{\{}}none}} was found. It may only appear once in an expectation. undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{none}} {{none}} - // CHECK: [[@LINE+1]]:134: error: {{{{}}none}} must be at the end. + // CHECK: [[@LINE+1]]:134: error: {{\{\{}}none}} must be at the end. labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} {{23-26=bb}} } @@ -173,27 +173,27 @@ func test1Fixits() { labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} - // CHECK: [[@LINE+1]]:134: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:134: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{15-18=xx}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{15-18=aa}} - // CHECK: [[@LINE+1]]:121: error: expected no fix-its; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected no fix-its; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{none}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{none}} - // CHECK: [[@LINE+1]]:134: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:134: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{15-18=xx}} {{none}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{15-18=aa}} {{none}} // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: @@ -215,13 +215,13 @@ func test1Fixits() { labeledFunc(aa: 0, // expected-error {{incorrect argument label in call (have 'aa:bbx:', expected 'aa:bb:')}} {{216:15-+1:18=bb}} bbx: 1) - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{61:15-18=aa}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{-1:15-18=aa}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{+0:15--1:18=aa}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} + // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}15-18=aa}} labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{61:15-+1:18=aa}} } @@ -232,7 +232,7 @@ func testDefaultedLineNumbers() { // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: unlabeledFunc(aa: // expected-error {{extraneous argument label 'aa:' in call}} {{+0:17-+1:5=}} 1) - // CHECK: [[@LINE+1]]:83: error: expected fix-it not seen; actual fix-it seen: {{{{}}17-[[@LINE+2]]:5=}} + // CHECK: [[@LINE+1]]:83: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}17-[[@LINE+2]]:5=}} unlabeledFunc(aa: // expected-error {{extraneous argument label 'aa:' in call}} {{+0:17-5=}} 1) @@ -240,7 +240,7 @@ func testDefaultedLineNumbers() { // CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error: labeledFunc(aa: 0, // expected-error {{incorrect argument label in call (have 'aa:bbx:', expected 'aa:bb:')}} {{+1:15-+1:18=bb}} bbx: 1) - // CHECK: [[@LINE+1]]:113: error: expected fix-it not seen; actual fix-it seen: {{{{}}[[@LINE+2]]:15-18=bb}} + // CHECK: [[@LINE+1]]:113: error: expected fix-it not seen; actual fix-it seen: {{\{\{}}[[@LINE+2]]:15-18=bb}} labeledFunc(aa: 0, // expected-error {{incorrect argument label in call (have 'aa:bbx:', expected 'aa:bb:')}} {{15-+1:18=bb}} bbx: 1) } @@ -250,22 +250,22 @@ func test2Fixits() { labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} - // CHECK: [[@LINE+1]]:124: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} + // CHECK: [[@LINE+1]]:124: error: expected fix-it not seen; actual fix-its seen: {{\{\{}}15-18=aa}} {{\{\{}}23-26=bb}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=xx}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} - // CHECK: [[@LINE+1]]:137: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} + // CHECK: [[@LINE+1]]:137: error: expected fix-it not seen; actual fix-its seen: {{\{\{}}15-18=aa}} {{\{\{}}23-26=bb}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=xx}} - // CHECK: [[@LINE+1]]:124: error: expected no fix-its; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} + // CHECK: [[@LINE+1]]:124: error: expected no fix-its; actual fix-its seen: {{\{\{}}15-18=aa}} {{\{\{}}23-26=bb}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{none}} - // CHECK: [[@LINE+1]]:137: error: unexpected fix-it seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} + // CHECK: [[@LINE+1]]:137: error: unexpected fix-it seen; actual fix-its seen: {{\{\{}}15-18=aa}} {{\{\{}}23-26=bb}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} {{none}} - // CHECK: [[@LINE+1]]:137: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} + // CHECK: [[@LINE+1]]:137: error: expected fix-it not seen; actual fix-its seen: {{\{\{}}15-18=aa}} {{\{\{}}23-26=bb}} labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=xx}} {{none}} } diff --git a/test/IRGen/class_field_other_module.swift b/test/IRGen/class_field_other_module.swift index 9bea86f328409..b74db17246396 100644 --- a/test/IRGen/class_field_other_module.swift +++ b/test/IRGen/class_field_other_module.swift @@ -3,11 +3,14 @@ // RUN: %target-swift-frontend -emit-module -emit-module-path=%t/other_class.swiftmodule %S/Inputs/other_class.swift // RUN: %target-swift-frontend -I %t -emit-ir -O -enforce-exclusivity=unchecked %s | %FileCheck %s -DINT=i%target-ptrsize +// REQUIRES: PTRSIZE=64 + import other_class // CHECK-LABEL: define {{(protected )?}}{{(dllexport )?}}swiftcc i32 @"$s24class_field_other_module12getSubclassXys5Int32V0c1_A00F0CF"(ptr nocapture readonly %0) // CHECK-NEXT: entry: -// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds %T11other_class5OtherC, ptr %0, [[INT]] 0, i32 1 +// An Int32 after the heap object header +// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %0, i64 16 // CHECK-NEXT: [[RESULT:%.*]] = load i32, ptr [[GEP]] // CHECK-NEXT: ret i32 [[RESULT]] public func getSubclassX(_ o: Subclass) -> Int32 { @@ -16,7 +19,8 @@ public func getSubclassX(_ o: Subclass) -> Int32 { // CHECK-LABEL: define {{(protected )?}}{{(dllexport )?}}swiftcc i32 @"$s24class_field_other_module12getSubclassYys5Int32V0c1_A00F0CF"(ptr nocapture readonly %0) // CHECK-NEXT: entry: -// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds %T11other_class8SubclassC, ptr %0, [[INT]] 0, i32 2 +// An Int32 after an Int32 after the heap object header +// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %0, i64 20 // CHECK-NEXT: [[RESULT:%.*]] = load i32, ptr [[GEP]] // CHECK-NEXT: ret i32 [[RESULT]] public func getSubclassY(_ o: Subclass) -> Int32 { diff --git a/test/IRGen/dllexport.swift b/test/IRGen/dllexport.swift index dc764bfbcef45..836cc85139bdc 100644 --- a/test/IRGen/dllexport.swift +++ b/test/IRGen/dllexport.swift @@ -37,7 +37,7 @@ open class d { // CHECK-DAG: define dllexport swiftcc ptr @"$s9dllexport1cCfd"(ptr{{.*}}) // CHECK-DAG-NO-OPT: define dllexport swiftcc ptr @"$s9dllexport1cCACycfc"(ptr %0) // CHECK-DAG-NO-OPT: define dllexport swiftcc ptr @"$s9dllexport1cCACycfC"(ptr %0) -// CHECK-DAG: define dllexport swiftcc {{(nonnull )?}}ptr @"$s9dllexport2ciAA1cCvau"() +// CHECK-DAG: define dllexport swiftcc {{(noundef )?(nonnull )?}}ptr @"$s9dllexport2ciAA1cCvau"() // CHECK-DAG-NO-OPT: define dllexport swiftcc void @"$s9dllexport1dC1m33_C57BA610BA35E21738CC992438E660E9LLyyF"(ptr %0) // CHECK-DAG-NO-OPT: define dllexport swiftcc void @"$s9dllexport1dCfD"(ptr %0) // CHECK-DAG: define dllexport swiftcc ptr @"$s9dllexport1dCfd"(ptr{{.*}}) diff --git a/test/IRGen/entrypoint-section-run-main_swift.cpp b/test/IRGen/entrypoint-section-run-main_swift.cpp index a83299ab88e5e..0e43b2f7a14ff 100644 --- a/test/IRGen/entrypoint-section-run-main_swift.cpp +++ b/test/IRGen/entrypoint-section-run-main_swift.cpp @@ -24,6 +24,13 @@ using mach_header_platform = mach_header_64; using mach_header_platform = mach_header; #endif +#if __has_feature(ptrauth_function_pointer_type_discrimination) +#define my_ptrauth_function_pointer_type_discriminator(__type) \ + __builtin_ptrauth_type_discriminator(__type) +#else +#define my_ptrauth_function_pointer_type_discriminator(__type) ((ptrauth_extra_data_t)0) +#endif + int main(int argc, char *argv[]) { if (argc != 2) { printf("no argument!\n"); @@ -67,7 +74,7 @@ int main(int argc, char *argv[]) { reinterpret_cast(data) + offset ), ptrauth_key_function_pointer, - ptrauth_function_pointer_type_discriminator(MainFunction) + my_ptrauth_function_pointer_type_discriminator(MainFunction) ) ); diff --git a/test/IRGen/entrypoint-section-run.cpp b/test/IRGen/entrypoint-section-run.cpp index 22c47354fe3a9..a429f5896f9f9 100644 --- a/test/IRGen/entrypoint-section-run.cpp +++ b/test/IRGen/entrypoint-section-run.cpp @@ -23,6 +23,13 @@ using mach_header_platform = mach_header_64; using mach_header_platform = mach_header; #endif +#if __has_feature(ptrauth_function_pointer_type_discrimination) +#define my_ptrauth_function_pointer_type_discriminator(__type) \ + __builtin_ptrauth_type_discriminator(__type) +#else +#define my_ptrauth_function_pointer_type_discriminator(__type) ((ptrauth_extra_data_t)0) +#endif + int main(int argc, char *argv[]) { if (argc != 2) { printf("no argument!\n"); @@ -66,7 +73,7 @@ int main(int argc, char *argv[]) { reinterpret_cast(data) + offset ), ptrauth_key_function_pointer, - ptrauth_function_pointer_type_discriminator(MainFunction) + my_ptrauth_function_pointer_type_discriminator(MainFunction) ) ); diff --git a/test/IRGen/enum_singleton.swift b/test/IRGen/enum_singleton.swift index 0df76406a196b..66f940619fbb3 100644 --- a/test/IRGen/enum_singleton.swift +++ b/test/IRGen/enum_singleton.swift @@ -41,7 +41,7 @@ public enum SingletonEnum { // CHECK-OPT: ret void // CHECK: } -// CHECK: define internal i32 @"$s14enum_singleton13SingletonEnumOwug" +// CHECK: define internal{{.*}} i32 @"$s14enum_singleton13SingletonEnumOwug" // CHECK: ret i32 0 // CHECK: } diff --git a/test/IRGen/has_symbol.swift b/test/IRGen/has_symbol.swift index a0c5d72237f55..2a9025953b2a2 100644 --- a/test/IRGen/has_symbol.swift +++ b/test/IRGen/has_symbol.swift @@ -55,11 +55,13 @@ public func testGlobalFunctions() { // --- funcWithOpaqueResult() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper20funcWithOpaqueResultQryFTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper20funcWithOpaqueResultQryFQOMQ", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper20funcWithOpaqueResultQryF", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper20funcWithOpaqueResultQryFQOMQ", ptr null), icmp ne (ptr @"$s17has_symbol_helper20funcWithOpaqueResultQryF", ptr null) +// CHECK: ret i1 %0 // --- cdeclFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper9cdeclFuncyyFTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper9cdeclFuncyyF", ptr null), i1 icmp ne (ptr @cdecl_func, ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper9cdeclFuncyyF", ptr null), icmp ne (ptr @cdecl_func, ptr null) +// CHECK: ret i1 %0 // --- forwardDeclaredFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper19forwardDeclaredFuncyyFTwS"() @@ -67,19 +69,33 @@ public func testGlobalFunctions() { // --- dynamicFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper11dynamicFuncyyFTwS"() -// CHECK: ret i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyF", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyFTX", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyFTx", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyF", ptr null), icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyFTX", ptr null) +// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper11dynamicFuncyyFTx", ptr null) +// CHECK: ret i1 %1 // --- replacementFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper15replacementFuncyyFTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper15replacementFuncyyF", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper15replacementFuncyyFTX", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper15replacementFuncyyF", ptr null), icmp ne (ptr @"$s17has_symbol_helper15replacementFuncyyFTX", ptr null) +// CHECK: ret i1 %0 // --- dynamicFuncOpaqueResult() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTwS"() -// CHECK: ret i1 and (i1 and (i1 and (i1 and (i1 and (i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMQ", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMh", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryF", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTX", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTx", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMQ", ptr null), icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null) +// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMh", ptr null) +// CHECK: %2 = and i1 %1, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null) +// CHECK: %3 = and i1 %2, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFQOMg", ptr null) +// CHECK: %4 = and i1 %3, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryF", ptr null) +// CHECK: %5 = and i1 %4, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTX", ptr null) +// CHECK: %6 = and i1 %5, icmp ne (ptr @"$s17has_symbol_helper23dynamicFuncOpaqueResultQryFTx", ptr null) +// CHECK: ret i1 %6 // --- replacementFuncOpaqueResult() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFTwS"() -// CHECK: ret i1 and (i1 and (i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMQ", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMg", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMg", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryF", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFTX", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMQ", ptr null), icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMg", ptr null) +// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFQOMg", ptr null) +// CHECK: %2 = and i1 %1, icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryF", ptr null) +// CHECK: %3 = and i1 %2, icmp ne (ptr @"$s17has_symbol_helper27replacementFuncOpaqueResultQryFTX", ptr null) +// CHECK: ret i1 %3 public func testVars() { // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper6globalSivpTwS"() @@ -100,11 +116,13 @@ public func testClass(_ c: C) { // --- C.init() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1CCACycfcTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1CCACycfc", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1CCACycfC", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1CCACycfc", ptr null), icmp ne (ptr @"$s17has_symbol_helper1CCACycfC", ptr null) +// CHECK: ret i1 %0 // --- C.method(with:) --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1CC6method4withySi_tFTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1CC6method4withySi_tFTj", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1CC6method4withySi_tFTq", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1CC6method4withySi_tFTj", ptr null), icmp ne (ptr @"$s17has_symbol_helper1CC6method4withySi_tFTq", ptr null) +// CHECK: ret i1 %0 public func testStruct(_ s: S) { // CHECK: %{{[0-9]+}} = call i1 @"$s17has_symbol_helper1SV6memberSivpTwS"() @@ -116,7 +134,10 @@ public func testStruct(_ s: S) { // --- S.member --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1SV6memberSivpTwS"() -// CHECK: ret i1 and (i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivpMV", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivg", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivs", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivM", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivpMV", ptr null), icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivg", ptr null) +// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivs", ptr null) +// CHECK: %2 = and i1 %1, icmp ne (ptr @"$s17has_symbol_helper1SV6memberSivM", ptr null) +// CHECK: ret i1 %2 // --- S.method(with:) --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1SV6method4withySi_tFTwS"() @@ -169,4 +190,6 @@ public func testMetatypes() { // --- S.self --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1SVTwS"() -// CHECK: ret i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1SVMn", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1SVN", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper1SVMa", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1SVMn", ptr null), icmp ne (ptr @"$s17has_symbol_helper1SVN", ptr null) +// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper1SVMa", ptr null) +// CHECK: ret i1 %1 diff --git a/test/IRGen/has_symbol_async.swift b/test/IRGen/has_symbol_async.swift index abef30caa448f..cb39dd5cefa3d 100644 --- a/test/IRGen/has_symbol_async.swift +++ b/test/IRGen/has_symbol_async.swift @@ -17,7 +17,8 @@ public func testGlobalFunctions() { // --- asyncFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper9asyncFuncyyYaFTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper9asyncFuncyyYaF", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper9asyncFuncyyYaFTu", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper9asyncFuncyyYaF", ptr null), icmp ne (ptr @"$s17has_symbol_helper9asyncFuncyyYaFTu", ptr null) +// CHECK: ret i1 %0 // --- isolatedFunc() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper12isolatedFuncyyFTwS"() @@ -35,8 +36,11 @@ public func testActor(_ a: A) { // --- A.init() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1ACACycfcTwS"() -// CHECK: ret i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1ACACycfc", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1ACACycfC", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1ACACycfc", ptr null), icmp ne (ptr @"$s17has_symbol_helper1ACACycfC", ptr null) +// CHECK: ret i1 %0 // --- A.asyncMethod() --- // CHECK: define linkonce_odr hidden i1 @"$s17has_symbol_helper1AC11asyncMethodyyYaFTwS"() -// CHECK: ret i1 and (i1 and (i1 icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTj", ptr null), i1 icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTjTu", ptr null)), i1 icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTq", ptr null)) +// CHECK: %0 = and i1 icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTj", ptr null), icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTjTu", ptr null) +// CHECK: %1 = and i1 %0, icmp ne (ptr @"$s17has_symbol_helper1AC11asyncMethodyyYaFTq", ptr null) +// CHECK: ret i1 %1 diff --git a/test/IRGen/large_argument_result_c.swift b/test/IRGen/large_argument_result_c.swift index 07d3f30d1ff86..c90042fbd4b66 100644 --- a/test/IRGen/large_argument_result_c.swift +++ b/test/IRGen/large_argument_result_c.swift @@ -16,7 +16,7 @@ // CHECK: call void @pass_and_return(ptr {{.*}} [[CALL_ALLOCA]], ptr nonnull [[TMP_ALLOCA]], ptr nonnull [[TMP_ALLOCA2]]) // CHECK: call {{.*}} @swift_allocObject // CHECK: [[BOX:%.*]] = call noalias ptr @swift_allocObject( -// CHECK: [[ADDR_IN_BOX:%.*]] = getelementptr inbounds <{ %swift.refcounted, [128 x i8] }>, ptr [[BOX]], i64 0, i32 1 +// CHECK: [[ADDR_IN_BOX:%.*]] = getelementptr inbounds i8, ptr [[BOX]], i64 16 // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}} [[ADDR_IN_BOX]], ptr {{.*}} [[CALL_ALLOCA]], i64 128, i1 false) // CHECK: call void @llvm.lifetime.end.p0(i64 128, ptr nonnull [[CALL_ALLOCA]]) public func runTest(_ l : large_thing) { diff --git a/test/IRGen/large_argument_result_c_x86_64.swift b/test/IRGen/large_argument_result_c_x86_64.swift index 7624d8b00849b..be69a0c5e09af 100644 --- a/test/IRGen/large_argument_result_c_x86_64.swift +++ b/test/IRGen/large_argument_result_c_x86_64.swift @@ -15,7 +15,7 @@ // CHECK: call void @pass_and_return(ptr {{.*}} [[CALL_ALLOCA]], ptr nonnull byval{{.*}} %0, ptr nonnull byval{{.*}} %0) // CHECK: call {{.*}} @swift_allocObject // CHECK: [[BOX:%.*]] = {{.*}}call noalias ptr @swift_allocObject( -// CHECK: [[ADDR_IN_BOX:%.*]] = getelementptr inbounds <{ %swift.refcounted, [128 x i8] }>, ptr [[BOX]], i64 0, i32 1 +// CHECK: [[ADDR_IN_BOX:%.*]] = getelementptr inbounds i8, ptr [[BOX]], i64 16 // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}} [[ADDR_IN_BOX]], ptr {{.*}} [[CALL_ALLOCA]], i64 128, i1 false) // CHECK: call void @llvm.lifetime.end.p0(i64 128, ptr nonnull [[CALL_ALLOCA]]) public func runTest(_ l : large_thing) { diff --git a/test/IRGen/non_fixed_return.swift b/test/IRGen/non_fixed_return.swift index 18d08cf30a91f..ec84250f3e596 100644 --- a/test/IRGen/non_fixed_return.swift +++ b/test/IRGen/non_fixed_return.swift @@ -64,8 +64,8 @@ func create(_ t: T) -> C { // Make sure we don't loose the stores for the optional UInt32? in optimize mode. // OPT-LABEL: define hidden swiftcc void @"$s16non_fixed_return1CVACyxGycfC"(ptr noalias sret(%swift.opaque) %0 // OPT: store i32 0, ptr [[BASE:%[0-9]+]] -// OPT: [[ADDR2:%.*]] = getelementptr inbounds %Ts6UInt32VSg, ptr [[BASE]], i64 0, i32 1 +// OPT: [[ADDR2:%.*]] = getelementptr inbounds i8, ptr [[BASE]], i64 4 // OPT: store i1 true, ptr [[ADDR2]] -// OPT: [[ADDR4:%.*]] = getelementptr inbounds %T16non_fixed_return1BV, ptr [[BASE]], i64 0, i32 2 +// OPT: [[ADDR4:%.*]] = getelementptr inbounds i8, ptr [[BASE]], i64 8 // OPT: call void @llvm.memset.p0.i64(ptr {{.*}}[[ADDR4]], i8 0, i64 16, i1 false) // OPT: ret void diff --git a/test/IRGen/objc_local.swift b/test/IRGen/objc_local.swift index d20e087b0d6f7..5b1a45ddb53c4 100644 --- a/test/IRGen/objc_local.swift +++ b/test/IRGen/objc_local.swift @@ -8,7 +8,7 @@ import Foundation func foo() -> Int64 { - // CHECK-LABEL: define internal i64 @"$s10objc_local3foos5Int64VyF3BarL_C10returnFiveADyFTo" + // CHECK-LABEL: define internal{{( noundef)?}} i64 @"$s10objc_local3foos5Int64VyF3BarL_C10returnFiveADyFTo" class Bar: NSObject { @objc func returnFive() -> Int64 { return 6 } } diff --git a/test/IRGen/recursion_infinite_optimized.sil b/test/IRGen/recursion_infinite_optimized.sil index ee0d26fed0dcc..fe8a676859fd3 100644 --- a/test/IRGen/recursion_infinite_optimized.sil +++ b/test/IRGen/recursion_infinite_optimized.sil @@ -13,7 +13,7 @@ bb0(%arg : $Int): return %res : $Int } -// CHECK: define{{.*}} swiftcc [[T:i[0-9]+]] @rec([[T]] %0) #0 { +// CHECK: define{{.*}} swiftcc{{( noundef)?}} [[T:i[0-9]+]] @rec([[T]] %0) #0 { // CHECK-NEXT: entry: // CHECK-NEXT: br label %tailrecurse // CHECK-EMPTY: diff --git a/test/IRGen/struct_with_resilient_type.swift b/test/IRGen/struct_with_resilient_type.swift index 91cdf93c7eae6..20bc54a4cfa0b 100644 --- a/test/IRGen/struct_with_resilient_type.swift +++ b/test/IRGen/struct_with_resilient_type.swift @@ -49,12 +49,12 @@ crashCaller() // VWT-macosx: store i64 [[VAL1]] // VWT-macosx: [[T1:%.*]] = tail call swiftcc %swift.metadata_response @"$s16resilient_struct13ResilientBoolVMa"(i64 0) // VWT-macosx: [[T2:%.*]] = extractvalue %swift.metadata_response [[T1]], 0 -// VWT-macosx: [[T3:%.*]] = getelementptr inbounds ptr, ptr [[T2]], i64 -1 +// VWT-macosx: [[T3:%.*]] = getelementptr inbounds i8, ptr [[T2]], i64 -8 // VWT-macosx: [[T5:%.*]] = load ptr, ptr [[T3]] -// VWT-macosx: [[T6:%.*]] = getelementptr inbounds ptr, ptr [[T5]], i64 5 +// VWT-macosx: [[T6:%.*]] = getelementptr inbounds i8, ptr [[T5]], i64 4 // VWT-macosx: [[T8:%.*]] = load ptr, ptr [[T6]] // VWT-macosx: tail call ptr [[T8]]( -// VWT-macosx: [[F01:%.*]] = getelementptr inbounds i32, ptr [[MT]], i64 6 +// VWT-macosx: [[F01:%.*]] = getelementptr inbounds i8, ptr [[MT]], i64 24 // VWT-macosx: [[F03:%.*]] = load i32, ptr [[F01]], align 8 // VWT-macosx: [[F04:%.*]] = sext i32 [[F03]] to i64 // VWT-macosx: [[FA1:%.*]] = getelementptr inbounds i8, ptr {{.*}}, i64 [[F04]] diff --git a/test/IRGen/typelayout_based_value_witness.swift b/test/IRGen/typelayout_based_value_witness.swift index 97af3213ab8cd..f16626c0617cc 100644 --- a/test/IRGen/typelayout_based_value_witness.swift +++ b/test/IRGen/typelayout_based_value_witness.swift @@ -2,6 +2,8 @@ // RUN: %target-swift-frontend -enable-type-layout -primary-file %s -O -emit-ir | %FileCheck %s --check-prefix=OPT --check-prefix=OPT-%target-ptrsize // RUN: %target-swift-frontend -primary-file %s -emit-ir | %FileCheck %s --check-prefix=NOTL +// REQUIRES: PTRSIZE=64 + public struct B { var x: T var y: T @@ -80,20 +82,20 @@ public enum ForwardEnum { // OPT: define{{.*}} void @"$s30typelayout_based_value_witness1AVwxx"(ptr noalias %object, ptr nocapture readonly %"A") -// OPT: [[T_PARAM:%.*]] = getelementptr inbounds ptr, ptr %"A", {{(i64|i32)}} 2 +// OPT: [[T_PARAM:%.*]] = getelementptr inbounds i8, ptr %"A", i64 16 // OPT: [[T:%.*]] = load ptr, ptr [[T_PARAM]] -// OPT: [[VWT_ADDR:%.*]] = getelementptr inbounds ptr, ptr [[T]], {{(i64|i32)}} -1 +// OPT: [[VWT_ADDR:%.*]] = getelementptr inbounds i8, ptr [[T]], {{(i64|i32)}} -8 // OPT: [[VWT:%.*]] = load ptr, ptr [[VWT_ADDR]] -// OPT: [[DESTROY_VW:%.*]] = getelementptr inbounds ptr, ptr [[VWT]], {{(i64|i32)}} 1 +// OPT: [[DESTROY_VW:%.*]] = getelementptr inbounds i8, ptr [[VWT]], {{(i64|i32)}} 8 // OPT: [[DESTROY:%.*]] = load ptr, ptr [[DESTROY_VW]] // OPT: tail call void [[DESTROY]](ptr noalias %object, ptr [[T]]) -// OPT: [[SIZE_VW:%.*]] = getelementptr inbounds %swift.vwtable, ptr [[VWT]], {{i64|i32}} 0, {{(i64|i32)}} 8 +// OPT: [[SIZE_VW:%.*]] = getelementptr inbounds i8, ptr [[VWT]], {{(i64|i32)}} 64 // OPT: [[SIZE_T:%.*]] = load {{(i64|i32)}}, ptr [[SIZE_VW]] // OPT: [[OBJECT:%.*]] = ptrtoint ptr %object to {{(i64|i32)}} -// OPT: [[FLAGS_VW:%.*]] = getelementptr inbounds {{.*}}, ptr [[VWT]], {{i64|i32}} 0, {{(i64|i32)}} 10 +// OPT: [[FLAGS_VW:%.*]] = getelementptr inbounds i8, ptr [[VWT]], {{(i64|i32)}} 80 // OPT: [[FLAGS3:%.*]] = load i32, ptr [[FLAGS_VW]] // OPT: [[FLAGS:%.*]] = and i32 [[FLAGS3]], 255 -// OPT-64: %flags.alignmentMask = zext i32 [[FLAGS]] to i64 +// OPT-64: %flags.alignmentMask = zext nneg i32 [[FLAGS]] to i64 // OPT-64: [[TMP:%.*]] = add {{(i64|i32)}} [[SIZE_T]], %flags.alignmentMask // OPT-32: [[TMP:%.*]] = add {{(i64|i32)}} %flags.alignmentMask, [[SIZE_T]] // OPT: [[TMP2:%.*]] = add {{(i64|i32)}} [[TMP]], [[OBJECT]] diff --git a/test/IRGen/variadic_generic_functions.sil b/test/IRGen/variadic_generic_functions.sil index 3737ce93d186a..0d8257698e285 100644 --- a/test/IRGen/variadic_generic_functions.sil +++ b/test/IRGen/variadic_generic_functions.sil @@ -126,13 +126,13 @@ sil @associatedtype_with_added_conformance_2_callee : $ () -> () {} // CHECK-SAME: ptr %"each T", // CHECK-SAME: ptr %"each T.Q") // CHECK: [[GEN2_TYPES:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]] -// CHECK: [[STORED_STACK_LOC:%[^,]+]] = call ptr @llvm.stacksave() +// CHECK: [[STORED_STACK_LOC:%[^,]+]] = call ptr @llvm.stacksave.p0() // CHECK: [[GEN2_CONFORMANCES_TO_Q:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]] // CHECK: call swiftcc void @associatedtype_with_forwarded_conformance_1_callee( // CHECK-SAME: [[INT]] [[SHAPE]], // CHECK-SAME: ptr [[GEN2_TYPES]], // CHECK-SAME: ptr [[GEN2_CONFORMANCES_TO_Q]]) -// CHECK: call void @llvm.stackrestore(ptr [[STORED_STACK_LOC]]) +// CHECK: call void @llvm.stackrestore.p0(ptr [[STORED_STACK_LOC]]) sil @associatedtype_with_forwarded_conformance_1 : $ () -> () { %i = function_ref @associatedtype_with_forwarded_conformance_1_callee : $@convention(thin) () -> () apply %i}>() : $@convention(thin) () -> () @@ -149,14 +149,14 @@ sil @associatedtype_with_forwarded_conformance_1_callee : $ () -> () // CHECK-SAME: ptr %"each T.PA", // CHECK-SAME: ptr %"(each T).A.Q") // CHECK: [[GEN1_TYPES:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]] -// CHECK: [[STORED_STACK_LOC:%[^,]+]] = call ptr @llvm.stacksave() +// CHECK: [[STORED_STACK_LOC:%[^,]+]] = call ptr @llvm.stacksave.p0() // CHECK: [[GEN1_CONFORMANCES_TO_PA:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]] // CHECK: call swiftcc void @generictype_with_forwarded_conformance_2_callee( // CHECK-SAME: [[INT]] [[SHAPE]], // CHECK-SAME: ptr [[GEN1_TYPES]], // CHECK-SAME: ptr [[GEN1_CONFORMANCES_TO_PA]], // CHECK-SAME: ptr %"(each T).A.Q") -// CHECK: call void @llvm.stackrestore(ptr [[STORED_STACK_LOC]]) +// CHECK: call void @llvm.stackrestore.p0(ptr [[STORED_STACK_LOC]]) sil @generictype_with_forwarded_conformance_2 : $() -> () { %callee = function_ref @generictype_with_forwarded_conformance_2_callee : $@convention(thin) () -> () apply %callee}>() : $@convention(thin) () -> () @@ -172,14 +172,14 @@ sil @generictype_with_forwarded_conformance_2_callee : $ () -> () { %callee = function_ref @generic_with_forwarded_conformance_3_callee : $@convention(thin) () -> () apply %callee>}>() : $@convention(thin) () -> () diff --git a/test/IRGen/variadic_generics.sil b/test/IRGen/variadic_generics.sil index 3fb598b5e6b8c..4876fe99b1d17 100644 --- a/test/IRGen/variadic_generics.sil +++ b/test/IRGen/variadic_generics.sil @@ -105,9 +105,9 @@ bb0(%pack : $*Pack{Int, repeat each T, Int}, %value : $Int): // CHECK-LABEL: define {{.*}}@test_pack_alloc_1_dynamic( // CHECK-SAME: [[INT]] [[PACK_SIZE:%[^,]+]] // CHECK: [[SIZE:%[^,]+]] = add [[INT]] [[PACK_SIZE]], [[PACK_SIZE]] -// CHECK: [[SP_SAVE:%[^,]+]] = call ptr @llvm.stacksave() +// CHECK: [[SP_SAVE:%[^,]+]] = call ptr @llvm.stacksave.p0() // CHECK: alloca ptr, [[INT]] [[SIZE]] -// CHECK: call void @llvm.stackrestore(ptr [[SP_SAVE]]) +// CHECK: call void @llvm.stackrestore.p0(ptr [[SP_SAVE]]) sil @test_pack_alloc_1_dynamic : $ () -> () { // Control flow so that stack saving/restoring is emitted entry: diff --git a/test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift b/test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift index cc722ffb5e9d9..2cbba9a6571b6 100644 --- a/test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift +++ b/test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift @@ -14,4 +14,4 @@ public func use() -> CInt { // CHECK: %[[result:.*]] = alloca %TSo19NonTrivialInWrapperV // CHECK: call void @_ZN10HasMethods28nonConstPassThroughAsWrapperEi(ptr noalias sret(%TSo19NonTrivialInWrapperV) %[[result]], ptr %[[instance]], i32 42) -// CHECK: define {{.*}} void @_ZN10HasMethods28nonConstPassThroughAsWrapperEi(ptr noalias sret(%struct.NonTrivialInWrapper) {{.*}} %{{.*}}, ptr {{.*}} %{{.*}}, i32 noundef %{{.*}}) +// CHECK: define {{.*}} void @_ZN10HasMethods28nonConstPassThroughAsWrapperEi(ptr noalias sret(%struct.NonTrivialInWrapper) {{.*}} %{{.*}}, ptr {{.*}} %{{.*}}, i32{{( noundef)?}} %{{.*}}) diff --git a/test/Serialization/load-target-normalization.swift b/test/Serialization/load-target-normalization.swift index 50b42addef435..09f3483219a13 100644 --- a/test/Serialization/load-target-normalization.swift +++ b/test/Serialization/load-target-normalization.swift @@ -1,10 +1,6 @@ // RUN: %empty-directory(%t/ForeignModule.swiftmodule) // RUN: touch %t/ForeignModule.swiftmodule/garbage-garbage-garbage.swiftmodule -// https://github.com/apple/swift/issues/54797 -// This test crashes on 'next' branch. -// XFAIL: asserts - // Test format: We try to import ForeignModule with architectures besides // garbage-garbage-garbage and check the target triple listed in the error // message to make sure it was normalized correctly. This works in lieu of a diff --git a/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp b/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp index cc11e3b15e124..b3f9be68d82a7 100644 --- a/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp +++ b/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp @@ -864,7 +864,7 @@ static void setLocationInfoForClangNode(ClangNode ClangNode, std::pair Decomp = ClangSM.getDecomposedLoc(CharRange.getBegin()); if (!Decomp.first.isInvalid()) { - if (auto FE = ClangSM.getFileEntryForID(Decomp.first)) { + if (auto FE = ClangSM.getFileEntryRefForID(Decomp.first)) { Location.Filename = FE->getName(); std::pair EndDecomp = @@ -1351,7 +1351,7 @@ getClangDeclarationName(const clang::NamedDecl *ND, NameTranslatingInfo &Info) { return clang::DeclarationName(); ArrayRef Args = llvm::ArrayRef(Info.ArgNames); - std::vector Pieces; + std::vector Pieces; for (unsigned i = 0; i < NumPieces; ++i) { if (i >= Info.ArgNames.size() || Info.ArgNames[i].empty()) { Pieces.push_back(OrigSel.getIdentifierInfoForSlot(i)); diff --git a/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp b/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp index 69cb760afa603..2fc43eade84f2 100644 --- a/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp +++ b/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp @@ -20,6 +20,7 @@ #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +using namespace llvm::opt; using namespace sourcekitd_test; using llvm::StringRef; @@ -28,9 +29,7 @@ namespace { // Create enum with OPT_xxx values for each option in Options.td. enum Opt { OPT_INVALID = 0, -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELP, META, VALUES) \ - OPT_##ID, +#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__), #include "Options.inc" LastOption #undef OPTION @@ -46,12 +45,7 @@ enum Opt { // Create table mapping all options defined in Options.td. static const llvm::opt::OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - {PREFIX, NAME, HELPTEXT, \ - METAVAR, OPT_##ID, llvm::opt::Option::KIND##Class, \ - PARAM, FLAGS, OPT_##GROUP, \ - OPT_##ALIAS, ALIASARGS, VALUES}, +#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__), #include "Options.inc" #undef OPTION }; diff --git a/tools/libMockPlugin/MockPlugin.cpp b/tools/libMockPlugin/MockPlugin.cpp index 3cd3b42d64c23..2e2b8faeac0ed 100644 --- a/tools/libMockPlugin/MockPlugin.cpp +++ b/tools/libMockPlugin/MockPlugin.cpp @@ -203,7 +203,7 @@ int TestRunner::run() { // Read request data. auto request_size = llvm::support::endian::byte_swap( - request_header, llvm::support::endianness::little); + request_header, llvm::endianness::little); llvm::SmallVector request_data; request_data.assign(request_size, 0); ioSize = fread(request_data.data(), request_size, 1, stdin); @@ -240,8 +240,9 @@ int TestRunner::run() { llvm::SmallVector response_data; llvm::raw_svector_ostream(response_data) << response; auto response_size = response_data.size(); - auto response_header = llvm::support::endian::byte_swap< - uint64_t, llvm::support::endianness::little>(response_size); + auto response_header = + llvm::support::endian::byte_swap( + response_size); ioSize = fwrite(&response_header, sizeof(response_header), 1, stdout); if (!ioSize) { llvm::errs() << "failed to write response header\n"; diff --git a/tools/libSwiftScan/SwiftCaching.cpp b/tools/libSwiftScan/SwiftCaching.cpp index aedf855423a9f..75b0dd10f1578 100644 --- a/tools/libSwiftScan/SwiftCaching.cpp +++ b/tools/libSwiftScan/SwiftCaching.cpp @@ -405,7 +405,7 @@ createCachedCompilation(SwiftScanCAS &CAS, const llvm::cas::CASID &ID, auto Input = KeyProxy->getData(); unsigned Index = - llvm::support::endian::read(Input.data()); { swift::cas::CompileJobResultSchema Schema(CAS.getCAS()); diff --git a/tools/libSwiftScan/libSwiftScan.cpp b/tools/libSwiftScan/libSwiftScan.cpp index 7575a2b6a14a1..7312969881304 100644 --- a/tools/libSwiftScan/libSwiftScan.cpp +++ b/tools/libSwiftScan/libSwiftScan.cpp @@ -655,9 +655,9 @@ swiftscan_string_set_t * swiftscan_compiler_supported_arguments_query() { std::unique_ptr table = swift::createSwiftOptTable(); std::vector frontendFlags; -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - addFrontendFlagOption(*table, swift::options::OPT_##ID, frontendFlags); +#define OPTION(...) \ + addFrontendFlagOption(*table, swift::options::LLVM_MAKE_OPT_ID(__VA_ARGS__), \ + frontendFlags); #include "swift/Option/Options.inc" #undef OPTION return swift::c_string_utils::create_set(frontendFlags); diff --git a/tools/swift-scan-test/swift-scan-test.cpp b/tools/swift-scan-test/swift-scan-test.cpp index 663dccdc561b9..4fce9186cbc25 100644 --- a/tools/swift-scan-test/swift-scan-test.cpp +++ b/tools/swift-scan-test/swift-scan-test.cpp @@ -279,7 +279,7 @@ int main(int argc, char *argv[]) { auto Args = createArgs(SwiftCommands, Saver, Action); std::atomic Ret = 0; - llvm::ThreadPool Pool(llvm::hardware_concurrency(Threads)); + llvm::StdThreadPool Pool(llvm::hardware_concurrency(Threads)); for (unsigned i = 0; i < Threads; ++i) { Pool.async([&]() { switch (Action) { diff --git a/unittests/DependencyScan/Features.cpp b/unittests/DependencyScan/Features.cpp index a35315819cb8f..89cdc1b900b46 100644 --- a/unittests/DependencyScan/Features.cpp +++ b/unittests/DependencyScan/Features.cpp @@ -45,9 +45,9 @@ TEST_F(ScanTest, TestHasArgumentQuery) { optionSet.insert(std::string(data, option.length)); } swiftscan_string_set_dispose(supported_args_set); -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - testHasOption(*table, swift::options::OPT_##ID, optionSet); +#define OPTION(...) \ + testHasOption(*table, swift::options::LLVM_MAKE_OPT_ID(__VA_ARGS__), \ + optionSet); #include "swift/Option/Options.inc" #undef OPTION } diff --git a/validation-test/IRGen/pack_stack_metadata_alloc_loop.sil b/validation-test/IRGen/pack_stack_metadata_alloc_loop.sil index e788af1a5a327..10bcbcbebfb9f 100644 --- a/validation-test/IRGen/pack_stack_metadata_alloc_loop.sil +++ b/validation-test/IRGen/pack_stack_metadata_alloc_loop.sil @@ -2,6 +2,7 @@ // RUN: %target-swift-frontend -parse-sil -enable-pack-metadata-stack-promotion=true -emit-ir -primary-file %s | %IRGenFileCheck %s // REQUIRES: executable_test +// REQUIRES: CPU=arm64 // Allocate metadata packs on the stack in a loop. If these packs weren't // deallocated, the stack would be exhausted. @@ -36,11 +37,11 @@ sil @callee : $@convention(thin) () -> () { // CHECK: [[HEADER]]: // CHECK: [[PREVIOUS:%[^,]+]] = phi i64 [ 10000000, %[[ENTRY]] ], [ [[REMAINING:%[^,]+]], %{{[^,]+}} ] // CHECK: [[COMBINED_PACK_SIZE:%[^,]+]] = add [[INT]] %0, %1 -// CHECK: [[STACK_BEFORE_FIRST_ALLOCA:%[^,]+]] = call ptr @llvm.stacksave() +// CHECK: [[STACK_BEFORE_FIRST_ALLOCA:%[^,]+]] = call ptr @llvm.stacksave.p0() // CHECK: [[FIRST_ALLOCA_METADATA_PACK:%[^,]+]] = alloca ptr, [[INT]] [[COMBINED_PACK_SIZE]] // CHECK: call swiftcc void @callee([[INT]] [[COMBINED_PACK_SIZE]], ptr [[FIRST_ALLOCA_METADATA_PACK]]) // CHECK: [[COMBINED_PACK_SIZE_2:%[^,]+]] = add [[INT]] %1, %0 -// CHECK: [[STACK_BEFORE_SECOND_ALLOCA:%[^,]+]] = call ptr @llvm.stacksave() +// CHECK: [[STACK_BEFORE_SECOND_ALLOCA:%[^,]+]] = call ptr @llvm.stacksave.p0() // CHECK: [[SECOND_ALLOCA_METADATA_PACK:%[^,]+]] = alloca ptr, [[INT]] [[COMBINED_PACK_SIZE_2]] // CHECK: call swiftcc void @callee([[INT]] [[COMBINED_PACK_SIZE_2]], ptr [[SECOND_ALLOCA_METADATA_PACK]]) // CHECK: [[REMAINING_AND_OVERFLOW:%[^,]+]] = call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 [[PREVIOUS]], i64 1) @@ -48,12 +49,14 @@ sil @callee : $@convention(thin) () -> () { // CHECK: [[IS_ZERO:%[^,]+]] = icmp eq i64 [[REMAINING]], 0 // CHECK: br i1 [[IS_ZERO]], label %[[EXIT:[^,]+]], label %[[BACKEDGE:[^,]+]] // CHECK: [[BACKEDGE]]: -// CHECK: call void @llvm.stackrestore(ptr [[STACK_BEFORE_SECOND_ALLOCA]]) -// CHECK: call void @llvm.stackrestore(ptr [[STACK_BEFORE_FIRST_ALLOCA]]) +// CHECK: call void @llvm.stackrestore.p0(ptr [[STACK_BEFORE_SECOND_ALLOCA]]) +// CHECK: call void @llvm.stackrestore.p0(ptr [[STACK_BEFORE_FIRST_ALLOCA]]) // CHECK: br label %[[HEADER]] // CHECK: [[EXIT]]: -// CHECK: call void @llvm.stackrestore(ptr [[STACK_BEFORE_SECOND_ALLOCA]]) -// CHECK: call void @llvm.stackrestore(ptr [[STACK_BEFORE_FIRST_ALLOCA]]) +// CHECK: [[STACK_BEFORE_SECOND_ALLOCAlcssa:%.*]] = phi ptr [ [[STACK_BEFORE_SECOND_ALLOCA]], %{{.*}} ] +// CHECK: [[STACK_BEFORE_FIRST_ALLOCAlcssa:%.*]] = phi ptr [ [[STACK_BEFORE_FIRST_ALLOCA]], %{{.*}} ] +// CHECK: call void @llvm.stackrestore.p0(ptr [[STACK_BEFORE_SECOND_ALLOCAlcssa]]) +// CHECK: call void @llvm.stackrestore.p0(ptr [[STACK_BEFORE_FIRST_ALLOCAlcssa]]) // CHECK: ret void // CHECK: } sil @looper : $@convention(thin) () -> () { diff --git a/validation-test/IRGen/rdar114013709.swift b/validation-test/IRGen/rdar114013709.swift index 71b1549c0d508..dc04b86ad3eb0 100644 --- a/validation-test/IRGen/rdar114013709.swift +++ b/validation-test/IRGen/rdar114013709.swift @@ -1,6 +1,6 @@ // RUN: %target-swift-frontend -O -primary-file %s -disable-availability-checking -emit-ir | %FileCheck %s -// CHECK: define{{( dllexport)?}}{{( protected)?}} i32 @main{{.*}} { +// CHECK: define{{( dllexport)?}}{{( protected)?}}{{( noundef)?}} i32 @main{{.*}} { // CHECK: store ptr %{{[0-9]+}}, ptr @"$s13rdar1140137091xQrvp" actor Actor {} let x: some Actor = Actor()