diff --git a/include/swift/AST/Expr.h b/include/swift/AST/Expr.h index 7d8e07de69957..b37d27de308ca 100644 --- a/include/swift/AST/Expr.h +++ b/include/swift/AST/Expr.h @@ -154,12 +154,12 @@ class alignas(8) Expr : public ASTAllocated { Implicit : 1 ); - SWIFT_INLINE_BITFIELD_FULL(CollectionExpr, Expr, 64-NumExprBits, + SWIFT_INLINE_BITFIELD_FULL(CollectionExpr, Expr, 64-NumberOfExprBits, /// True if the type of this collection expr was inferred by the collection /// fallback type, like [Any]. IsTypeDefaulted : 1, /// Number of comma source locations. - NumCommas : 32 - 1 - NumExprBits, + NumCommas : 32 - 1 - NumberOfExprBits, /// Number of entries in the collection. If this is a DictionaryExpr, /// each entry is a Tuple with the key and value pair. NumSubExprs : 32 @@ -256,8 +256,8 @@ class alignas(8) Expr : public ASTAllocated { LitKind : 3 ); - SWIFT_INLINE_BITFIELD(AbstractClosureExpr, Expr, (16-NumExprBits)+16, - : 16 - NumExprBits, // Align and leave room for subclasses + SWIFT_INLINE_BITFIELD(AbstractClosureExpr, Expr, (16-NumberOfExprBits)+16, + : 16 - NumberOfExprBits, // Align and leave room for subclasses Discriminator : 16 ); diff --git a/include/swift/AST/IRGenOptions.h b/include/swift/AST/IRGenOptions.h index 9336f5f66f10d..9b2e6e96d4aea 100644 --- a/include/swift/AST/IRGenOptions.h +++ b/include/swift/AST/IRGenOptions.h @@ -29,9 +29,9 @@ #include "llvm/IR/CallingConv.h" // FIXME: This include is just for llvm::SanitizerCoverageOptions. We should // split the header upstream so we don't include so much. -#include "llvm/Transforms/Instrumentation.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/VersionTuple.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/Transforms/Utils/Instrumentation.h" #include #include #include diff --git a/include/swift/Basic/InlineBitfield.h b/include/swift/Basic/InlineBitfield.h index b41ae018d4edf..1378115aee012 100644 --- a/include/swift/Basic/InlineBitfield.h +++ b/include/swift/Basic/InlineBitfield.h @@ -41,7 +41,7 @@ namespace swift { uint64_t : 64 - (C); /* Better code gen */ \ } T; \ LLVM_PACKED_END \ - enum { Num##T##Bits = (C) }; \ + enum { NumberOf##T##Bits = (C) }; \ static_assert(sizeof(T##Bitfield) <= 8, "Bitfield overflow") /// Define an bitfield for type 'T' with parent class 'U' and 'C' bits used. @@ -49,11 +49,11 @@ namespace swift { LLVM_PACKED_START \ class T##Bitfield { \ friend class T; \ - uint64_t : Num##U##Bits, __VA_ARGS__; \ - uint64_t : 64 - (Num##U##Bits + (HC) + (C)); /* Better code gen */ \ + uint64_t : NumberOf##U##Bits, __VA_ARGS__; \ + uint64_t : 64 - (NumberOf##U##Bits + (HC) + (C)); /* Better code gen */ \ } T; \ LLVM_PACKED_END \ - enum { Num##T##Bits = Num##U##Bits + (C) }; \ + enum { NumberOf##T##Bits = NumberOf##U##Bits + (C) }; \ static_assert(sizeof(T##Bitfield) <= 8, "Bitfield overflow") #define SWIFT_INLINE_BITFIELD(T, U, C, ...) \ @@ -75,8 +75,8 @@ namespace swift { LLVM_PACKED_START \ class T##Bitfield { \ friend class T; \ - enum { NumPadBits = 64 - (Num##U##Bits + (C)) }; \ - uint64_t : Num##U##Bits, __VA_ARGS__; \ + enum { NumPadBits = 64 - (NumberOf##U##Bits + (C)) }; \ + uint64_t : NumberOf##U##Bits, __VA_ARGS__; \ } T; \ LLVM_PACKED_END \ static_assert(sizeof(T##Bitfield) <= 8, "Bitfield overflow") @@ -101,15 +101,15 @@ namespace swift { class T##Bitfield { \ template \ friend class T; \ - enum { NumPadBits = 64 - (Num##U##Bits + (C)) }; \ - uint64_t : Num##U##Bits, __VA_ARGS__; \ + enum { NumPadBits = 64 - (NumberOf##U##Bits + (C)) }; \ + uint64_t : NumberOf##U##Bits, __VA_ARGS__; \ } T; \ LLVM_PACKED_END \ static_assert(sizeof(T##Bitfield) <= 8, "Bitfield overflow") /// Define an empty bitfield for type 'T'. #define SWIFT_INLINE_BITFIELD_EMPTY(T, U) \ - enum { Num##T##Bits = Num##U##Bits } + enum { NumberOf##T##Bits = NumberOf##U##Bits } // XXX/HACK: templated max() doesn't seem to work in a bitfield size context. constexpr unsigned bitmax(unsigned a, unsigned b) { diff --git a/include/swift/Migrator/FixitApplyDiagnosticConsumer.h b/include/swift/Migrator/FixitApplyDiagnosticConsumer.h index 4937a881b827d..ce5aebf58f5e9 100644 --- a/include/swift/Migrator/FixitApplyDiagnosticConsumer.h +++ b/include/swift/Migrator/FixitApplyDiagnosticConsumer.h @@ -21,7 +21,7 @@ #include "swift/Migrator/FixitFilter.h" #include "swift/Migrator/Migrator.h" #include "swift/Migrator/Replacement.h" -#include "clang/Rewrite/Core/RewriteBuffer.h" +#include "llvm/ADT/RewriteBuffer.h" #include "llvm/ADT/SmallSet.h" namespace swift { @@ -37,7 +37,7 @@ struct Replacement; class FixitApplyDiagnosticConsumer final : public DiagnosticConsumer, public FixitFilter { - clang::RewriteBuffer RewriteBuf; + llvm::RewriteBuffer RewriteBuf; /// The entire text of the input file. const StringRef Text; diff --git a/include/swift/Migrator/RewriteBufferEditsReceiver.h b/include/swift/Migrator/RewriteBufferEditsReceiver.h index 91c86d893bc6d..e9366ead711f5 100644 --- a/include/swift/Migrator/RewriteBufferEditsReceiver.h +++ b/include/swift/Migrator/RewriteBufferEditsReceiver.h @@ -16,7 +16,7 @@ #include "clang/Basic/SourceManager.h" #include "clang/Basic/SourceLocation.h" #include "clang/Edit/EditsReceiver.h" -#include "clang/Rewrite/Core/RewriteBuffer.h" +#include "llvm/ADT/RewriteBuffer.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/raw_ostream.h" @@ -26,12 +26,13 @@ namespace swift { namespace migrator { /// An EditsReceiver that collects edits from an EditedSource and directly -/// applies it to a clang::RewriteBuffer. +/// applies it to a llvm::RewriteBuffer. class RewriteBufferEditsReceiver final : public clang::edit::EditsReceiver { const clang::SourceManager &ClangSourceManager; const clang::FileID InputFileID; const StringRef InputText; - clang::RewriteBuffer RewriteBuf; + llvm::RewriteBuffer RewriteBuf; + public: RewriteBufferEditsReceiver(const clang::SourceManager &ClangSourceManager, const clang::FileID InputFileID, diff --git a/include/swift/Option/SanitizerOptions.h b/include/swift/Option/SanitizerOptions.h index faa394f39b072..ab7f3bbdb8776 100644 --- a/include/swift/Option/SanitizerOptions.h +++ b/include/swift/Option/SanitizerOptions.h @@ -20,7 +20,7 @@ #include "llvm/Option/ArgList.h" // FIXME: This include is just for llvm::SanitizerCoverageOptions. We should // split the header upstream so we don't include so much. -#include "llvm/Transforms/Instrumentation.h" +#include "llvm/Transforms/Utils/Instrumentation.h" namespace swift { class DiagnosticEngine; diff --git a/include/swift/SIL/MemAccessUtils.h b/include/swift/SIL/MemAccessUtils.h index 6c8d0633b707f..d3f803d15b039 100644 --- a/include/swift/SIL/MemAccessUtils.h +++ b/include/swift/SIL/MemAccessUtils.h @@ -375,12 +375,12 @@ class AccessRepresentation { // Define bits for use in AccessStorageAnalysis. Each identified storage // object is mapped to one instance of this subclass. SWIFT_INLINE_BITFIELD_FULL(StorageAccessInfo, AccessRepresentation, - 64 - NumAccessRepresentationBits, + 64 - NumberOfAccessRepresentationBits, accessKind : NumSILAccessKindBits, noNestedConflict : 1, - storageIndex : 64 - (NumAccessRepresentationBits - + NumSILAccessKindBits - + 1)); + storageIndex : 64 - + (NumberOfAccessRepresentationBits + + NumSILAccessKindBits + 1)); // Define bits for use in the AccessEnforcementOpts pass. Each begin_access // in the function is mapped to one instance of this subclass. Reserve a @@ -390,13 +390,11 @@ class AccessRepresentation { // // `AccessRepresentation` refers to the AccessRepresentationBitfield defined // above, setting aside enough bits for common data. - SWIFT_INLINE_BITFIELD_FULL(AccessEnforcementOptsInfo, - AccessRepresentation, - 64 - NumAccessRepresentationBits, - seenNestedConflict : 1, - seenIdenticalStorage : 1, - beginAccessIndex : - 62 - NumAccessRepresentationBits); + SWIFT_INLINE_BITFIELD_FULL(AccessEnforcementOptsInfo, AccessRepresentation, + 64 - NumberOfAccessRepresentationBits, + seenNestedConflict : 1, seenIdenticalStorage : 1, + beginAccessIndex : 62 - + NumberOfAccessRepresentationBits); // Define data flow bits for use in the AccessEnforcementDom pass. Each // begin_access in the function is mapped to one instance of this subclass. diff --git a/include/swift/SILOptimizer/Analysis/Analysis.h b/include/swift/SILOptimizer/Analysis/Analysis.h index a0647818b0418..ec6c729117198 100644 --- a/include/swift/SILOptimizer/Analysis/Analysis.h +++ b/include/swift/SILOptimizer/Analysis/Analysis.h @@ -231,19 +231,19 @@ class FunctionAnalysisBase : public SILAnalysis { // Check that the analysis can handle this function. verifyFunction(f); - auto &it = storage.FindAndConstruct(f); - if (!it.second) - it.second = newFunctionAnalysis(f); - return it.second.get(); + auto &value = storage[f]; + if (!value) + value = newFunctionAnalysis(f); + return value.get(); } virtual void forcePrecompute(SILFunction *f) override { // Check that the analysis can handle this function. verifyFunction(f); - auto &it = storage.FindAndConstruct(f); - if (!it.second) - it.second = newFunctionAnalysis(f); + auto &value = storage[f]; + if (!value) + value = newFunctionAnalysis(f); } /// Invalidate all information in this analysis. diff --git a/lib/AST/Builtins.cpp b/lib/AST/Builtins.cpp index e7ea0ad0703ca..a2e42e317d8ae 100644 --- a/lib/AST/Builtins.cpp +++ b/lib/AST/Builtins.cpp @@ -2363,18 +2363,6 @@ bool swift::canBuiltinBeOverloadedForType(BuiltinValueKind ID, Type Ty) { return isBuiltinTypeOverloaded(Ty, OverloadedBuiltinKinds[unsigned(ID)]); } -/// Table of string intrinsic names indexed by enum value. -static const char *const IntrinsicNameTable[] = { - "not_intrinsic", -#define GET_INTRINSIC_NAME_TABLE -#include "llvm/IR/IntrinsicImpl.inc" -#undef GET_INTRINSIC_NAME_TABLE -}; - -#define GET_INTRINSIC_TARGET_DATA -#include "llvm/IR/IntrinsicImpl.inc" -#undef GET_INTRINSIC_TARGET_DATA - llvm::Intrinsic::ID swift::getLLVMIntrinsicID(StringRef InName) { using namespace llvm; @@ -2390,10 +2378,8 @@ llvm::Intrinsic::ID swift::getLLVMIntrinsicID(StringRef InName) { NameS.push_back(C == '_' ? '.' : C); const char *Name = NameS.c_str(); - ArrayRef NameTable(&IntrinsicNameTable[1], - TargetInfos[1].Offset); - int Idx = Intrinsic::lookupLLVMIntrinsicByName(NameTable, Name); - return static_cast(Idx + 1); + + return Intrinsic::lookupIntrinsicID(Name); } llvm::Intrinsic::ID @@ -2488,6 +2474,9 @@ Type IntrinsicTypeDecoder::decodeImmediate() { case IITDescriptor::Subdivide4Argument: case IITDescriptor::PPCQuad: case IITDescriptor::AArch64Svcount: + case IITDescriptor::OneThirdVecArgument: + case IITDescriptor::OneFifthVecArgument: + case IITDescriptor::OneSeventhVecArgument: // These types cannot be expressed in swift yet. return Type(); diff --git a/lib/AST/ClangTypeConverter.cpp b/lib/AST/ClangTypeConverter.cpp index a939a5e8a95b8..89f9cb8cd234a 100644 --- a/lib/AST/ClangTypeConverter.cpp +++ b/lib/AST/ClangTypeConverter.cpp @@ -84,10 +84,14 @@ getClangBuiltinTypeFromKind(const clang::ASTContext &context, case clang::BuiltinType::Id: \ return context.SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" -#define AMDGPU_TYPE(Name, Id, SingletonId) \ +#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \ case clang::BuiltinType::Id: \ return context.SingletonId; #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ + case clang::BuiltinType::Id: \ + return context.SingletonId; +#include "clang/Basic/HLSLIntangibleTypes.def" } // Not a valid BuiltinType. diff --git a/lib/AST/RequirementMachine/ApplyInverses.cpp b/lib/AST/RequirementMachine/ApplyInverses.cpp index a37726b7c4a48..bed9797a7ec3d 100644 --- a/lib/AST/RequirementMachine/ApplyInverses.cpp +++ b/lib/AST/RequirementMachine/ApplyInverses.cpp @@ -212,7 +212,7 @@ void swift::rewriting::applyInverses( continue; } - auto state = inverses.getOrInsertDefault(representativeSubject); + auto &state = inverses[representativeSubject]; // Check if this inverse has already been seen. auto inverseKind = inverse.getKind(); diff --git a/lib/ClangImporter/ClangAdapter.cpp b/lib/ClangImporter/ClangAdapter.cpp index f832a5af21f05..691eef5ae1d43 100644 --- a/lib/ClangImporter/ClangAdapter.cpp +++ b/lib/ClangImporter/ClangAdapter.cpp @@ -450,6 +450,11 @@ OmissionTypeName importer::getClangTypeNameForOmission(clang::ASTContext &ctx, #define AMDGPU_TYPE(Name, Id, ...) case clang::BuiltinType::Id: #include "clang/Basic/AMDGPUTypes.def" return OmissionTypeName(); + + // HLSL intangible builtin types that don't have Swift equivalents. +#define HLSL_INTANGIBLE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" + return OmissionTypeName(); } } diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 9db9c4ca8b89d..deca1a9112629 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -986,8 +986,8 @@ bool ClangImporter::canReadPCH(StringRef PCHFilename) { CI.setInvocation(std::move(invocation)); CI.setTarget(&Impl.Instance->getTarget()); - CI.setDiagnostics( - &*clang::CompilerInstance::createDiagnostics(new clang::DiagnosticOptions())); + CI.setDiagnostics(&*clang::CompilerInstance::createDiagnostics( + Impl.Instance->getVirtualFileSystem(), new clang::DiagnosticOptions())); // Note: Reusing the file manager is safe; this is a component that's already // reused when building PCM files for the module cache. @@ -1127,6 +1127,8 @@ ClangImporter::getClangDriverArguments(ASTContext &ctx, bool ignoreClangTarget) std::optional> ClangImporter::getClangCC1Arguments( ASTContext &ctx, llvm::IntrusiveRefCntPtr VFS, bool ignoreClangTarget) { + ASSERT(VFS && "Expected non-null file system"); + std::unique_ptr CI; // Set up a temporary diagnostic client to report errors from parsing the @@ -1143,7 +1145,7 @@ std::optional> ClangImporter::getClangCC1Arguments( new ClangDiagnosticConsumer(Impl, *tempDiagOpts, ctx.ClangImporterOpts.DumpClangDiagnostics); auto clangDiags = clang::CompilerInstance::createDiagnostics( - tempDiagOpts.get(), tempDiagClient, + *VFS, tempDiagOpts.get(), tempDiagClient, /*owned*/ true); // If using direct cc1 module build, use extra args to setup ClangImporter. @@ -1227,9 +1229,7 @@ std::optional> ClangImporter::getClangCC1Arguments( // to missing files and report the error that clang would throw manually. // rdar://77516546 is tracking that the clang importer should be more // resilient and provide a module even if there were building it. - auto TempVFS = clang::createVFSFromCompilerInvocation( - *CI, *clangDiags, - VFS ? VFS : Impl.SwiftContext.SourceMgr.getFileSystem()); + auto TempVFS = clang::createVFSFromCompilerInvocation(*CI, *clangDiags, VFS); std::vector FilteredModuleMapFiles; for (auto ModuleMapFile : CI->getFrontendOpts().ModuleMapFiles) { @@ -1379,7 +1379,7 @@ ClangImporter::create(ASTContext &ctx, auto actualDiagClient = std::make_unique( importer->Impl, instance.getDiagnosticOpts(), importerOpts.DumpClangDiagnostics); - instance.createDiagnostics(actualDiagClient.release()); + instance.createDiagnostics(*VFS, actualDiagClient.release()); } // Set up the file manager. @@ -1770,14 +1770,14 @@ bool ClangImporter::importHeader(StringRef header, ModuleDecl *adapter, off_t expectedSize, time_t expectedModTime, StringRef cachedContents, SourceLoc diagLoc) { clang::FileManager &fileManager = Impl.Instance->getFileManager(); - auto headerFile = fileManager.getFile(header, /*OpenFile=*/true); + auto headerFile = fileManager.getOptionalFileRef(header, /*OpenFile=*/true); // Prefer importing the header directly if the header content matches by // checking size and mod time. This allows correct import if some no-modular // headers are already imported into clang importer. If mod time is zero, then // the module should be built from CAS and there is no mod time to verify. - if (headerFile && (*headerFile)->getSize() == expectedSize && + if (headerFile && headerFile->getSize() == expectedSize && (expectedModTime == 0 || - (*headerFile)->getModificationTime() == expectedModTime)) { + headerFile->getModificationTime() == expectedModTime)) { return importBridgingHeader(header, adapter, diagLoc, false, true); } @@ -1804,7 +1804,7 @@ bool ClangImporter::importBridgingHeader(StringRef header, ModuleDecl *adapter, } clang::FileManager &fileManager = Impl.Instance->getFileManager(); - auto headerFile = fileManager.getFile(header, /*OpenFile=*/true); + auto headerFile = fileManager.getOptionalFileRef(header, /*OpenFile=*/true); if (!headerFile) { Impl.diagnose(diagLoc, diag::bridging_header_missing, header); return true; @@ -1897,13 +1897,14 @@ std::string ClangImporter::getBridgingHeaderContents( invocation->getPreprocessorOpts().resetNonModularOptions(); + clang::FileManager &fileManager = Impl.Instance->getFileManager(); + clang::CompilerInstance rewriteInstance( Impl.Instance->getPCHContainerOperations(), &Impl.Instance->getModuleCache()); rewriteInstance.setInvocation(invocation); - rewriteInstance.createDiagnostics(new clang::IgnoringDiagConsumer); - - clang::FileManager &fileManager = Impl.Instance->getFileManager(); + rewriteInstance.createDiagnostics(fileManager.getVirtualFileSystem(), + new clang::IgnoringDiagConsumer); rewriteInstance.setFileManager(&fileManager); rewriteInstance.createSourceManager(fileManager); rewriteInstance.setTarget(&Impl.Instance->getTarget()); @@ -1953,9 +1954,9 @@ std::string ClangImporter::getBridgingHeaderContents( return ""; } - if (auto fileInfo = fileManager.getFile(headerPath)) { - fileSize = (*fileInfo)->getSize(); - fileModTime = (*fileInfo)->getModificationTime(); + if (auto fileInfo = fileManager.getOptionalFileRef(headerPath)) { + fileSize = fileInfo->getSize(); + fileModTime = fileInfo->getModificationTime(); } return result; } @@ -2002,14 +2003,15 @@ ClangImporter::cloneCompilerInstanceForPrecompiling() { // Share the CASOption and the underlying CAS. invocation->setCASOption(Impl.Invocation->getCASOptsPtr()); + clang::FileManager &fileManager = Impl.Instance->getFileManager(); + auto clonedInstance = std::make_unique( Impl.Instance->getPCHContainerOperations(), &Impl.Instance->getModuleCache()); clonedInstance->setInvocation(std::move(invocation)); - clonedInstance->createDiagnostics(&Impl.Instance->getDiagnosticClient(), + clonedInstance->createDiagnostics(fileManager.getVirtualFileSystem(), + &Impl.Instance->getDiagnosticClient(), /*ShouldOwnClient=*/false); - - clang::FileManager &fileManager = Impl.Instance->getFileManager(); clonedInstance->setFileManager(&fileManager); clonedInstance->createSourceManager(fileManager); clonedInstance->setTarget(&Impl.Instance->getTarget()); @@ -7114,7 +7116,8 @@ ClangImporter::instantiateCXXClassTemplate( ctsd = clang::ClassTemplateSpecializationDecl::Create( decl->getASTContext(), decl->getTemplatedDecl()->getTagKind(), decl->getDeclContext(), decl->getTemplatedDecl()->getBeginLoc(), - decl->getLocation(), decl, arguments, nullptr); + decl->getLocation(), decl, arguments, /*StrictPackMatch*/ false, + nullptr); decl->AddSpecialization(ctsd, InsertPos); } diff --git a/lib/ClangImporter/ClangIncludePaths.cpp b/lib/ClangImporter/ClangIncludePaths.cpp index 948b99876f02d..9939333443443 100644 --- a/lib/ClangImporter/ClangIncludePaths.cpp +++ b/lib/ClangImporter/ClangIncludePaths.cpp @@ -127,9 +127,12 @@ std::pair vfs) { + + auto diagVFS = vfs ? vfs : llvm::vfs::getRealFileSystem(); + auto *silentDiagConsumer = new clang::DiagnosticConsumer(); auto clangDiags = clang::CompilerInstance::createDiagnostics( - new clang::DiagnosticOptions(), silentDiagConsumer); + *diagVFS, new clang::DiagnosticOptions(), silentDiagConsumer); clang::driver::Driver clangDriver(ClangImporterOpts.clangPath, LangOpts.Target.str(), *clangDiags, "clang LLVM compiler", vfs); diff --git a/lib/ClangImporter/ClangModuleDependencyScanner.cpp b/lib/ClangImporter/ClangModuleDependencyScanner.cpp index cc054f3de524a..f5488fdce2189 100644 --- a/lib/ClangImporter/ClangModuleDependencyScanner.cpp +++ b/lib/ClangImporter/ClangModuleDependencyScanner.cpp @@ -156,7 +156,7 @@ ModuleDependencyVector ClangImporter::bridgeClangModuleDependencies( // CASFileSystemRootID. std::string RootID = clangModuleDep.CASFileSystemRootID - ? clangModuleDep.CASFileSystemRootID->toString() + ? clangModuleDep.CASFileSystemRootID.value() : ""; std::string IncludeTree = diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 8079302590a23..e85a924d0fa92 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -383,6 +383,7 @@ getSwiftStdlibType(const clang::TypedefNameDecl *D, case clang::TargetInfo::PNaClABIBuiltinVaList: case clang::TargetInfo::SystemZBuiltinVaList: case clang::TargetInfo::X86_64ABIBuiltinVaList: + case clang::TargetInfo::XtensaABIBuiltinVaList: return std::make_pair(Type(), ""); } break; @@ -3269,7 +3270,7 @@ namespace { decl->getLocation(), const_cast(decl), clang::TemplateSpecializationKind::TSK_ImplicitInstantiation, - /*Complain*/ false); + /*Complain*/ false, /*PrimaryStrictPackMatch*/ false); // If the template can't be instantiated, bail. if (notInstantiated) return nullptr; diff --git a/lib/ClangImporter/ImportType.cpp b/lib/ClangImporter/ImportType.cpp index 6bffbf3c3ef1c..fcb0b1efbdc15 100644 --- a/lib/ClangImporter/ImportType.cpp +++ b/lib/ClangImporter/ImportType.cpp @@ -365,10 +365,15 @@ namespace { return Type(); // AMDGPU builtin types that don't have Swift equivalents. -#define AMDGPU_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id: +#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \ + case clang::BuiltinType::Id: #include "clang/Basic/AMDGPUTypes.def" return Type(); + // HLSL intangible builtin types that don't have Swift equivalents. +#define HLSL_INTANGIBLE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" + return Type(); } llvm_unreachable("Invalid BuiltinType."); @@ -414,6 +419,16 @@ namespace { return Type(); } + ImportResult VisitHLSLAttributedResourceType( + const clang::HLSLAttributedResourceType *type) { + Impl.addImportDiagnostic( + type, + Diagnostic(diag::unsupported_builtin_type, type->getTypeClassName()), + clang::SourceLocation()); + // FIXME: (?) HLSL types are not supported in Swift. + return Type(); + } + ImportResult VisitCountAttributedType(const clang::CountAttributedType *type) { return Visit(type->desugar()); diff --git a/lib/ClangImporter/SwiftLookupTable.cpp b/lib/ClangImporter/SwiftLookupTable.cpp index a367e6c487723..a5fd89a07329f 100644 --- a/lib/ClangImporter/SwiftLookupTable.cpp +++ b/lib/ClangImporter/SwiftLookupTable.cpp @@ -1107,7 +1107,8 @@ namespace { ids = StoredSingleEntry::forSerializedDecl( astWriter.getDeclID(decl).getRawValue()); } else if (auto *macro = mappedEntry.dyn_cast()) { - ids = StoredSingleEntry::forSerializedMacro(astWriter.getMacroID(macro)); + ids = StoredSingleEntry::forSerializedMacro( + astWriter.getMacroRef(macro, /*Name=*/nullptr)); } else { auto *moduleMacro = mappedEntry.get(); StoredSingleEntry::SerializationID nameID = diff --git a/lib/DriverTool/swift_cache_tool_main.cpp b/lib/DriverTool/swift_cache_tool_main.cpp index 7fc902e4483d2..d32519b0928a9 100644 --- a/lib/DriverTool/swift_cache_tool_main.cpp +++ b/lib/DriverTool/swift_cache_tool_main.cpp @@ -65,12 +65,13 @@ enum ID { #undef OPTION }; -#define PREFIX(NAME, VALUE) \ - constexpr llvm::StringLiteral NAME##_init[] = VALUE; \ - constexpr llvm::ArrayRef NAME( \ - NAME##_init, std::size(NAME##_init) - 1); +#define OPTTABLE_STR_TABLE_CODE #include "SwiftCacheToolOptions.inc" -#undef PREFIX +#undef OPTTABLE_STR_TABLE_CODE + +#define OPTTABLE_PREFIXES_TABLE_CODE +#include "SwiftCacheToolOptions.inc" +#undef OPTTABLE_PREFIXES_TABLE_CODE static const OptTable::Info InfoTable[] = { #define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__), @@ -80,7 +81,8 @@ static const OptTable::Info InfoTable[] = { class CacheToolOptTable : public llvm::opt::GenericOptTable { public: - CacheToolOptTable() : GenericOptTable(InfoTable) {} + CacheToolOptTable() + : GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable) {} }; class SwiftCacheToolInvocation { diff --git a/lib/DriverTool/swift_llvm_opt_main.cpp b/lib/DriverTool/swift_llvm_opt_main.cpp index 00b97178dee56..37b757b82a0fb 100644 --- a/lib/DriverTool/swift_llvm_opt_main.cpp +++ b/lib/DriverTool/swift_llvm_opt_main.cpp @@ -174,7 +174,8 @@ int swift_llvm_opt_main(ArrayRef argv, void *MainAddr) { // If we are supposed to override the target triple, do so now. if (!options.TargetTriple.empty()) - M->setTargetTriple(llvm::Triple::normalize(options.TargetTriple)); + M->setTargetTriple( + llvm::Triple(llvm::Triple::normalize(options.TargetTriple))); // Figure out what stream we are supposed to write to... std::unique_ptr Out; diff --git a/lib/IDE/Utils.cpp b/lib/IDE/Utils.cpp index 6dbb2fb7aa320..1b338aa62d593 100644 --- a/lib/IDE/Utils.cpp +++ b/lib/IDE/Utils.cpp @@ -20,7 +20,7 @@ #include "swift/Parse/Parser.h" #include "swift/Subsystems.h" #include "clang/AST/ASTContext.h" -#include "clang/Rewrite/Core/RewriteBuffer.h" +#include "llvm/ADT/RewriteBuffer.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/MemoryBuffer.h" @@ -782,11 +782,11 @@ accept(SourceManager &SM, RegionType Type, ArrayRef Replacements) { namespace { class ClangFileRewriterHelper { unsigned InterestedId; - clang::RewriteBuffer RewriteBuf; + llvm::RewriteBuffer RewriteBuf; bool HasChange; llvm::raw_ostream &OS; - void removeCommentLines(clang::RewriteBuffer &Buffer, StringRef Input, + void removeCommentLines(llvm::RewriteBuffer &Buffer, StringRef Input, StringRef LineHeader) { size_t Pos = 0; while (true) { diff --git a/lib/IDETool/CompilerInvocation.cpp b/lib/IDETool/CompilerInvocation.cpp index 278d579b6dd2f..f16c441b4f12a 100644 --- a/lib/IDETool/CompilerInvocation.cpp +++ b/lib/IDETool/CompilerInvocation.cpp @@ -271,9 +271,11 @@ bool ide::initInvocationByClangArguments(ArrayRef ArgList, new clang::DiagnosticOptions() }; + const auto VFS = llvm::vfs::getRealFileSystem(); + clang::TextDiagnosticBuffer DiagBuf; llvm::IntrusiveRefCntPtr ClangDiags = - clang::CompilerInstance::createDiagnostics(DiagOpts.get(), &DiagBuf, + clang::CompilerInstance::createDiagnostics(*VFS, DiagOpts.get(), &DiagBuf, /*ShouldOwnClient=*/false); // Clang expects this to be like an actual command line. So we need to pass in @@ -351,7 +353,7 @@ bool ide::initInvocationByClangArguments(ArrayRef ArgList, if (!PPOpts.ImplicitPCHInclude.empty()) { clang::FileSystemOptions FileSysOpts; - clang::FileManager FileMgr(FileSysOpts); + clang::FileManager FileMgr(FileSysOpts, VFS); auto PCHContainerOperations = std::make_shared(); std::string HeaderFile = clang::ASTReader::getOriginalSourceFile( diff --git a/lib/IRGen/CallEmission.h b/lib/IRGen/CallEmission.h index 89ac2baa265f7..e6c6ac8b36ebd 100644 --- a/lib/IRGen/CallEmission.h +++ b/lib/IRGen/CallEmission.h @@ -152,11 +152,12 @@ class CallEmission { WitnessMetadata *witnessMetadata); virtual Address getCalleeErrorSlot(SILType errorType, bool isCalleeAsync) = 0; - void addFnAttribute(llvm::Attribute::AttrKind Attr); + void addFnAttribute(llvm::Attribute::AttrKind kind); void setIndirectReturnAddress(Address addr) { indirectReturnAddress = addr; } - void addParamAttribute(unsigned ParamIndex, llvm::Attribute::AttrKind Attr); + void addParamAttribute(unsigned paramIndex, llvm::Attribute::AttrKind kind); + void addParamAttribute(unsigned paramIndex, llvm::Attribute attr); void emitToMemory(Address addr, const LoadableTypeInfo &substResultTI, bool isOutlined); diff --git a/lib/IRGen/GenCall.cpp b/lib/IRGen/GenCall.cpp index e16a714a2e847..79e0a9b3f6ca2 100644 --- a/lib/IRGen/GenCall.cpp +++ b/lib/IRGen/GenCall.cpp @@ -317,7 +317,7 @@ static void addIndirectValueParameterAttributes(IRGenModule &IGM, // Bitwise takable value types are guaranteed not to capture // a pointer into itself. if (!addressable && ti.isBitwiseTakable(ResilienceExpansion::Maximal)) - b.addAttribute(llvm::Attribute::NoCapture); + b.addCapturesAttr(llvm::CaptureInfo::none()); // The parameter must reference dereferenceable memory of the type. addDereferenceableAttributeToBuilder(IGM, b, ti); @@ -330,7 +330,7 @@ static void addPackParameterAttributes(IRGenModule &IGM, unsigned argIndex) { llvm::AttrBuilder b(IGM.getLLVMContext()); // Pack parameter pointers can't alias. - // Note: they are not marked `nocapture` as one + // Note: they are not marked `captures(none)` as one // pack parameter could be a value type (e.g. a C++ type) // that captures its own pointer in itself. b.addAttribute(llvm::Attribute::NoAlias); @@ -357,7 +357,7 @@ static void addInoutParameterAttributes(IRGenModule &IGM, SILType paramSILType, // Bitwise takable value types are guaranteed not to capture // a pointer into itself. if (!addressable && ti.isBitwiseTakable(ResilienceExpansion::Maximal)) - b.addAttribute(llvm::Attribute::NoCapture); + b.addCapturesAttr(llvm::CaptureInfo::none()); // The inout must reference dereferenceable memory of the type. addDereferenceableAttributeToBuilder(IGM, b, ti); @@ -411,7 +411,7 @@ static void addIndirectResultAttributes(IRGenModule &IGM, // Bitwise takable value types are guaranteed not to capture // a pointer into itself. if (typeInfo.isBitwiseTakable(ResilienceExpansion::Maximal)) - b.addAttribute(llvm::Attribute::NoCapture); + b.addCapturesAttr(llvm::CaptureInfo::none()); if (allowSRet) { assert(storageType); b.addStructRetAttr(storageType); @@ -530,7 +530,7 @@ void IRGenModule::addSwiftErrorAttributes(llvm::AttributeList &attrs, // The error result should not be aliased, captured, or pointed at invalid // addresses regardless. b.addAttribute(llvm::Attribute::NoAlias); - b.addAttribute(llvm::Attribute::NoCapture); + b.addCapturesAttr(llvm::CaptureInfo::none()); b.addDereferenceableAttr(getPointerSize().getValue()); attrs = attrs.addParamAttributes(this->getLLVMContext(), argIndex, b); @@ -1213,6 +1213,7 @@ namespace { } case clang::Type::ArrayParameter: + case clang::Type::HLSLAttributedResource: llvm_unreachable("HLSL type in ABI lowering"); @@ -1343,6 +1344,11 @@ namespace { #include "clang/Basic/AMDGPUTypes.def" llvm_unreachable("AMDGPU type in ABI lowering"); + // We should never see HLSL intangible types at all. +#define HLSL_INTANGIBLE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" + llvm_unreachable("HLSL intangible type in ABI lowering"); + // Handle all the integer types as opaque values. #define BUILTIN_TYPE(Id, SingletonId) #define SIGNED_TYPE(Id, SingletonId) \ @@ -1684,6 +1690,9 @@ void SignatureExpansion::expandExternalSignatureTypes() { paramTI.getStorageType(), paramTI); break; } + case clang::ParameterABI::HLSLOut: + case clang::ParameterABI::HLSLInOut: + llvm_unreachable("not implemented"); } // If the coercion type is a struct which can be flattened, we need to @@ -2854,7 +2863,9 @@ class SyncCallEmission final : public CallEmission { } } Args[--LastArgWritten] = errorResultSlot.getAddress(); - addParamAttribute(LastArgWritten, llvm::Attribute::NoCapture); + addParamAttribute(LastArgWritten, llvm::Attribute::getWithCaptureInfo( + IGF.IGM.getLLVMContext(), + llvm::CaptureInfo::none())); IGF.IGM.addSwiftErrorAttributes(CurCallee.getMutableAttributes(), LastArgWritten); @@ -5579,14 +5590,20 @@ void CallEmission::setArgs(Explosion &adjusted, bool isOutlined, } } -void CallEmission::addFnAttribute(llvm::Attribute::AttrKind attr) { +void CallEmission::addFnAttribute(llvm::Attribute::AttrKind kind) { assert(state == State::Emitting); auto &attrs = CurCallee.getMutableAttributes(); - attrs = attrs.addFnAttribute(IGF.IGM.getLLVMContext(), attr); + attrs = attrs.addFnAttribute(IGF.IGM.getLLVMContext(), kind); +} + +void CallEmission::addParamAttribute(unsigned paramIndex, + llvm::Attribute::AttrKind kind) { + addParamAttribute(paramIndex, + llvm::Attribute::get(IGF.IGM.getLLVMContext(), kind)); } void CallEmission::addParamAttribute(unsigned paramIndex, - llvm::Attribute::AttrKind attr) { + llvm::Attribute attr) { assert(state == State::Emitting); auto &attrs = CurCallee.getMutableAttributes(); attrs = attrs.addParamAttribute(IGF.IGM.getLLVMContext(), paramIndex, attr); diff --git a/lib/IRGen/GenPointerAuth.cpp b/lib/IRGen/GenPointerAuth.cpp index 9d094032747be..b28db161be422 100644 --- a/lib/IRGen/GenPointerAuth.cpp +++ b/lib/IRGen/GenPointerAuth.cpp @@ -26,6 +26,7 @@ #include "swift/SIL/TypeLowering.h" #include "clang/CodeGen/CodeGenABITypes.h" #include "llvm/ADT/APInt.h" +#include "llvm/Support/SipHash.h" #include "llvm/Support/raw_ostream.h" using namespace swift; @@ -324,16 +325,10 @@ PointerAuthInfo::getOtherDiscriminator(IRGenModule &IGM, llvm_unreachable("bad kind"); } -static llvm::ConstantInt *getDiscriminatorForHash(IRGenModule &IGM, - uint64_t rawHash) { - uint16_t reducedHash = (rawHash % 0xFFFF) + 1; - return llvm::ConstantInt::get(IGM.Int64Ty, reducedHash); -} - static llvm::ConstantInt *getDiscriminatorForString(IRGenModule &IGM, StringRef string) { - uint64_t rawHash = clang::CodeGen::computeStableStringHash(string); - return getDiscriminatorForHash(IGM, rawHash); + return llvm::ConstantInt::get(IGM.Int64Ty, + llvm::getPointerAuthStableSipHash(string)); } static std::string mangle(AssociatedTypeDecl *assocType) { @@ -570,7 +565,8 @@ static void hashStringForFunctionType(IRGenModule &IGM, CanSILFunctionType type, } } -static uint64_t getTypeHash(IRGenModule &IGM, CanSILFunctionType type) { +static llvm::ConstantInt *getTypeDiscriminator(IRGenModule &IGM, + CanSILFunctionType type) { // The hash we need to do here ignores: // - thickness, so that we can promote thin-to-thick without rehashing; // - error results, so that we can promote nonthrowing-to-throwing @@ -590,10 +586,11 @@ static uint64_t getTypeHash(IRGenModule &IGM, CanSILFunctionType type) { hashStringForFunctionType( IGM, type, Out, genericSig.getCanonicalSignature().getGenericEnvironment()); - return clang::CodeGen::computeStableStringHash(Out.str()); + return getDiscriminatorForString(IGM, Out.str()); } -static uint64_t getYieldTypesHash(IRGenModule &IGM, CanSILFunctionType type) { +static llvm::ConstantInt * +getCoroutineYieldTypesDiscriminator(IRGenModule &IGM, CanSILFunctionType type) { SmallString<32> buffer; llvm::raw_svector_ostream out(buffer); auto genericSig = type->getInvocationGenericSignature(); @@ -629,7 +626,7 @@ static uint64_t getYieldTypesHash(IRGenModule &IGM, CanSILFunctionType type) { out << ":"; } - return clang::CodeGen::computeStableStringHash(out.str()); + return getDiscriminatorForString(IGM, out.str()); } llvm::ConstantInt * @@ -649,8 +646,7 @@ PointerAuthEntity::getTypeDiscriminator(IRGenModule &IGM) const { llvm::ConstantInt *&cache = IGM.getPointerAuthCaches().Types[fnType]; if (cache) return cache; - auto hash = getTypeHash(IGM, fnType); - cache = getDiscriminatorForHash(IGM, hash); + cache = ::getTypeDiscriminator(IGM, fnType); return cache; } @@ -667,15 +663,6 @@ PointerAuthEntity::getTypeDiscriminator(IRGenModule &IGM) const { llvm_unreachable("invalid representation"); }; - auto getCoroutineYieldTypesDiscriminator = [&](CanSILFunctionType fnType) { - llvm::ConstantInt *&cache = IGM.getPointerAuthCaches().Types[fnType]; - if (cache) return cache; - - auto hash = getYieldTypesHash(IGM, fnType); - cache = getDiscriminatorForHash(IGM, hash); - return cache; - }; - switch (StoredKind) { case Kind::None: case Kind::Special: @@ -687,7 +674,13 @@ PointerAuthEntity::getTypeDiscriminator(IRGenModule &IGM) const { case Kind::CoroutineYieldTypes: { auto fnType = Storage.get(StoredKind); - return getCoroutineYieldTypesDiscriminator(fnType); + + llvm::ConstantInt *&cache = IGM.getPointerAuthCaches().Types[fnType]; + if (cache) + return cache; + + cache = getCoroutineYieldTypesDiscriminator(IGM, fnType); + return cache; } case Kind::CanSILFunctionType: { diff --git a/lib/IRGen/GenStruct.cpp b/lib/IRGen/GenStruct.cpp index 53b4fac82b31d..ed40a475d677b 100644 --- a/lib/IRGen/GenStruct.cpp +++ b/lib/IRGen/GenStruct.cpp @@ -1398,7 +1398,7 @@ class ClangRecordLowering { // Collect all of the following bitfields. unsigned bitStart = layout.getFieldOffset(clangField->getFieldIndex()); - unsigned bitEnd = bitStart + clangField->getBitWidthValue(ClangContext); + unsigned bitEnd = bitStart + clangField->getBitWidthValue(); while (cfi != cfe && (*cfi)->isBitField()) { clangField = *cfi++; @@ -1414,7 +1414,7 @@ class ClangRecordLowering { bitStart = nextStart; } - bitEnd = nextStart + clangField->getBitWidthValue(ClangContext); + bitEnd = nextStart + clangField->getBitWidthValue(); } addOpaqueBitField(bitStart, bitEnd); diff --git a/lib/IRGen/IRGen.cpp b/lib/IRGen/IRGen.cpp index 79de76923f69a..b9580fba1f112 100644 --- a/lib/IRGen/IRGen.cpp +++ b/lib/IRGen/IRGen.cpp @@ -85,7 +85,6 @@ #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/AlwaysInliner.h" #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h" -#include "llvm/Transforms/Instrumentation.h" #include "llvm/Transforms/Instrumentation/AddressSanitizer.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/SanitizerCoverage.h" @@ -93,6 +92,7 @@ #include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar/DCE.h" +#include "llvm/Transforms/Utils/Instrumentation.h" #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h" #include "llvm/IR/DiagnosticInfo.h" @@ -342,7 +342,8 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts, FPM.addPass(SwiftARCOptPass()); }); PB.registerOptimizerLastEPCallback([&](ModulePassManager &MPM, - OptimizationLevel Level) { + OptimizationLevel Level, + llvm::ThinOrFullLTOPhase) { if (Level != OptimizationLevel::O0) MPM.addPass(createModuleToFunctionPassAdaptor(SwiftARCContractPass())); if (Level == OptimizationLevel::O0) @@ -357,7 +358,8 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts, if (Opts.Sanitizers & SanitizerKind::Address) { PB.registerOptimizerLastEPCallback([&](ModulePassManager &MPM, - OptimizationLevel Level) { + OptimizationLevel Level, + llvm::ThinOrFullLTOPhase) { AddressSanitizerOptions ASOpts; ASOpts.CompileKernel = false; ASOpts.Recover = bool(Opts.SanitizersWithRecoveryInstrumentation & @@ -376,17 +378,19 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts, } if (Opts.Sanitizers & SanitizerKind::Thread) { - PB.registerOptimizerLastEPCallback( - [&](ModulePassManager &MPM, OptimizationLevel Level) { - MPM.addPass(ModuleThreadSanitizerPass()); - MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass())); - }); + PB.registerOptimizerLastEPCallback([&](ModulePassManager &MPM, + OptimizationLevel Level, + llvm::ThinOrFullLTOPhase) { + MPM.addPass(ModuleThreadSanitizerPass()); + MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass())); + }); } if (Opts.SanitizeCoverage.CoverageType != llvm::SanitizerCoverageOptions::SCK_None) { PB.registerOptimizerLastEPCallback([&](ModulePassManager &MPM, - OptimizationLevel Level) { + OptimizationLevel Level, + llvm::ThinOrFullLTOPhase) { std::vector allowlistFiles; std::vector ignorelistFiles; MPM.addPass(SanitizerCoveragePass(Opts.SanitizeCoverage, @@ -395,14 +399,15 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts, } if (RunSwiftSpecificLLVMOptzns && !Opts.DisableLLVMMergeFunctions) { - PB.registerOptimizerLastEPCallback( - [&](ModulePassManager &MPM, OptimizationLevel Level) { - if (Level != OptimizationLevel::O0) { - const PointerAuthSchema &schema = Opts.PointerAuth.FunctionPointers; - unsigned key = (schema.isEnabled() ? schema.getKey() : 0); - MPM.addPass(SwiftMergeFunctionsPass(schema.isEnabled(), key)); - } - }); + PB.registerOptimizerLastEPCallback([&](ModulePassManager &MPM, + OptimizationLevel Level, + llvm::ThinOrFullLTOPhase) { + if (Level != OptimizationLevel::O0) { + const PointerAuthSchema &schema = Opts.PointerAuth.FunctionPointers; + unsigned key = (schema.isEnabled() ? schema.getKey() : 0); + MPM.addPass(SwiftMergeFunctionsPass(schema.isEnabled(), key)); + } + }); } if (Opts.GenerateProfile) { @@ -424,7 +429,13 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts, bool isThinLTO = Opts.LLVMLTOKind == IRGenLLVMLTOKind::Thin; bool isFullLTO = Opts.LLVMLTOKind == IRGenLLVMLTOKind::Full; if (!Opts.shouldOptimize() || Opts.DisableLLVMOptzns) { - MPM = PB.buildO0DefaultPipeline(level, isFullLTO || isThinLTO); + auto phase = llvm::ThinOrFullLTOPhase::None; + if (isFullLTO) { + phase = llvm::ThinOrFullLTOPhase::FullLTOPreLink; + } else if (isThinLTO) { + phase = llvm::ThinOrFullLTOPhase::ThinLTOPreLink; + } + MPM = PB.buildO0DefaultPipeline(level, phase); } else if (isThinLTO) { MPM = PB.buildThinLTOPreLinkDefaultPipeline(level); } else if (isFullLTO) { @@ -1169,8 +1180,8 @@ static void embedBitcode(llvm::Module *M, const IRGenOptions &Opts) static void initLLVMModule(const IRGenModule &IGM, SILModule &SIL) { auto *Module = IGM.getModule(); assert(Module && "Expected llvm:Module for IR generation!"); - - Module->setTargetTriple(IGM.Triple.str()); + + Module->setTargetTriple(IGM.Triple); if (IGM.Context.LangOpts.SDKVersion) { if (Module->getSDKVersion().empty()) diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index 7533bb622ef66..aaab7fbea881b 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -1949,7 +1949,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { nullptr, PtrSize, 0, /* DWARFAddressSpace */ std::nullopt, MangledName); - return DBuilder.createObjectPointerType(PTy); + return DBuilder.createObjectPointerType(PTy, /*Implicit=*/true); } case TypeKind::BuiltinExecutor: { return createDoublePointerSizedStruct( @@ -3861,19 +3861,23 @@ void IRGenDebugInfoImpl::emitDbgIntrinsic( } // Insert a dbg.value at the current insertion point. - if (isa(Storage) && !Var->getArg() && - ParentBlock->getFirstNonPHIOrDbg()) - // SelectionDAGISel only generates debug info for a dbg.value - // that is associated with a llvm::Argument if either its !DIVariable - // is marked as argument or there is no non-debug intrinsic instruction - // before it. So In the case of associating a llvm::Argument with a - // non-argument debug variable -- usually via a !DIExpression -- we - // need to make sure that dbg.value is before any non-phi / no-dbg - // instruction. - DBuilder.insertDbgValueIntrinsic(Storage, Var, Expr, DL, - ParentBlock->getFirstNonPHIOrDbg()); - else - DBuilder.insertDbgValueIntrinsic(Storage, Var, Expr, DL, ParentBlock); + if (isa(Storage) && !Var->getArg()) { + const auto InsertPt = ParentBlock->getFirstNonPHIOrDbg(); + if (InsertPt != ParentBlock->end()) { + // SelectionDAGISel only generates debug info for a dbg.value + // that is associated with a llvm::Argument if either its !DIVariable + // is marked as argument or there is no non-debug intrinsic instruction + // before it. So In the case of associating a llvm::Argument with a + // non-argument debug variable -- usually via a !DIExpression -- we + // need to make sure that dbg.value is before any non-phi / no-dbg + // instruction. + DBuilder.insertDbgValueIntrinsic(Storage, Var, Expr, DL, InsertPt); + + return; + } + } + + DBuilder.insertDbgValueIntrinsic(Storage, Var, Expr, DL, ParentBlock->end()); } void IRGenDebugInfoImpl::emitGlobalVariableDeclaration( diff --git a/lib/IRGen/IRGenModule.cpp b/lib/IRGen/IRGenModule.cpp index a3a4ba6857b68..2fe0fb8929981 100644 --- a/lib/IRGen/IRGenModule.cpp +++ b/lib/IRGen/IRGenModule.cpp @@ -2443,7 +2443,7 @@ bool swift::writeEmptyOutputFilesFor( auto *clangImporter = static_cast( Context.getClangModuleLoader()); llvmModule->setTargetTriple( - clangImporter->getTargetInfo().getTargetOpts().Triple); + llvm::Triple(clangImporter->getTargetInfo().getTargetOpts().Triple)); // Add LLVM module flags. auto &clangASTContext = clangImporter->getClangASTContext(); diff --git a/lib/Immediate/SwiftMaterializationUnit.cpp b/lib/Immediate/SwiftMaterializationUnit.cpp index 7203a8ab141c8..0465188f2b270 100644 --- a/lib/Immediate/SwiftMaterializationUnit.cpp +++ b/lib/Immediate/SwiftMaterializationUnit.cpp @@ -197,11 +197,11 @@ renameFunctionBodies(llvm::orc::MaterializationResponsibility &MR, if (!Sym->hasName() || !Sym->isCallable()) continue; - if (ToRename.count(Sym->getName())) { - // FIXME: Get rid of the temporary when Swift's llvm-project is - // updated to LLVM 17. - auto NewName = G.allocateCString(Twine(mangle(Sym->getName()))); - Sym->setName({NewName.data(), NewName.size() - 1}); + const StringRef Name = *Sym->getName(); + + if (ToRename.count(Name)) { + auto NewName = G.intern(mangle(Name)); + Sym->setName(NewName); } } } diff --git a/lib/LLVMPasses/ARCEntryPointBuilder.h b/lib/LLVMPasses/ARCEntryPointBuilder.h index 6811d8c405b0a..33290a95d7471 100644 --- a/lib/LLVMPasses/ARCEntryPointBuilder.h +++ b/lib/LLVMPasses/ARCEntryPointBuilder.h @@ -252,11 +252,16 @@ class ARCEntryPointBuilder { auto *ObjectPtrTy = getObjectPtrTy(); auto &M = getModule(); - auto AttrList = AttributeList::get(M.getContext(), 1, Attribute::NoCapture); - AttrList = AttrList.addFnAttribute(M.getContext(), Attribute::NoUnwind); + auto &C = M.getContext(); + + AttributeList AttrList; + AttrList = AttrList.addFnAttribute(C, Attribute::NoUnwind); + AttrList = AttrList.addParamAttribute( + C, 0, Attribute::getWithCaptureInfo(C, llvm::CaptureInfo::none())); + CheckUnowned = cast( M.getOrInsertFunction("swift_checkUnowned", AttrList, - Type::getVoidTy(M.getContext()), ObjectPtrTy) + Type::getVoidTy(C), ObjectPtrTy) .getCallee()); if (llvm::Triple(M.getTargetTriple()).isOSBinFormatCOFF() && !llvm::Triple(M.getTargetTriple()).isOSCygMing()) diff --git a/lib/LLVMPasses/LLVMMergeFunctions.cpp b/lib/LLVMPasses/LLVMMergeFunctions.cpp index 3f53edfa891ad..7f33a935d5676 100644 --- a/lib/LLVMPasses/LLVMMergeFunctions.cpp +++ b/lib/LLVMPasses/LLVMMergeFunctions.cpp @@ -30,7 +30,6 @@ #include "swift/Basic/Assertions.h" #include "swift/LLVMPasses/Passes.h" -#include "clang/AST/StableHash.h" #include "clang/Basic/PointerAuthOptions.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/FoldingSet.h" @@ -55,6 +54,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/SipHash.h" #include "llvm/TargetParser/Triple.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Utils/FunctionComparator.h" @@ -258,7 +258,7 @@ class SwiftMergeFunctions { FunctionEntry *First; /// A very cheap hash, used to early exit if functions do not match. - llvm::IRHash Hash; + llvm::stable_hash Hash; public: // Note the hash is recalculated potentially multiple times, but it is cheap. @@ -416,9 +416,10 @@ class SwiftMergeFunctions { if (auto *GO = dyn_cast(value)) concatenatedCalleeNames += GO->getName(); } - uint64_t rawHash = clang::getStableStringHash(concatenatedCalleeNames); + uint64_t hash = + llvm::getPointerAuthStableSipHash(concatenatedCalleeNames); IntegerType *discrTy = Type::getInt64Ty(Context); - discriminator = ConstantInt::get(discrTy, (rawHash % 0xFFFF) + 1); + discriminator = ConstantInt::get(discrTy, hash); } }; @@ -713,7 +714,7 @@ 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)) { @@ -721,10 +722,11 @@ bool SwiftMergeFunctions::runOnModule(Module &M) { } } - std::stable_sort( - HashedFuncs.begin(), HashedFuncs.end(), - [](const std::pair &a, - const std::pair &b) { return a.first < b.first; }); + std::stable_sort(HashedFuncs.begin(), HashedFuncs.end(), + [](const std::pair &a, + const std::pair &b) { + return a.first < b.first; + }); std::vector FuncEntryStorage; FuncEntryStorage.reserve(HashedFuncs.size()); diff --git a/lib/Migrator/APIDiffMigratorPass.cpp b/lib/Migrator/APIDiffMigratorPass.cpp index 97110502ef59e..dd60b9de657f0 100644 --- a/lib/Migrator/APIDiffMigratorPass.cpp +++ b/lib/Migrator/APIDiffMigratorPass.cpp @@ -29,7 +29,7 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Edit/EditedSource.h" -#include "clang/Rewrite/Core/RewriteBuffer.h" +#include "llvm/ADT/RewriteBuffer.h" #include "llvm/Support/FileSystem.h" using namespace swift; diff --git a/lib/Migrator/Migrator.cpp b/lib/Migrator/Migrator.cpp index 7549d14200480..034c056dc370a 100644 --- a/lib/Migrator/Migrator.cpp +++ b/lib/Migrator/Migrator.cpp @@ -21,7 +21,7 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Edit/EditedSource.h" -#include "clang/Rewrite/Core/RewriteBuffer.h" +#include "llvm/ADT/RewriteBuffer.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" diff --git a/lib/Option/Options.cpp b/lib/Option/Options.cpp index 6a159de3150ba..5a334e131bcc1 100644 --- a/lib/Option/Options.cpp +++ b/lib/Option/Options.cpp @@ -16,15 +16,16 @@ #include "llvm/Option/OptTable.h" #include "llvm/Option/Option.h" -using namespace swift::options; -using namespace llvm::opt; +#define OPTTABLE_STR_TABLE_CODE +#include "swift/Option/Options.inc" +#undef OPTTABLE_STR_TABLE_CODE -#define PREFIX(NAME, VALUE) \ - constexpr llvm::StringLiteral NAME##_init[] = VALUE; \ - constexpr llvm::ArrayRef NAME( \ - NAME##_init, std::size(NAME##_init) - 1); +#define OPTTABLE_PREFIXES_TABLE_CODE #include "swift/Option/Options.inc" -#undef PREFIX +#undef OPTTABLE_PREFIXES_TABLE_CODE + +using namespace swift::options; +using namespace llvm::opt; static const llvm::opt::GenericOptTable::Info InfoTable[] = { #define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__), @@ -36,7 +37,8 @@ namespace { class SwiftOptTable : public llvm::opt::GenericOptTable { public: - SwiftOptTable() : GenericOptTable(InfoTable) {} + SwiftOptTable() + : GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable) {} }; } // end anonymous namespace diff --git a/lib/SIL/IR/SILInstructions.cpp b/lib/SIL/IR/SILInstructions.cpp index da4c39e2e3872..eb7bbe82bfc59 100644 --- a/lib/SIL/IR/SILInstructions.cpp +++ b/lib/SIL/IR/SILInstructions.cpp @@ -1145,7 +1145,9 @@ IntegerLiteralInst *IntegerLiteralInst::create(SILDebugLocation Loc, static APInt getAPInt(AnyBuiltinIntegerType *anyIntTy, intmax_t value) { // If we're forming a fixed-width type, build using the greatest width. if (auto intTy = dyn_cast(anyIntTy)) - return APInt(intTy->getGreatestWidth(), value); + // TODO: Avoid implicit trunc? + return APInt(intTy->getGreatestWidth(), value, /*isSigned=*/false, + /*implicitTrunc=*/true); // Otherwise, build using the size of the type and then truncate to the // minimum width necessary. diff --git a/lib/SILOptimizer/Analysis/ColdBlockInfo.cpp b/lib/SILOptimizer/Analysis/ColdBlockInfo.cpp index f42fe7b60d449..9fde5f1ea0431 100644 --- a/lib/SILOptimizer/Analysis/ColdBlockInfo.cpp +++ b/lib/SILOptimizer/Analysis/ColdBlockInfo.cpp @@ -441,7 +441,7 @@ bool ColdBlockInfo::isCold(const SILBasicBlock *BB) const { } void ColdBlockInfo::resetToCold(const SILBasicBlock *BB) { - auto &entry = EnergyMap.getOrInsertDefault(BB); + auto &entry = EnergyMap[BB]; if (isColdEnergy(entry)) return; @@ -451,7 +451,7 @@ void ColdBlockInfo::resetToCold(const SILBasicBlock *BB) { } void ColdBlockInfo::set(const SILBasicBlock *BB, State::Temperature temp) { - auto &entry = EnergyMap.getOrInsertDefault(BB); + auto &entry = EnergyMap[BB]; if (entry.contains(temp)) return; diff --git a/test/IRGen/annotated_cond_fail.swift b/test/IRGen/annotated_cond_fail.swift index bb754384aa3c9..ef50e578426da 100644 --- a/test/IRGen/annotated_cond_fail.swift +++ b/test/IRGen/annotated_cond_fail.swift @@ -19,7 +19,7 @@ public func test(_ a: [Int], _ i: Int) -> Int { // CHECK: [[SIZE_ADDR:%.*]] = getelementptr // CHECK: [[SIZE:%.*]] = load i64, ptr [[SIZE_ADDR]] -// CHECK: [[C1:%.*]] = icmp ult i64 [[IDX]], [[SIZE]] +// CHECK: [[C1:%.*]] = icmp samesign ult i64 [[IDX]], [[SIZE]] // CHECK: br i1 [[C1]], {{.*}}!annotation ![[ARRAY_INDEX_OUT_OF_BOUNDS]] diff --git a/test/IRGen/argument_attrs.sil b/test/IRGen/argument_attrs.sil index ee82eb7eb4ddb..4e2a98d6b732f 100644 --- a/test/IRGen/argument_attrs.sil +++ b/test/IRGen/argument_attrs.sil @@ -4,49 +4,49 @@ import Builtin struct Huge { var x, y, z, w, a, b, c, d, e, f: Builtin.Int32 } -// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @arguments_in_def(ptr nocapture dereferenceable(4) %0, ptr noalias nocapture dereferenceable(4) %1, ptr noalias nocapture dereferenceable(4) %2, ptr noalias nocapture dereferenceable(40) %3, ptr noalias %4, ptr noalias nocapture %5, ptr %T) +// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @arguments_in_def(ptr captures(none) dereferenceable(4) %0, ptr noalias captures(none) dereferenceable(4) %1, ptr noalias captures(none) dereferenceable(4) %2, ptr noalias captures(none) dereferenceable(40) %3, ptr noalias %4, ptr noalias captures(none) %5, ptr %T) sil @arguments_in_def : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> () { entry(%1 : $*Builtin.Int32, %2 : $*Builtin.Int32, %3 : $*Builtin.Int32, %4 : $Huge, %5 : $*T, %6 : $*()): - // CHECK: call swiftcc void @arguments_in_decl(ptr nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(40) {{%.*}}, ptr noalias {{%.*}}, ptr noalias nocapture {{%.*}}, ptr %T) + // CHECK: call swiftcc void @arguments_in_decl(ptr captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(40) {{%.*}}, ptr noalias {{%.*}}, ptr noalias captures(none) {{%.*}}, ptr %T) %f = function_ref @arguments_in_decl : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> () %x = apply %f(%1, %2, %3, %4, %5, %6) : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> () - // CHECK: call swiftcc void @arguments_in_def(ptr nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(40) {{%.*}}, ptr noalias {{%.*}}, ptr noalias nocapture {{%.*}}, ptr %T) + // CHECK: call swiftcc void @arguments_in_def(ptr captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(40) {{%.*}}, ptr noalias {{%.*}}, ptr noalias captures(none) {{%.*}}, ptr %T) %g = function_ref @arguments_in_def : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> () %y = apply %g(%1, %2, %3, %4, %5, %6) : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> () return undef : $() } -// CHECK-LABEL: declare{{( dllimport)?}} swiftcc void @arguments_in_decl(ptr nocapture dereferenceable(4), ptr noalias nocapture dereferenceable(4), ptr noalias nocapture dereferenceable(4), ptr noalias nocapture dereferenceable(40), ptr noalias, ptr noalias nocapture, ptr) +// CHECK-LABEL: declare{{( dllimport)?}} swiftcc void @arguments_in_decl(ptr captures(none) dereferenceable(4), ptr noalias captures(none) dereferenceable(4), ptr noalias captures(none) dereferenceable(4), ptr noalias captures(none) dereferenceable(40), ptr noalias, ptr noalias captures(none), ptr) sil @arguments_in_decl : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> () -// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @arguments_in_def_out(ptr noalias nocapture sret({{.*}}) %0, ptr nocapture dereferenceable(4) %1, ptr noalias nocapture dereferenceable(4) %2, ptr noalias nocapture dereferenceable(4) %3, ptr noalias nocapture dereferenceable(40) %4, ptr noalias %5, ptr noalias nocapture %6, ptr %T) +// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @arguments_in_def_out(ptr noalias sret({{.*}}) captures(none) %0, ptr captures(none) dereferenceable(4) %1, ptr noalias captures(none) dereferenceable(4) %2, ptr noalias captures(none) dereferenceable(4) %3, ptr noalias captures(none) dereferenceable(40) %4, ptr noalias %5, ptr noalias captures(none) %6, ptr %T) sil @arguments_in_def_out : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> @out Builtin.Int32 { entry(%0 : $*Builtin.Int32, %1 : $*Builtin.Int32, %2 : $*Builtin.Int32, %3 : $*Builtin.Int32, %4 : $Huge, %5 : $*T, %6 : $*()): - // CHECK: call swiftcc void @arguments_in_decl_out(ptr noalias nocapture sret({{.*}}) {{%.*}}, ptr nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(40) {{%.*}}, ptr noalias {{%.*}}, ptr noalias nocapture {{%.*}}, ptr {{%.*}}) + // CHECK: call swiftcc void @arguments_in_decl_out(ptr noalias sret({{.*}}) captures(none) {{%.*}}, ptr captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(40) {{%.*}}, ptr noalias {{%.*}}, ptr noalias captures(none) {{%.*}}, ptr {{%.*}}) %f = function_ref @arguments_in_decl_out : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> @out Builtin.Int32 %x = apply %f(%0, %1, %2, %3, %4, %5, %6) : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> @out Builtin.Int32 - // CHECK: call swiftcc void @arguments_in_def_out(ptr noalias nocapture sret({{.*}}) {{%.*}}, ptr nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(40) {{%.*}}, ptr noalias {{%.*}}, ptr noalias nocapture {{%.*}}, ptr {{%.*}}) + // CHECK: call swiftcc void @arguments_in_def_out(ptr noalias sret({{.*}}) captures(none) {{%.*}}, ptr captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(40) {{%.*}}, ptr noalias {{%.*}}, ptr noalias captures(none) {{%.*}}, ptr {{%.*}}) %g = function_ref @arguments_in_def_out : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> @out Builtin.Int32 %y = apply %g(%0, %1, %2, %3, %4, %5, %6) : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> @out Builtin.Int32 return undef : $() } -// CHECK-LABEL: declare{{( dllimport)?}} swiftcc void @arguments_in_decl_out(ptr noalias nocapture sret({{.*}}), ptr nocapture dereferenceable(4), ptr noalias nocapture dereferenceable(4), ptr noalias nocapture dereferenceable(4), ptr noalias nocapture dereferenceable(40), ptr noalias, ptr noalias nocapture, ptr) +// CHECK-LABEL: declare{{( dllimport)?}} swiftcc void @arguments_in_decl_out(ptr noalias sret({{.*}}) captures(none), ptr captures(none) dereferenceable(4), ptr noalias captures(none) dereferenceable(4), ptr noalias captures(none) dereferenceable(4), ptr noalias captures(none) dereferenceable(40), ptr noalias, ptr noalias captures(none), ptr) sil @arguments_in_decl_out : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> @out Builtin.Int32 -// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @arguments_in_def_huge_ret(ptr noalias nocapture sret({{.*}}V) %0, ptr nocapture dereferenceable(4) %1, ptr noalias nocapture dereferenceable(4) %2, ptr noalias nocapture dereferenceable(4) %3, ptr noalias nocapture dereferenceable(40) %4, ptr noalias %5, ptr noalias nocapture %6, ptr %T) +// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @arguments_in_def_huge_ret(ptr noalias sret({{.*}}V) captures(none) %0, ptr captures(none) dereferenceable(4) %1, ptr noalias captures(none) dereferenceable(4) %2, ptr noalias captures(none) dereferenceable(4) %3, ptr noalias captures(none) dereferenceable(40) %4, ptr noalias %5, ptr noalias captures(none) %6, ptr %T) sil @arguments_in_def_huge_ret : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> Huge { entry(%1 : $*Builtin.Int32, %2 : $*Builtin.Int32, %3 : $*Builtin.Int32, %4 : $Huge, %5 : $*T, %6 : $*()): %f = function_ref @arguments_in_decl_huge_ret : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> Huge - // CHECK: call swiftcc void @arguments_in_decl_huge_ret(ptr noalias nocapture sret({{.*}}) {{%.*}}, ptr nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(40) {{%.*}}, ptr noalias {{%.*}}, ptr noalias nocapture {{%.*}}, ptr {{%.*}}) + // CHECK: call swiftcc void @arguments_in_decl_huge_ret(ptr noalias sret({{.*}}) captures(none) {{%.*}}, ptr captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(40) {{%.*}}, ptr noalias {{%.*}}, ptr noalias captures(none) {{%.*}}, ptr {{%.*}}) %x = apply %f(%1, %2, %3, %4, %5, %6) : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> Huge - // CHECK: call swiftcc void @arguments_in_def_huge_ret(ptr noalias nocapture sret({{.*}}) {{%.*}}, ptr nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(4) {{%.*}}, ptr noalias nocapture dereferenceable(40) {{%.*}}, ptr noalias {{%.*}}, ptr noalias nocapture {{%.*}}, ptr {{%.*}}) + // CHECK: call swiftcc void @arguments_in_def_huge_ret(ptr noalias sret({{.*}}) captures(none) {{%.*}}, ptr captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(4) {{%.*}}, ptr noalias captures(none) dereferenceable(40) {{%.*}}, ptr noalias {{%.*}}, ptr noalias captures(none) {{%.*}}, ptr {{%.*}}) %g = function_ref @arguments_in_def_huge_ret : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> Huge %y = apply %g(%1, %2, %3, %4, %5, %6) : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> Huge return %y : $Huge } -// CHECK-LABEL: declare{{( dllimport)?}} swiftcc void @arguments_in_decl_huge_ret(ptr noalias nocapture sret({{.*}}), ptr nocapture dereferenceable(4), ptr noalias nocapture dereferenceable(4), ptr noalias nocapture dereferenceable(4), ptr noalias nocapture dereferenceable(40), ptr noalias, ptr noalias nocapture, ptr) +// CHECK-LABEL: declare{{( dllimport)?}} swiftcc void @arguments_in_decl_huge_ret(ptr noalias sret({{.*}}) captures(none), ptr captures(none) dereferenceable(4), ptr noalias captures(none) dereferenceable(4), ptr noalias captures(none) dereferenceable(4), ptr noalias captures(none) dereferenceable(40), ptr noalias, ptr noalias captures(none), ptr) sil @arguments_in_decl_huge_ret : $@convention(thin) (@inout Builtin.Int32, @in Builtin.Int32, @in_guaranteed Builtin.Int32, Huge, @in T, @in ()) -> Huge diff --git a/test/IRGen/integer-comparison.swift b/test/IRGen/integer-comparison.swift index ac7d4677ce13a..d5052c461cf4c 100644 --- a/test/IRGen/integer-comparison.swift +++ b/test/IRGen/integer-comparison.swift @@ -4,11 +4,11 @@ func f(_ x: Int, _ y: UInt32) -> Bool { x < y } // CHECK-LABEL: define {{.*}} @"$s4main1fySbSi_s6UInt32VtF"(i64 %0, i32 %1) // CHECK: %2 = zext i32 %1 to i64 -// CHECK-NEXT: %3 = icmp sgt i64 %2, %0 +// CHECK-NEXT: %3 = icmp slt i64 %0, %2 // CHECK-NEXT: ret i1 %3 func g(_ x: UInt32, _ y: Int) -> Bool { x < y } // CHECK-LABEL: define {{.*}} @"$s4main1gySbs6UInt32V_SitF"(i32 %0, i64 %1) // CHECK: %2 = zext i32 %0 to i64 -// CHECK-NEXT: %3 = icmp slt i64 %2, %1 +// CHECK-NEXT: %3 = icmp sgt i64 %1, %2 // CHECK-NEXT: ret i1 %3 diff --git a/test/LLVMPasses/allocation-deletion.ll b/test/LLVMPasses/allocation-deletion.ll index 81d9b181dc576..3dc2ebb2ad3f7 100644 --- a/test/LLVMPasses/allocation-deletion.ll +++ b/test/LLVMPasses/allocation-deletion.ll @@ -7,7 +7,7 @@ target triple = "x86_64-apple-macosx10.9" %swift.heapmetadata = type { ptr, ptr } declare ptr @swift_allocObject(ptr , i64, i64) nounwind -declare void @swift_release(ptr nocapture) +declare void @swift_release(ptr captures(none)) declare void @swift_retain(ptr ) nounwind declare { i64, i64, i64 } @swift_retainAndReturnThree(ptr , i64, i64 , i64 ) @@ -36,7 +36,7 @@ entry: ; trivial_alloc_eliminate1 - Show that we can eliminate an allocation with a ; trivial destructor. @trivial_dtor_metadata = internal constant %swift.heapmetadata { ptr @trivial_dtor, ptr null } -define internal i64 @trivial_dtor(ptr nocapture) nounwind readonly { +define internal i64 @trivial_dtor(ptr captures(none)) nounwind readonly { entry: %1 = getelementptr inbounds %swift.refcounted, ptr %0, i64 1 %length = load i64, ptr %1, align 8 @@ -59,7 +59,7 @@ entry: ; trivial_alloc_eliminate2 - Show that we can eliminate an allocation with a ; destructor that does a retain on the 'self' object. @trivial_dtor_metadata2 = internal constant %swift.heapmetadata { ptr @trivial_dtor2, ptr null } -define internal i64 @trivial_dtor2(ptr nocapture %this) nounwind readonly { +define internal i64 @trivial_dtor2(ptr captures(none) %this) nounwind readonly { entry: %0 = getelementptr inbounds %swift.refcounted, ptr %this, i64 1, i32 0 store ptr inttoptr (i64 4 to ptr), ptr %0, align 8 diff --git a/test/LLVMPasses/basic.ll b/test/LLVMPasses/basic.ll index be8b54b3e16dc..f53e1f9fc66a1 100644 --- a/test/LLVMPasses/basic.ll +++ b/test/LLVMPasses/basic.ll @@ -16,7 +16,7 @@ declare void @swift_unknownObjectRelease(ptr) declare ptr @llvm.objc.retain(ptr) declare void @llvm.objc.release(ptr) declare ptr @swift_allocObject(ptr , i64, i64) nounwind -declare void @swift_release(ptr nocapture) +declare void @swift_release(ptr captures(none)) declare ptr @swift_retain(ptr returned) nounwind declare ptr @swift_bridgeObjectRetain(ptr) declare void @swift_bridgeObjectRelease(ptr) diff --git a/test/LLVMPasses/contract.ll b/test/LLVMPasses/contract.ll index d5081e5c9e3f9..23c05a02096b3 100644 --- a/test/LLVMPasses/contract.ll +++ b/test/LLVMPasses/contract.ll @@ -10,9 +10,9 @@ target triple = "x86_64-apple-macosx10.9" declare ptr @swift_allocObject(ptr , i64, i64) nounwind declare ptr @swift_bridgeObjectRetain(ptr) declare void @swift_bridgeObjectRelease(ptr ) -declare void @swift_release(ptr nocapture) +declare void @swift_release(ptr captures(none)) declare ptr @swift_retain(ptr ) nounwind -declare void @swift_unknownObjectRelease(ptr nocapture) +declare void @swift_unknownObjectRelease(ptr captures(none)) declare ptr @swift_unknownObjectRetain(ptr ) nounwind declare void @__swift_fixLifetime(ptr) declare void @noread_user(ptr) readnone diff --git a/test/LLVMPasses/crash.ll b/test/LLVMPasses/crash.ll index 020ce65262495..1aa748c1a9254 100644 --- a/test/LLVMPasses/crash.ll +++ b/test/LLVMPasses/crash.ll @@ -8,7 +8,7 @@ target triple = "x86_64-apple-macosx10.9" declare { ptr, i64, ptr } @_Tsop1pFT3lhsNs6String3rhsS__S_(ptr, i64, ptr, ptr, i64, ptr) declare { ptr, i64, ptr } @_TNs6String24convertFromStringLiteralFT3valp_S_(ptr) -declare void @swift_release(ptr nocapture) +declare void @swift_release(ptr captures(none)) @0 = private unnamed_addr constant [3 x i8] c"So\00" diff --git a/test/LLVMPasses/disable_llvm_optzns.ll b/test/LLVMPasses/disable_llvm_optzns.ll index e71f22ae88a5f..c0a4ba020c4bd 100644 --- a/test/LLVMPasses/disable_llvm_optzns.ll +++ b/test/LLVMPasses/disable_llvm_optzns.ll @@ -16,7 +16,7 @@ declare void @swift_unknownObjectRelease(ptr) declare ptr @llvm.objc.retain(ptr) declare void @llvm.objc.release(ptr) declare ptr @swift_allocObject(ptr , i64, i64) nounwind -declare void @swift_release(ptr nocapture) +declare void @swift_release(ptr captures(none)) declare ptr @swift_retain(ptr returned) nounwind declare ptr @swift_bridgeObjectRetain(ptr) declare void @swift_bridgeObjectRelease(ptr) diff --git a/test/LLVMPasses/missing_runtime_declarations.ll b/test/LLVMPasses/missing_runtime_declarations.ll index 3b5c20414afc0..f20263bc8472f 100644 --- a/test/LLVMPasses/missing_runtime_declarations.ll +++ b/test/LLVMPasses/missing_runtime_declarations.ll @@ -3,11 +3,11 @@ target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-apple-macosx10.9" -; CHECK: declare void @swift_bridgeObjectRelease(ptr nocapture) +; CHECK: declare void @swift_bridgeObjectRelease(ptr captures(none)) %a = type opaque -declare void @swift_bridgeObjectRelease(ptr nocapture) -declare ptr @swift_bridgeObjectRetain(ptr nocapture) +declare void @swift_bridgeObjectRelease(ptr captures(none)) +declare ptr @swift_bridgeObjectRetain(ptr captures(none)) ; CHECK-LABEL: define void @testcase1(ptr %0) { ; CHECK: entry: diff --git a/test/LLVMPasses/release_motion_landingpad.ll b/test/LLVMPasses/release_motion_landingpad.ll index 3a3c5ae4045f9..f6bee19d82dc5 100644 --- a/test/LLVMPasses/release_motion_landingpad.ll +++ b/test/LLVMPasses/release_motion_landingpad.ll @@ -3,7 +3,7 @@ target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-apple-macosx10.9" -declare void @swift_release(ptr nocapture) +declare void @swift_release(ptr captures(none)) declare void @swift_retain(ptr) nounwind declare ptr @_Znwm(i64) declare i32 @__gxx_personality_v0(...) diff --git a/tools/SourceKit/lib/Support/ImmutableTextBuffer.cpp b/tools/SourceKit/lib/Support/ImmutableTextBuffer.cpp index 81a4623b1a93b..0ebf2619ba200 100644 --- a/tools/SourceKit/lib/Support/ImmutableTextBuffer.cpp +++ b/tools/SourceKit/lib/Support/ImmutableTextBuffer.cpp @@ -11,13 +11,13 @@ //===----------------------------------------------------------------------===// #include "SourceKit/Support/ImmutableTextBuffer.h" -#include "clang/Rewrite/Core/RewriteRope.h" +#include "llvm/ADT/RewriteRope.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/SourceMgr.h" using namespace SourceKit; using namespace llvm; -using clang::RewriteRope; +using llvm::RewriteRope; void ImmutableTextUpdate::anchor() {} diff --git a/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp b/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp index 14345dfbb40f6..90a696db11c73 100644 --- a/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp +++ b/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp @@ -35,13 +35,13 @@ enum Opt { #undef OPTION }; -// Create prefix string literals used in Options.td. -#define PREFIX(NAME, VALUE) \ - constexpr llvm::StringLiteral NAME##_init[] = VALUE; \ - constexpr llvm::ArrayRef NAME( \ - NAME##_init, std::size(NAME##_init) - 1); +#define OPTTABLE_STR_TABLE_CODE #include "Options.inc" -#undef PREFIX +#undef OPTTABLE_STR_TABLE_CODE + +#define OPTTABLE_PREFIXES_TABLE_CODE +#include "Options.inc" +#undef OPTTABLE_PREFIXES_TABLE_CODE // Create table mapping all options defined in Options.td. static const llvm::opt::OptTable::Info InfoTable[] = { @@ -53,7 +53,8 @@ static const llvm::opt::OptTable::Info InfoTable[] = { // Create OptTable class for parsing actual command line arguments class TestOptTable : public llvm::opt::GenericOptTable { public: - TestOptTable() : GenericOptTable(InfoTable) {} + TestOptTable() + : GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable) {} }; } // end anonymous namespace diff --git a/tools/swift-ide-test/swift-ide-test.cpp b/tools/swift-ide-test/swift-ide-test.cpp index ab3cd49d9b647..f7eb4d920d2eb 100644 --- a/tools/swift-ide-test/swift-ide-test.cpp +++ b/tools/swift-ide-test/swift-ide-test.cpp @@ -53,7 +53,7 @@ #include "swift/Markup/Markup.h" #include "swift/Parse/ParseVersion.h" #include "swift/Sema/IDETypeChecking.h" -#include "clang/Rewrite/Core/RewriteBuffer.h" +#include "llvm/ADT/RewriteBuffer.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/CommandLine.h" @@ -2082,7 +2082,7 @@ static int doDumpImporterLookupTables(const CompilerInvocation &InitInvok, class StructureAnnotator : public ide::SyntaxModelWalker { SourceManager &SM; unsigned BufferID; - clang::RewriteBuffer RewriteBuf; + llvm::RewriteBuffer RewriteBuf; std::vector NodeStack; CharSourceRange LastPoppedNodeRange;