diff --git a/benchmark/scripts/compare_perf_tests.py b/benchmark/scripts/compare_perf_tests.py index 57ad939720820..5c4af709da146 100755 --- a/benchmark/scripts/compare_perf_tests.py +++ b/benchmark/scripts/compare_perf_tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: utf-8 -*- # ===--- compare_perf_tests.py -------------------------------------------===// diff --git a/benchmark/scripts/test_Benchmark_Driver.py b/benchmark/scripts/test_Benchmark_Driver.py index 0f83eb74ca701..abc4ed18b3fea 100644 --- a/benchmark/scripts/test_Benchmark_Driver.py +++ b/benchmark/scripts/test_Benchmark_Driver.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: utf-8 -*- # ===--- test_Benchmark_Driver.py ----------------------------------------===// diff --git a/benchmark/scripts/test_compare_perf_tests.py b/benchmark/scripts/test_compare_perf_tests.py index 469c591afb3e2..20d821208f752 100644 --- a/benchmark/scripts/test_compare_perf_tests.py +++ b/benchmark/scripts/test_compare_perf_tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: utf-8 -*- # ===--- test_compare_perf_tests.py --------------------------------------===// diff --git a/benchmark/scripts/test_utils.py b/benchmark/scripts/test_utils.py index 70465f0b83d52..05ab9d2a5c6c8 100644 --- a/benchmark/scripts/test_utils.py +++ b/benchmark/scripts/test_utils.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: utf-8 -*- # ===--- test_utils.py ---------------------------------------------------===// diff --git a/include/swift/AST/ASTWalker.h b/include/swift/AST/ASTWalker.h index 994111f7ffdf4..a14877301d51d 100644 --- a/include/swift/AST/ASTWalker.h +++ b/include/swift/AST/ASTWalker.h @@ -13,6 +13,7 @@ #ifndef SWIFT_AST_ASTWALKER_H #define SWIFT_AST_ASTWALKER_H +#include "llvm/ADT/Optional.h" #include "llvm/ADT/PointerUnion.h" #include diff --git a/include/swift/AST/DiagnosticsParse.def b/include/swift/AST/DiagnosticsParse.def index f06addefe94b6..ba9ed66599c25 100644 --- a/include/swift/AST/DiagnosticsParse.def +++ b/include/swift/AST/DiagnosticsParse.def @@ -528,6 +528,8 @@ ERROR(sil_invalid_column_in_sil_location,none, "column number must be a positive integer", ()) ERROR(sil_invalid_scope_slot,none, "scope number must be a positive integer ", ()) +ERROR(sil_invalid_constant,none, + "constant operand must be an integer literal ", ()) ERROR(sil_scope_undeclared,none, "scope number %0 needs to be declared before first use", (unsigned)) ERROR(sil_scope_redefined,none, diff --git a/include/swift/AST/Identifier.h b/include/swift/AST/Identifier.h index 5d93f225c2d96..f3999438ed0a5 100644 --- a/include/swift/AST/Identifier.h +++ b/include/swift/AST/Identifier.h @@ -20,6 +20,7 @@ #include "swift/Basic/EditorPlaceholder.h" #include "swift/Basic/Debug.h" #include "swift/Basic/LLVM.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/Support/TrailingObjects.h" diff --git a/include/swift/AST/Module.h b/include/swift/AST/Module.h index 217acf422d16f..9dc3a211eca73 100644 --- a/include/swift/AST/Module.h +++ b/include/swift/AST/Module.h @@ -257,6 +257,9 @@ class ModuleDecl AccessNotesFile accessNotes; + /// Used by the debugger to bypass resilient access to fields. + bool BypassResilience = false; + ModuleDecl(Identifier name, ASTContext &ctx, ImplicitImportInfo importInfo); public: @@ -290,6 +293,12 @@ class ModuleDecl AccessNotesFile &getAccessNotes() { return accessNotes; } const AccessNotesFile &getAccessNotes() const { return accessNotes; } + /// Return whether the module was imported with resilience disabled. The + /// debugger does this to access private fields. + bool getBypassResilience() const { return BypassResilience; } + /// Only to be called by MemoryBufferSerializedModuleLoader. + void setBypassResilience() { BypassResilience = true; } + ArrayRef getFiles() { assert(!Files.empty() || failedToLoad()); return Files; diff --git a/include/swift/AST/Ownership.h b/include/swift/AST/Ownership.h index ee8c2e273e5cd..c8bf8c0c16fb6 100644 --- a/include/swift/AST/Ownership.h +++ b/include/swift/AST/Ownership.h @@ -26,6 +26,7 @@ #include "llvm/Support/raw_ostream.h" #include #include +#include namespace swift { diff --git a/include/swift/AST/TBDGenRequests.h b/include/swift/AST/TBDGenRequests.h index d68f36854b4d0..6bfa735c1031e 100644 --- a/include/swift/AST/TBDGenRequests.h +++ b/include/swift/AST/TBDGenRequests.h @@ -70,7 +70,7 @@ class TBDGenDescriptor final { const TBDGenOptions &getOptions() const { return Opts; } TBDGenOptions &getOptions() { return Opts; } - const llvm::DataLayout &getDataLayout() const; + const StringRef getDataLayoutString() const; const llvm::Triple &getTarget() const; bool operator==(const TBDGenDescriptor &other) const; diff --git a/include/swift/Basic/BlotSetVector.h b/include/swift/Basic/BlotSetVector.h index bf57c311c7929..fd72af4cffaa3 100644 --- a/include/swift/Basic/BlotSetVector.h +++ b/include/swift/Basic/BlotSetVector.h @@ -15,6 +15,7 @@ #include "swift/Basic/LLVM.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include diff --git a/include/swift/Basic/MultiMapCache.h b/include/swift/Basic/MultiMapCache.h index ab90b710823cc..b13fc7975d40d 100644 --- a/include/swift/Basic/MultiMapCache.h +++ b/include/swift/Basic/MultiMapCache.h @@ -14,6 +14,7 @@ #define SWIFT_BASIC_MULTIMAPCACHE_H #include "swift/Basic/LLVM.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" namespace swift { diff --git a/include/swift/Basic/Platform.h b/include/swift/Basic/Platform.h index b19e3c0450b18..6fdc07495ba26 100644 --- a/include/swift/Basic/Platform.h +++ b/include/swift/Basic/Platform.h @@ -16,7 +16,7 @@ #include "swift/Basic/LLVM.h" #include "swift/Config.h" #include "llvm/ADT/StringRef.h" -#include "clang/Driver/DarwinSDKInfo.h" +#include "clang/Basic/DarwinSDKInfo.h" namespace llvm { class Triple; @@ -105,7 +105,7 @@ namespace swift { getSwiftRuntimeCompatibilityVersionForTarget(const llvm::Triple &Triple); /// Retrieve the target SDK version for the given SDKInfo and target triple. - llvm::VersionTuple getTargetSDKVersion(clang::driver::DarwinSDKInfo &SDKInfo, + llvm::VersionTuple getTargetSDKVersion(clang::DarwinSDKInfo &SDKInfo, const llvm::Triple &triple); /// Get SDK build version. diff --git a/include/swift/Basic/Version.h b/include/swift/Basic/Version.h index 353500f693095..98ba4e2550f11 100644 --- a/include/swift/Basic/Version.h +++ b/include/swift/Basic/Version.h @@ -25,6 +25,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/VersionTuple.h" +#include #include namespace swift { diff --git a/include/swift/LLVMPasses/Passes.h b/include/swift/LLVMPasses/Passes.h index d716d3087ec78..09abe2847b811 100644 --- a/include/swift/LLVMPasses/Passes.h +++ b/include/swift/LLVMPasses/Passes.h @@ -34,7 +34,7 @@ namespace swift { using AAResultBase::getModRefInfo; llvm::ModRefInfo getModRefInfo(const llvm::CallBase *Call, const llvm::MemoryLocation &Loc) { - llvm::AAQueryInfo AAQI; + llvm::SimpleAAQueryInfo AAQI; return getModRefInfo(Call, Loc, AAQI); } llvm::ModRefInfo getModRefInfo(const llvm::CallBase *Call, diff --git a/include/swift/SIL/Notifications.h b/include/swift/SIL/Notifications.h index f7ecd87024c70..d3682cb0d5a17 100644 --- a/include/swift/SIL/Notifications.h +++ b/include/swift/SIL/Notifications.h @@ -17,6 +17,7 @@ #include "swift/Basic/STLExtras.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" #include namespace swift { diff --git a/include/swift/SIL/SILBuilder.h b/include/swift/SIL/SILBuilder.h index d3ddb1babbf83..3bfeb489d2f3c 100644 --- a/include/swift/SIL/SILBuilder.h +++ b/include/swift/SIL/SILBuilder.h @@ -363,16 +363,34 @@ class SILBuilder { // SILInstruction Creation Methods //===--------------------------------------------------------------------===// + /// Substitute anonymous function arguments with "_$ArgNo". + Optional + substituteAnonymousArgs(llvm::SmallString<4> Name, + Optional Var, SILLocation Loc) { + if (!Var || !Var->ArgNo || !Var->Name.empty()) + return Var; + + auto *VD = Loc.getAsASTNode(); + if (VD && !VD->getName().empty()) + return Var; + + llvm::raw_svector_ostream(Name) << '_' << (Var->ArgNo - 1); + Var->Name = Name; + return Var; + } + AllocStackInst *createAllocStack(SILLocation Loc, SILType elementType, Optional Var = None, bool hasDynamicLifetime = false, bool isLexical = false) { + llvm::SmallString<4> Name; Loc.markAsPrologue(); assert((!dyn_cast_or_null(Loc.getAsASTNode()) || Var) && "location is a VarDecl, but SILDebugVariable is empty"); - return insert(AllocStackInst::create(getSILDebugLocation(Loc), elementType, - getFunction(), Var, hasDynamicLifetime, - isLexical)); + return insert(AllocStackInst::create( + getSILDebugLocation(Loc), elementType, getFunction(), + substituteAnonymousArgs(Name, Var, Loc), hasDynamicLifetime, + isLexical)); } AllocRefInst *createAllocRef(SILLocation Loc, SILType ObjectType, @@ -408,11 +426,13 @@ class SILBuilder { AllocBoxInst *createAllocBox(SILLocation Loc, CanSILBoxType BoxType, Optional Var = None, bool hasDynamicLifetime = false) { + llvm::SmallString<4> Name; Loc.markAsPrologue(); assert((!dyn_cast_or_null(Loc.getAsASTNode()) || Var) && "location is a VarDecl, but SILDebugVariable is empty"); return insert(AllocBoxInst::create(getSILDebugLocation(Loc), BoxType, *F, - Var, hasDynamicLifetime)); + substituteAnonymousArgs(Name, Var, Loc), + hasDynamicLifetime)); } AllocExistentialBoxInst * diff --git a/include/swift/SIL/SILDebugInfoExpression.h b/include/swift/SIL/SILDebugInfoExpression.h index c5d9b42f24912..ea9639b577192 100644 --- a/include/swift/SIL/SILDebugInfoExpression.h +++ b/include/swift/SIL/SILDebugInfoExpression.h @@ -18,6 +18,7 @@ #ifndef SWIFT_SIL_DEBUGINFOEXPRESSION_H #define SWIFT_SIL_DEBUGINFOEXPRESSION_H #include "swift/AST/Decl.h" +#include "llvm/ADT/APInt.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/iterator_range.h" @@ -36,17 +37,30 @@ enum class SILDIExprOperator : unsigned { /// VarDecl operand pointing to the field declaration. /// Note that this directive can only appear at the end of an /// expression. - Fragment + Fragment, + /// Perform arithmetic addition on the top two elements of the + /// expression stack and push the result back to the stack. + Plus, + /// Subtract the top element in expression stack by the second + /// element. Then push the result back to the stack. + Minus, + /// Push an unsigned integer constant onto the stack. + ConstUInt, + /// Push a signed integer constant onto the stack. + ConstSInt }; /// Represents a single component in a debug info expression. /// Including operator and operand. struct SILDIExprElement { enum Kind { - /// A di-expression operator + /// A di-expression operator. OperatorKind, - /// An operand that has declaration type - DeclKind + /// An operand that has declaration type. + DeclKind, + /// An integer constant value. Note that + /// we don't specify its signedness here. + ConstIntKind }; private: @@ -55,6 +69,7 @@ struct SILDIExprElement { union { SILDIExprOperator Operator; Decl *Declaration; + uint64_t ConstantInt; }; explicit SILDIExprElement(Kind OpK) : OpKind(OpK) {} @@ -68,6 +83,13 @@ struct SILDIExprElement { Decl *getAsDecl() const { return OpKind == DeclKind ? Declaration : nullptr; } + Optional getAsConstInt() const { + if (OpKind == ConstIntKind) + return ConstantInt; + else + return {}; + } + static SILDIExprElement createOperator(SILDIExprOperator Op) { SILDIExprElement DIOp(OperatorKind); DIOp.Operator = Op; @@ -79,6 +101,12 @@ struct SILDIExprElement { DIOp.Declaration = D; return DIOp; } + + static SILDIExprElement createConstInt(uint64_t V) { + SILDIExprElement DIOp(ConstIntKind); + DIOp.ConstantInt = V; + return DIOp; + } }; /// For a given SILDIExprOperator, provides information @@ -231,6 +259,19 @@ class SILDebugInfoExpression { /// Create a op_fragment expression static SILDebugInfoExpression createFragment(VarDecl *Field); + + /// Return true if this DIExpression starts with op_deref + bool startsWithDeref() const { + return Elements.size() && + Elements[0].getAsOperator() == SILDIExprOperator::Dereference; + } + + /// Return true if this DIExpression has op_fragment (at the end) + bool hasFragment() const { + return Elements.size() >= 2 && + Elements[Elements.size() - 2].getAsOperator() == + SILDIExprOperator::Fragment; + } }; } // end namespace swift #endif diff --git a/include/swift/SIL/SILInstruction.h b/include/swift/SIL/SILInstruction.h index 0f724dab341aa..25ea9e4e8a4e5 100644 --- a/include/swift/SIL/SILInstruction.h +++ b/include/swift/SIL/SILInstruction.h @@ -1810,13 +1810,11 @@ class TailAllocatedDebugVariable { if (!Bits.Data.HasValue) return None; - if (VD) - return SILDebugVariable(VD->getName().empty() ? "" : VD->getName().str(), - VD->isLet(), getArgNo(), isImplicit(), AuxVarType, - DeclLoc, DeclScope, DIExprElements); - else - return SILDebugVariable(getName(buf), isLet(), getArgNo(), isImplicit(), - AuxVarType, DeclLoc, DeclScope, DIExprElements); + StringRef name = getName(buf); + if (VD && name.empty()) + name = VD->getName().str(); + return SILDebugVariable(name, isLet(), getArgNo(), isImplicit(), AuxVarType, + DeclLoc, DeclScope, DIExprElements); } }; static_assert(sizeof(TailAllocatedDebugVariable) == 4, diff --git a/include/swift/SIL/SILInstructionWorklist.h b/include/swift/SIL/SILInstructionWorklist.h index 790f3f9fc5b06..58025ee529019 100644 --- a/include/swift/SIL/SILInstructionWorklist.h +++ b/include/swift/SIL/SILInstructionWorklist.h @@ -37,6 +37,7 @@ #include "swift/SIL/SILInstruction.h" #include "swift/SIL/InstructionUtils.h" #include "swift/SIL/SILValue.h" +#include "swift/SILOptimizer/Utils/DebugOptUtils.h" #include "swift/SILOptimizer/Utils/InstOptUtils.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" @@ -309,7 +310,9 @@ class SILInstructionWorklist : SILInstructionWorklistBase { void eraseInstFromFunction(SILInstruction &instruction, SILBasicBlock::iterator &iterator, bool addOperandsToWorklist = true) { - // Delete any debug users first. + // Try to salvage debug info first. + swift::salvageDebugInfo(&instruction); + // Then delete old debug users. for (auto result : instruction.getResults()) { while (!result->use_empty()) { auto *user = result->use_begin()->getUser(); diff --git a/include/swift/Serialization/SerializedModuleLoader.h b/include/swift/Serialization/SerializedModuleLoader.h index f488abac01455..4248d050b2479 100644 --- a/include/swift/Serialization/SerializedModuleLoader.h +++ b/include/swift/Serialization/SerializedModuleLoader.h @@ -263,9 +263,11 @@ class MemoryBufferSerializedModuleLoader : public SerializedModuleLoaderBase { MemoryBufferSerializedModuleLoader(ASTContext &ctx, DependencyTracker *tracker, ModuleLoadingMode loadMode, - bool IgnoreSwiftSourceInfo) + bool IgnoreSwiftSourceInfo, + bool BypassResilience) : SerializedModuleLoaderBase(ctx, tracker, loadMode, - IgnoreSwiftSourceInfo) {} + IgnoreSwiftSourceInfo), + BypassResilience(BypassResilience) {} std::error_code findModuleFilesInDirectory( ImportPath::Element ModuleID, @@ -281,6 +283,7 @@ class MemoryBufferSerializedModuleLoader : public SerializedModuleLoaderBase { StringRef moduleName, const SerializedModuleBaseName &BaseName) override; + bool BypassResilience; public: virtual ~MemoryBufferSerializedModuleLoader(); @@ -310,10 +313,10 @@ class MemoryBufferSerializedModuleLoader : public SerializedModuleLoaderBase { static std::unique_ptr create(ASTContext &ctx, DependencyTracker *tracker = nullptr, ModuleLoadingMode loadMode = ModuleLoadingMode::PreferSerialized, - bool IgnoreSwiftSourceInfo = false) { + bool IgnoreSwiftSourceInfo = false, bool BypassResilience = false) { return std::unique_ptr{ - new MemoryBufferSerializedModuleLoader(ctx, tracker, loadMode, - IgnoreSwiftSourceInfo)}; + new MemoryBufferSerializedModuleLoader( + ctx, tracker, loadMode, IgnoreSwiftSourceInfo, BypassResilience)}; } }; diff --git a/include/swift/Syntax/AbsoluteRawSyntax.h b/include/swift/Syntax/AbsoluteRawSyntax.h index 21ca9b2abf4f5..ed40f6fbcd985 100644 --- a/include/swift/Syntax/AbsoluteRawSyntax.h +++ b/include/swift/Syntax/AbsoluteRawSyntax.h @@ -16,6 +16,8 @@ #include "swift/Basic/SourceLoc.h" #include "swift/Syntax/RawSyntax.h" +#include "llvm/ADT/STLForwardCompat.h" + namespace swift { namespace syntax { @@ -388,8 +390,7 @@ class OptionalStorage { OptionalStorage(OptionalStorage &&other) = default; template - explicit OptionalStorage(llvm::optional_detail::in_place_t, - ArgTypes &&...Args) + explicit OptionalStorage(llvm::in_place_t, ArgTypes &&...Args) : Storage(std::forward(Args)...) {} void reset() { Storage = AbsoluteRawSyntax(nullptr); } diff --git a/include/swift/Syntax/SyntaxData.h b/include/swift/Syntax/SyntaxData.h index 370fc3ea54fb2..43af44264650f 100644 --- a/include/swift/Syntax/SyntaxData.h +++ b/include/swift/Syntax/SyntaxData.h @@ -409,8 +409,7 @@ class OptionalStorage { OptionalStorage(OptionalStorage &&other) = default; template - explicit OptionalStorage(llvm::optional_detail::in_place_t, - ArgTypes &&...Args) + explicit OptionalStorage(llvm::in_place_t, ArgTypes &&...Args) : Storage(std::forward(Args)...) {} void reset() { Storage = SyntaxDataRef(AbsoluteRawSyntax(nullptr), nullptr); } diff --git a/lib/APIDigester/ModuleAnalyzerNodes.cpp b/lib/APIDigester/ModuleAnalyzerNodes.cpp index cd59b02dbffe0..d3b167f1cc9a4 100644 --- a/lib/APIDigester/ModuleAnalyzerNodes.cpp +++ b/lib/APIDigester/ModuleAnalyzerNodes.cpp @@ -2194,7 +2194,7 @@ void SwiftDeclCollector::deSerialize(StringRef Filename) { // Serialize the content of all roots to a given file using JSON format. void SwiftDeclCollector::serialize(StringRef Filename, SDKNode *Root) { std::error_code EC; - llvm::raw_fd_ostream fs(Filename, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream fs(Filename, EC, llvm::sys::fs::OF_None); json::Output yout(fs); yout << Root; } @@ -2290,7 +2290,7 @@ int swift::ide::api::dumpSDKContent(const CompilerInvocation &InitInvok, int swift::ide::api::deserializeSDKDump(StringRef dumpPath, StringRef OutputPath, CheckerOptions Opts) { std::error_code EC; - llvm::raw_fd_ostream FS(OutputPath, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream FS(OutputPath, EC, llvm::sys::fs::OF_None); if (!fs::exists(dumpPath)) { llvm::errs() << dumpPath << " does not exist\n"; return 1; diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 87bd5e118b3f4..0a26c9960af43 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -2099,7 +2099,7 @@ void ASTContext::getVisibleTopLevelModuleNames( // Sort and unique. std::sort(names.begin(), names.end(), [](Identifier LHS, Identifier RHS) { - return LHS.str().compare_lower(RHS.str()) < 0; + return LHS.str().compare_insensitive(RHS.str()) < 0; }); names.erase(std::unique(names.begin(), names.end()), names.end()); } diff --git a/lib/AST/ClangTypeConverter.cpp b/lib/AST/ClangTypeConverter.cpp index 572b3da7c31ac..76ddd8a4a014d 100644 --- a/lib/AST/ClangTypeConverter.cpp +++ b/lib/AST/ClangTypeConverter.cpp @@ -85,6 +85,10 @@ getClangBuiltinTypeFromKind(const clang::ASTContext &context, case clang::BuiltinType::Id: \ return context.Id##Ty; #include "clang/Basic/PPCTypes.def" +#define RVV_TYPE(Name, Id, SingletonId) \ + case clang::BuiltinType::Id: \ + return context.Id##Ty; +#include "clang/Basic/RISCVVTypes.def" } // Not a valid BuiltinType. diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index a30cb537d50bf..fdebce8f43933 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -1916,7 +1916,7 @@ static bool isDirectToStorageAccess(const DeclContext *UseDC, // If the storage is resilient, we cannot access it directly at all. if (var->isResilient(UseDC->getParentModule(), UseDC->getResilienceExpansion())) - return false; + return var->getModuleContext()->getBypassResilience(); if (isa(AFD) || isa(AFD)) { // The access must also be a member access on 'self' in all language modes. diff --git a/lib/AST/DocComment.cpp b/lib/AST/DocComment.cpp index 8f28dd83cb2ff..9d290a180f623 100644 --- a/lib/AST/DocComment.cpp +++ b/lib/AST/DocComment.cpp @@ -115,7 +115,7 @@ bool extractParameterOutline( } auto HeadingContent = HeadingText->getLiteralContent(); - if (!HeadingContent.rtrim().equals_lower("parameters:")) { + if (!HeadingContent.rtrim().equals_insensitive("parameters:")) { NormalItems.push_back(Child); continue; } @@ -191,7 +191,7 @@ bool extractSeparatedParams( auto ParagraphContent = ParagraphText->getLiteralContent(); auto PotentialMatch = ParagraphContent.substr(0, ParameterPrefix.size()); - if (!PotentialMatch.startswith_lower(ParameterPrefix)) { + if (!PotentialMatch.startswith_insensitive(ParameterPrefix)) { NormalItems.push_back(Child); continue; } diff --git a/lib/Basic/FileSystem.cpp b/lib/Basic/FileSystem.cpp index 963ea61c65b62..8b6f5ea68e1ab 100644 --- a/lib/Basic/FileSystem.cpp +++ b/lib/Basic/FileSystem.cpp @@ -101,7 +101,8 @@ tryToOpenTemporaryFile(Optional &openedStream, int fd; const unsigned perms = fs::all_read | fs::all_write; - std::error_code EC = fs::createUniqueFile(tempPath, fd, tempPath, perms); + std::error_code EC = fs::createUniqueFile(tempPath, fd, tempPath, + fs::OF_None, perms); if (EC) { // Ignore the specific error; the caller has to fall back to not using a @@ -145,7 +146,7 @@ std::error_code swift::atomicallyWritingToFile( if (!OS.hasValue()) { std::error_code error; - OS.emplace(outputPath, error, fs::F_None); + OS.emplace(outputPath, error, fs::OF_None); if (error) { return error; } diff --git a/lib/Basic/OutputFileMap.cpp b/lib/Basic/OutputFileMap.cpp index 26535a373beaf..085fc905b74b8 100644 --- a/lib/Basic/OutputFileMap.cpp +++ b/lib/Basic/OutputFileMap.cpp @@ -88,7 +88,10 @@ void OutputFileMap::dump(llvm::raw_ostream &os, bool Sort) const { const TypeToPathMap &Map = InputPair.second; std::vector Pairs; Pairs.insert(Pairs.end(), Map.begin(), Map.end()); - std::sort(Pairs.begin(), Pairs.end()); + std::sort(Pairs.begin(), Pairs.end(), [](const TypePathPair &LHS, + const TypePathPair &RHS) -> bool { + return LHS < RHS; + }); for (auto &OutputPair : Pairs) { printOutputPair(InputPair.first, OutputPair); } diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp index a6d84a004b2cb..aa1f1dcb3f96f 100644 --- a/lib/Basic/Platform.cpp +++ b/lib/Basic/Platform.cpp @@ -445,44 +445,12 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget( } -/// Remap the given version number via the version map, or produce \c None if -/// there is no mapping for this version. -static Optional remapVersion( - const llvm::StringMap &versionMap, - llvm::VersionTuple version) { - // The build number is never used in the lookup. - version = version.withoutBuild(); - - // Look for this specific version. - auto known = versionMap.find(version.getAsString()); - if (known != versionMap.end()) - return known->second; - - // If an extra ".0" was specified (in the subminor version), drop that - // and look again. - if (!version.getSubminor() || *version.getSubminor() != 0) - return None; - - version = llvm::VersionTuple(version.getMajor(), *version.getMinor()); - known = versionMap.find(version.getAsString()); - if (known != versionMap.end()) - return known->second; - - // If another extra ".0" wa specified (in the minor version), drop that - // and look again. - if (!version.getMinor() || *version.getMinor() != 0) - return None; - - version = llvm::VersionTuple(version.getMajor()); - known = versionMap.find(version.getAsString()); - if (known != versionMap.end()) - return known->second; - - return None; +static const llvm::VersionTuple minimumMacCatalystDeploymentTarget() { + return llvm::VersionTuple(13, 1); } llvm::VersionTuple -swift::getTargetSDKVersion(clang::driver::DarwinSDKInfo &SDKInfo, +swift::getTargetSDKVersion(clang::DarwinSDKInfo &SDKInfo, const llvm::Triple &triple) { // Retrieve the SDK version. auto SDKVersion = SDKInfo.getVersion(); @@ -491,9 +459,12 @@ swift::getTargetSDKVersion(clang::driver::DarwinSDKInfo &SDKInfo, // SDK version. Map that to the corresponding iOS version number to pass // down to the linker. if (tripleIsMacCatalystEnvironment(triple)) { - return remapVersion( - SDKInfo.getVersionMap().MacOS2iOSMacMapping, SDKVersion) - .getValueOr(llvm::VersionTuple(0, 0, 0)); + if (const auto *MacOStoMacCatalystMapping = SDKInfo.getVersionMapping( + clang::DarwinSDKInfo::OSEnvPair::macOStoMacCatalystPair())) { + return MacOStoMacCatalystMapping->map( + SDKVersion, minimumMacCatalystDeploymentTarget(), None).getValueOr(llvm::VersionTuple(0, 0, 0)); + } + return llvm::VersionTuple(0, 0, 0); } return SDKVersion; diff --git a/lib/Basic/Statistic.cpp b/lib/Basic/Statistic.cpp index b44fb5ec9d3d2..08451423165eb 100644 --- a/lib/Basic/Statistic.cpp +++ b/lib/Basic/Statistic.cpp @@ -251,7 +251,7 @@ class StatsProfiler { SmallString<256> Path(Dirname); llvm::sys::path::append(Path, Filename); std::error_code EC; - raw_fd_ostream Stream(Path, EC, fs::F_Append | fs::F_Text); + raw_fd_ostream Stream(Path, EC, fs::OF_Append | fs::OF_Text); if (EC) { llvm::errs() << "Error opening profile file '" << Path << "' for writing\n"; @@ -688,7 +688,7 @@ UnifiedStatsReporter::~UnifiedStatsReporter() } std::error_code EC; - raw_fd_ostream ostream(StatsFilename, EC, fs::F_Append | fs::F_Text); + raw_fd_ostream ostream(StatsFilename, EC, fs::OF_Append | fs::OF_Text); if (EC) { llvm::errs() << "Error opening -stats-output-dir file '" << StatsFilename << "' for writing\n"; @@ -726,7 +726,7 @@ UnifiedStatsReporter::flushTracesAndProfiles() { if (FrontendStatsEvents && SourceMgr) { std::error_code EC; - raw_fd_ostream tstream(TraceFilename, EC, fs::F_Append | fs::F_Text); + raw_fd_ostream tstream(TraceFilename, EC, fs::OF_Append | fs::OF_Text); if (EC) { llvm::errs() << "Error opening -trace-stats-events file '" << TraceFilename << "' for writing\n"; diff --git a/lib/Basic/StringExtras.cpp b/lib/Basic/StringExtras.cpp index ce3ee468df6ef..57dd2ecd0f5b8 100644 --- a/lib/Basic/StringExtras.cpp +++ b/lib/Basic/StringExtras.cpp @@ -45,8 +45,8 @@ bool swift::canBeMemberName(StringRef identifier) { } bool swift::isPreposition(StringRef word) { -#define PREPOSITION(Word) \ - if (word.equals_lower(#Word)) \ +#define PREPOSITION(Word) \ + if (word.equals_insensitive(#Word)) \ return true; #include "PartsOfSpeech.def" @@ -55,11 +55,11 @@ bool swift::isPreposition(StringRef word) { PartOfSpeech swift::getPartOfSpeech(StringRef word) { // FIXME: This implementation is woefully inefficient. -#define PREPOSITION(Word) \ - if (word.equals_lower(#Word)) \ +#define PREPOSITION(Word) \ + if (word.equals_insensitive(#Word)) \ return PartOfSpeech::Preposition; -#define VERB(Word) \ - if (word.equals_lower(#Word)) \ +#define VERB(Word) \ + if (word.equals_insensitive(#Word)) \ return PartOfSpeech::Verb; #include "PartsOfSpeech.def" @@ -392,8 +392,8 @@ static bool matchNameWordToTypeWord(StringRef nameWord, StringRef typeWord) { // We can match the suffix of the type so long as everything preceding the // match is neither a lowercase letter nor a '_'. This ignores type // prefixes for acronyms, e.g., the 'NS' in 'NSURL'. - if (typeWord.endswith_lower(nameWord) && - !clang::isLowercase(typeWord[typeWord.size()-nameWord.size()])) { + if (typeWord.endswith_insensitive(nameWord) && + !clang::isLowercase(typeWord[typeWord.size() - nameWord.size()])) { // Check that everything preceding the match is neither a lowercase letter // nor a '_'. for (unsigned i = 0, n = nameWord.size(); i != n; ++i) { @@ -405,7 +405,7 @@ static bool matchNameWordToTypeWord(StringRef nameWord, StringRef typeWord) { // We can match a prefix so long as everything following the match is // a number. - if (typeWord.startswith_lower(nameWord)) { + if (typeWord.startswith_insensitive(nameWord)) { for (unsigned i = nameWord.size(), n = typeWord.size(); i != n; ++i) { if (!clang::isDigit(typeWord[i])) return false; } @@ -417,7 +417,7 @@ static bool matchNameWordToTypeWord(StringRef nameWord, StringRef typeWord) { } // Check for an exact match. - return nameWord.equals_lower(typeWord); + return nameWord.equals_insensitive(typeWord); } /// Match the beginning of the name to the given type name. diff --git a/lib/ClangImporter/ClangAdapter.cpp b/lib/ClangImporter/ClangAdapter.cpp index d54175c768eac..1d576226156de 100644 --- a/lib/ClangImporter/ClangAdapter.cpp +++ b/lib/ClangImporter/ClangAdapter.cpp @@ -468,16 +468,19 @@ OmissionTypeName importer::getClangTypeNameForOmission(clang::ASTContext &ctx, return OmissionTypeName(); // ARM SVE builtin types that don't have Swift equivalents. -#define SVE_TYPE(Name, Id, ...) \ - case clang::BuiltinType::Id: +#define SVE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: #include "clang/Basic/AArch64SVEACLETypes.def" return OmissionTypeName(); // PPC MMA builtin types that don't have Swift equivalents. -#define PPC_VECTOR_TYPE(Name, Id, Size) \ - case clang::BuiltinType::Id: +#define PPC_VECTOR_TYPE(Name, Id, Size) case clang::BuiltinType::Id: #include "clang/Basic/PPCTypes.def" return OmissionTypeName(); + + // RISC-V V builtin types that don't have Swift equivalents. +#define RVV_TYPE(Name, Id, Size) case clang::BuiltinType::Id: +#include "clang/Basic/RISCVVTypes.def" + return OmissionTypeName(); } } diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index dc335d5eeb71c..f3e267b6b87b7 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -1180,7 +1180,7 @@ ClangImporter::create(ASTContext &ctx, // // FIXME: We shouldn't need to do this, the target should be immutable once // created. This complexity should be lifted elsewhere. - instance.getTarget().adjust(instance.getLangOpts()); + instance.getTarget().adjust(clangDiags, instance.getLangOpts()); if (importerOpts.Mode == ClangImporterOptions::Modes::EmbedBitcode) return importer; diff --git a/lib/ClangImporter/ClangModuleDependencyScanner.cpp b/lib/ClangImporter/ClangModuleDependencyScanner.cpp index a126251e98497..438841fbe8fc0 100644 --- a/lib/ClangImporter/ClangModuleDependencyScanner.cpp +++ b/lib/ClangImporter/ClangModuleDependencyScanner.cpp @@ -80,26 +80,6 @@ llvm::ErrorOr ClangModuleDependenciesCacheImpl::getImportHackFile(Str return importHackFileCache[moduleName]; } -namespace { - class SingleCommandCompilationDatabase : public CompilationDatabase { - public: - SingleCommandCompilationDatabase(CompileCommand Cmd) - : Command(std::move(Cmd)) {} - - virtual std::vector - getCompileCommands(StringRef FilePath) const override { - return {Command}; - } - - virtual std::vector getAllCompileCommands() const override { - return {Command}; - } - - private: - CompileCommand Command; - }; -} - // Add search paths. // Note: This is handled differently for the Clang importer itself, which // adds search paths to Clang's data structures rather than to its @@ -206,7 +186,7 @@ void ClangImporter::recordModuleDependencies( for (const auto &clangModuleDep : clangDependencies.DiscoveredModules) { // If we've already cached this information, we're done. if (cache.hasDependencies( - clangModuleDep.ModuleName, + clangModuleDep.ID.ModuleName, {ModuleDependenciesKind::Clang, currentSwiftSearchPathSet})) continue; @@ -261,7 +241,8 @@ void ClangImporter::recordModuleDependencies( // Add all args the non-path arguments required to be passed in, according // to the Clang scanner - for (const auto &clangArg : clangModuleDep.NonPathCommandLine) { + for (const auto &clangArg : + clangModuleDep.getAdditionalArgsWithoutModulePaths()) { swiftArgs.push_back("-Xcc"); swiftArgs.push_back("-Xclang"); swiftArgs.push_back("-Xcc"); @@ -281,7 +262,7 @@ void ClangImporter::recordModuleDependencies( // Swift frontend action: -emit-pcm swiftArgs.push_back("-emit-pcm"); swiftArgs.push_back("-module-name"); - swiftArgs.push_back(clangModuleDep.ModuleName); + swiftArgs.push_back(clangModuleDep.ID.ModuleName); // Pass down search paths to the -emit-module action. // Unlike building Swift modules, we need to include all search paths to @@ -301,7 +282,7 @@ void ClangImporter::recordModuleDependencies( llvm::StringSet<> alreadyAddedModules; auto dependencies = ModuleDependencies::forClangModule( clangModuleDep.ClangModuleMapFile, - clangModuleDep.ContextHash, + clangModuleDep.ID.ContextHash, swiftArgs, fileDeps, capturedPCMArgs); @@ -309,7 +290,7 @@ void ClangImporter::recordModuleDependencies( dependencies.addModuleDependency(moduleName.ModuleName, &alreadyAddedModules); } - cache.recordDependencies(clangModuleDep.ModuleName, + cache.recordDependencies(clangModuleDep.ID.ModuleName, std::move(dependencies)); } } @@ -336,17 +317,13 @@ Optional ClangImporter::getModuleDependencies( } // Determine the command-line arguments for dependency scanning. - std::vector commandLineArgs = getClangDepScanningInvocationArguments(ctx, *importHackFile); - std::string workingDir = ctx.SourceMgr.getFileSystem()->getCurrentWorkingDirectory().get(); - CompileCommand command(workingDir, *importHackFile, commandLineArgs, "-"); - SingleCommandCompilationDatabase database(command); auto clangDependencies = clangImpl->tool.getFullDependencies( - database, workingDir, clangImpl->alreadySeen); + commandLineArgs, workingDir, clangImpl->alreadySeen); if (!clangDependencies) { // FIXME: Route this to a normal diagnostic. llvm::logAllUnhandledErrors(clangDependencies.takeError(), llvm::errs()); @@ -394,14 +371,11 @@ bool ClangImporter::addBridgingHeaderDependencies( // Determine the command-line arguments for dependency scanning. std::vector commandLineArgs = getClangDepScanningInvocationArguments(ctx, bridgingHeader); - std::string workingDir = ctx.SourceMgr.getFileSystem()->getCurrentWorkingDirectory().get(); - CompileCommand command(workingDir, bridgingHeader, commandLineArgs, "-"); - SingleCommandCompilationDatabase database(command); auto clangDependencies = clangImpl->tool.getFullDependencies( - database, workingDir, clangImpl->alreadySeen); + commandLineArgs, workingDir, clangImpl->alreadySeen); if (!clangDependencies) { // FIXME: Route this to a normal diagnostic. diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index bc7c9c8cbcec8..f07b38186efa5 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -1171,14 +1171,14 @@ makeBitFieldAccessors(ClangImporter::Implementation &Impl, auto cGetterSelfExpr = new (Ctx) clang::DeclRefExpr(Ctx, cGetterSelf, false, recordType, - clang::VK_RValue, + clang::VK_PRValue, clang::SourceLocation()); auto cGetterExpr = clang::MemberExpr::CreateImplicit(Ctx, cGetterSelfExpr, /*isarrow=*/ false, fieldDecl, fieldType, - clang::VK_RValue, + clang::VK_PRValue, clang::OK_BitField); @@ -1215,7 +1215,7 @@ makeBitFieldAccessors(ClangImporter::Implementation &Impl, auto cSetterSelfExpr = new (Ctx) clang::DeclRefExpr(Ctx, cSetterSelf, false, recordPointerType, - clang::VK_RValue, + clang::VK_PRValue, clang::SourceLocation()); auto cSetterMemberExpr = clang::MemberExpr::CreateImplicit(Ctx, @@ -1228,7 +1228,7 @@ makeBitFieldAccessors(ClangImporter::Implementation &Impl, auto cSetterValueExpr = new (Ctx) clang::DeclRefExpr(Ctx, cSetterValue, false, fieldType, - clang::VK_RValue, + clang::VK_PRValue, clang::SourceLocation()); auto cSetterExpr = clang::BinaryOperator::Create(Ctx, @@ -1236,7 +1236,7 @@ makeBitFieldAccessors(ClangImporter::Implementation &Impl, cSetterValueExpr, clang::BO_Assign, fieldType, - clang::VK_RValue, + clang::VK_PRValue, clang::OK_Ordinary, clang::SourceLocation(), clang::FPOptionsOverride()); diff --git a/lib/ClangImporter/ImportType.cpp b/lib/ClangImporter/ImportType.cpp index 276da6c854287..3ff8662635f1a 100644 --- a/lib/ClangImporter/ImportType.cpp +++ b/lib/ClangImporter/ImportType.cpp @@ -361,16 +361,19 @@ namespace { return Type(); // ARM SVE builtin types that don't have Swift equivalents. -#define SVE_TYPE(Name, Id, ...) \ - case clang::BuiltinType::Id: +#define SVE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: #include "clang/Basic/AArch64SVEACLETypes.def" return Type(); // PPC SVE builtin types that don't have Swift equivalents. -#define PPC_VECTOR_TYPE(Name, Id, Size) \ - case clang::BuiltinType::Id: +#define PPC_VECTOR_TYPE(Name, Id, Size) case clang::BuiltinType::Id: #include "clang/Basic/PPCTypes.def" return Type(); + + // RISC-V V builtin types that don't have Swift equivalents. +#define RVV_TYPE(Name, Id, Size) case clang::BuiltinType::Id: +#include "clang/Basic/RISCVVTypes.def" + return Type(); } llvm_unreachable("Invalid BuiltinType."); diff --git a/lib/ClangImporter/ImporterImpl.h b/lib/ClangImporter/ImporterImpl.h index 79309dc5fc174..69b2b37d20536 100644 --- a/lib/ClangImporter/ImporterImpl.h +++ b/lib/ClangImporter/ImporterImpl.h @@ -1606,7 +1606,9 @@ class SwiftNameLookupExtension : public clang::ModuleFileExtension { LookupTableMap &tables, ASTContext &ctx, ClangSourceBufferImporter &buffersForDiagnostics, const PlatformAvailability &avail) - : pchLookupTable(pchLookupTable), lookupTables(tables), swiftCtx(ctx), + : // Update in response to D97702 landing. + clang::ModuleFileExtension(), + pchLookupTable(pchLookupTable), lookupTables(tables), swiftCtx(ctx), buffersForDiagnostics(buffersForDiagnostics), availability(avail) {} clang::ModuleFileExtensionMetadata getExtensionMetadata() const override; diff --git a/lib/DependencyScan/ScanDependencies.cpp b/lib/DependencyScan/ScanDependencies.cpp index c5b273a16d3e7..daffda1142a32 100644 --- a/lib/DependencyScan/ScanDependencies.cpp +++ b/lib/DependencyScan/ScanDependencies.cpp @@ -1200,7 +1200,7 @@ bool swift::dependencies::scanDependencies(CompilerInstance &instance) { const FrontendOptions &opts = instance.getInvocation().getFrontendOptions(); std::string path = opts.InputsAndOutputs.getSingleOutputFilename(); std::error_code EC; - llvm::raw_fd_ostream out(path, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream out(path, EC, llvm::sys::fs::OF_None); if (out.has_error() || EC) { Context.Diags.diagnose(SourceLoc(), diag::error_opening_output, path, EC.message()); @@ -1246,7 +1246,7 @@ bool swift::dependencies::prescanDependencies(CompilerInstance &instance) { const FrontendOptions &opts = instance.getInvocation().getFrontendOptions(); std::string path = opts.InputsAndOutputs.getSingleOutputFilename(); std::error_code EC; - llvm::raw_fd_ostream out(path, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream out(path, EC, llvm::sys::fs::OF_None); // `-scan-dependencies` invocations use a single new instance // of a module cache GlobalModuleDependenciesCache singleUseGlobalCache; @@ -1302,7 +1302,7 @@ bool swift::dependencies::batchScanDependencies( for (; ientries != batchInput->end() and iresults != batchScanResults.end(); ++ientries, ++iresults) { std::error_code EC; - llvm::raw_fd_ostream out((*ientries).outputPath, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream out((*ientries).outputPath, EC, llvm::sys::fs::OF_None); if ((*iresults).getError()) return true; @@ -1337,7 +1337,7 @@ bool swift::dependencies::batchPrescanDependencies( ientries != batchInput->end() and iresults != batchPrescanResults.end(); ++ientries, ++iresults) { std::error_code EC; - llvm::raw_fd_ostream out((*ientries).outputPath, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream out((*ientries).outputPath, EC, llvm::sys::fs::OF_None); if ((*iresults).getError()) return true; diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp index 9bc9709163725..22ecbd790be1d 100644 --- a/lib/Driver/Compilation.cpp +++ b/lib/Driver/Compilation.cpp @@ -1614,7 +1614,7 @@ static void writeCompilationRecord(StringRef path, StringRef argsHash, llvm::sys::fs::rename(path, path + "~"); std::error_code error; - llvm::raw_fd_ostream out(path, error, llvm::sys::fs::F_None); + llvm::raw_fd_ostream out(path, error, llvm::sys::fs::OF_None); if (out.has_error()) { // FIXME: How should we report this error? out.clear_error(); @@ -1718,7 +1718,7 @@ static bool writeFilelistIfNecessary(const Job *job, const ArgList &args, return true; std::error_code error; - llvm::raw_fd_ostream out(filelistInfo.path, error, llvm::sys::fs::F_None); + llvm::raw_fd_ostream out(filelistInfo.path, error, llvm::sys::fs::OF_None); if (out.has_error()) { out.clear_error(); diags.diagnose(SourceLoc(), diag::error_unable_to_make_temporary_file, @@ -1826,7 +1826,7 @@ Compilation::Result Compilation::performSingleCommand(const Job *Cmd) { static bool writeAllSourcesFile(DiagnosticEngine &diags, StringRef path, ArrayRef inputFiles) { std::error_code error; - llvm::raw_fd_ostream out(path, error, llvm::sys::fs::F_None); + llvm::raw_fd_ostream out(path, error, llvm::sys::fs::OF_None); if (out.has_error()) { out.clear_error(); diags.diagnose(SourceLoc(), diag::error_unable_to_make_temporary_file, @@ -1923,7 +1923,7 @@ void Compilation::addDependencyPathOrCreateDummy( } else if (!depPath.empty()) { // Create dummy empty file std::error_code EC; - llvm::raw_fd_ostream(depPath, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream(depPath, EC, llvm::sys::fs::OF_None); } } diff --git a/lib/Driver/DarwinToolChains.cpp b/lib/Driver/DarwinToolChains.cpp index 87d3e52c73811..c6440a54d6934 100644 --- a/lib/Driver/DarwinToolChains.cpp +++ b/lib/Driver/DarwinToolChains.cpp @@ -22,7 +22,7 @@ #include "swift/Basic/TaskQueue.h" #include "swift/Config.h" #include "swift/Driver/Compilation.h" -#include "clang/Driver/DarwinSDKInfo.h" +#include "clang/Basic/DarwinSDKInfo.h" #include "swift/Driver/Driver.h" #include "swift/Driver/Job.h" #include "swift/Option/Options.h" @@ -960,7 +960,7 @@ toolchains::Darwin::validateOutputInfo(DiagnosticEngine &diags, const OutputInfo &outputInfo) const { // If we have been provided with an SDK, go read the SDK information. if (!outputInfo.SDKPath.empty()) { - auto SDKInfoOrErr = clang::driver::parseDarwinSDKInfo( + auto SDKInfoOrErr = clang::parseDarwinSDKInfo( *llvm::vfs::getRealFileSystem(), outputInfo.SDKPath); if (SDKInfoOrErr) { SDKInfo = *SDKInfoOrErr; diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 6da917a50c52d..0ab7cbf3ea6ed 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -2761,7 +2761,7 @@ static void addDiagFileOutputForPersistentPCHAction( llvm::sys::path::append(outPathBuf, stem); outPathBuf += '-'; auto code = llvm::hash_value(ModuleOutPath); - outPathBuf += llvm::APInt(64, code).toString(36, /*Signed=*/false); + llvm::APInt(64, code).toString(outPathBuf, 36, /*Signed=*/false); llvm::sys::path::replace_extension(outPathBuf, suffix); } @@ -3540,7 +3540,7 @@ void Driver::printHelp(bool ShowHidden) const { if (!ShowHidden) ExcludedFlagsBitmask |= HelpHidden; - getOpts().PrintHelp(llvm::outs(), Name.c_str(), "Swift compiler", + getOpts().printHelp(llvm::outs(), Name.c_str(), "Swift compiler", IncludedFlagsBitmask, ExcludedFlagsBitmask, /*ShowAllAliases*/false); diff --git a/lib/Driver/Job.cpp b/lib/Driver/Job.cpp index 2d1ca77a723ac..10acf122015eb 100644 --- a/lib/Driver/Job.cpp +++ b/lib/Driver/Job.cpp @@ -464,7 +464,7 @@ void Job::printSummary(raw_ostream &os) const { bool Job::writeArgsToResponseFile() const { assert(hasResponseFile()); std::error_code EC; - llvm::raw_fd_ostream OS(ResponseFile->path, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream OS(ResponseFile->path, EC, llvm::sys::fs::OF_None); if (EC) { return true; } diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 6421de437072d..442c555b76fea 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -15,7 +15,7 @@ #include "swift/Basic/LLVM.h" #include "swift/Driver/ToolChain.h" -#include "clang/Driver/DarwinSDKInfo.h" +#include "clang/Basic/DarwinSDKInfo.h" #include "llvm/Option/ArgList.h" #include "llvm/Support/Compiler.h" @@ -81,7 +81,7 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public ToolChain { /// Information about the SDK that the application is being built against. /// This information is only used by the linker, so it is only populated /// when there will be a linker job. - mutable Optional SDKInfo; + mutable Optional SDKInfo; const Optional TargetVariant; diff --git a/lib/DriverTool/autolink_extract_main.cpp b/lib/DriverTool/autolink_extract_main.cpp index f79923e10a741..8d00c791589cb 100644 --- a/lib/DriverTool/autolink_extract_main.cpp +++ b/lib/DriverTool/autolink_extract_main.cpp @@ -84,7 +84,7 @@ class AutolinkExtractInvocation { if (ParsedArgs.getLastArg(OPT_help)) { std::string ExecutableName = llvm::sys::path::stem(MainExecutablePath).str(); - Table->PrintHelp(llvm::outs(), ExecutableName.c_str(), + Table->printHelp(llvm::outs(), ExecutableName.c_str(), "Swift Autolink Extract", options::AutolinkExtractOption, 0, /*ShowAllAliases*/false); return 1; @@ -252,7 +252,7 @@ int autolink_extract_main(ArrayRef Args, const char *Argv0, std::string OutputFilename = Invocation.getOutputFilename(); std::error_code EC; - llvm::raw_fd_ostream OutOS(OutputFilename, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream OutOS(OutputFilename, EC, llvm::sys::fs::OF_None); if (OutOS.has_error() || EC) { Instance.getDiags().diagnose(SourceLoc(), diag::error_opening_output, OutputFilename, EC.message()); diff --git a/lib/DriverTool/modulewrap_main.cpp b/lib/DriverTool/modulewrap_main.cpp index cc924157afa8d..2b63afa20a0df 100644 --- a/lib/DriverTool/modulewrap_main.cpp +++ b/lib/DriverTool/modulewrap_main.cpp @@ -96,7 +96,7 @@ class ModuleWrapInvocation { if (ParsedArgs.getLastArg(OPT_help)) { std::string ExecutableName = llvm::sys::path::stem(MainExecutablePath).str(); - Table->PrintHelp(llvm::outs(), ExecutableName.c_str(), + Table->printHelp(llvm::outs(), ExecutableName.c_str(), "Swift Module Wrapper", options::ModuleWrapOption, 0, /*ShowAllAliases*/false); return 1; diff --git a/lib/DriverTool/swift_api_digester_main.cpp b/lib/DriverTool/swift_api_digester_main.cpp index 60ba731bb5ef9..654800c0e2443 100644 --- a/lib/DriverTool/swift_api_digester_main.cpp +++ b/lib/DriverTool/swift_api_digester_main.cpp @@ -186,13 +186,15 @@ class RemovedAddedNodeMatcher : public NodeMatcher, public MatchedNodeListener { bool detectFuncToProperty(SDKNode *R, SDKNode *A) { if (R->getKind() == SDKNodeKind::DeclFunction) { if (A->getKind() == SDKNodeKind::DeclVar) { - if (A->getName().compare_lower(R->getName()) == 0) { + if (A->getName().compare_insensitive(R->getName()) == 0) { R->annotate(NodeAnnotation::GetterToProperty); } else if (R->getName().startswith("get") && - R->getName().substr(3).compare_lower(A->getName()) == 0) { + R->getName().substr(3).compare_insensitive(A->getName()) == + 0) { R->annotate(NodeAnnotation::GetterToProperty); } else if (R->getName().startswith("set") && - R->getName().substr(3).compare_lower(A->getName()) == 0) { + R->getName().substr(3).compare_insensitive(A->getName()) == + 0) { R->annotate(NodeAnnotation::SetterToProperty); } else { return false; @@ -1877,7 +1879,7 @@ static int diagnoseModuleChange(SDKContext &Ctx, SDKNodeRoot *LeftModule, std::unique_ptr FileOS; if (!OutputPath.empty()) { std::error_code EC; - FileOS.reset(new llvm::raw_fd_ostream(OutputPath, EC, llvm::sys::fs::F_None)); + FileOS.reset(new llvm::raw_fd_ostream(OutputPath, EC, llvm::sys::fs::OF_None)); OS = FileOS.get(); } bool FailOnError; @@ -2023,7 +2025,7 @@ static int generateMigrationScript(StringRef LeftPath, StringRef RightPath, auto &typeMemberDiffs = Ctx.getTypeMemberDiffs(); std::error_code EC; - llvm::raw_fd_ostream Fs(DiffPath, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream Fs(DiffPath, EC, llvm::sys::fs::OF_None); removeRedundantAndSort(AllItems); removeRedundantAndSort(typeMemberDiffs); removeRedundantAndSort(AllNoEscapingFuncs); @@ -2069,7 +2071,7 @@ static int deserializeDiffItems(APIDiffItemStore &Store, StringRef DiffPath, StringRef OutputPath) { Store.addStorePath(DiffPath); std::error_code EC; - llvm::raw_fd_ostream FS(OutputPath, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream FS(OutputPath, EC, llvm::sys::fs::OF_None); APIDiffItemStore::serialize(FS, Store.getAllDiffItems()); return 0; } @@ -2077,7 +2079,7 @@ static int deserializeDiffItems(APIDiffItemStore &Store, StringRef DiffPath, static int deserializeNameCorrection(APIDiffItemStore &Store, StringRef OutputPath) { std::error_code EC; - llvm::raw_fd_ostream FS(OutputPath, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream FS(OutputPath, EC, llvm::sys::fs::OF_None); std::set Result; for (auto *Item: Store.getAllDiffItems()) { if (auto *CI = dyn_cast(Item)) { @@ -2346,7 +2348,7 @@ class SwiftAPIDigesterInvocation { void printHelp() { std::string ExecutableName = llvm::sys::path::stem(MainExecutablePath).str(); - Table->PrintHelp(llvm::outs(), ExecutableName.c_str(), "Swift API Digester", + Table->printHelp(llvm::outs(), ExecutableName.c_str(), "Swift API Digester", /*IncludedFlagsBitmask*/ SwiftAPIDigesterOption, /*ExcludedFlagsBitmask*/ 0, /*ShowAllAliases*/ false); diff --git a/lib/DriverTool/swift_api_extract_main.cpp b/lib/DriverTool/swift_api_extract_main.cpp index 70dda49862c41..57c98dbd9f092 100644 --- a/lib/DriverTool/swift_api_extract_main.cpp +++ b/lib/DriverTool/swift_api_extract_main.cpp @@ -65,7 +65,7 @@ class SwiftAPIExtractInvocation { if (ParsedArgs.getLastArg(OPT_help)) { std::string ExecutableName = llvm::sys::path::stem(MainExecutablePath).str(); - Table->PrintHelp(llvm::outs(), ExecutableName.c_str(), + Table->printHelp(llvm::outs(), ExecutableName.c_str(), "Swift API Extract", options::SwiftAPIExtractOption, 0, /*ShowAllAliases*/ false); return 1; diff --git a/lib/DriverTool/swift_indent_main.cpp b/lib/DriverTool/swift_indent_main.cpp index 2652e4aa8c992..cb38a7a7f86ce 100644 --- a/lib/DriverTool/swift_indent_main.cpp +++ b/lib/DriverTool/swift_indent_main.cpp @@ -149,7 +149,7 @@ class SwiftIndentInvocation { if (ParsedArgs.getLastArg(OPT_help)) { std::string ExecutableName = llvm::sys::path::stem(MainExecutablePath).str(); - Table->PrintHelp(llvm::outs(), ExecutableName.c_str(), + Table->printHelp(llvm::outs(), ExecutableName.c_str(), "Swift Format Tool", options::SwiftIndentOption, 0, /*ShowAllAliases*/false); return 1; @@ -220,7 +220,7 @@ class SwiftIndentInvocation { Destination = Filename; else Destination = OutputFilename; - llvm::raw_fd_ostream out(Destination, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream out(Destination, EC, llvm::sys::fs::OF_None); if (out.has_error() || EC) { Diags.diagnose(SourceLoc(), diag::error_opening_output, Filename, EC.message()); diff --git a/lib/DriverTool/swift_symbolgraph_extract_main.cpp b/lib/DriverTool/swift_symbolgraph_extract_main.cpp index 7297c5ac55aa4..36451d9020a61 100644 --- a/lib/DriverTool/swift_symbolgraph_extract_main.cpp +++ b/lib/DriverTool/swift_symbolgraph_extract_main.cpp @@ -62,7 +62,7 @@ int swift_symbolgraph_extract_main(ArrayRef Args, if (ParsedArgs.getLastArg(OPT_help) || Args.empty()) { std::string ExecutableName = llvm::sys::path::stem(MainExecutablePath).str(); - Table->PrintHelp(llvm::outs(), ExecutableName.c_str(), + Table->printHelp(llvm::outs(), ExecutableName.c_str(), "Swift Symbol Graph Extractor", SwiftSymbolGraphExtractOption, 0, /*ShowAllAliases*/ false); @@ -235,7 +235,7 @@ int swift_symbolgraph_extract_main(ArrayRef Args, // don't need to print these errors. CI.removeDiagnosticConsumer(&DiagPrinter); - SmallVector Overlays; + SmallVector Overlays; M->findDeclaredCrossImportOverlaysTransitive(Overlays); for (const auto *OM : Overlays) { auto CIM = CI.getASTContext().getModuleByName(OM->getNameStr()); diff --git a/lib/Frontend/DiagnosticVerifier.cpp b/lib/Frontend/DiagnosticVerifier.cpp index 23c5a281ff55c..80a69bc5e5787 100644 --- a/lib/Frontend/DiagnosticVerifier.cpp +++ b/lib/Frontend/DiagnosticVerifier.cpp @@ -209,7 +209,7 @@ static void autoApplyFixes(SourceManager &SM, unsigned BufferID, std::error_code error; llvm::raw_fd_ostream outs(memBuffer->getBufferIdentifier(), error, - llvm::sys::fs::OpenFlags::F_None); + llvm::sys::fs::OpenFlags::OF_None); if (!error) outs << Result; } diff --git a/lib/Frontend/Frontend.cpp b/lib/Frontend/Frontend.cpp index fa01ad0d7f36a..dbd5bd03f51b5 100644 --- a/lib/Frontend/Frontend.cpp +++ b/lib/Frontend/Frontend.cpp @@ -30,9 +30,9 @@ #include "swift/SIL/SILModule.h" #include "swift/SILOptimizer/PassManager/Passes.h" #include "swift/SILOptimizer/Utils/Generics.h" +#include "swift/Serialization/ModuleDependencyScanner.h" #include "swift/Serialization/SerializationOptions.h" #include "swift/Serialization/SerializedModuleLoader.h" -#include "swift/Serialization/ModuleDependencyScanner.h" #include "swift/Strings.h" #include "swift/Subsystems.h" #include "clang/AST/ASTContext.h" @@ -44,6 +44,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" +#include using namespace swift; @@ -61,7 +62,7 @@ std::string CompilerInvocation::getPCHHash() const { SILOpts.getPCHHashComponents(), IRGenOpts.getPCHHashComponents()); - return llvm::APInt(64, Code).toString(36, /*Signed=*/false); + return llvm::toString(llvm::APInt(64, Code), 36, /*Signed=*/false); } const PrimarySpecificPaths & diff --git a/lib/Frontend/ModuleInterfaceLoader.cpp b/lib/Frontend/ModuleInterfaceLoader.cpp index 6db72727e6463..d3e0a8d646070 100644 --- a/lib/Frontend/ModuleInterfaceLoader.cpp +++ b/lib/Frontend/ModuleInterfaceLoader.cpp @@ -33,6 +33,7 @@ #include "llvm/ADT/APInt.h" #include "llvm/ADT/Hashing.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Errc.h" @@ -1571,7 +1572,7 @@ InterfaceSubContextDelegateImpl::getCacheHash(StringRef useInterfacePath) { // ensure that we compile all swift interface files with the option set. unsigned(genericSubInvocation.getSILOptions().EnableOSSAModules)); - return llvm::APInt(64, H).toString(36, /*Signed=*/false); + return llvm::toString(llvm::APInt(64, H), 36, /*Signed=*/false); } std::error_code diff --git a/lib/Frontend/SerializedDiagnosticConsumer.cpp b/lib/Frontend/SerializedDiagnosticConsumer.cpp index f8f1ead32cc59..3e87d1268b6de 100644 --- a/lib/Frontend/SerializedDiagnosticConsumer.cpp +++ b/lib/Frontend/SerializedDiagnosticConsumer.cpp @@ -133,7 +133,7 @@ class SerializedDiagnosticConsumer : public DiagnosticConsumer { std::error_code EC; std::unique_ptr OS; OS.reset(new llvm::raw_fd_ostream(State->SerializedDiagnosticsPath, EC, - llvm::sys::fs::F_None)); + llvm::sys::fs::OF_None)); if (EC) { // Create a temporary diagnostics engine to print the error to stderr. SourceManager dummyMgr; diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp index 534bb4545a034..baf16761e4a37 100644 --- a/lib/FrontendTool/FrontendTool.cpp +++ b/lib/FrontendTool/FrontendTool.cpp @@ -127,7 +127,7 @@ static std::unique_ptr getFileOutputStream(StringRef OutputFilename, ASTContext &Ctx) { std::error_code errorCode; auto os = std::make_unique( - OutputFilename, errorCode, llvm::sys::fs::F_None); + OutputFilename, errorCode, llvm::sys::fs::OF_None); if (errorCode) { Ctx.Diags.diagnose(SourceLoc(), diag::error_opening_output, OutputFilename, errorCode.message()); @@ -247,7 +247,7 @@ class JSONFixitWriter std::unique_ptr OS; OS.reset(new llvm::raw_fd_ostream(FixitsOutputPath, EC, - llvm::sys::fs::F_None)); + llvm::sys::fs::OF_None)); if (EC) { // Create a temporary diagnostics engine to print the error to stderr. SourceManager dummyMgr; @@ -1021,7 +1021,7 @@ static bool printSwiftFeature(CompilerInstance &instance) { const FrontendOptions &opts = invocation.getFrontendOptions(); std::string path = opts.InputsAndOutputs.getSingleOutputFilename(); std::error_code EC; - llvm::raw_fd_ostream out(path, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream out(path, EC, llvm::sys::fs::OF_None); if (out.has_error() || EC) { context.Diags.diagnose(SourceLoc(), diag::error_opening_output, path, @@ -2072,7 +2072,7 @@ int swift::performFrontend(ArrayRef Args, Invocation.getFrontendOptions().PrintHelpHidden ? 0 : llvm::opt::HelpHidden; std::unique_ptr Options(createSwiftOptTable()); - Options->PrintHelp(llvm::outs(), displayName(MainExecutablePath).c_str(), + Options->printHelp(llvm::outs(), displayName(MainExecutablePath).c_str(), "Swift frontend", IncludedFlagsBitmask, ExcludedFlagsBitmask, /*ShowAllAliases*/false); return finishDiagProcessing(0, /*verifierEnabled*/ false); diff --git a/lib/FrontendTool/ImportedModules.cpp b/lib/FrontendTool/ImportedModules.cpp index 9316af5a09dc1..f73dfc64d25cf 100644 --- a/lib/FrontendTool/ImportedModules.cpp +++ b/lib/FrontendTool/ImportedModules.cpp @@ -47,7 +47,7 @@ bool swift::emitImportedModules(ModuleDecl *mainModule, auto &Context = mainModule->getASTContext(); std::string path = opts.InputsAndOutputs.getSingleOutputFilename(); std::error_code EC; - llvm::raw_fd_ostream out(path, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream out(path, EC, llvm::sys::fs::OF_None); if (out.has_error() || EC) { Context.Diags.diagnose(SourceLoc(), diag::error_opening_output, path, diff --git a/lib/FrontendTool/LoadedModuleTrace.cpp b/lib/FrontendTool/LoadedModuleTrace.cpp index 7ec8fd1bd6665..99cce3da1760a 100644 --- a/lib/FrontendTool/LoadedModuleTrace.cpp +++ b/lib/FrontendTool/LoadedModuleTrace.cpp @@ -707,7 +707,7 @@ bool swift::emitLoadedModuleTraceIfNeeded(ModuleDecl *mainModule, if (loadedModuleTracePath.empty()) return false; std::error_code EC; - llvm::raw_fd_ostream out(loadedModuleTracePath, EC, llvm::sys::fs::F_Append); + llvm::raw_fd_ostream out(loadedModuleTracePath, EC, llvm::sys::fs::OF_Append); if (out.has_error() || EC) { ctxt.Diags.diagnose(SourceLoc(), diag::error_opening_output, diff --git a/lib/FrontendTool/MakeStyleDependencies.cpp b/lib/FrontendTool/MakeStyleDependencies.cpp index 9e2fa946926bf..02368ea8d5e19 100644 --- a/lib/FrontendTool/MakeStyleDependencies.cpp +++ b/lib/FrontendTool/MakeStyleDependencies.cpp @@ -97,7 +97,7 @@ bool swift::emitMakeDependenciesIfNeeded(DiagnosticEngine &diags, return false; std::error_code EC; - llvm::raw_fd_ostream out(dependenciesFilePath, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream out(dependenciesFilePath, EC, llvm::sys::fs::OF_None); if (out.has_error() || EC) { diags.diagnose(SourceLoc(), diag::error_opening_output, diff --git a/lib/FrontendTool/TBD.cpp b/lib/FrontendTool/TBD.cpp index 8f26fd03f6bb2..3872ced6233f7 100644 --- a/lib/FrontendTool/TBD.cpp +++ b/lib/FrontendTool/TBD.cpp @@ -44,7 +44,7 @@ static std::vector sortSymbols(llvm::StringSet<> &symbols) { bool swift::writeTBD(ModuleDecl *M, StringRef OutputFilename, const TBDGenOptions &Opts) { std::error_code EC; - llvm::raw_fd_ostream OS(OutputFilename, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream OS(OutputFilename, EC, llvm::sys::fs::OF_None); if (EC) { M->getASTContext().Diags.diagnose(SourceLoc(), diag::error_opening_output, OutputFilename, EC.message()); diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp index 1db35ddc078d4..397fac397efc5 100644 --- a/lib/IDE/CodeCompletion.cpp +++ b/lib/IDE/CodeCompletion.cpp @@ -1462,13 +1462,13 @@ void CodeCompletionContext::sortCompletionResults( // Sort nameCache, and then transform Results to return the pointers in order. std::sort(nameCache.begin(), nameCache.end(), [](const ResultAndName &LHS, const ResultAndName &RHS) { - int Result = StringRef(LHS.name).compare_lower(RHS.name); - // If the case insensitive comparison is equal, then secondary sort order - // should be case sensitive. - if (Result == 0) - Result = LHS.name.compare(RHS.name); - return Result < 0; - }); + int Result = StringRef(LHS.name).compare_insensitive(RHS.name); + // If the case insensitive comparison is equal, then secondary + // sort order should be case sensitive. + if (Result == 0) + Result = LHS.name.compare(RHS.name); + return Result < 0; + }); llvm::transform(nameCache, Results.begin(), [](const ResultAndName &entry) { return entry.result; }); diff --git a/lib/IDE/ModuleInterfacePrinting.cpp b/lib/IDE/ModuleInterfacePrinting.cpp index f11e4e3126da2..ede301374bc9c 100644 --- a/lib/IDE/ModuleInterfacePrinting.cpp +++ b/lib/IDE/ModuleInterfacePrinting.cpp @@ -207,8 +207,9 @@ void swift::ide::collectModuleGroups(ModuleDecl *M, for (auto File : M->getFiles()) { File->collectAllGroups(Into); } - std::sort(Into.begin(), Into.end(), - [](StringRef L, StringRef R) { return L.compare_lower(R) < 0; }); + std::sort(Into.begin(), Into.end(), [](StringRef L, StringRef R) { + return L.compare_insensitive(R) < 0; + }); } /// Determine whether the given extension has a Clang node that diff --git a/lib/IDE/SyntaxModel.cpp b/lib/IDE/SyntaxModel.cpp index 9ada8e102f7c0..f531ac8d6f93f 100644 --- a/lib/IDE/SyntaxModel.cpp +++ b/lib/IDE/SyntaxModel.cpp @@ -1606,7 +1606,7 @@ class DocFieldParser { ; StringRef ident(identStart, ptr - identStart); - if (ident.equals_lower("parameter")) { + if (ident.equals_insensitive("parameter")) { if (numSpaces > 1 || !advanceIf(' ')) return None; while (advanceIf([](char c) { return c != ':'; })) @@ -1616,7 +1616,7 @@ class DocFieldParser { return ident; } else if (advanceIf(':')) { - if (ident.equals_lower("parameters") && numSpaces > 1) + if (ident.equals_insensitive("parameters") && numSpaces > 1) return None; auto lowerIdent = ident.lower(); bool isField = llvm::StringSwitch(lowerIdent) diff --git a/lib/IRGen/DebugTypeInfo.cpp b/lib/IRGen/DebugTypeInfo.cpp index 9f183d306870f..779f30d9c782a 100644 --- a/lib/IRGen/DebugTypeInfo.cpp +++ b/lib/IRGen/DebugTypeInfo.cpp @@ -24,11 +24,13 @@ using namespace swift; using namespace irgen; -DebugTypeInfo::DebugTypeInfo(swift::Type Ty, llvm::Type *StorageTy, +DebugTypeInfo::DebugTypeInfo(swift::Type Ty, llvm::Type *FragmentStorageTy, Optional size, Alignment align, - bool HasDefaultAlignment, bool IsMetadata) - : Type(Ty.getPointer()), StorageType(StorageTy), size(size), align(align), - DefaultAlignment(HasDefaultAlignment), IsMetadataType(IsMetadata) { + bool HasDefaultAlignment, bool IsMetadata, + bool SizeIsFragmentSize) + : Type(Ty.getPointer()), FragmentStorageType(FragmentStorageTy), size(size), + align(align), DefaultAlignment(HasDefaultAlignment), + IsMetadataType(IsMetadata), SizeIsFragmentSize(SizeIsFragmentSize) { assert(align.getValue() != 0); } @@ -42,7 +44,8 @@ static bool hasDefaultAlignment(swift::Type Ty) { } DebugTypeInfo DebugTypeInfo::getFromTypeInfo(swift::Type Ty, - const TypeInfo &Info) { + const TypeInfo &Info, + bool IsFragmentTypeInfo) { Optional size; if (Info.isFixedSize()) { const FixedTypeInfo &FixTy = *cast(&Info); @@ -51,11 +54,12 @@ DebugTypeInfo DebugTypeInfo::getFromTypeInfo(swift::Type Ty, assert(Info.getStorageType() && "StorageType is a nullptr"); return DebugTypeInfo(Ty.getPointer(), Info.getStorageType(), size, Info.getBestKnownAlignment(), ::hasDefaultAlignment(Ty), - false); + false, IsFragmentTypeInfo); } DebugTypeInfo DebugTypeInfo::getLocalVariable(VarDecl *Decl, swift::Type Ty, - const TypeInfo &Info) { + const TypeInfo &Info, + bool IsFragmentTypeInfo) { auto DeclType = Decl->getInterfaceType(); auto RealType = Ty; @@ -69,30 +73,32 @@ DebugTypeInfo DebugTypeInfo::getLocalVariable(VarDecl *Decl, swift::Type Ty, // the type hasn't been mucked with by an optimization pass. auto *Type = Sugared->isEqual(RealType) ? DeclType.getPointer() : RealType.getPointer(); - return getFromTypeInfo(Type, Info); + return getFromTypeInfo(Type, Info, IsFragmentTypeInfo); } DebugTypeInfo DebugTypeInfo::getMetadata(swift::Type Ty, llvm::Type *StorageTy, Size size, Alignment align) { DebugTypeInfo DbgTy(Ty.getPointer(), StorageTy, size, - align, true, false); + align, true, false, false); assert(StorageTy && "StorageType is a nullptr"); - assert(!DbgTy.isContextArchetype() && "type metadata cannot contain an archetype"); + assert(!DbgTy.isContextArchetype() && + "type metadata cannot contain an archetype"); return DbgTy; } DebugTypeInfo DebugTypeInfo::getArchetype(swift::Type Ty, llvm::Type *StorageTy, Size size, Alignment align) { DebugTypeInfo DbgTy(Ty.getPointer(), StorageTy, size, - align, true, true); + align, true, true, false); assert(StorageTy && "StorageType is a nullptr"); - assert(!DbgTy.isContextArchetype() && "type metadata cannot contain an archetype"); + assert(!DbgTy.isContextArchetype() && + "type metadata cannot contain an archetype"); return DbgTy; } DebugTypeInfo DebugTypeInfo::getForwardDecl(swift::Type Ty) { DebugTypeInfo DbgTy(Ty.getPointer(), nullptr, {}, Alignment(1), true, - false); + false, false); return DbgTy; } @@ -109,8 +115,8 @@ DebugTypeInfo DebugTypeInfo::getGlobal(SILGlobalVariable *GV, Type = DeclType.getPointer(); } DebugTypeInfo DbgTy(Type, StorageTy, size, align, ::hasDefaultAlignment(Type), - false); - assert(StorageTy && "StorageType is a nullptr"); + false, false); + assert(StorageTy && "FragmentStorageType is a nullptr"); assert(!DbgTy.isContextArchetype() && "type of global variable cannot be an archetype"); assert(align.getValue() != 0); @@ -118,20 +124,21 @@ DebugTypeInfo DebugTypeInfo::getGlobal(SILGlobalVariable *GV, } DebugTypeInfo DebugTypeInfo::getObjCClass(ClassDecl *theClass, - llvm::Type *StorageType, Size size, - Alignment align) { - DebugTypeInfo DbgTy(theClass->getInterfaceType().getPointer(), StorageType, - size, align, true, false); - assert(StorageType && "StorageType is a nullptr"); - assert(!DbgTy.isContextArchetype() && "type of objc class cannot be an archetype"); + llvm::Type *FragmentStorageType, + Size size, Alignment align) { + DebugTypeInfo DbgTy(theClass->getInterfaceType().getPointer(), + FragmentStorageType, size, align, true, false, false); + assert(FragmentStorageType && "FragmentStorageType is a nullptr"); + assert(!DbgTy.isContextArchetype() && + "type of objc class cannot be an archetype"); return DbgTy; } DebugTypeInfo DebugTypeInfo::getErrorResult(swift::Type Ty, llvm::Type *StorageType, Size size, Alignment align) { - assert(StorageType && "StorageType is a nullptr"); - return {Ty, StorageType, size, align, true, false}; + assert(StorageType && "FragmentStorageType is a nullptr"); + return {Ty, StorageType, size, align, true, false, false}; } bool DebugTypeInfo::operator==(DebugTypeInfo T) const { @@ -162,9 +169,9 @@ LLVM_DUMP_METHOD void DebugTypeInfo::dump() const { llvm::errs() << "Alignment " << align.getValue() << "] "; getType()->dump(llvm::errs()); - if (StorageType) { - llvm::errs() << "StorageType="; - StorageType->dump(); + if (FragmentStorageType) { + llvm::errs() << "FragmentStorageType="; + FragmentStorageType->dump(); } else llvm::errs() << "forward-declared\n"; } diff --git a/lib/IRGen/DebugTypeInfo.h b/lib/IRGen/DebugTypeInfo.h index aaa5c7e0e4678..abbd2eb4bf005 100644 --- a/lib/IRGen/DebugTypeInfo.h +++ b/lib/IRGen/DebugTypeInfo.h @@ -42,21 +42,24 @@ class DebugTypeInfo { TypeBase *Type = nullptr; /// Needed to determine the size of basic types and to determine /// the storage type for undefined variables. - llvm::Type *StorageType = nullptr; + llvm::Type *FragmentStorageType = nullptr; Optional size; Alignment align; bool DefaultAlignment = true; bool IsMetadataType = false; + bool SizeIsFragmentSize; public: DebugTypeInfo() = default; DebugTypeInfo(swift::Type Ty, llvm::Type *StorageTy, Optional SizeInBytes, Alignment AlignInBytes, - bool HasDefaultAlignment, bool IsMetadataType); + bool HasDefaultAlignment, bool IsMetadataType, + bool IsFragmentTypeInfo); /// Create type for a local variable. - static DebugTypeInfo getLocalVariable(VarDecl *Decl, - swift::Type Ty, const TypeInfo &Info); + static DebugTypeInfo getLocalVariable(VarDecl *Decl, swift::Type Ty, + const TypeInfo &Info, + bool IsFragmentTypeInfo); /// Create type for global type metadata. static DebugTypeInfo getMetadata(swift::Type Ty, llvm::Type *StorageTy, Size size, Alignment align); @@ -68,10 +71,12 @@ class DebugTypeInfo { static DebugTypeInfo getForwardDecl(swift::Type Ty); /// Create a standalone type from a TypeInfo object. - static DebugTypeInfo getFromTypeInfo(swift::Type Ty, const TypeInfo &Info); + static DebugTypeInfo getFromTypeInfo(swift::Type Ty, const TypeInfo &Info, + bool IsFragmentTypeInfo); /// Global variables. - static DebugTypeInfo getGlobal(SILGlobalVariable *GV, llvm::Type *StorageType, - Size size, Alignment align); + static DebugTypeInfo getGlobal(SILGlobalVariable *GV, + llvm::Type *StorageType, Size size, + Alignment align); /// ObjC classes. static DebugTypeInfo getObjCClass(ClassDecl *theClass, llvm::Type *StorageType, Size size, @@ -86,24 +91,29 @@ class DebugTypeInfo { // Determine whether this type is an Archetype dependent on a generic context. bool isContextArchetype() const { - if (auto archetype = Type->getWithoutSpecifierType()->getAs()) { + if (auto archetype = + Type->getWithoutSpecifierType()->getAs()) { return !isa(archetype->getRoot()); } return false; } - llvm::Type *getStorageType() const { + llvm::Type *getFragmentStorageType() const { if (size && size->isZero()) - assert(StorageType && "only defined types may have a size"); - return StorageType; + assert(FragmentStorageType && "only defined types may have a size"); + return FragmentStorageType; } - Optional getSize() const { return size; } + Optional getTypeSize() const { + return SizeIsFragmentSize ? llvm::None : size; + } + Optional getRawSize() const { return size; } void setSize(Size NewSize) { size = NewSize; } Alignment getAlignment() const { return align; } bool isNull() const { return Type == nullptr; } - bool isForwardDecl() const { return StorageType == nullptr; } + bool isForwardDecl() const { return FragmentStorageType == nullptr; } bool isMetadataType() const { return IsMetadataType; } bool hasDefaultAlignment() const { return DefaultAlignment; } + bool isSizeFragmentSize() const { return SizeIsFragmentSize; } bool operator==(DebugTypeInfo T) const; bool operator!=(DebugTypeInfo T) const; @@ -115,9 +125,10 @@ class DebugTypeInfo { /// A DebugTypeInfo with a defined size (that may be 0). class CompletedDebugTypeInfo : public DebugTypeInfo { CompletedDebugTypeInfo(DebugTypeInfo DbgTy) : DebugTypeInfo(DbgTy) {} + public: static Optional get(DebugTypeInfo DbgTy) { - if (!DbgTy.getSize()) + if (!DbgTy.getRawSize() || DbgTy.isSizeFragmentSize()) return {}; return CompletedDebugTypeInfo(DbgTy); } @@ -125,7 +136,7 @@ class CompletedDebugTypeInfo : public DebugTypeInfo { static Optional getFromTypeInfo(swift::Type Ty, const TypeInfo &Info) { return CompletedDebugTypeInfo::get( - DebugTypeInfo::getFromTypeInfo(Ty, Info)); + DebugTypeInfo::getFromTypeInfo(Ty, Info, /*IsFragment*/ false)); } Size::int_type getSizeValue() const { return size->getValue(); } @@ -144,7 +155,7 @@ template <> struct DenseMapInfo { static swift::irgen::DebugTypeInfo getTombstoneKey() { return swift::irgen::DebugTypeInfo( llvm::DenseMapInfo::getTombstoneKey(), nullptr, - swift::irgen::Size(0), swift::irgen::Alignment(), false, false); + swift::irgen::Size(0), swift::irgen::Alignment(), false, false, false); } static unsigned getHashValue(swift::irgen::DebugTypeInfo Val) { return DenseMapInfo::getHashValue(Val.getType()); diff --git a/lib/IRGen/GenBuiltin.cpp b/lib/IRGen/GenBuiltin.cpp index b72174f0ce638..1ccb6f2938cc6 100644 --- a/lib/IRGen/GenBuiltin.cpp +++ b/lib/IRGen/GenBuiltin.cpp @@ -757,7 +757,8 @@ if (Builtin.ID == BuiltinValueKind::id) { \ pointer = IGF.Builder.CreateBitCast(pointer, llvm::PointerType::getUnqual(cmp->getType())); llvm::Value *value = IGF.Builder.CreateAtomicCmpXchg( - pointer, cmp, newval, successOrdering, failureOrdering, + pointer, cmp, newval, llvm::MaybeAlign(), + successOrdering, failureOrdering, isSingleThread ? llvm::SyncScope::SingleThread : llvm::SyncScope::System); cast(value)->setVolatile(isVolatile); @@ -825,7 +826,7 @@ if (Builtin.ID == BuiltinValueKind::id) { \ pointer = IGF.Builder.CreateBitCast(pointer, llvm::PointerType::getUnqual(val->getType())); llvm::Value *value = IGF.Builder.CreateAtomicRMW( - SubOpcode, pointer, val, ordering, + SubOpcode, pointer, val, llvm::MaybeAlign(), ordering, isSingleThread ? llvm::SyncScope::SingleThread : llvm::SyncScope::System); cast(value)->setVolatile(isVolatile); diff --git a/lib/IRGen/GenCall.cpp b/lib/IRGen/GenCall.cpp index 5d8269477b096..c80e6c2528fe9 100644 --- a/lib/IRGen/GenCall.cpp +++ b/lib/IRGen/GenCall.cpp @@ -1092,17 +1092,20 @@ namespace { llvm_unreachable("OpenCL type in ABI lowering"); // We should never see ARM SVE types at all. -#define SVE_TYPE(Name, Id, ...) \ - case clang::BuiltinType::Id: +#define SVE_TYPE(Name, Id, ...) case clang::BuiltinType::Id: #include "clang/Basic/AArch64SVEACLETypes.def" llvm_unreachable("ARM SVE type in ABI lowering"); // We should never see PPC MMA types at all. -#define PPC_VECTOR_TYPE(Name, Id, Size) \ - case clang::BuiltinType::Id: +#define PPC_VECTOR_TYPE(Name, Id, Size) case clang::BuiltinType::Id: #include "clang/Basic/PPCTypes.def" llvm_unreachable("PPC MMA type in ABI lowering"); + // We should never see RISC-V V types at all. +#define RVV_TYPE(Name, Id, Size) case clang::BuiltinType::Id: +#include "clang/Basic/RISCVVTypes.def" + llvm_unreachable("RISC-V V type in ABI lowering"); + // Handle all the integer types as opaque values. #define BUILTIN_TYPE(Id, SingletonId) #define SIGNED_TYPE(Id, SingletonId) \ diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp index a552c04478579..9e02e4e491b49 100644 --- a/lib/IRGen/GenDecl.cpp +++ b/lib/IRGen/GenDecl.cpp @@ -697,13 +697,13 @@ void IRGenModule::emitRuntimeRegistration() { llvm::ConstantInt::get(Int32Ty, 0), }; auto begin = llvm::ConstantExpr::getGetElementPtr( - /*Ty=*/nullptr, protocols, beginIndices); + protocols->getType()->getPointerElementType(), protocols, beginIndices); llvm::Constant *endIndices[] = { llvm::ConstantInt::get(Int32Ty, 0), llvm::ConstantInt::get(Int32Ty, SwiftProtocols.size()), }; auto end = llvm::ConstantExpr::getGetElementPtr( - /*Ty=*/nullptr, protocols, endIndices); + protocols->getType()->getPointerElementType() , protocols, endIndices); RegIGF.Builder.CreateCall(getRegisterProtocolsFn(), {begin, end}); } @@ -716,13 +716,15 @@ void IRGenModule::emitRuntimeRegistration() { llvm::ConstantInt::get(Int32Ty, 0), }; auto begin = llvm::ConstantExpr::getGetElementPtr( - /*Ty=*/nullptr, conformances, beginIndices); + conformances->getType()->getPointerElementType(), + conformances, beginIndices); llvm::Constant *endIndices[] = { llvm::ConstantInt::get(Int32Ty, 0), llvm::ConstantInt::get(Int32Ty, ProtocolConformances.size()), }; auto end = llvm::ConstantExpr::getGetElementPtr( - /*Ty=*/nullptr, conformances, endIndices); + conformances->getType()->getPointerElementType(), + conformances, endIndices); RegIGF.Builder.CreateCall(getRegisterProtocolConformancesFn(), {begin, end}); } @@ -736,13 +738,13 @@ void IRGenModule::emitRuntimeRegistration() { llvm::ConstantInt::get(Int32Ty, 0), }; auto begin = llvm::ConstantExpr::getGetElementPtr( - /*Ty=*/nullptr, records, beginIndices); + records->getType()->getPointerElementType(), records, beginIndices); llvm::Constant *endIndices[] = { llvm::ConstantInt::get(Int32Ty, 0), llvm::ConstantInt::get(Int32Ty, RuntimeResolvableTypes.size()), }; auto end = llvm::ConstantExpr::getGetElementPtr( - /*Ty=*/nullptr, records, endIndices); + records->getType()->getPointerElementType(), records, endIndices); RegIGF.Builder.CreateCall(getRegisterTypeMetadataRecordsFn(), {begin, end}); } @@ -909,6 +911,15 @@ bool LinkInfo::isUsed(IRLinkage IRL) { /// /// This value must have a definition by the time the module is finalized. void IRGenModule::addUsedGlobal(llvm::GlobalValue *global) { + + // As of reviews.llvm.org/D97448 "ELF: Create unique SHF_GNU_RETAIN sections + // for llvm.used global objects" LLVM creates separate sections for globals in + // llvm.used on ELF. Therefore we use llvm.compiler.used on ELF instead. + if (TargetInfo.OutputObjectFormat == llvm::Triple::ELF) { + addCompilerUsedGlobal(global); + return; + } + LLVMUsed.push_back(global); } @@ -1655,7 +1666,7 @@ static llvm::GlobalVariable *getChainEntryForDynamicReplacement( llvm::Constant *indices[] = {llvm::ConstantInt::get(IGM.Int32Ty, 0), llvm::ConstantInt::get(IGM.Int32Ty, 0)}; auto *storageAddr = llvm::ConstantExpr::getInBoundsGetElementPtr( - nullptr, linkEntry, indices); + linkEntry->getType()->getPointerElementType(), linkEntry, indices); bool isAsyncFunction = entity.hasSILFunction() && entity.getSILFunction()->isAsync(); auto &schema = @@ -2480,7 +2491,8 @@ Address IRGenModule::getAddrOfSILGlobalVariable(SILGlobalVariable *var, }; // Return the address of the initialized object itself (and not the address // to a reference to it). - addr = llvm::ConstantExpr::getGetElementPtr(nullptr, gvar, Indices); + addr = llvm::ConstantExpr::getGetElementPtr( + gvar->getType()->getPointerElementType(), gvar, Indices); } addr = llvm::ConstantExpr::getBitCast( addr, @@ -2614,7 +2626,8 @@ void IRGenModule::createReplaceableProlog(IRGenFunction &IGF, SILFunction *f) { llvm::ConstantInt::get(Int32Ty, 0)}; auto *fnPtrAddr = - llvm::ConstantExpr::getInBoundsGetElementPtr(nullptr, linkEntry, indices); + llvm::ConstantExpr::getInBoundsGetElementPtr( + linkEntry->getType()->getPointerElementType(), linkEntry, indices); auto *ReplAddr = llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(fnPtrAddr, @@ -2829,7 +2842,8 @@ static void emitDynamicallyReplaceableThunk(IRGenModule &IGM, llvm::ConstantInt::get(IGM.Int32Ty, 0)}; auto *fnPtrAddr = - llvm::ConstantExpr::getInBoundsGetElementPtr(nullptr, linkEntry, indices); + llvm::ConstantExpr::getInBoundsGetElementPtr( + linkEntry->getType()->getPointerElementType(), linkEntry, indices); auto *fnPtr = IGF.Builder.CreateLoad(fnPtrAddr, IGM.getPointerAlignment()); auto *typeFnPtr = IGF.Builder.CreateBitOrPointerCast(fnPtr, implFn->getType()); @@ -2948,7 +2962,8 @@ void IRGenModule::emitDynamicReplacementOriginalFunctionThunk(SILFunction *f) { auto *fnPtrAddr = llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast( - llvm::ConstantExpr::getInBoundsGetElementPtr(nullptr, linkEntry, indices), + llvm::ConstantExpr::getInBoundsGetElementPtr( + linkEntry->getType()->getPointerElementType(), linkEntry, indices), FunctionPtrTy->getPointerTo()); auto *OrigFn = @@ -4434,8 +4449,8 @@ llvm::GlobalValue *IRGenModule::defineTypeMetadata( llvm::Constant *indices[] = { llvm::ConstantInt::get(Int32Ty, 0), llvm::ConstantInt::get(Int32Ty, adjustmentIndex)}; - auto addr = llvm::ConstantExpr::getInBoundsGetElementPtr(/*Ty=*/nullptr, var, - indices); + auto addr = llvm::ConstantExpr::getInBoundsGetElementPtr( + var->getType()->getPointerElementType(), var, indices); addr = llvm::ConstantExpr::getBitCast(addr, TypeMetadataPtrTy); // For concrete metadata, declare the alias to its address point. @@ -4555,7 +4570,8 @@ IRGenModule::getAddrOfTypeMetadata(CanType concreteType, }; addr = ConstantReference( llvm::ConstantExpr::getInBoundsGetElementPtr( - /*Ty=*/nullptr, addr.getValue(), indices), + addr.getValue()->getType()->getPointerElementType(), + addr.getValue(), indices), addr.isIndirect()); } @@ -5128,7 +5144,10 @@ llvm::Constant *IRGenModule::getAddrOfGlobalUTF16String(StringRef utf8) { /// - For enums, new cases can be added /// - For classes, the superclass might change the size or number /// of stored properties -bool IRGenModule::isResilient(NominalTypeDecl *D, ResilienceExpansion expansion) { +bool IRGenModule::isResilient(NominalTypeDecl *D, + ResilienceExpansion expansion) { + if (D->getModuleContext()->getBypassResilience()) + return false; if (expansion == ResilienceExpansion::Maximal && Types.getLoweringMode() == TypeConverter::Mode::CompletelyFragile) { return false; diff --git a/lib/IRGen/GenHeap.cpp b/lib/IRGen/GenHeap.cpp index f8f992452b9d6..6a596aa4cc501 100644 --- a/lib/IRGen/GenHeap.cpp +++ b/lib/IRGen/GenHeap.cpp @@ -517,7 +517,7 @@ static llvm::Constant *buildPrivateMetadata(IRGenModule &IGM, llvm::ConstantInt::get(IGM.Int32Ty, 2) }; return llvm::ConstantExpr::getInBoundsGetElementPtr( - /*Ty=*/nullptr, var, indices); + var->getType()->getPointerElementType(), var, indices); } llvm::Constant * diff --git a/lib/IRGen/GenIntegerLiteral.cpp b/lib/IRGen/GenIntegerLiteral.cpp index 3183513d453e9..c36bb0a5ee299 100644 --- a/lib/IRGen/GenIntegerLiteral.cpp +++ b/lib/IRGen/GenIntegerLiteral.cpp @@ -16,9 +16,10 @@ #include "GenIntegerLiteral.h" +#include "swift/ABI/MetadataValues.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/IR/Constants.h" #include "llvm/IR/GlobalVariable.h" -#include "swift/ABI/MetadataValues.h" #include "BitPatternBuilder.h" #include "Explosion.h" @@ -177,12 +178,12 @@ ConstantIntegerLiteralMap::get(IRGenModule &IGM, APInt &&value) { // TODO: make this shared within the image auto arrayTy = llvm::ArrayType::get(IGM.SizeTy, numChunks); auto initV = llvm::ConstantArray::get(arrayTy, chunks); - auto globalArray = - new llvm::GlobalVariable(*IGM.getModule(), arrayTy, /*constant*/ true, - llvm::GlobalVariable::PrivateLinkage, initV, - IGM.EnableValueNames - ? Twine("intliteral.") + value.toString(10, true) - : ""); + auto globalArray = new llvm::GlobalVariable( + *IGM.getModule(), arrayTy, /*constant*/ true, + llvm::GlobalVariable::PrivateLinkage, initV, + IGM.EnableValueNames + ? Twine("intliteral.") + llvm::toString(value, 10, true) + : ""); globalArray->setUnnamedAddr(llvm::GlobalVariable::UnnamedAddr::Global); // Various clients expect this to be a i64*, not an [N x i64]*, so cast down. diff --git a/lib/IRGen/GenKeyPath.cpp b/lib/IRGen/GenKeyPath.cpp index 5b3d1696c8699..e81d474a473aa 100644 --- a/lib/IRGen/GenKeyPath.cpp +++ b/lib/IRGen/GenKeyPath.cpp @@ -682,7 +682,8 @@ emitMetadataTypeRefForKeyPath(IRGenModule &IGM, CanType type, // Mask the bottom bit to tell the key path runtime this is a mangled name // rather than a direct reference. auto bitConstant = llvm::ConstantInt::get(IGM.IntPtrTy, 1); - return llvm::ConstantExpr::getGetElementPtr(nullptr, constant, bitConstant); + return llvm::ConstantExpr::getGetElementPtr( + constant->getType()->getPointerElementType(), constant, bitConstant); } static unsigned getClassFieldIndex(ClassDecl *classDecl, VarDecl *property) { diff --git a/lib/IRGen/GenMeta.cpp b/lib/IRGen/GenMeta.cpp index 97a1dc0b84863..593a1e1058d90 100644 --- a/lib/IRGen/GenMeta.cpp +++ b/lib/IRGen/GenMeta.cpp @@ -872,8 +872,9 @@ namespace { B.getAddrOfCurrentPosition(IGM.ProtocolRequirementStructTy); int offset = WitnessTableFirstRequirementOffset; auto firstReqAdjustment = llvm::ConstantInt::get(IGM.Int32Ty, -offset); - address = llvm::ConstantExpr::getGetElementPtr(nullptr, address, - firstReqAdjustment); + address = llvm::ConstantExpr::getGetElementPtr( + address->getType()->getPointerElementType(), address, + firstReqAdjustment); IGM.defineProtocolRequirementsBaseDescriptor(Proto, address); } diff --git a/lib/IRGen/GenProto.cpp b/lib/IRGen/GenProto.cpp index f382dbd3fb584..1e6c4157fc4d3 100644 --- a/lib/IRGen/GenProto.cpp +++ b/lib/IRGen/GenProto.cpp @@ -1498,8 +1498,8 @@ llvm::Constant *IRGenModule::getAssociatedTypeWitness(Type type, auto witness = llvm::ConstantExpr::getBitCast(typeRef, Int8PtrTy); unsigned bit = ProtocolRequirementFlags::AssociatedTypeMangledNameBit; auto bitConstant = llvm::ConstantInt::get(IntPtrTy, bit); - return llvm::ConstantExpr::getInBoundsGetElementPtr(nullptr, witness, - bitConstant); + return llvm::ConstantExpr::getInBoundsGetElementPtr( + witness->getType()->getPointerElementType(), witness, bitConstant); } static void buildAssociatedTypeValueName(CanType depAssociatedType, diff --git a/lib/IRGen/GenReflection.cpp b/lib/IRGen/GenReflection.cpp index af19129a771f4..b9cfae11f8897 100644 --- a/lib/IRGen/GenReflection.cpp +++ b/lib/IRGen/GenReflection.cpp @@ -503,7 +503,8 @@ llvm::Constant *IRGenModule::getMangledAssociatedConformance( // Set the low bit. unsigned bit = ProtocolRequirementFlags::AssociatedTypeMangledNameBit; auto bitConstant = llvm::ConstantInt::get(IntPtrTy, bit); - addr = llvm::ConstantExpr::getGetElementPtr(nullptr, addr, bitConstant); + addr = llvm::ConstantExpr::getGetElementPtr( + addr->getType()->getPointerElementType(), addr, bitConstant); // Update the entry. entry = {var, addr}; diff --git a/lib/IRGen/IRGen.cpp b/lib/IRGen/IRGen.cpp index 37c65f4342def..01dc3417f2af7 100644 --- a/lib/IRGen/IRGen.cpp +++ b/lib/IRGen/IRGen.cpp @@ -548,7 +548,7 @@ bool swift::performLLVM(const IRGenOptions &Opts, if (!OutputFilename.empty()) { // Try to open the output file. Clobbering an existing file is fine. // Open in binary mode if we're doing binary output. - llvm::sys::fs::OpenFlags OSFlags = llvm::sys::fs::F_None; + llvm::sys::fs::OpenFlags OSFlags = llvm::sys::fs::OF_None; std::error_code EC; RawOS.emplace(OutputFilename, EC, OSFlags); @@ -846,7 +846,7 @@ static void embedBitcode(llvm::Module *M, const IRGenOptions &Opts) // Save llvm.compiler.used and remove it. SmallVector UsedArray; - SmallSet UsedGlobals; + SmallVector UsedGlobals; auto *UsedElementType = llvm::Type::getInt8Ty(M->getContext())->getPointerTo(0); llvm::GlobalVariable *Used = @@ -1555,7 +1555,7 @@ bool swift::performLLVM(const IRGenOptions &Opts, ASTContext &Ctx, auto *Clang = static_cast(Ctx.getClangModuleLoader()); // Use clang's datalayout. - Module->setDataLayout(Clang->getTargetInfo().getDataLayout()); + Module->setDataLayout(Clang->getTargetInfo().getDataLayoutString()); embedBitcode(Module, Opts); if (::performLLVM(Opts, Ctx.Diags, nullptr, nullptr, Module, diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index e7e6157a286d9..24aa94a7fbe42 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -47,6 +47,7 @@ #include "clang/Basic/TargetInfo.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Serialization/ASTReader.h" +#include "llvm/ADT/StringSet.h" #include "llvm/Config/config.h" #include "llvm/IR/DIBuilder.h" #include "llvm/IR/DebugInfo.h" @@ -107,7 +108,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { const PathRemapper &DebugPrefixMap; /// Various caches. - /// @{ + /// \{ + llvm::StringSet<> VarNames; + using VarID = std::tuple; + llvm::DenseMap LocalVarCache; llvm::DenseMap ScopeCache; llvm::DenseMap InlinedAtCache; llvm::DenseMap @@ -117,7 +121,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { llvm::StringMap DIFileCache; TrackingDIRefMap DIRefMap; TrackingDIRefMap InnerTypeCache; - /// @} + /// \} /// A list of replaceable fwddecls that need to be RAUWed at the end. std::vector> ReplaceMap; @@ -613,8 +617,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { void createParameterType(llvm::SmallVectorImpl &Parameters, SILType type) { auto RealType = type.getASTType(); - auto DbgTy = - DebugTypeInfo::getFromTypeInfo(RealType, IGM.getTypeInfo(type)); + auto DbgTy = DebugTypeInfo::getFromTypeInfo(RealType, IGM.getTypeInfo(type), + /*isFragment*/ false); Parameters.push_back(getOrCreateType(DbgTy)); } @@ -978,7 +982,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { llvm::DINode::DIFlags Flags) { StringRef Name = Decl->getName().str(); unsigned SizeOfByte = CI.getTargetInfo().getCharWidth(); - unsigned SizeInBits = DbgTy.getSize()->getValue() * SizeOfByte; + unsigned SizeInBits = DbgTy.getSizeValue() * SizeOfByte; // Default, since Swift doesn't allow specifying a custom alignment. unsigned AlignInBits = 0; @@ -1009,8 +1013,9 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { // all enum values. Use the raw type for the debug type, but // the storage size from the enum. ElemDbgTy = CompletedDebugTypeInfo::get( - DebugTypeInfo(Decl->getRawType(), DbgTy.getStorageType(), - DbgTy.getSize(), DbgTy.getAlignment(), true, false)); + DebugTypeInfo(Decl->getRawType(), DbgTy.getFragmentStorageType(), + DbgTy.getRawSize(), DbgTy.getAlignment(), true, false, + DbgTy.isSizeFragmentSize())); else if (auto ArgTy = ElemDecl->getArgumentInterfaceType()) { // A discriminated union. This should really be described as a // DW_TAG_variant_type. For now only describing the data. @@ -1021,8 +1026,9 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { // Discriminated union case without argument. Fallback to Int // as the element type; there is no storage here. Type IntTy = IGM.Context.getIntType(); - ElemDbgTy = CompletedDebugTypeInfo::get(DebugTypeInfo( - IntTy, DbgTy.getStorageType(), Size(0), Alignment(1), true, false)); + ElemDbgTy = CompletedDebugTypeInfo::get( + DebugTypeInfo(IntTy, DbgTy.getFragmentStorageType(), Size(0), + Alignment(1), true, false, false)); } if (!ElemDbgTy) { // Without complete type info we can only create a forward decl. @@ -1046,19 +1052,18 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { } llvm::DIType *getOrCreateDesugaredType(Type Ty, DebugTypeInfo DbgTy) { - DebugTypeInfo BlandDbgTy(Ty, DbgTy.getStorageType(), DbgTy.getSize(), - DbgTy.getAlignment(), DbgTy.hasDefaultAlignment(), - DbgTy.isMetadataType()); + DebugTypeInfo BlandDbgTy( + Ty, DbgTy.getFragmentStorageType(), DbgTy.getRawSize(), + DbgTy.getAlignment(), DbgTy.hasDefaultAlignment(), + DbgTy.isMetadataType(), DbgTy.isSizeFragmentSize()); return getOrCreateType(BlandDbgTy); } uint64_t getSizeOfBasicType(CompletedDebugTypeInfo DbgTy) { uint64_t SizeOfByte = CI.getTargetInfo().getCharWidth(); - uint64_t BitWidth = 0; - if (DbgTy.getSize()) - BitWidth = DbgTy.getSizeValue() * SizeOfByte; - llvm::Type *StorageType = DbgTy.getStorageType() - ? DbgTy.getStorageType() + uint64_t BitWidth = DbgTy.getSizeValue() * SizeOfByte; + llvm::Type *StorageType = DbgTy.getFragmentStorageType() + ? DbgTy.getFragmentStorageType() : IGM.DataLayout.getSmallestLegalIntType( IGM.getLLVMContext(), BitWidth); @@ -1291,8 +1296,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { uint64_t SizeOfByte = CI.getTargetInfo().getCharWidth(); // FIXME: SizeInBits is redundant with DbgTy, remove it. uint64_t SizeInBits = 0; - if (DbgTy.getSize()) - SizeInBits = DbgTy.getSize()->getValue() * SizeOfByte; + if (DbgTy.getTypeSize()) + SizeInBits = DbgTy.getTypeSize()->getValue() * SizeOfByte; unsigned AlignInBits = DbgTy.hasDefaultAlignment() ? 0 : DbgTy.getAlignment().getValue() * SizeOfByte; @@ -1407,7 +1412,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { SizeInBits, AlignInBits, Flags, nullptr, llvm::dwarf::DW_LANG_Swift, MangledName); StringRef Name = Decl->getName().str(); - if (DbgTy.getSize()) + if (DbgTy.getTypeSize()) return createOpaqueStruct(Scope, Name, File, FwdDeclLine, SizeInBits, AlignInBits, Flags, MangledName); return DBuilder.createForwardDecl( @@ -1529,7 +1534,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { auto PTy = IGM.getLoweredType(ProtocolDecl->getInterfaceType()).getASTType(); auto PDbgTy = DebugTypeInfo::getFromTypeInfo( - ProtocolDecl->getInterfaceType(), IGM.getTypeInfoForLowered(PTy)); + ProtocolDecl->getInterfaceType(), IGM.getTypeInfoForLowered(PTy), + false); auto PDITy = getOrCreateType(PDbgTy); Protocols.push_back( DBuilder.createInheritance(FwdDecl.get(), PDITy, 0, 0, Flags)); @@ -1600,7 +1606,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { auto *BuiltinVectorTy = BaseTy->castTo(); auto ElemTy = BuiltinVectorTy->getElementType(); auto ElemDbgTy = DebugTypeInfo::getFromTypeInfo( - ElemTy, IGM.getTypeInfoForUnlowered(ElemTy)); + ElemTy, IGM.getTypeInfoForUnlowered(ElemTy), false); unsigned Count = BuiltinVectorTy->getNumElements(); auto Subscript = DBuilder.getOrCreateSubrange(0, Count ? Count : -1); return DBuilder.createVectorType(SizeInBits, AlignInBits, @@ -1634,9 +1640,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { // For TypeAlias types, the DeclContext for the aliased type is // in the decl of the alias type. - DebugTypeInfo AliasedDbgTy(AliasedTy, DbgTy.getStorageType(), - DbgTy.getSize(), DbgTy.getAlignment(), - DbgTy.hasDefaultAlignment(), false); + DebugTypeInfo AliasedDbgTy(AliasedTy, DbgTy.getFragmentStorageType(), + DbgTy.getRawSize(), DbgTy.getAlignment(), + DbgTy.hasDefaultAlignment(), false, + DbgTy.isSizeFragmentSize()); return DBuilder.createTypedef(getOrCreateType(AliasedDbgTy), MangledName, File, 0, Scope); } @@ -2312,7 +2319,8 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn, ErrorInfo->getReturnValueType(IGM.getSILModule(), FnTy, IGM.getMaximalTypeExpansionContext()), IGM.getTypeInfo(IGM.silConv.getSILType( - *ErrorInfo, FnTy, IGM.getMaximalTypeExpansionContext()))); + *ErrorInfo, FnTy, IGM.getMaximalTypeExpansionContext())), + false); Error = DBuilder.getOrCreateArray({getOrCreateType(DTI)}).get(); } @@ -2413,8 +2421,22 @@ bool IRGenDebugInfoImpl::buildDebugInfoExpression( case SILDIExprOperator::Dereference: Operands.push_back(llvm::dwarf::DW_OP_deref); break; - default: - llvm_unreachable("Unrecognized operator"); + case SILDIExprOperator::Plus: + Operands.push_back(llvm::dwarf::DW_OP_plus); + break; + case SILDIExprOperator::Minus: + Operands.push_back(llvm::dwarf::DW_OP_minus); + break; + case SILDIExprOperator::ConstUInt: + Operands.push_back(llvm::dwarf::DW_OP_constu); + Operands.push_back(*ExprOperand[1].getAsConstInt()); + break; + case SILDIExprOperator::ConstSInt: + Operands.push_back(llvm::dwarf::DW_OP_consts); + Operands.push_back(*ExprOperand[1].getAsConstInt()); + break; + case SILDIExprOperator::INVALID: + return false; } } return true; @@ -2434,7 +2456,7 @@ void IRGenDebugInfoImpl::emitVariableDeclaration( if (DbgTy.getType()->hasOpenedExistential()) return; - if (!DbgTy.getSize()) + if (!DbgTy.getTypeSize()) DbgTy.setSize(getStorageSize(IGM.DataLayout, Storage)); auto *Scope = dyn_cast_or_null(getOrCreateScope(DS)); @@ -2443,7 +2465,8 @@ void IRGenDebugInfoImpl::emitVariableDeclaration( // FIXME: this should be the scope of the type's declaration. // If this is an argument, attach it to the current function scope. - if (VarInfo.ArgNo > 0) { + uint16_t ArgNo = VarInfo.ArgNo; + if (ArgNo > 0) { while (isa(Scope)) Scope = cast(Scope)->getScope(); } @@ -2457,35 +2480,50 @@ void IRGenDebugInfoImpl::emitVariableDeclaration( unsigned DInstLine = DInstLoc.line; // Self is always an artificial argument, so are variables without location. - if (!DInstLine || - (VarInfo.ArgNo > 0 && VarInfo.Name == IGM.Context.Id_self.str())) + if (!DInstLine || (ArgNo > 0 && VarInfo.Name == IGM.Context.Id_self.str())) Artificial = ArtificialValue; llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero; if (Artificial || DITy->isArtificial() || DITy == InternalType) Flags |= llvm::DINode::FlagArtificial; - // This could be Opts.Optimize if we would also unique DIVariables here. - bool Optimized = false; // Create the descriptor for the variable. unsigned DVarLine = DInstLine; + uint16_t DVarCol = 0; if (VarInfo.Loc) { auto DVarLoc = getStartLocation(VarInfo.Loc); DVarLine = DVarLoc.line; + DVarCol = DVarLoc.column; } llvm::DIScope *VarScope = Scope; - if (VarInfo.Scope) { + if (ArgNo == 0 && VarInfo.Scope) { if (auto *VS = dyn_cast_or_null( - getOrCreateScope(VarInfo.Scope))) + getOrCreateScope(VarInfo.Scope))) { VarScope = VS; + } + } + + // Get or create the DILocalVariable. + llvm::DILocalVariable *Var; + // VarInfo.Name points into tail-allocated storage in debug_value insns. + llvm::StringRef UniqueName = VarNames.insert(VarInfo.Name).first->getKey(); + VarID Key(VarScope, UniqueName, DVarLine, DVarCol); + auto CachedVar = LocalVarCache.find(Key); + if (CachedVar != LocalVarCache.end()) { + Var = cast(CachedVar->second); + } else { + // The llvm.dbg.value(undef) emitted for zero-sized variables get filtered + // out by DwarfDebug::collectEntityInfo(), so all variables need to be + // preserved even at -Onone. + bool Preserve = true; + if (ArgNo > 0) + Var = DBuilder.createParameterVariable( + VarScope, VarInfo.Name, ArgNo, Unit, DVarLine, DITy, Preserve, Flags); + else + Var = DBuilder.createAutoVariable(VarScope, VarInfo.Name, Unit, DVarLine, + DITy, Preserve, Flags); + LocalVarCache.insert({Key, llvm::TrackingMDNodeRef(Var)}); } - llvm::DILocalVariable *Var = - (VarInfo.ArgNo > 0) - ? DBuilder.createParameterVariable(VarScope, VarInfo.Name, - VarInfo.ArgNo, Unit, DVarLine, - DITy, Optimized, Flags) - : DBuilder.createAutoVariable(VarScope, VarInfo.Name, Unit, DVarLine, - DITy, Optimized, Flags); auto appendDIExpression = [&VarInfo, this](llvm::DIExpression *DIExpr) -> llvm::DIExpression * { @@ -2520,9 +2558,14 @@ void IRGenDebugInfoImpl::emitVariableDeclaration( AlignInBits = SizeOfByte; // Sanity checks. +#ifndef NDEBUG assert(SizeInBits && "zero-sized piece"); - assert(SizeInBits < getSizeInBits(Var) && "piece covers entire var"); - assert(OffsetInBits + SizeInBits <= getSizeInBits(Var) && "pars > totum"); + if (getSizeInBits(Var)) { + assert(SizeInBits < getSizeInBits(Var) && "piece covers entire var"); + assert(OffsetInBits + SizeInBits <= getSizeInBits(Var) && + "pars > totum"); + } +#endif // Add the piece DWARF expression. Operands.push_back(llvm::dwarf::DW_OP_LLVM_fragment); diff --git a/lib/IRGen/IRGenFunction.cpp b/lib/IRGen/IRGenFunction.cpp index 321a2b02b83c1..c2137a443b216 100644 --- a/lib/IRGen/IRGenFunction.cpp +++ b/lib/IRGen/IRGenFunction.cpp @@ -694,7 +694,7 @@ void IRGenFunction::emitAwaitAsyncContinuation( contAwaitSyncAddr->getType()->getPointerElementType(), unsigned(ContinuationStatus::Awaited)); auto results = Builder.CreateAtomicCmpXchg( - contAwaitSyncAddr, pendingV, awaitedV, + contAwaitSyncAddr, pendingV, awaitedV, llvm::MaybeAlign(), llvm::AtomicOrdering::Release /*success ordering*/, llvm::AtomicOrdering::Acquire /* failure ordering */, llvm::SyncScope::System); diff --git a/lib/IRGen/IRGenModule.cpp b/lib/IRGen/IRGenModule.cpp index cf6a4ac4d554a..2c6c4db7985e5 100644 --- a/lib/IRGen/IRGenModule.cpp +++ b/lib/IRGen/IRGenModule.cpp @@ -192,19 +192,18 @@ static void sanityCheckStdlib(IRGenModule &IGM) { IRGenModule::IRGenModule(IRGenerator &irgen, std::unique_ptr &&target, - SourceFile *SF, - StringRef ModuleName, StringRef OutputFilename, + SourceFile *SF, StringRef ModuleName, + StringRef OutputFilename, StringRef MainInputFilenameForDebugInfo, StringRef PrivateDiscriminator) - : LLVMContext(new llvm::LLVMContext()), - IRGen(irgen), Context(irgen.SIL.getASTContext()), + : LLVMContext(new llvm::LLVMContext()), IRGen(irgen), + Context(irgen.SIL.getASTContext()), // The LLVMContext (and the IGM itself) will get deleted by the IGMDeleter // as long as the IGM is registered with the IRGenerator. - ClangCodeGen(createClangCodeGenerator(Context, *LLVMContext, - irgen.Opts, + ClangCodeGen(createClangCodeGenerator(Context, *LLVMContext, irgen.Opts, ModuleName, PrivateDiscriminator)), Module(*ClangCodeGen->GetModule()), - DataLayout(irgen.getClangDataLayout()), + DataLayout(irgen.getClangDataLayoutString()), Triple(irgen.getEffectiveClangTriple()), TargetMachine(std::move(target)), silConv(irgen.SIL), OutputFilename(OutputFilename), MainInputFilenameForDebugInfo(MainInputFilenameForDebugInfo), @@ -1235,7 +1234,7 @@ llvm::SmallString<32> getTargetDependentLibraryOption(const llvm::Triple &T, if (quote) buffer += '"'; buffer += library; - if (!library.endswith_lower(".lib")) + if (!library.endswith_insensitive(".lib")) buffer += ".lib"; if (quote) buffer += '"'; @@ -1466,13 +1465,6 @@ void AutolinkKind::writeEntries(llvm::SetVector Ent } auto EntriesConstant = llvm::ConstantDataArray::getString( IGM.getLLVMContext(), EntriesString, /*AddNull=*/false); - // Mark the swift1_autolink_entries section with the SHF_EXCLUDE attribute - // to get the linker to drop it in the final linked binary. - // LLVM doesn't provide an interface to specify section attributs in the - // IR so we pass the attribute with inline assembly. - if (IGM.TargetInfo.OutputObjectFormat == llvm::Triple::ELF) - IGM.Module.appendModuleInlineAsm(".section .swift1_autolink_entries," - "\"0x80000000\""); auto var = new llvm::GlobalVariable(*IGM.getModule(), EntriesConstant->getType(), true, llvm::GlobalValue::PrivateLinkage, @@ -1762,12 +1754,12 @@ llvm::Triple IRGenerator::getEffectiveClangTriple() { return llvm::Triple(CI->getTargetInfo().getTargetOpts().Triple); } -const llvm::DataLayout &IRGenerator::getClangDataLayout() { +const llvm::StringRef IRGenerator::getClangDataLayoutString() { return static_cast( SIL.getASTContext().getClangModuleLoader()) ->getTargetInfo() - .getDataLayout(); - } + .getDataLayoutString(); +} TypeExpansionContext IRGenModule::getMaximalTypeExpansionContext() const { return TypeExpansionContext::maximal(getSwiftModule(), diff --git a/lib/IRGen/IRGenModule.h b/lib/IRGen/IRGenModule.h index 36d332ef28056..a0045cefc4056 100644 --- a/lib/IRGen/IRGenModule.h +++ b/lib/IRGen/IRGenModule.h @@ -519,7 +519,7 @@ class IRGenerator { /// Return the effective triple used by clang. llvm::Triple getEffectiveClangTriple(); - const llvm::DataLayout &getClangDataLayout(); + const llvm::StringRef getClangDataLayoutString(); }; class ConstantReference { diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index 715ec890fb406..b94e4eaa6639b 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -649,7 +649,7 @@ class IRGenSILFunction : if (Name.empty()) { { llvm::raw_svector_ostream S(Name); - S << '_' << NumAnonVars++; + S << "$_" << NumAnonVars++; } AnonymousVariables.insert({Decl, Name}); } @@ -952,9 +952,6 @@ class IRGenSILFunction : if (ValueVariables.insert(shadow).second) ValueDomPoints.push_back({shadow, getActiveDominancePoint()}); } - auto inst = cast(shadow); - llvm::IRBuilder<> builder(inst->getNextNode()); - shadow = builder.CreateLoad(shadow); } return shadow; @@ -1027,16 +1024,9 @@ class IRGenSILFunction : LTI.initialize(*this, e, Alloca, false /* isOutlined */); auto shadow = Alloca.getAddress(); // Async functions use the value of the artificial address. - if (CurSILFn->isAsync() && emitLifetimeExtendingUse(shadow)) { + if (CurSILFn->isAsync() && emitLifetimeExtendingUse(shadow)) if (ValueVariables.insert(shadow).second) ValueDomPoints.push_back({shadow, getActiveDominancePoint()}); - auto inst = cast(shadow); - llvm::IRBuilder<> builder(inst->getNextNode()); - shadow = builder.CreateLoad(shadow); - copy.push_back(shadow); - return; - } - } copy.push_back(Alloca.getAddress()); } @@ -4749,11 +4739,15 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) { VarInfo->Name = getVarName(i, IsAnonymous); DebugTypeInfo DbgTy; SILType SILTy; - if (auto MaybeSILTy = VarInfo->Type) + bool IsFragmentType = false; + if (auto MaybeSILTy = VarInfo->Type) { // If there is auxiliary type info, use it SILTy = *MaybeSILTy; - else + } else { SILTy = SILVal->getType(); + if (VarInfo->DIExpr) + IsFragmentType = VarInfo->DIExpr.hasFragment(); + } auto RealTy = SILTy.getASTType(); if (IsAddrVal && IsInCoro) @@ -4769,11 +4763,12 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) { // Figure out the debug variable type if (VarDecl *Decl = i->getDecl()) { - DbgTy = DebugTypeInfo::getLocalVariable( - Decl, RealTy, getTypeInfo(SILVal->getType())); + DbgTy = DebugTypeInfo::getLocalVariable(Decl, RealTy, getTypeInfo(SILTy), + IsFragmentType); } else if (!SILTy.hasArchetype() && !VarInfo->Name.empty()) { // Handle the cases that read from a SIL file - DbgTy = DebugTypeInfo::getFromTypeInfo(RealTy, getTypeInfo(SILTy)); + DbgTy = DebugTypeInfo::getFromTypeInfo(RealTy, getTypeInfo(SILTy), + IsFragmentType); } else return; @@ -5128,18 +5123,24 @@ void IRGenSILFunction::emitDebugInfoForAllocStack(AllocStackInst *i, } SILType SILTy; - if (auto MaybeSILTy = VarInfo->Type) + bool IsFragmentType = false; + if (auto MaybeSILTy = VarInfo->Type) { // If there is auxiliary type info, use it SILTy = *MaybeSILTy; - else + } else { SILTy = i->getType(); + if (VarInfo->DIExpr) + IsFragmentType = VarInfo->DIExpr.hasFragment(); + } auto RealType = SILTy.getASTType(); DebugTypeInfo DbgTy; if (Decl) { - DbgTy = DebugTypeInfo::getLocalVariable(Decl, RealType, type); + DbgTy = + DebugTypeInfo::getLocalVariable(Decl, RealType, type, IsFragmentType); } else if (i->getFunction()->isBare() && !SILTy.hasArchetype() && !VarInfo->Name.empty()) { - DbgTy = DebugTypeInfo::getFromTypeInfo(RealType, getTypeInfo(SILTy)); + DbgTy = DebugTypeInfo::getFromTypeInfo(RealType, getTypeInfo(SILTy), + IsFragmentType); } else return; @@ -5359,7 +5360,7 @@ void IRGenSILFunction::visitAllocBoxInst(swift::AllocBoxInst *i) { IGM.getMaximalTypeExpansionContext(), i->getBoxType(), IGM.getSILModule().Types, 0); auto RealType = SILTy.getASTType(); - auto DbgTy = DebugTypeInfo::getLocalVariable(Decl, RealType, type); + auto DbgTy = DebugTypeInfo::getLocalVariable(Decl, RealType, type, false); auto VarInfo = i->getVarInfo(); assert(VarInfo && "debug_value without debug info"); diff --git a/lib/IRGen/MetadataRequest.cpp b/lib/IRGen/MetadataRequest.cpp index 08055baa7c3ac..21ff16f54e6c4 100644 --- a/lib/IRGen/MetadataRequest.cpp +++ b/lib/IRGen/MetadataRequest.cpp @@ -269,7 +269,8 @@ llvm::Constant *IRGenModule::getAddrOfStringForMetadataRef( return addr; auto bitConstant = llvm::ConstantInt::get(IntPtrTy, 1); - return llvm::ConstantExpr::getGetElementPtr(nullptr, addr, bitConstant); + return llvm::ConstantExpr::getGetElementPtr( + addr->getType()->getPointerElementType(), addr, bitConstant); }; // Check whether we already have an entry with this name. @@ -1114,7 +1115,8 @@ static llvm::Constant *emitEmptyTupleTypeMetadataRef(IRGenModule &IGM) { llvm::ConstantInt::get(IGM.Int32Ty, 1) }; return llvm::ConstantExpr::getInBoundsGetElementPtr( - /*Ty=*/nullptr, fullMetadata, indices); + fullMetadata->getType()->getPointerElementType(), fullMetadata, + indices); } using GetElementMetadataFn = @@ -1663,7 +1665,8 @@ namespace { }; return MetadataResponse::forComplete( llvm::ConstantExpr::getInBoundsGetElementPtr( - /*Ty=*/nullptr, singletonMetadata, indices)); + singletonMetadata->getType()->getPointerElementType(), + singletonMetadata, indices)); } auto layout = type.getExistentialLayout(); diff --git a/lib/Immediate/Immediate.cpp b/lib/Immediate/Immediate.cpp index 1e49aca2e46ba..27c4632245db8 100644 --- a/lib/Immediate/Immediate.cpp +++ b/lib/Immediate/Immediate.cpp @@ -33,7 +33,8 @@ #include "llvm/ExecutionEngine/Orc/DebugUtils.h" #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h" #include "llvm/ExecutionEngine/Orc/LLJIT.h" -#include "llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h" +#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h" +#include "llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h" #include "llvm/IR/LLVMContext.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" diff --git a/lib/Localization/LocalizationFormat.cpp b/lib/Localization/LocalizationFormat.cpp index ee830337a35e1..249b094d248d9 100644 --- a/lib/Localization/LocalizationFormat.cpp +++ b/lib/Localization/LocalizationFormat.cpp @@ -76,7 +76,7 @@ void SerializedLocalizationWriter::insert(swift::DiagID id, bool SerializedLocalizationWriter::emit(llvm::StringRef filePath) { assert(llvm::sys::path::extension(filePath) == ".db"); std::error_code error; - llvm::raw_fd_ostream OS(filePath, error, llvm::sys::fs::F_None); + llvm::raw_fd_ostream OS(filePath, error, llvm::sys::fs::OF_None); if (OS.has_error()) { return true; } diff --git a/lib/Markup/AST.cpp b/lib/Markup/AST.cpp index b4b3bec013557..9d55716a20382 100644 --- a/lib/Markup/AST.cpp +++ b/lib/Markup/AST.cpp @@ -341,9 +341,9 @@ swift::markup::MarkupASTNode *swift::markup::createSimpleField( if (false) { } -#define MARKUP_SIMPLE_FIELD(Id, Keyword, XMLKind) \ - else if (Tag.compare_lower(#Keyword) == 0) { \ - return Id::create(MC, Children); \ +#define MARKUP_SIMPLE_FIELD(Id, Keyword, XMLKind) \ + else if (Tag.compare_insensitive(#Keyword) == 0) { \ + return Id::create(MC, Children); \ } #include "swift/Markup/SimpleFields.def" llvm_unreachable("Given tag not for any simple markup field"); @@ -353,9 +353,9 @@ bool swift::markup::isAFieldTag(StringRef Tag) { if (false) { } -#define MARKUP_SIMPLE_FIELD(Id, Keyword, XMLKind) \ - else if (Tag.compare_lower(#Keyword) == 0) { \ - return true; \ +#define MARKUP_SIMPLE_FIELD(Id, Keyword, XMLKind) \ + else if (Tag.compare_insensitive(#Keyword) == 0) { \ + return true; \ } #include "swift/Markup/SimpleFields.def" return false; diff --git a/lib/Migrator/MigrationState.cpp b/lib/Migrator/MigrationState.cpp index 5493a29f4742f..8128e61646b08 100644 --- a/lib/Migrator/MigrationState.cpp +++ b/lib/Migrator/MigrationState.cpp @@ -35,7 +35,7 @@ std::string MigrationState::getOutputText() const { static bool quickDumpText(StringRef OutFilename, StringRef Text) { std::error_code Error; llvm::raw_fd_ostream FileOS(OutFilename, - Error, llvm::sys::fs::F_Text); + Error, llvm::sys::fs::OF_Text); if (FileOS.has_error()) { return true; } diff --git a/lib/Migrator/Migrator.cpp b/lib/Migrator/Migrator.cpp index baf7ae64c2870..b183c74c6aa9c 100644 --- a/lib/Migrator/Migrator.cpp +++ b/lib/Migrator/Migrator.cpp @@ -385,7 +385,7 @@ bool Migrator::emitRemap() const { std::error_code Error; llvm::raw_fd_ostream FileOS(RemapPath, - Error, llvm::sys::fs::F_Text); + Error, llvm::sys::fs::OF_Text); if (FileOS.has_error()) { return true; } @@ -406,7 +406,7 @@ bool Migrator::emitMigratedFile() const { std::error_code Error; llvm::raw_fd_ostream FileOS(OutFilename, - Error, llvm::sys::fs::F_Text); + Error, llvm::sys::fs::OF_Text); if (FileOS.has_error()) { return true; } diff --git a/lib/SIL/IR/SILBuilder.cpp b/lib/SIL/IR/SILBuilder.cpp index bb1204e8c0bef..f9fb210e08c80 100644 --- a/lib/SIL/IR/SILBuilder.cpp +++ b/lib/SIL/IR/SILBuilder.cpp @@ -569,20 +569,23 @@ void SILBuilder::emitDestructureValueOperation( DebugValueInst *SILBuilder::createDebugValue(SILLocation Loc, SILValue src, SILDebugVariable Var, bool poisonRefs) { + llvm::SmallString<4> Name; // Debug location overrides cannot apply to debug value instructions. DebugLocOverrideRAII LocOverride{*this, None}; - return insert( - DebugValueInst::create(getSILDebugLocation(Loc), src, getModule(), Var, - poisonRefs)); + return insert(DebugValueInst::create( + getSILDebugLocation(Loc), src, getModule(), + *substituteAnonymousArgs(Name, Var, Loc), poisonRefs)); } DebugValueInst *SILBuilder::createDebugValueAddr(SILLocation Loc, SILValue src, SILDebugVariable Var) { + llvm::SmallString<4> Name; // Debug location overrides cannot apply to debug addr instructions. DebugLocOverrideRAII LocOverride{*this, None}; - return insert(DebugValueInst::createAddr(getSILDebugLocation(Loc), src, - getModule(), Var)); + return insert( + DebugValueInst::createAddr(getSILDebugLocation(Loc), src, getModule(), + *substituteAnonymousArgs(Name, Var, Loc))); } void SILBuilder::emitScopedBorrowOperation(SILLocation loc, SILValue original, diff --git a/lib/SIL/IR/SILDebugInfoExpression.cpp b/lib/SIL/IR/SILDebugInfoExpression.cpp index 25cd17737d09e..cfea4a24a1fc4 100644 --- a/lib/SIL/IR/SILDebugInfoExpression.cpp +++ b/lib/SIL/IR/SILDebugInfoExpression.cpp @@ -37,7 +37,13 @@ const SILDIExprInfo *SILDIExprInfo::get(SILDIExprOperator Op) { static const std::unordered_map Infos = { {SILDIExprOperator::Fragment, {"op_fragment", {SILDIExprElement::DeclKind}}}, - {SILDIExprOperator::Dereference, {"op_deref", {}}}}; + {SILDIExprOperator::Dereference, {"op_deref", {}}}, + {SILDIExprOperator::Plus, {"op_plus", {}}}, + {SILDIExprOperator::Minus, {"op_minus", {}}}, + {SILDIExprOperator::ConstUInt, + {"op_constu", {SILDIExprElement::ConstIntKind}}}, + {SILDIExprOperator::ConstSInt, + {"op_consts", {SILDIExprElement::ConstIntKind}}}}; return Infos.count(Op) ? &Infos.at(Op) : nullptr; } diff --git a/lib/SIL/IR/SILInstructions.cpp b/lib/SIL/IR/SILInstructions.cpp index 2ccc0ffac1685..461adb860d3f1 100644 --- a/lib/SIL/IR/SILInstructions.cpp +++ b/lib/SIL/IR/SILInstructions.cpp @@ -202,6 +202,7 @@ AllocStackInst::AllocStackInst(SILDebugLocation Loc, SILType elementType, TypeDependentOperands.size(); assert(SILNode::Bits.AllocStackInst.NumOperands == TypeDependentOperands.size() && "Truncation"); + auto *VD = Loc.getLocation().getAsASTNode(); SILNode::Bits.AllocStackInst.VarInfo = TailAllocatedDebugVariable(Var, getTrailingObjects(), getTrailingObjects(), @@ -209,7 +210,7 @@ AllocStackInst::AllocStackInst(SILDebugLocation Loc, SILType elementType, getTrailingObjects(), getTrailingObjects()) .getRawValue(); - if (auto *VD = Loc.getLocation().getAsASTNode()) { + if (Var && VD) { TailAllocatedDebugVariable DbgVar(SILNode::Bits.AllocStackInst.VarInfo); DbgVar.setImplicit(VD->isImplicit() || DbgVar.isImplicit()); SILNode::Bits.AllocStackInst.VarInfo = DbgVar.getRawValue(); @@ -308,11 +309,10 @@ AllocBoxInst::AllocBoxInst(SILDebugLocation Loc, CanSILBoxType BoxType, ArrayRef TypeDependentOperands, SILFunction &F, Optional Var, bool hasDynamicLifetime) - : InstructionBaseWithTrailingOperands(TypeDependentOperands, Loc, - SILType::getPrimitiveObjectType(BoxType)), + : InstructionBaseWithTrailingOperands( + TypeDependentOperands, Loc, SILType::getPrimitiveObjectType(BoxType)), VarInfo(Var, getTrailingObjects()), - dynamicLifetime(hasDynamicLifetime) { -} + dynamicLifetime(hasDynamicLifetime) {} AllocBoxInst *AllocBoxInst::create(SILDebugLocation Loc, CanSILBoxType BoxType, diff --git a/lib/SIL/IR/SILPrinter.cpp b/lib/SIL/IR/SILPrinter.cpp index f6b671ffb6861..ffc2b545419ba 100644 --- a/lib/SIL/IR/SILPrinter.cpp +++ b/lib/SIL/IR/SILPrinter.cpp @@ -607,6 +607,7 @@ class SILPrinter : public SILInstructionVisitor { SIMPLE_PRINTER(char) SIMPLE_PRINTER(unsigned) SIMPLE_PRINTER(uint64_t) + SIMPLE_PRINTER(int64_t) SIMPLE_PRINTER(StringRef) SIMPLE_PRINTER(Identifier) SIMPLE_PRINTER(ID) @@ -1191,32 +1192,46 @@ class SILPrinter : public SILInstructionVisitor { assert(DIExpr && "DIExpression empty?"); *this << ", expr "; bool IsFirst = true; - for (const auto &E : DIExpr.elements()) { + for (const auto &Operand : DIExpr.operands()) { if (IsFirst) IsFirst = false; else *this << ":"; - switch (E.getKind()) { - case SILDIExprElement::OperatorKind: { - SILDIExprOperator Op = E.getAsOperator(); - assert(Op != SILDIExprOperator::INVALID && - "Invalid SILDIExprOperator kind"); - *this << SILDIExprInfo::get(Op)->OpText; - break; - } - case SILDIExprElement::DeclKind: { - const Decl *D = E.getAsDecl(); - // FIXME: Can we generalize this special handling for VarDecl - // to other kinds of Decl? - if (const auto *VD = dyn_cast(D)) { - *this << "#"; - printFullContext(VD->getDeclContext(), PrintState.OS); - *this << VD->getName().get(); - } else - D->print(PrintState.OS, PrintState.ASTOptions); - break; - } + // Print the operator + SILDIExprOperator Op = Operand.getOperator(); + assert(Op != SILDIExprOperator::INVALID && + "Invalid SILDIExprOperator kind"); + *this << SILDIExprInfo::get(Op)->OpText; + + // Print arguments + for (const auto &Arg : Operand.args()) { + *this << ":"; + switch (Arg.getKind()) { + case SILDIExprElement::OperatorKind: + llvm_unreachable("Cannot use operator as argument"); + break; + case SILDIExprElement::DeclKind: { + const Decl *D = Arg.getAsDecl(); + // FIXME: Can we generalize this special handling for VarDecl + // to other kinds of Decl? + if (const auto *VD = dyn_cast(D)) { + *this << "#"; + printFullContext(VD->getDeclContext(), PrintState.OS); + *this << VD->getName().get(); + } else + D->print(PrintState.OS, PrintState.ASTOptions); + break; + } + case SILDIExprElement::ConstIntKind: { + uint64_t V = *Arg.getAsConstInt(); + if (Op == SILDIExprOperator::ConstSInt) + *this << static_cast(V); + else + *this << V; + break; + } + } } } } @@ -1453,12 +1468,12 @@ class SILPrinter : public SILInstructionVisitor { *this << ILI->getType() << ", " << lit; } void visitFloatLiteralInst(FloatLiteralInst *FLI) { - *this << FLI->getType() << ", 0x"; - APInt bits = FLI->getBits(); - *this << bits.toString(16, /*Signed*/ false); + llvm::SmallString<12> hex; llvm::SmallString<12> decimal; + FLI->getBits().toString(hex, 16, /*Signed*/ false); FLI->getValue().toString(decimal); - *this << " // " << decimal; + *this << FLI->getType() + << (llvm::Twine(", 0x") + hex + " // " + decimal).str(); } static StringRef getStringEncodingName(StringLiteralInst::Encoding kind) { switch (kind) { @@ -2742,7 +2757,7 @@ void SILFunction::dump() const { void SILFunction::dump(const char *FileName) const { std::error_code EC; - llvm::raw_fd_ostream os(FileName, EC, llvm::sys::fs::OpenFlags::F_None); + llvm::raw_fd_ostream os(FileName, EC, llvm::sys::fs::OpenFlags::OF_None); print(os); } @@ -2991,7 +3006,7 @@ void SILModule::dump(bool Verbose) const { void SILModule::dump(const char *FileName, bool Verbose, bool PrintASTDecls) const { std::error_code EC; - llvm::raw_fd_ostream os(FileName, EC, llvm::sys::fs::OpenFlags::F_None); + llvm::raw_fd_ostream os(FileName, EC, llvm::sys::fs::OpenFlags::OF_None); SILPrintContext Ctx(os, Verbose); print(Ctx, getSwiftModule(), PrintASTDecls); } diff --git a/lib/SIL/Parser/ParseSIL.cpp b/lib/SIL/Parser/ParseSIL.cpp index 316c2d0aac006..beba567dc27a5 100644 --- a/lib/SIL/Parser/ParseSIL.cpp +++ b/lib/SIL/Parser/ParseSIL.cpp @@ -1680,7 +1680,11 @@ bool SILParser::parseSILDebugInfoExpression(SILDebugInfoExpression &DIExpr) { // All operators that we currently support static const SILDIExprOperator AllOps[] = { SILDIExprOperator::Dereference, - SILDIExprOperator::Fragment + SILDIExprOperator::Fragment, + SILDIExprOperator::Plus, + SILDIExprOperator::Minus, + SILDIExprOperator::ConstUInt, + SILDIExprOperator::ConstSInt }; do { @@ -1714,6 +1718,22 @@ bool SILParser::parseSILDebugInfoExpression(SILDebugInfoExpression &DIExpr) { DIExpr.push_back(NewOperand); break; } + case SILDIExprElement::ConstIntKind: { + bool IsNegative = false; + if (P.Tok.is(tok::oper_prefix) && P.Tok.getRawText() == "-") { + P.consumeToken(); + IsNegative = true; + } + int64_t Val; + if (parseInteger(Val, diag::sil_invalid_constant)) + return true; + if (IsNegative) + Val = -Val; + auto NewOperand = + SILDIExprElement::createConstInt(static_cast(Val)); + DIExpr.push_back(NewOperand); + break; + } default: P.diagnose(P.Tok.getLoc(), diag::sil_dbg_unknown_expr_part, "operand kind"); diff --git a/lib/SIL/Utils/SILRemarkStreamer.cpp b/lib/SIL/Utils/SILRemarkStreamer.cpp index 68317a23ba4a5..156562c665df5 100644 --- a/lib/SIL/Utils/SILRemarkStreamer.cpp +++ b/lib/SIL/Utils/SILRemarkStreamer.cpp @@ -60,7 +60,7 @@ SILRemarkStreamer::create(SILModule &silModule) { auto &diagEngine = silModule.getASTContext().Diags; std::error_code errorCode; auto file = std::make_unique(filename, errorCode, - llvm::sys::fs::F_None); + llvm::sys::fs::OF_None); if (errorCode) { diagEngine.diagnose(SourceLoc(), diag::cannot_open_file, filename, errorCode.message()); diff --git a/lib/SIL/Verifier/SILVerifier.cpp b/lib/SIL/Verifier/SILVerifier.cpp index b0207a11d4d98..7903e3302421f 100644 --- a/lib/SIL/Verifier/SILVerifier.cpp +++ b/lib/SIL/Verifier/SILVerifier.cpp @@ -104,6 +104,15 @@ static bool isArchetypeValidInFunction(ArchetypeType *A, const SILFunction *F) { namespace { +/// When resilience is bypassed, direct access is legal, but the decls are still +/// resilient. +template +bool checkResilience(DeclType *D, ModuleDecl *M, + ResilienceExpansion expansion) { + return !D->getModuleContext()->getBypassResilience() && + D->isResilient(M, expansion); +} + /// Metaprogramming-friendly base class. template class SILVerifierBase : public SILInstructionVisitor { @@ -234,7 +243,7 @@ void verifyKeyPathComponent(SILModule &M, "property decl should be a member of the base with the same type " "as the component"); require(property->hasStorage(), "property must be stored"); - require(!property->isResilient(M.getSwiftModule(), expansion), + require(!checkResilience(property, M.getSwiftModule(), expansion), "cannot access storage of resilient property"); auto propertyTy = loweredBaseTy.getFieldType(property, M, typeExpansionContext); @@ -666,7 +675,7 @@ class SILVerifier : public SILVerifierBase { const SILFunction &F; SILFunctionConventions fnConv; Lowering::TypeConverter &TC; - SmallVector DebugVars; + SmallVector, 16> DebugVars; const SILInstruction *CurInstruction = nullptr; const SILArgument *CurArgument = nullptr; std::unique_ptr Dominance; @@ -1265,7 +1274,34 @@ class SILVerifier : public SILVerifierBase { if (!varInfo) return; + // Retrive debug variable type + SILType DebugVarTy; + if (varInfo->Type) + DebugVarTy = *varInfo->Type; + else { + // Fetch from related SSA value + switch (inst->getKind()) { + case SILInstructionKind::AllocStackInst: + case SILInstructionKind::AllocBoxInst: + DebugVarTy = inst->getResult(0)->getType(); + break; + case SILInstructionKind::DebugValueInst: + DebugVarTy = inst->getOperand(0)->getType(); + if (DebugVarTy.isAddress()) { + auto Expr = varInfo->DIExpr.operands(); + if (!Expr.empty() && + Expr.begin()->getOperator() == SILDIExprOperator::Dereference) + DebugVarTy = DebugVarTy.getObjectType(); + } + break; + default: + llvm_unreachable("impossible instruction kind"); + } + } + auto *debugScope = inst->getDebugScope(); + if (varInfo->ArgNo) + require(!varInfo->Name.empty(), "function argument without a name"); // Check that there is at most one debug variable defined for each argument // slot if our debug scope is not an inlined call site. @@ -1276,18 +1312,20 @@ class SILVerifier : public SILVerifierBase { if (debugScope && !debugScope->InlinedCallSite) if (unsigned argNum = varInfo->ArgNo) { // It is a function argument. - if (argNum < DebugVars.size() && !DebugVars[argNum].empty() && - !varInfo->Name.empty()) { - require(DebugVars[argNum] == varInfo->Name, + if (argNum < DebugVars.size() && !DebugVars[argNum].first.empty()) { + require(DebugVars[argNum].first == varInfo->Name, "Scope contains conflicting debug variables for one function " "argument"); + // Check for type + require(DebugVars[argNum].second == DebugVarTy, + "conflicting debug variable type!"); } else { // Reserve enough space. while (DebugVars.size() <= argNum) { - DebugVars.push_back(StringRef()); + DebugVars.push_back({StringRef(), SILType()}); } } - DebugVars[argNum] = varInfo->Name; + DebugVars[argNum] = {varInfo->Name, DebugVarTy}; } // Check the (auxiliary) debug variable scope @@ -2016,7 +2054,7 @@ class SILVerifier : public SILVerifierBase { void checkAllocGlobalInst(AllocGlobalInst *AGI) { SILGlobalVariable *RefG = AGI->getReferencedGlobal(); if (auto *VD = RefG->getDecl()) { - require(!VD->isResilient(F.getModule().getSwiftModule(), + require(!checkResilience(VD, F.getModule().getSwiftModule(), F.getResilienceExpansion()), "cannot access storage of resilient global"); } @@ -2035,7 +2073,7 @@ class SILVerifier : public SILVerifierBase { RefG->getLoweredTypeInContext(F.getTypeExpansionContext()), "global_addr/value must be the type of the variable it references"); if (auto *VD = RefG->getDecl()) { - require(!VD->isResilient(F.getModule().getSwiftModule(), + require(!checkResilience(VD, F.getModule().getSwiftModule(), F.getResilienceExpansion()), "cannot access storage of resilient global"); } @@ -2723,8 +2761,8 @@ class SILVerifier : public SILVerifierBase { require(!structDecl->hasUnreferenceableStorage(), "Cannot build a struct with unreferenceable storage from elements " "using StructInst"); - require(!structDecl->isResilient(F.getModule().getSwiftModule(), - F.getResilienceExpansion()), + require(!checkResilience(structDecl, F.getModule().getSwiftModule(), + F.getResilienceExpansion()), "cannot access storage of resilient struct"); require(SI->getType().isObject(), "StructInst must produce an object"); @@ -2925,8 +2963,8 @@ class SILVerifier : public SILVerifierBase { require(cd, "Operand of dealloc_ref must be of class type"); if (!DI->canAllocOnStack()) { - require(!cd->isResilient(F.getModule().getSwiftModule(), - F.getResilienceExpansion()), + require(!checkResilience(cd, F.getModule().getSwiftModule(), + F.getResilienceExpansion()), "cannot directly deallocate resilient class"); } } @@ -3042,7 +3080,7 @@ class SILVerifier : public SILVerifierBase { "result of struct_extract cannot be address"); StructDecl *sd = operandTy.getStructOrBoundGenericStruct(); require(sd, "must struct_extract from struct"); - require(!sd->isResilient(F.getModule().getSwiftModule(), + require(!checkResilience(sd, F.getModule().getSwiftModule(), F.getResilienceExpansion()), "cannot access storage of resilient struct"); require(!EI->getField()->isStatic(), @@ -3091,7 +3129,7 @@ class SILVerifier : public SILVerifierBase { "must derive struct_element_addr from address"); StructDecl *sd = operandTy.getStructOrBoundGenericStruct(); require(sd, "struct_element_addr operand must be struct address"); - require(!sd->isResilient(F.getModule().getSwiftModule(), + require(!checkResilience(sd, F.getModule().getSwiftModule(), F.getResilienceExpansion()), "cannot access storage of resilient struct"); require(EI->getType().isAddress(), @@ -3124,7 +3162,7 @@ class SILVerifier : public SILVerifierBase { SILType operandTy = EI->getOperand()->getType(); ClassDecl *cd = operandTy.getClassOrBoundGenericClass(); require(cd, "ref_element_addr operand must be a class instance"); - require(!cd->isResilient(F.getModule().getSwiftModule(), + require(!checkResilience(cd, F.getModule().getSwiftModule(), F.getResilienceExpansion()), "cannot access storage of resilient class"); @@ -3148,7 +3186,7 @@ class SILVerifier : public SILVerifierBase { SILType operandTy = RTAI->getOperand()->getType(); ClassDecl *cd = operandTy.getClassOrBoundGenericClass(); require(cd, "ref_tail_addr operand must be a class instance"); - require(!cd->isResilient(F.getModule().getSwiftModule(), + require(!checkResilience(cd, F.getModule().getSwiftModule(), F.getResilienceExpansion()), "cannot access storage of resilient class"); require(cd, "ref_tail_addr operand must be a class instance"); @@ -3158,7 +3196,7 @@ class SILVerifier : public SILVerifierBase { SILType operandTy = DSI->getOperand()->getType(); StructDecl *sd = operandTy.getStructOrBoundGenericStruct(); require(sd, "must struct_extract from struct"); - require(!sd->isResilient(F.getModule().getSwiftModule(), + require(!checkResilience(sd, F.getModule().getSwiftModule(), F.getResilienceExpansion()), "cannot access storage of resilient struct"); if (F.hasOwnership()) { diff --git a/lib/SILGen/SILGenProlog.cpp b/lib/SILGen/SILGenProlog.cpp index ba53d7b6ce772..8472f03f43d2b 100644 --- a/lib/SILGen/SILGenProlog.cpp +++ b/lib/SILGen/SILGenProlog.cpp @@ -302,12 +302,11 @@ struct ArgumentInitHelper { // Emit debug information for the argument. SILLocation loc(PD); loc.markAsPrologue(); + SILDebugVariable DebugVar(PD->isLet(), ArgNo); if (argrv.getType().isAddress()) - SGF.B.createDebugValueAddr(loc, argrv.getValue(), - SILDebugVariable(PD->isLet(), ArgNo)); + SGF.B.createDebugValueAddr(loc, argrv.getValue(), DebugVar); else - SGF.B.createDebugValue(loc, argrv.getValue(), - SILDebugVariable(PD->isLet(), ArgNo)); + SGF.B.createDebugValue(loc, argrv.getValue(), DebugVar); } }; } // end anonymous namespace @@ -391,7 +390,7 @@ static void emitCaptureArguments(SILGenFunction &SGF, if (auto *AllocStack = dyn_cast(val)) AllocStack->setArgNo(ArgNo); else { - SILDebugVariable DbgVar(/*Constant*/ true, ArgNo); + SILDebugVariable DbgVar(VD->isLet(), ArgNo); SGF.B.createDebugValue(Loc, val, DbgVar); } @@ -416,7 +415,7 @@ static void emitCaptureArguments(SILGenFunction &SGF, SILType::getPrimitiveObjectType(boxTy), VD); SILValue addr = SGF.B.createProjectBox(VD, box, 0); SGF.VarLocs[VD] = SILGenFunction::VarLoc::get(addr, box); - SILDebugVariable DbgVar(/*Constant*/ false, ArgNo); + SILDebugVariable DbgVar(VD->isLet(), ArgNo); SGF.B.createDebugValueAddr(Loc, addr, DbgVar); break; } @@ -427,7 +426,7 @@ static void emitCaptureArguments(SILGenFunction &SGF, SILType ty = SGF.getLoweredType(type).getAddressType(); SILValue addr = SGF.F.begin()->createFunctionArgument(ty, VD); SGF.VarLocs[VD] = SILGenFunction::VarLoc::get(addr); - SILDebugVariable DbgVar(/*Constant*/ true, ArgNo); + SILDebugVariable DbgVar(VD->isLet(), ArgNo); SGF.B.createDebugValueAddr(Loc, addr, DbgVar); break; } diff --git a/lib/SILOptimizer/Analysis/CallerAnalysis.cpp b/lib/SILOptimizer/Analysis/CallerAnalysis.cpp index f27316bd95e9f..738d08ab79226 100644 --- a/lib/SILOptimizer/Analysis/CallerAnalysis.cpp +++ b/lib/SILOptimizer/Analysis/CallerAnalysis.cpp @@ -447,7 +447,7 @@ void CallerAnalysis::dump() const { print(llvm::errs()); } void CallerAnalysis::print(const char *filePath) const { using namespace llvm::sys; std::error_code error; - llvm::raw_fd_ostream fileOutputStream(filePath, error, fs::F_Text); + llvm::raw_fd_ostream fileOutputStream(filePath, error, fs::OF_Text); if (error) { llvm::errs() << "Failed to open path \"" << filePath << "\" for writing.!"; llvm_unreachable("default error handler"); diff --git a/lib/SILOptimizer/Transforms/SILMem2Reg.cpp b/lib/SILOptimizer/Transforms/SILMem2Reg.cpp index 335d816cfa6c2..1e92d5b99eb0d 100644 --- a/lib/SILOptimizer/Transforms/SILMem2Reg.cpp +++ b/lib/SILOptimizer/Transforms/SILMem2Reg.cpp @@ -838,7 +838,7 @@ void StackAllocationPromoter::propagateLiveness( // If liveness has not been propagated, go over the incoming operands and mark // any operand values that are proactivePhis as live livePhis.insert(proactivePhi); - SmallVector incomingPhiVals; + SmallVector incomingPhiVals; proactivePhi->getIncomingPhiValues(incomingPhiVals); for (auto &inVal : incomingPhiVals) { auto *inPhi = dyn_cast(inVal); diff --git a/lib/SILOptimizer/UtilityPasses/SILDebugInfoGenerator.cpp b/lib/SILOptimizer/UtilityPasses/SILDebugInfoGenerator.cpp index cb3a4d861903f..6869832b9e425 100644 --- a/lib/SILOptimizer/UtilityPasses/SILDebugInfoGenerator.cpp +++ b/lib/SILOptimizer/UtilityPasses/SILDebugInfoGenerator.cpp @@ -114,7 +114,7 @@ class SILDebugInfoGenerator : public SILModuleTransform { std::error_code EC; llvm::raw_fd_ostream OutFile(FileName, EC, - llvm::sys::fs::OpenFlags::F_None); + llvm::sys::fs::OpenFlags::OF_None); assert(!OutFile.has_error() && !EC && "Can't write SIL debug file"); PrintContext Ctx(OutFile); diff --git a/lib/SILOptimizer/Utils/ConstantFolding.cpp b/lib/SILOptimizer/Utils/ConstantFolding.cpp index cb9974f002b1a..9cebb72552a64 100644 --- a/lib/SILOptimizer/Utils/ConstantFolding.cpp +++ b/lib/SILOptimizer/Utils/ConstantFolding.cpp @@ -23,6 +23,7 @@ #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/Statistic.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/IR/Intrinsics.h" #include "llvm/Support/Debug.h" @@ -245,24 +246,23 @@ constantFoldBinaryWithOverflow(BuiltinInst *BI, llvm::Intrinsic::ID ID, break; } + SmallString<10> LhsStr; + SmallString<10> RhsStr; + LHSInt.toString(LhsStr, /*Radix*/ 10, Signed); + RHSInt.toString(RhsStr, /*Radix*/ 10, Signed); if (!OpType.isNull()) { - diagnose(BI->getModule().getASTContext(), - Loc.getSourceLoc(), - diag::arithmetic_operation_overflow, - LHSInt.toString(/*Radix*/ 10, Signed), - Operator, - RHSInt.toString(/*Radix*/ 10, Signed), - OpType).highlight(LHSRange).highlight(RHSRange); + diagnose(BI->getModule().getASTContext(), Loc.getSourceLoc(), + diag::arithmetic_operation_overflow, LhsStr, Operator, RhsStr, + OpType) + .highlight(LHSRange) + .highlight(RHSRange); } else { // If we cannot get the type info in an expected way, describe the type. - diagnose(BI->getModule().getASTContext(), - Loc.getSourceLoc(), - diag::arithmetic_operation_overflow_generic_type, - LHSInt.toString(/*Radix*/ 10, Signed), - Operator, - RHSInt.toString(/*Radix*/ 10, Signed), - Signed, - LHSInt.getBitWidth()).highlight(LHSRange).highlight(RHSRange); + diagnose(BI->getModule().getASTContext(), Loc.getSourceLoc(), + diag::arithmetic_operation_overflow_generic_type, LhsStr, + Operator, RhsStr, Signed, LHSInt.getBitWidth()) + .highlight(LHSRange) + .highlight(RHSRange); } ResultsInError = Optional(true); } @@ -570,12 +570,11 @@ constantFoldAndCheckDivision(BuiltinInst *BI, BuiltinValueKind ID, // Otherwise emit the diagnostic, set ResultsInError to be true, and return // nullptr. - diagnose(M.getASTContext(), - BI->getLoc().getSourceLoc(), + diagnose(M.getASTContext(), BI->getLoc().getSourceLoc(), diag::division_overflow, - NumVal.toString(/*Radix*/ 10, /*Signed*/true), + llvm::toString(NumVal, /*Radix*/ 10, /*Signed*/ true), IsRem ? "%" : "/", - DenomVal.toString(/*Radix*/ 10, /*Signed*/true)); + llvm::toString(DenomVal, /*Radix*/ 10, /*Signed*/ true)); ResultsInError = Optional(true); return nullptr; } @@ -1321,7 +1320,7 @@ case BuiltinValueKind::id: if (VInt.isNegative() && ResultsInError.hasValue()) { diagnose(M.getASTContext(), BI->getLoc().getSourceLoc(), diag::wrong_non_negative_assumption, - VInt.toString(/*Radix*/ 10, /*Signed*/ true)); + llvm::toString(VInt, /*Radix*/ 10, /*Signed*/ true)); ResultsInError = Optional(true); } return V; diff --git a/lib/SILOptimizer/Utils/InstOptUtils.cpp b/lib/SILOptimizer/Utils/InstOptUtils.cpp index 08bd93589e724..d268e1903a14a 100644 --- a/lib/SILOptimizer/Utils/InstOptUtils.cpp +++ b/lib/SILOptimizer/Utils/InstOptUtils.cpp @@ -22,6 +22,7 @@ #include "swift/SIL/InstructionUtils.h" #include "swift/SIL/SILArgument.h" #include "swift/SIL/SILBuilder.h" +#include "swift/SIL/SILDebugInfoExpression.h" #include "swift/SIL/SILModule.h" #include "swift/SIL/SILUndef.h" #include "swift/SIL/TypeLowering.h" @@ -1389,14 +1390,12 @@ static bool keepArgsOfPartialApplyAlive(PartialApplyInst *pai, for (Operand *argOp : argsToHandle) { SILValue arg = argOp->get(); - int argIdx = argOp->getOperandNumber() - pai->getArgumentOperandNumber(); - SILDebugVariable dbgVar(/*Constant*/ true, argIdx); SILValue tmp = arg; if (arg->getType().isAddress()) { // Move the value to a stack-allocated temporary. SILBuilderWithScope builder(pai, builderCtxt); - tmp = builder.createAllocStack(pai->getLoc(), arg->getType(), dbgVar); + tmp = builder.createAllocStack(pai->getLoc(), arg->getType()); builder.createCopyAddr(pai->getLoc(), arg, tmp, IsTake_t::IsTake, IsInitialization_t::IsInitialization); } @@ -2132,4 +2131,67 @@ void swift::salvageDebugInfo(SILInstruction *I) { .createDebugValue(SI->getLoc(), SI->getSrc(), *VarInfo); } } + + // If a `struct` SIL instruction is "unwrapped" and removed, + // for instance, in favor of using its enclosed value directly, + // we need to make sure any of its related `debug_value` instruction + // is preserved. + if (auto *STI = dyn_cast(I)) { + auto STVal = STI->getResult(0); + llvm::ArrayRef FieldDecls = + STI->getStructDecl()->getStoredProperties(); + for (Operand *U : getDebugUses(STVal)) { + auto *DbgInst = cast(U->getUser()); + auto VarInfo = DbgInst->getVarInfo(); + if (!VarInfo) + continue; + if (VarInfo->DIExpr.hasFragment()) + // Since we can't merge two different op_fragment + // now, we're simply bailing out if there is an + // existing op_fragment in DIExpresison. + // TODO: Try to merge two op_fragment expressions here. + continue; + for (VarDecl *FD : FieldDecls) { + SILDebugVariable NewVarInfo = *VarInfo; + auto FieldVal = STI->getFieldValue(FD); + // Build the corresponding fragment DIExpression + auto FragDIExpr = SILDebugInfoExpression::createFragment(FD); + NewVarInfo.DIExpr.append(FragDIExpr); + + if (!NewVarInfo.Type) + NewVarInfo.Type = STI->getType(); + + // Create a new debug_value + SILBuilder(DbgInst, DbgInst->getDebugScope()) + .createDebugValue(DbgInst->getLoc(), FieldVal, NewVarInfo); + } + } + } + + if (auto *IA = dyn_cast(I)) { + if (IA->getBase() && IA->getIndex()) + // Only handle cases where offset is constant. + if (const auto *LiteralInst = + dyn_cast(IA->getIndex())) { + SILValue Base = IA->getBase(); + SILValue ResultAddr = IA->getResult(0); + APInt OffsetVal = LiteralInst->getValue(); + const SILDIExprElement ExprElements[3] = { + SILDIExprElement::createOperator(OffsetVal.isNegative() ? + SILDIExprOperator::ConstSInt : SILDIExprOperator::ConstUInt), + SILDIExprElement::createConstInt(OffsetVal.getLimitedValue()), + SILDIExprElement::createOperator(SILDIExprOperator::Plus) + }; + for (Operand *U : getDebugUses(ResultAddr)) { + auto *DbgInst = cast(U->getUser()); + auto VarInfo = DbgInst->getVarInfo(); + if (!VarInfo) + continue; + VarInfo->DIExpr.prependElements(ExprElements); + // Create a new debug_value + SILBuilder(DbgInst, DbgInst->getDebugScope()) + .createDebugValue(DbgInst->getLoc(), Base, *VarInfo); + } + } + } } diff --git a/lib/SILOptimizer/Utils/OptimizerStatsUtils.cpp b/lib/SILOptimizer/Utils/OptimizerStatsUtils.cpp index 4e6d8a114eae2..95a78ba10bbe2 100644 --- a/lib/SILOptimizer/Utils/OptimizerStatsUtils.cpp +++ b/lib/SILOptimizer/Utils/OptimizerStatsUtils.cpp @@ -558,7 +558,7 @@ llvm::raw_ostream &stats_os() { // Try to open the file. std::error_code EC; auto fd_stream = std::make_unique( - SILStatsOutputFile, EC, llvm::sys::fs::OpenFlags::F_Text); + SILStatsOutputFile, EC, llvm::sys::fs::OpenFlags::OF_Text); if (!fd_stream->has_error() && !EC) { stats_output_stream = {fd_stream.release(), [](llvm::raw_ostream *d) { delete d; }}; diff --git a/lib/SILOptimizer/Utils/PartialApplyCombiner.cpp b/lib/SILOptimizer/Utils/PartialApplyCombiner.cpp index cbc9ff8ee9e82..3c81442b9e0cf 100644 --- a/lib/SILOptimizer/Utils/PartialApplyCombiner.cpp +++ b/lib/SILOptimizer/Utils/PartialApplyCombiner.cpp @@ -98,16 +98,13 @@ bool PartialApplyCombiner::copyArgsToTemporaries( for (Operand *argOp : argsToHandle) { SILValue arg = argOp->get(); - int argIdx = ApplySite(pai).getAppliedArgIndex(*argOp); - SILDebugVariable dbgVar(/*Constant*/ true, argIdx); - SILValue tmp = arg; SILBuilderWithScope builder(pai, builderCtxt); if (arg->getType().isObject()) { tmp = builder.emitCopyValueOperation(pai->getLoc(), arg); } else { // Copy address-arguments into a stack-allocated temporary. - tmp = builder.createAllocStack(pai->getLoc(), arg->getType(), dbgVar); + tmp = builder.createAllocStack(pai->getLoc(), arg->getType()); builder.createCopyAddr(pai->getLoc(), arg, tmp, IsTake_t::IsNotTake, IsInitialization_t::IsInitialization); } diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index f3b6a25d9f39b..34e7f5149f04c 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -3514,7 +3514,7 @@ DeclName MissingMemberFailure::findCorrectEnumCaseName( auto candidate = corrections.getUniqueCandidateMatching([&](ValueDecl *candidate) { return (isa(candidate) && - candidate->getBaseIdentifier().str().equals_lower( + candidate->getBaseIdentifier().str().equals_insensitive( memberName.getBaseIdentifier().str())); }); return (candidate ? candidate->getName() : DeclName()); diff --git a/lib/Sema/CSStep.cpp b/lib/Sema/CSStep.cpp index b0a75d00a0f37..b1b7ec6c4a730 100644 --- a/lib/Sema/CSStep.cpp +++ b/lib/Sema/CSStep.cpp @@ -717,7 +717,7 @@ bool swift::isSIMDOperator(ValueDecl *value) { if (nominal->getName().empty()) return false; - return nominal->getName().str().startswith_lower("simd"); + return nominal->getName().str().startswith_insensitive("simd"); } bool DisjunctionStep::shortCircuitDisjunctionAt( diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index 996f6929e7dab..9fcdb9d967af4 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -1550,7 +1550,7 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) { // Look for types and value decls in other modules. This extra information // is mostly for compiler engineers to understand a likely solution at a // quick glance. - SmallVector strScratch; + SmallVector strScratch; SmallVector notes; auto declName = getXRefDeclNameForError(); if (recordID == XREF_TYPE_PATH_PIECE || diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp index c0dc41a69b1ae..b4669afe7bb72 100644 --- a/lib/Serialization/Serialization.cpp +++ b/lib/Serialization/Serialization.cpp @@ -80,6 +80,10 @@ using llvm::BCBlockRAII; ASTContext &SerializerBase::getASTContext() const { return M->getASTContext(); } +static StringRef withNullAsEmptyStringRef(const char *data) { + return StringRef(data ? data : ""); +} + /// Used for static_assert. static constexpr bool declIDFitsIn32Bits() { using Int32Info = std::numeric_limits; @@ -5668,7 +5672,7 @@ void swift::serializeToBuffers( std::unique_ptr *moduleSourceInfoBuffer, const SILModule *M) { - assert(!StringRef::withNullAsEmpty(options.OutputPath).empty()); + assert(!withNullAsEmptyStringRef(options.OutputPath).empty()); { FrontendStatsTracer tracer(getContext(DC).Stats, "Serialization, swiftmodule, to buffer"); @@ -5690,7 +5694,7 @@ void swift::serializeToBuffers( std::move(buf), options.OutputPath); } - if (!StringRef::withNullAsEmpty(options.DocOutputPath).empty()) { + if (!withNullAsEmptyStringRef(options.DocOutputPath).empty()) { FrontendStatsTracer tracer(getContext(DC).Stats, "Serialization, swiftdoc, to buffer"); llvm::SmallString<1024> buf; @@ -5707,7 +5711,7 @@ void swift::serializeToBuffers( std::move(buf), options.DocOutputPath); } - if (!StringRef::withNullAsEmpty(options.SourceInfoOutputPath).empty()) { + if (!withNullAsEmptyStringRef(options.SourceInfoOutputPath).empty()) { FrontendStatsTracer tracer(getContext(DC).Stats, "Serialization, swiftsourceinfo, to buffer"); llvm::SmallString<1024> buf; @@ -5729,12 +5733,12 @@ void swift::serialize(ModuleOrSourceFile DC, const SerializationOptions &options, const SILModule *M, const fine_grained_dependencies::SourceFileDepGraph *DG) { - assert(!StringRef::withNullAsEmpty(options.OutputPath).empty()); + assert(!withNullAsEmptyStringRef(options.OutputPath).empty()); if (StringRef(options.OutputPath) == "-") { // Special-case writing to stdout. Serializer::writeToStream(llvm::outs(), DC, M, options, DG); - assert(StringRef::withNullAsEmpty(options.DocOutputPath).empty()); + assert(withNullAsEmptyStringRef(options.DocOutputPath).empty()); return; } @@ -5749,7 +5753,7 @@ void swift::serialize(ModuleOrSourceFile DC, if (hadError) return; - if (!StringRef::withNullAsEmpty(options.DocOutputPath).empty()) { + if (!withNullAsEmptyStringRef(options.DocOutputPath).empty()) { (void)withOutputFile(getContext(DC).Diags, options.DocOutputPath, [&](raw_ostream &out) { @@ -5760,7 +5764,7 @@ void swift::serialize(ModuleOrSourceFile DC, }); } - if (!StringRef::withNullAsEmpty(options.SourceInfoOutputPath).empty()) { + if (!withNullAsEmptyStringRef(options.SourceInfoOutputPath).empty()) { (void)withOutputFile(getContext(DC).Diags, options.SourceInfoOutputPath, [&](raw_ostream &out) { diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp index bceb228de858e..d954d4bb03636 100644 --- a/lib/Serialization/SerializeSIL.cpp +++ b/lib/Serialization/SerializeSIL.cpp @@ -1613,26 +1613,26 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) { case SILInstructionKind::FloatLiteralInst: case SILInstructionKind::IntegerLiteralInst: { // Use SILOneOperandLayout to specify the type and the literal. - std::string Str; + llvm::SmallString<10> Str; SILType Ty; switch (SI.getKind()) { default: llvm_unreachable("Out of sync with parent switch"); case SILInstructionKind::IntegerLiteralInst: - Str = cast(&SI)->getValue().toString(10, true); + cast(&SI)->getValue().toString(Str, 10, + /*signed*/ true); Ty = cast(&SI)->getType(); break; case SILInstructionKind::FloatLiteralInst: - Str = cast(&SI)->getBits().toString(16, - /*Signed*/false); + cast(&SI)->getBits().toString(Str, 16, + /*signed*/ true); Ty = cast(&SI)->getType(); break; } unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code]; - SILOneOperandLayout::emitRecord(Out, ScratchRecord, abbrCode, - (unsigned)SI.getKind(), 0, - S.addTypeRef(Ty.getASTType()), - (unsigned)Ty.getCategory(), - S.addUniquedStringRef(Str)); + SILOneOperandLayout::emitRecord( + Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), 0, + S.addTypeRef(Ty.getASTType()), (unsigned)Ty.getCategory(), + S.addUniquedStringRef(Str.str())); break; } case SILInstructionKind::MarkFunctionEscapeInst: { diff --git a/lib/Serialization/SerializedModuleLoader.cpp b/lib/Serialization/SerializedModuleLoader.cpp index d7d88dcc24e82..b05558c712b90 100644 --- a/lib/Serialization/SerializedModuleLoader.cpp +++ b/lib/Serialization/SerializedModuleLoader.cpp @@ -1244,6 +1244,11 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc, if (!file) return nullptr; + // The MemoryBuffer loader is used by LLDB during debugging. Modules imported + // from .swift_ast sections are never produced from textual interfaces. By + // disabling resilience the debugger can directly access private members. + if (BypassResilience) + M->setBypassResilience(); M->addFile(*file); Ctx.addLoadedModule(M); return M; diff --git a/lib/TBDGen/TBDGen.cpp b/lib/TBDGen/TBDGen.cpp index afdcd2658c3e7..e6b18d5ae6b69 100644 --- a/lib/TBDGen/TBDGen.cpp +++ b/lib/TBDGen/TBDGen.cpp @@ -47,10 +47,10 @@ #include "llvm/Support/Process.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/YAMLParser.h" -#include "llvm/TextAPI/MachO/InterfaceFile.h" -#include "llvm/TextAPI/MachO/Symbol.h" -#include "llvm/TextAPI/MachO/TextAPIReader.h" -#include "llvm/TextAPI/MachO/TextAPIWriter.h" +#include "llvm/TextAPI/InterfaceFile.h" +#include "llvm/TextAPI/Symbol.h" +#include "llvm/TextAPI/TextAPIReader.h" +#include "llvm/TextAPI/TextAPIWriter.h" #include "APIGen.h" #include "TBDGenVisitor.h" @@ -68,7 +68,7 @@ static bool isGlobalOrStaticVar(VarDecl *VD) { TBDGenVisitor::TBDGenVisitor(const TBDGenDescriptor &desc, APIRecorder &recorder) - : TBDGenVisitor(desc.getTarget(), desc.getDataLayout(), + : TBDGenVisitor(desc.getTarget(), desc.getDataLayoutString(), desc.getParentModule(), desc.getOptions(), recorder) {} void TBDGenVisitor::addSymbolInternal(StringRef name, SymbolKind kind, @@ -390,7 +390,9 @@ void TBDGenVisitor::addSymbol(StringRef name, SymbolSource source, if (kind == SymbolKind::ObjectiveCClass) { mangled = name; } else { - llvm::Mangler::getNameWithPrefix(mangled, name, DataLayout); + if (!DataLayout) + DataLayout = llvm::DataLayout(DataLayoutDescription); + llvm::Mangler::getNameWithPrefix(mangled, name, *DataLayout); } addSymbolInternal(mangled, kind, source); diff --git a/lib/TBDGen/TBDGenRequests.cpp b/lib/TBDGen/TBDGenRequests.cpp index a71bdcd925632..09c3fd613cc87 100644 --- a/lib/TBDGen/TBDGenRequests.cpp +++ b/lib/TBDGen/TBDGenRequests.cpp @@ -19,7 +19,7 @@ #include "swift/Subsystems.h" #include "swift/TBDGen/TBDGen.h" #include "clang/Basic/TargetInfo.h" -#include "llvm/TextAPI/MachO/InterfaceFile.h" +#include "llvm/TextAPI/InterfaceFile.h" #include "APIGen.h" @@ -48,10 +48,10 @@ ModuleDecl *TBDGenDescriptor::getParentModule() const { return Input.get()->getParentModule(); } -const llvm::DataLayout &TBDGenDescriptor::getDataLayout() const { +const StringRef TBDGenDescriptor::getDataLayoutString() const { auto &ctx = getParentModule()->getASTContext(); auto *clang = static_cast(ctx.getClangModuleLoader()); - return clang->getTargetInfo().getDataLayout(); + return llvm::StringRef(clang->getTargetInfo().getDataLayoutString()); } const llvm::Triple &TBDGenDescriptor::getTarget() const { diff --git a/lib/TBDGen/TBDGenVisitor.h b/lib/TBDGen/TBDGenVisitor.h index 75f79f1ee8ad8..d7c1a878cfd5f 100644 --- a/lib/TBDGen/TBDGenVisitor.h +++ b/lib/TBDGen/TBDGenVisitor.h @@ -29,7 +29,7 @@ #include "swift/SIL/TypeLowering.h" #include "llvm/ADT/StringSet.h" #include "llvm/ADT/Triple.h" -#include "llvm/TextAPI/MachO/InterfaceFile.h" +#include "llvm/TextAPI/InterfaceFile.h" using namespace swift::irgen; using StringSet = llvm::StringSet<>; @@ -92,7 +92,9 @@ class TBDGenVisitor : public ASTVisitor { llvm::StringSet<> DuplicateSymbolChecker; #endif - const llvm::DataLayout &DataLayout; + Optional DataLayout = None; + const StringRef DataLayoutDescription; + UniversalLinkageInfo UniversalLinkInfo; ModuleDecl *SwiftModule; const TBDGenOptions &Opts; @@ -167,10 +169,10 @@ class TBDGenVisitor : public ASTVisitor { const AutoDiffConfig &config); public: - TBDGenVisitor(const llvm::Triple &target, const llvm::DataLayout &dataLayout, + TBDGenVisitor(const llvm::Triple &target, const StringRef dataLayoutString, ModuleDecl *swiftModule, const TBDGenOptions &opts, APIRecorder &recorder) - : DataLayout(dataLayout), + : DataLayoutDescription(dataLayoutString), UniversalLinkInfo(target, opts.HasMultipleIGMs, /*forcePublic*/ false), SwiftModule(swiftModule), Opts(opts), recorder(recorder), previousInstallNameMap(parsePreviousModuleInstallNameMap()) {} diff --git a/stdlib/public/Reflection/TypeRef.cpp b/stdlib/public/Reflection/TypeRef.cpp index d89dae57cccc4..3304229699b01 100644 --- a/stdlib/public/Reflection/TypeRef.cpp +++ b/stdlib/public/Reflection/TypeRef.cpp @@ -784,7 +784,6 @@ class DemanglingForTypeRef Demangle::NodePointer visitGenericTypeParameterTypeRef(const GenericTypeParameterTypeRef *GTP) { - assert(false && "not tested"); auto node = Dem.createNode(Node::Kind::DependentGenericParamType); node->addChild(Dem.createNode(Node::Kind::Index, GTP->getDepth()), Dem); node->addChild(Dem.createNode(Node::Kind::Index, GTP->getIndex()), Dem); @@ -793,7 +792,6 @@ class DemanglingForTypeRef Demangle::NodePointer visitDependentMemberTypeRef(const DependentMemberTypeRef *DM) { - assert(false && "not tested"); assert(DM->getProtocol().empty() && "not implemented"); auto node = Dem.createNode(Node::Kind::DependentMemberType); node->addChild(visit(DM->getBase()), Dem); diff --git a/test/ClangImporter/CoreGraphics_test.swift b/test/ClangImporter/CoreGraphics_test.swift index f0490eb5c3a1e..a48322867d61b 100644 --- a/test/ClangImporter/CoreGraphics_test.swift +++ b/test/ClangImporter/CoreGraphics_test.swift @@ -24,7 +24,8 @@ public func testEnums(_ model: CGColorSpaceModel) -> Int { } // CHECK: [[GEP:%.+]] = getelementptr inbounds [8 x i64], [8 x i64]* [[SWITCHTABLE]], i64 0, i64 %{{.*}} // CHECK: [[LOAD:%.+]] = load i64, i64* [[GEP]], align 8 -// CHECK: ret i64 [[LOAD]] +// CHECK: [[PHI:%.*]] = phi i64 [ [[LOAD]], %{{.*}} ], [ -1, %{{.*}} ] +// CHECK: ret i64 [[PHI]] } // CHECK-LABEL: define swiftcc void {{.*}}rotationAround{{.*}} { diff --git a/test/ClangImporter/overlay.swift b/test/ClangImporter/overlay.swift index 6f949d87ae74a..a36cf722a6931 100644 --- a/test/ClangImporter/overlay.swift +++ b/test/ClangImporter/overlay.swift @@ -3,6 +3,8 @@ // REQUIRES: objc_interop +// REQUIRES: rdar83592270 + // Do not import Foundation! This tests indirect visibility. #if REVERSED import Redeclaration diff --git a/test/Concurrency/throwing.swift b/test/Concurrency/throwing.swift index 0f5a8fe83044a..4e4c73fb86327 100644 --- a/test/Concurrency/throwing.swift +++ b/test/Concurrency/throwing.swift @@ -6,6 +6,9 @@ // REQUIRES: concurrency_runtime // UNSUPPORTED: back_deployment_runtime +// SR-15252 +// XFAIL: OS=windows-msvc + import _Concurrency import StdlibUnittest diff --git a/test/DebugInfo/ErrorVar.swift b/test/DebugInfo/ErrorVar.swift index ca921180dce4a..bc186ac95c125 100644 --- a/test/DebugInfo/ErrorVar.swift +++ b/test/DebugInfo/ErrorVar.swift @@ -17,10 +17,8 @@ func simple(_ placeholder: Int64) throws -> () { // CHECK-SAME: %swift.error** noalias nocapture dereferenceable(4) // CHECK: call void @llvm.dbg.declare // CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[ERROR:[0-9]+]], metadata !DIExpression(DW_OP_deref)) - // CHECK: ![[ERRTY:.*]] = !DICompositeType({{.*}}identifier: "$ss5Error_pD" - // CHECK: ![[ERROR]] = !DILocalVariable(name: "$error", arg: 2, - // CHECK-SAME: type: ![[ERRTY]], - // CHECK-SAME: flags: DIFlagArtificial) + // CHECK-DAG: ![[ERRTY:.*]] = !DICompositeType({{.*}}identifier: "$ss5Error_pD" + // CHECK-DAG: ![[ERROR]] = !DILocalVariable(name: "$error", arg: 2, {{.*}}, type: ![[ERRTY]], flags: DIFlagArtificial) throw MyError.Simple } diff --git a/test/DebugInfo/Errors.swift b/test/DebugInfo/Errors.swift index 819873042da78..ffe704a1a8678 100644 --- a/test/DebugInfo/Errors.swift +++ b/test/DebugInfo/Errors.swift @@ -4,9 +4,8 @@ public enum E : Error { case Err } // Function throws. public func throwError() throws { throw E.Err } // CHECK: !DISubprogram(name: "throwError", {{.*}}thrownTypes: ![[THROWN:.*]]) -// CHECK: ![[THROWN]] = !{![[ERROR:[0-9]+]]} -// CHECK: ![[ERROR]] = !DICompositeType(tag: DW_TAG_structure_type, -// CHECK-SAME: name: "Error" +// CHECK-DAG: ![[THROWN]] = !{![[ERROR:[0-9]+]]} +// CHECK-DAG: ![[ERROR]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Error" // Function rethrows. diff --git a/test/DebugInfo/anonymous.swift b/test/DebugInfo/anonymous.swift index 4b2e4e1c2763b..21fa079f41be3 100644 --- a/test/DebugInfo/anonymous.swift +++ b/test/DebugInfo/anonymous.swift @@ -1,9 +1,14 @@ +// RUN: %target-swift-frontend %s -emit-sil -g -o - | %FileCheck --check-prefix=SIL %s // RUN: %target-swift-frontend -primary-file %s -emit-ir -g -o - | %FileCheck %s -// CHECK: !DILocalVariable(name: "x4", arg: 4 +// SIL: debug_value %1 : $*T, let, name "_0", argno 1, expr op_deref +// SIL: debug_value %2 : $*T, let, name "_1", argno 2, expr op_deref +// SIL: debug_value %3 : $*T, let, name "_2", argno 3, expr op_deref +// SIL: debug_value %4 : $*T, let, name "x4", argno 4, expr op_deref // CHECK: !DILocalVariable(name: "_0", arg: 1 // CHECK: !DILocalVariable(name: "_1", arg: 2 // CHECK: !DILocalVariable(name: "_2", arg: 3 +// CHECK: !DILocalVariable(name: "x4", arg: 4 public func fourth(_: T, _: T, _: T, x4 : T) -> T { return x4 diff --git a/test/DebugInfo/apple-names-accel.swift b/test/DebugInfo/apple-names-accel.swift index ff28e6e45d2e9..a7f3fb4f69aa2 100644 --- a/test/DebugInfo/apple-names-accel.swift +++ b/test/DebugInfo/apple-names-accel.swift @@ -1,7 +1,7 @@ // Check that the apple-names section is emitted on Darwin. // Adapted from llvm/test/DebugInfo/X86/debugger-tune.ll // RUN: %target-swiftc_driver -emit-object -g %s -o %t -// RUN: llvm-readobj -sections %t | %FileCheck --check-prefix=CHECK-LLDB %s +// RUN: %llvm-dwarfdump -a %t | %FileCheck --check-prefix=CHECK-LLDB %s // CHECK-LLDB-NOT: debug_pubnames // CHECK-LLDB: apple_names diff --git a/test/DebugInfo/async-args.swift b/test/DebugInfo/async-args.swift index dd41325c8cda8..c287307b4eae2 100644 --- a/test/DebugInfo/async-args.swift +++ b/test/DebugInfo/async-args.swift @@ -10,17 +10,15 @@ func withGenericArg(_ msg: T) async { // This odd debug info is part of a contract with CoroSplit/CoroFrame to fix // this up after coroutine splitting. // CHECK-LABEL: {{^define .*}} @"$s1M14withGenericArgyyxYalF"(%swift.context* swiftasync %0 - // CHECK: call void @llvm.dbg.declare(metadata %swift.context* %0, - // CHECK-SAME: metadata ![[MSG:[0-9]+]], metadata !DIExpression( - // CHECK-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref)) - // CHECK: call void @llvm.dbg.declare(metadata %swift.context* %0, - // CHECK-SAME: metadata ![[TAU:[0-9]+]], metadata !DIExpression( - // CHECK-SAME: DW_OP_plus_uconst, {{[0-9]+}})) + // CHECK: call void @llvm.dbg.declare(metadata %swift.context* %0 + // CHECK-SAME: metadata ![[MSG:[0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, {{.*}}DW_OP_deref)) + // CHECK: call void @llvm.dbg.declare(metadata %swift.context* %0 + // CHECK-SAME: metadata ![[TAU:[0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, await forceSplit() // CHECK-LABEL: {{^define .*}} @"$s1M14withGenericArgyyxYalFTQ0_"(i8* swiftasync %0) // CHECK: call void @llvm.dbg.declare(metadata i8* %0, - // CHECK-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(DW_OP_deref, + // CHECK-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression( // CHECK-SAME: DW_OP_plus_uconst, [[OFFSET:[0-9]+]], // CHECK-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref)) // CHECK: call void @llvm.dbg.declare(metadata i8* %0, @@ -35,7 +33,8 @@ func withGenericArg(_ msg: T) async { await withGenericArg("hello (asynchronously)") } } -// CHECK: ![[MSG]] = !DILocalVariable(name: "msg", arg: 1, // CHECK: ![[TAU]] = !DILocalVariable(name: "$\CF\84_0_0", -// CHECK: ![[MSG_R]] = !DILocalVariable(name: "msg", arg: 1, +// CHECK: ![[MSG]] = !DILocalVariable(name: "msg", arg: 1, // CHECK: ![[TAU_R]] = !DILocalVariable(name: "$\CF\84_0_0", +// CHECK: ![[MSG_R]] = !DILocalVariable(name: "msg", arg: 1, + diff --git a/test/DebugInfo/async-let-await.swift b/test/DebugInfo/async-let-await.swift index 37450e90685b1..5c71c22a4a7d4 100644 --- a/test/DebugInfo/async-let-await.swift +++ b/test/DebugInfo/async-let-await.swift @@ -11,7 +11,7 @@ public func getVegetables() async -> [String] { public func chopVegetables() async throws -> [String] { let veggies = await getVegetables() // CHECK-NOT: {{^define }} - // CHECK: call void @llvm.dbg.declare(metadata i8* %0, metadata ![[V:[0-9]+]], metadata !DIExpression(DW_OP_deref + // CHECK: call void @llvm.dbg.declare(metadata i8* %0, metadata ![[V:[0-9]+]], metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_plus_uconst, {{[0-9]+}}) // CHECK: ![[V]] = !DILocalVariable(name: "veggies" return veggies.map { "chopped \($0)" } } diff --git a/test/DebugInfo/async-lifetime-extension.swift b/test/DebugInfo/async-lifetime-extension.swift index 4006e0bd371d5..f7e259c83b580 100644 --- a/test/DebugInfo/async-lifetime-extension.swift +++ b/test/DebugInfo/async-lifetime-extension.swift @@ -8,16 +8,16 @@ // CHECK-LABEL: define {{.*}} void @"$s1a4fiboyS2iYaFTQ0_" // CHECK-NEXT: entryresume.0: -// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[RHS:[0-9]+]], {{.*}}!DIExpression(DW_OP -// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[LHS:[0-9]+]], {{.*}}!DIExpression(DW_OP // CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[R:[0-9]+]], {{.*}}!DIExpression(DW_OP // CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[N:[0-9]+]], {{.*}}!DIExpression(DW_OP +// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[LHS:[0-9]+]], {{.*}}!DIExpression(DW_OP +// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[RHS:[0-9]+]], {{.*}}!DIExpression(DW_OP // CHECK-NOT: {{ ret }} // CHECK: call void asm sideeffect "" -// CHECK: ![[RHS]] = !DILocalVariable(name: "rhs" -// CHECK: ![[LHS]] = !DILocalVariable(name: "lhs" -// CHECK: ![[R]] = !DILocalVariable(name: "retval" // CHECK: ![[N]] = !DILocalVariable(name: "n" +// CHECK: ![[R]] = !DILocalVariable(name: "retval" +// CHECK: ![[LHS]] = !DILocalVariable(name: "lhs" +// CHECK: ![[RHS]] = !DILocalVariable(name: "rhs" public func fibo(_ n: Int) async -> Int { var retval = n if retval < 2 { return 1 } diff --git a/test/DebugInfo/async-local-var.swift b/test/DebugInfo/async-local-var.swift index 83aeed47ee242..27c69b75db824 100644 --- a/test/DebugInfo/async-local-var.swift +++ b/test/DebugInfo/async-local-var.swift @@ -16,7 +16,7 @@ public func makeDinner() async throws -> String { // CHECK-LABEL: define {{.*}} void @"$s1a10makeDinnerSSyYaKFTQ0_" // CHECK-NEXT: entryresume.0: // CHECK-NOT: {{ ret }} -// CHECK: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[LOCAL:[0-9]+]], {{.*}}!DIExpression(DW_OP_deref +// CHECK: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[LOCAL:[0-9]+]], {{.*}}!DIExpression(DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}) // CHECK: ![[LOCAL]] = !DILocalVariable(name: "local" return local } diff --git a/test/DebugInfo/constant_propagation.sil b/test/DebugInfo/constant_propagation.sil new file mode 100644 index 0000000000000..055315d765bae --- /dev/null +++ b/test/DebugInfo/constant_propagation.sil @@ -0,0 +1,41 @@ +// RUN: %target-sil-opt -enable-sil-verify-all -sil-print-debuginfo -diagnostic-constant-propagation %s | %FileCheck %s +// REQUIRES: CPU=arm64 || CPU=x86_64 + +sil_stage canonical + +import Builtin +import Swift +import SwiftShims + +func foo(x: Int, y: Int) -> Int + +sil_scope 1 { loc "file.swift":1:6 parent @foo : $@convention(thin) (Int, Int) -> Int } + +// Test if debug_value got preserved when %16 is removed in favor of directly using %13 +// CHECK-LABEL: sil {{.*}} @foo +sil hidden @foo : $@convention(thin) (Int, Int) -> Int { +bb0(%0 : $Int, %1 : $Int): + %4 = integer_literal $Builtin.Int64, 87, loc "file.swift":2:17, scope 1 + %9 = struct_extract %0 : $Int, #Int._value, loc "file.swift":2:15, scope 1 + %11 = integer_literal $Builtin.Int1, -1, loc "file.swift":2:15, scope 1 + // CHECK: %[[ADD:.+]] = builtin "sadd_with_overflow + %12 = builtin "sadd_with_overflow_Int64"(%9 : $Builtin.Int64, %4 : $Builtin.Int64, %11 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1), loc "file.swift":2:15, scope 1 + // CHECK: (%[[RESULT:.+]], %{{.*}}) = destructure_tuple %[[ADD]] + (%13, %14) = destructure_tuple %12 : $(Builtin.Int64, Builtin.Int1), loc "file.swift":2:15, scope 1 + %16 = struct $Int (%13 : $Builtin.Int64), loc "file.swift":2:15, scope 1 + // In addition to checking if `op_fragment` is generated, we're also checking if "z"'s declared + // source location, as well as `debug_value`'s instruction source location are preserved. + // CHECK: debug_value %[[RESULT]] : $Builtin.Int{{[0-9]+}}, let, name "z" + // CHECK-SAME: type $Int + // CHECK-SAME: expr op_fragment:#Int._value + // CHECK-SAME: loc "file.swift":2:9, scope 1 + debug_value %16 : $Int, let, name "z", loc "file.swift":2:9, scope 1 + %19 = struct_extract %16 : $Int, #Int._value, loc "file.swift":3:14, scope 1 + %20 = struct_extract %1 : $Int, #Int._value, loc "file.swift":3:14, scope 1 + %21 = integer_literal $Builtin.Int1, -1, loc "file.swift":3:14, scope 1 + %22 = builtin "sadd_with_overflow_Int64"(%19 : $Builtin.Int64, %20 : $Builtin.Int64, %21 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1), loc "file.swift":3:14, scope 1 + (%23, %24) = destructure_tuple %22 : $(Builtin.Int64, Builtin.Int1), loc "file.swift":3:14, scope 1 + %26 = struct $Int (%23 : $Builtin.Int64), loc "file.swift":3:14, scope 1 + return %26 : $Int, loc "file.swift":3:5, scope 1 +} // end sil function 'foo' + diff --git a/test/DebugInfo/debug_info_expression.sil b/test/DebugInfo/debug_info_expression.sil index c7104f045545a..fc53d4c9b3726 100644 --- a/test/DebugInfo/debug_info_expression.sil +++ b/test/DebugInfo/debug_info_expression.sil @@ -14,7 +14,7 @@ struct SmallStruct { sil_scope 1 { loc "file.swift":7:6 parent @test_fragment : $@convention(thin) () -> () } -// Testing op_fragment w/ debug_value_addr +// Testing op_fragment w/ debug_value sil hidden @test_fragment : $@convention(thin) () -> () { bb0: %2 = alloc_stack $MyStruct, var, name "my_struct", loc "file.swift":8:9, scope 1 @@ -67,3 +67,26 @@ bb0: %r = tuple() return %r : $() } + +sil_scope 3 { loc "file.swift":16:7 parent @test_op_const : $@convention(thin) (Int64, Int64) -> () } + +// Testing op_constu and op_consts +sil hidden @test_op_const : $@convention(thin) (Int64, Int64) -> () { +bb0(%arg : $Int64, %arg2 : $Int64): + debug_value %arg : $Int64, let, name "the_arg", argno 1, expr op_constu:77, loc "file.swift":17:2, scope 3 + debug_value %arg2 : $Int64, let, name "the_2nd_arg", argno 2, expr op_consts:-87, loc "file.swift":17:4, scope 3 + %r = tuple() + return %r : $() +} + +sil_scope 4 { loc "file.swift":18:8 parent @test_arithmetic : $@convention(thin) (Int64, Int64) -> () } + +// Testing basic arithmetic operators like op_plus and op_minus +sil hidden @test_arithmetic : $@convention(thin) (Int64, Int64) -> () { +bb0(%arg : $Int64, %arg2 : $Int64): + debug_value %arg : $Int64, let, name "the_arg", argno 1, expr op_constu:3:op_plus, loc "file.swift":19:2, scope 4 + debug_value %arg2 : $Int64, let, name "the_2nd_arg", argno 2, expr op_constu:5:op_minus, loc "file.swift":19:4, scope 4 + %r = tuple() + return %r : $() +} + diff --git a/test/DebugInfo/inout.swift b/test/DebugInfo/inout.swift index 8ebc2b6d0796c..2a92bbeedd353 100644 --- a/test/DebugInfo/inout.swift +++ b/test/DebugInfo/inout.swift @@ -18,9 +18,8 @@ typealias MyFloat = Float // PROMO-CHECK: call void @llvm.dbg.declare(metadata %Ts5Int64V** % // PROMO-CHECK-SAME: metadata ![[A1:[0-9]+]], metadata !DIExpression(DW_OP_deref)) -// PROMO-CHECK-DAG: ![[INT:.*]] = !DICompositeType({{.*}}identifier: "$ss5Int64VD" -// PROMO-CHECK: ![[A1]] = !DILocalVariable(name: "a", arg: 1 -// PROMO-CHECK-SAME: type: ![[INT]] +// PROMO-CHECK: ![[INT:.*]] = !DICompositeType({{.*}}identifier: "$ss5Int64VD" +// PROMO-CHECK: ![[A1]] = !DILocalVariable(name: "a", arg: 1,{{.*}} type: ![[INT]] func modifyFooHeap(_ a: inout Int64, // CHECK-DAG: ![[A]] = !DILocalVariable(name: "a", arg: 1{{.*}} line: [[@LINE-1]],{{.*}} type: ![[RINT:[0-9]+]] // CHECK-DAG: ![[RINT]] = !DICompositeType({{.*}}identifier: "$ss5Int64VD" diff --git a/test/DebugInfo/patternmatching.swift b/test/DebugInfo/patternmatching.swift index 365c7ed2e0101..5474412cd215d 100644 --- a/test/DebugInfo/patternmatching.swift +++ b/test/DebugInfo/patternmatching.swift @@ -92,9 +92,8 @@ func classifyPoint2(_ p: (Double, Double)) { // CHECK-SCOPES: ![[X1]] = {{.*}}name: "x", scope: ![[SCOPE1:[0-9]+]], {{.*}}line: 37 // CHECK-SCOPES: ![[SCOPE1]] = distinct !DILexicalBlock(scope: ![[SWITCH1:[0-9]+]], {{.*}}line: 37 // CHECK-SCOPES: ![[SWITCH1]] = distinct !DILexicalBlock({{.*}}, line: 20 -// CHECK-SCOPES: ![[X1LOC]] = {{.*}}line: 37 - // CHECK-SCOPES: ![[Y1]] = {{.*}}name: "y", scope: ![[SCOPE1]], {{.*}}line: 37 +// CHECK-SCOPES: ![[X1LOC]] = {{.*}}line: 37 // CHECK-SCOPES: ![[Y1LOC]] = {{.*}}line: 37 // CHECK: !DILocation(line: [[@LINE+1]], diff --git a/test/DebugInfo/prologue.swift b/test/DebugInfo/prologue.swift index 4ff2fbeeedc56..7c6e125f9a91b 100644 --- a/test/DebugInfo/prologue.swift +++ b/test/DebugInfo/prologue.swift @@ -7,7 +7,7 @@ func markUsed(_ t: T) {} // CHECK: .file [[F:[0-9]+]] "{{.*}}prologue.swift" func bar(_ x: T, y: U) { markUsed("bar") } // CHECK: $s8prologue3bar_1yyx_q_tr0_lF: -// CHECK: .loc [[F]] 0 0 prologue_end +// CHECK: .loc [[F]] 0 0 is_stmt 0 // Make sure there is no allocation happening between the end of // prologue and the beginning of the function body. // CHECK-NOT: callq * diff --git a/test/DebugInfo/sil_combine.sil b/test/DebugInfo/sil_combine.sil new file mode 100644 index 0000000000000..4f555bd0d04b4 --- /dev/null +++ b/test/DebugInfo/sil_combine.sil @@ -0,0 +1,28 @@ +// RUN: %target-sil-opt -sil-verify-all -sil-combine %s | %FileCheck %s +// RUN: %target-swift-frontend -g -O -emit-ir -primary-file %s | %FileCheck --check-prefix=CHECK-IR %s + +sil_stage canonical + +import Builtin +import Swift + +// CHECK-LABEL: sil {{.*}} @test_nested_index_addr +// CHECK-IR-LABEL: define {{.*}} @test_nested_index_addr +sil hidden @test_nested_index_addr : $@convention(thin) (Builtin.RawPointer) -> Builtin.RawPointer { +bb0(%0 : $Builtin.RawPointer): + %offset1 = integer_literal $Builtin.Word, 3 + %offset2 = integer_literal $Builtin.Word, 7 + // CHECK: %[[ADDR:.+]] = pointer_to_address %0 + %addr = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*UInt8 + %addr1 = index_addr %addr : $*UInt8, %offset1 : $Builtin.Word + // CHECK: debug_value %[[ADDR]] : $*UInt8, let, name "hello" + // CHECK-SAME: expr op_constu:3:op_plus:op_deref + // CHECK-IR: call void @llvm.dbg.value(metadata i8* %0, metadata ![[DBG_VAR:[0-9]+]], + // CHECK-IR-SAME: !DIExpression(DW_OP_constu, 3, DW_OP_plus, DW_OP_deref) + debug_value %addr1 : $*UInt8, let, name "hello", expr op_deref + %addr2 = index_addr %addr1 : $*UInt8, %offset2 : $Builtin.Word + %ptr = address_to_pointer %addr2 : $*UInt8 to $Builtin.RawPointer + return %ptr : $Builtin.RawPointer +} + +// CHECK-IR: ![[DBG_VAR]] = !DILocalVariable(name: "hello" diff --git a/test/DebugInfo/sroa_mem2reg.sil b/test/DebugInfo/sroa_mem2reg.sil index e265ad1390e78..8cfd067d3cb33 100644 --- a/test/DebugInfo/sroa_mem2reg.sil +++ b/test/DebugInfo/sroa_mem2reg.sil @@ -74,13 +74,14 @@ bb0(%0 : $Int64, %1 : $Int64): return %0 : $Int64, loc "sroa.swift":11:5, scope 2 } // end sil function 'foo' -// CHECK-IR: ![[STRUCT_MD]] = !DILocalVariable(name: "my_struct" -// CHECK-IR-SAME: line: 8 // CHECK-IR: ![[ARG1_MD]] = !DILocalVariable(name: "in_x", arg: 1 // CHECK-IR-SAME: line: 7 // CHECK-IR: ![[ARG2_MD]] = !DILocalVariable(name: "in_y", arg: 2 // CHECK-IR-SAME: line: 7 +// CHECK-IR: ![[STRUCT_MD]] = !DILocalVariable(name: "my_struct" +// CHECK-IR-SAME: line: 8 + // CHECK-DWARF-LABEL: DW_AT_name ("foo") // CHECK-DWARF: DW_TAG_variable // CHECK-DWARF: DW_AT_name ("my_struct") diff --git a/test/Driver/driver-time-compilation.swift b/test/Driver/driver-time-compilation.swift index 78a7555d98fa6..faca856df18f3 100644 --- a/test/Driver/driver-time-compilation.swift +++ b/test/Driver/driver-time-compilation.swift @@ -1,10 +1,15 @@ // RUN: %target-build-swift -typecheck -driver-time-compilation %s 2>&1 | %FileCheck %s // RUN: %target-build-swift -typecheck -driver-time-compilation %s %S/../Inputs/empty.swift 2>&1 | %FileCheck -check-prefix CHECK-MULTIPLE %s +// REQUIRES: rdar82895550 + // CHECK: Driver Compilation Time // CHECK: Total Execution Time: {{[0-9]+}}.{{[0-9]+}} seconds ({{[0-9]+}}.{{[0-9]+}} wall clock) -// CHECK: ---Wall Time--- -// CHECK: --- Name --- -// CHECK: {compile: {{.*}}driver-time-compilation.swift} +// CHECK: ---User Time--- +// CHECK-SAME: --System Time-- +// CHECK-SAME: --User+System-- +// CHECK-SAME: ---Wall Time--- +// CHECK-SAME: ---Instr--- +// CHECK-SAME: --- Name --- // CHECK-MULTIPLE: {compile: {{.*}}empty.swift} -// CHECK: {{[0-9]+}}.{{[0-9]+}} (100.0%) Total +// CHECK: {{[0-9]+}}.{{[0-9]+}} (100.0%) {{[0-9]+}}.{{[0-9]+}} (100.0%) {{[0-9]+}}.{{[0-9]+}} (100.0%) {{[0-9]+}}.{{[0-9]+}} (100.0%) {{.*}} {compile: {{.*}}driver-time-compilation.swift} diff --git a/test/IRGen/ELF-remove-autolink-section.swift b/test/IRGen/ELF-remove-autolink-section.swift index be94f083f40a6..5f46d4f2e4aa4 100644 --- a/test/IRGen/ELF-remove-autolink-section.swift +++ b/test/IRGen/ELF-remove-autolink-section.swift @@ -12,12 +12,10 @@ print("Hi from Swift!") -// ELF: module asm ".section .swift1_autolink_entries,\220x80000000\22" - // Find the metadata entry for the denylisting of the metadata symbol // Ensure that it is in the ASAN metadata -// ELF-DAG: !llvm.asan.globals = !{ +// ELF: !llvm.asan.globals = !{ // ELF-SAME: [[MD:![0-9]+]] // ELF-SAME: } diff --git a/test/IRGen/autolink_elf.swift b/test/IRGen/autolink_elf.swift index 06caf06d81a47..df4a10dc4e0a5 100644 --- a/test/IRGen/autolink_elf.swift +++ b/test/IRGen/autolink_elf.swift @@ -10,5 +10,5 @@ import Empty // as used. // CHECK-DAG: @_swift1_autolink_entries = private constant [26 x i8] c"-lswiftEmpty\00-lanotherLib\00", section ".swift1_autolink_entries", align 8 -// CHECK-DAG: @llvm.used = appending global [{{.*}} x i8*] [{{.*}}i8* getelementptr inbounds ([26 x i8], [26 x i8]* @_swift1_autolink_entries, i32 0, i32 0){{.*}}], section "llvm.metadata" +// CHECK-DAG: @llvm.compiler.used = appending global [{{.*}} x i8*] [{{.*}}i8* getelementptr inbounds ([26 x i8], [26 x i8]* @_swift1_autolink_entries, i32 0, i32 0){{.*}}], section "llvm.metadata" diff --git a/test/IRGen/newtype.swift b/test/IRGen/newtype.swift index c913c9593e26c..35e092fa970fd 100644 --- a/test/IRGen/newtype.swift +++ b/test/IRGen/newtype.swift @@ -129,11 +129,9 @@ class ObjCTest { // CHECK: {{^}$}} // OPT-LABEL: define hidden %0* @"$s7newtype8ObjCTestC19optionalPassThroughySo14SNTErrorDomainaSgAGFTo" - // OPT: [[ARG_CASTED:%.*]] = bitcast %0* %2 to %objc_object* - // OPT: [[ARG_RECASTED:%.*]] = bitcast %objc_object* [[ARG_CASTED]] to i8* // OPT: [[ARG_CASTED2:%.*]] = bitcast %0* %2 to i8* - // OPT: tail call i8* @llvm.objc.retainAutoreleaseReturnValue(i8* [[ARG_RECASTED]]) - // OPT: [[CAST_FOR_RETURN:%.*]] = bitcast i8* [[ARG_CASTED2]] to %0* + // OPT: [[RES:%.*]] = tail call i8* @llvm.objc.retainAutoreleaseReturnValue(i8* [[ARG_CASTED2]]) + // OPT: [[CAST_FOR_RETURN:%.*]] = bitcast i8* [[RES]] to %0* // OPT: ret %0* [[CAST_FOR_RETURN]] // OPT: {{^}$}} @objc func optionalPassThrough(_ ed: ErrorDomain?) -> ErrorDomain? { diff --git a/test/IRGen/objc_protocol_vars.sil b/test/IRGen/objc_protocol_vars.sil index d3ac4b7822c78..c102f3fc4fe21 100644 --- a/test/IRGen/objc_protocol_vars.sil +++ b/test/IRGen/objc_protocol_vars.sil @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -parse-as-library -emit-ir %s | %FileCheck %s +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -parse-as-library -emit-ir %s | %FileCheck %s --check-prefix=CHECK-%target-object-format // It tests whether the vars @"\01l_OBJC_LABEL_PROTOCOL_$__TtP18objc_protocol_vars1T_" // and @"\01l_OBJC_PROTOCOL_REFERENCE_$__TtP18objc_protocol_vars1T_" are in llvm.used. @@ -25,5 +25,7 @@ import Foundation @objc func clone() -> T } -// CHECK: @llvm.used = appending global [{{.*}}] [{{.*}}, i8* bitcast (i8** @"\01l_OBJC_LABEL_PROTOCOL_$__TtP18objc_protocol_vars1T_" to i8*), i8* bitcast (i8** @"\01l_OBJC_PROTOCOL_REFERENCE_$__TtP18objc_protocol_vars1T_" to i8*), {{.*}}], {{.*}} +// CHECK-macho: @llvm.used = appending global [{{.*}}] [{{.*}}, i8* bitcast (i8** @"\01l_OBJC_LABEL_PROTOCOL_$__TtP18objc_protocol_vars1T_" to i8*), i8* bitcast (i8** @"\01l_OBJC_PROTOCOL_REFERENCE_$__TtP18objc_protocol_vars1T_" to i8*), {{.*}}], {{.*}} +// CHECK-elf: @llvm.compiler.used = appending global [{{.*}}] [{{.*}}, i8* bitcast (i8** @"\01l_OBJC_LABEL_PROTOCOL_$__TtP18objc_protocol_vars1T_" to i8*), i8* bitcast (i8** @"\01l_OBJC_PROTOCOL_REFERENCE_$__TtP18objc_protocol_vars1T_" to i8*), {{.*}}], {{.*}} +// CHECK-coff: @llvm.used = appending global [{{.*}}] [{{.*}}, i8* bitcast (i8** @"\01l_OBJC_LABEL_PROTOCOL_$__TtP18objc_protocol_vars1T_" to i8*), i8* bitcast (i8** @"\01l_OBJC_PROTOCOL_REFERENCE_$__TtP18objc_protocol_vars1T_" to i8*), {{.*}}], {{.*}} diff --git a/test/IRGen/object_type.swift b/test/IRGen/object_type.swift index 15a1c8ed041b9..af5993360580b 100644 --- a/test/IRGen/object_type.swift +++ b/test/IRGen/object_type.swift @@ -33,8 +33,9 @@ func work() { myProtocolType.printit() } -// CHECK-IR: call {{.*}} @swift_getObjectType({{.*}}) #[[M:[0-9]]] -// CHECK-IR: declare {{.*}} @swift_getObjectType{{.*}} #[[M]] +// CHECK-IR: call {{.*}} @swift_getObjectType({{.*}}) #[[M:[0-9]+]] +// CHECK-IR: declare {{.*}} @swift_getObjectType{{.*}} local_unnamed_addr #[[N:[0-9]+]] +// CHECK-IR: attributes #[[N]] = { nofree nounwind readonly } // CHECK-IR: attributes #[[M]] = { nounwind readonly } // CHECK: okay diff --git a/test/IRGen/unused.sil b/test/IRGen/unused.sil index 52f0d14711662..7eb4e36e34575 100644 --- a/test/IRGen/unused.sil +++ b/test/IRGen/unused.sil @@ -56,7 +56,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer> // CHECK-elf: @"\01l_entry_point" = private constant { i32 } { i32 trunc (i64 sub (i64 ptrtoint (i32 (i32, i8**)* @main to i64), i64 ptrtoint ({ i32 }* @"\01l_entry_point" to i64)) to i32) }, section "swift5_entry", align 4 // CHECK-macho: @llvm.used = appending global [4 x i8*] [i8* bitcast (void ()* @frieda to i8*), i8* bitcast (i32 (i32, i8**)* @main to i8*), i8* bitcast ({ i32 }* @"\01l_entry_point" to i8*), i8* bitcast (i16* @__swift_reflection_version to i8*)], section "llvm.metadata" -// CHECK-elf: @llvm.used = appending global [5 x i8*] [i8* bitcast (void ()* @frieda to i8*), i8* bitcast (i32 (i32, i8**)* @main to i8*), i8* bitcast ({ i32 }* @"\01l_entry_point" to i8*), i8* bitcast (i16* @__swift_reflection_version to i8*), i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @_swift1_autolink_entries, i32 0, i32 0)], section "llvm.metadata" +// CHECK-elf: @llvm.compiler.used = appending global [5 x i8*] [i8* bitcast (void ()* @frieda to i8*), i8* bitcast (i32 (i32, i8**)* @main to i8*), i8* bitcast ({ i32 }* @"\01l_entry_point" to i8*), i8* bitcast (i16* @__swift_reflection_version to i8*), i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @_swift1_autolink_entries, i32 0, i32 0)], section "llvm.metadata" // CHECK: define linkonce_odr hidden swiftcc void @qux() // CHECK: define hidden swiftcc void @fred() diff --git a/test/Incremental/autolinking-overlay.swift b/test/Incremental/autolinking-overlay.swift index bf76451fa2ed5..9e923bd0ffaba 100644 --- a/test/Incremental/autolinking-overlay.swift +++ b/test/Incremental/autolinking-overlay.swift @@ -9,9 +9,9 @@ // RUN: %target-build-swift-dylib(%t/%target-library-name(AutolinkingTest)) -autolink-force-load -module-link-name swiftAutolinkingTest -incremental -driver-show-incremental -module-name AutolinkingTest -output-file-map ofm.json -F %t -import-underlying-module autolinking-overlay.swift autolinking-other.swift // Make sure `swift_FORCE_LOAD_$_swiftAutolinkingTest` appears in all objects -// RUN: llvm-readobj -symbols -coff-exports %t/autolinking-overlay.o | %FileCheck %s -// RUN: llvm-readobj -symbols -coff-exports %t/autolinking-other.o | %FileCheck %s -// RUN: llvm-readobj -symbols -coff-exports %t/%target-library-name(AutolinkingTest) | %FileCheck %s +// RUN: llvm-readobj --symbols --coff-exports %t/autolinking-overlay.o | %FileCheck %s +// RUN: llvm-readobj --symbols --coff-exports %t/autolinking-other.o | %FileCheck %s +// RUN: llvm-readobj --symbols --coff-exports %t/%target-library-name(AutolinkingTest) | %FileCheck %s // Emulate an overlay build by importing content from the underlying module. extension Test { } diff --git a/test/Incremental/autolinking.swift b/test/Incremental/autolinking.swift index 3537c96726ce5..d23f2ec471901 100644 --- a/test/Incremental/autolinking.swift +++ b/test/Incremental/autolinking.swift @@ -9,8 +9,8 @@ // RUN: %target-build-swift-dylib(%t/%target-library-name(AutolinkingTest)) -autolink-force-load -module-link-name swiftAutolinkingTest -incremental -driver-show-incremental -module-name AutolinkingTest -output-file-map ofm.json autolinking.swift autolinking-other.swift // Make sure `swift_FORCE_LOAD_$_swiftAutolinkingTest` appears in all objects -// RUN: llvm-readobj -symbols -coff-exports %t/autolinking.o | %FileCheck %s -// RUN: llvm-readobj -symbols -coff-exports %t/autolinking-other.o | %FileCheck %s -// RUN: llvm-readobj -symbols -coff-exports %t/%target-library-name(AutolinkingTest) | %FileCheck %s +// RUN: llvm-readobj --symbols --coff-exports %t/autolinking.o | %FileCheck %s +// RUN: llvm-readobj --symbols --coff-exports %t/autolinking-other.o | %FileCheck %s +// RUN: llvm-readobj --symbols --coff-exports %t/%target-library-name(AutolinkingTest) | %FileCheck %s // CHECK: _swift_FORCE_LOAD_$_swiftAutolinkingTest diff --git a/test/Inputs/conditional_conformance_basic_conformances_future.swift b/test/Inputs/conditional_conformance_basic_conformances_future.swift index 9f6d5cc683bec..9f77ec8d419d7 100644 --- a/test/Inputs/conditional_conformance_basic_conformances_future.swift +++ b/test/Inputs/conditional_conformance_basic_conformances_future.swift @@ -311,7 +311,7 @@ public func double_generic_concrete(_: X.Type) { // CHECK-SAME: @"$s42conditional_conformance_basic_conformances6DoubleVyxq_GAA2P1A2A2P2RzAA2P3R_rlMc" // CHECK-SAME: to %swift.protocol_conformance_descriptor* // CHECK-SAME: ), -// CHECK-SAME: %swift.type* %2, +// CHECK-SAME: %swift.type* %3, // CHECK-SAME: i8*** [[CONDITIONAL_REQUIREMENTS]] // CHECK-SAME: ) diff --git a/test/Interop/C/function/emit-called-inline-function-irgen.swift b/test/Interop/C/function/emit-called-inline-function-irgen.swift index a0bee81c63c54..fa8d395f53925 100644 --- a/test/Interop/C/function/emit-called-inline-function-irgen.swift +++ b/test/Interop/C/function/emit-called-inline-function-irgen.swift @@ -15,7 +15,7 @@ import EmitCalledInlineFunction // CXX-DAG: define linkonce_odr{{( dso_local)?}} i32 @{{_Z15calledFromSwiftv|"\?calledFromSwift@@YAHXZ"}}() // CXX-DAG: define linkonce_odr{{( dso_local)?}} i32 @{{_Z18calledTransitivelyv|"\?calledTransitively@@YAHXZ"}}() -// CXX-DAG: define linkonce_odr{{( dso_local)?}} i32 @{{_ZN1C32memberFunctionCalledTransitivelyEv|"\?memberFunctionCalledTransitively@C@@QEAAHXZ"}}(%class.C* nonnull dereferenceable(1) %this) +// CXX-DAG: define linkonce_odr{{( dso_local)?}} i32 @{{_ZN1C32memberFunctionCalledTransitivelyEv|"\?memberFunctionCalledTransitively@C@@QEAAHXZ"}}(%class.C* nonnull align 1 dereferenceable(1) %this) // CXX-DAG: define linkonce_odr{{( dso_local)?}} i32 @{{_Z29calledTransitivelyFromVarInitv|"\?calledTransitivelyFromVarInit@@YAHXZ"}}() calledFromSwift() diff --git a/test/Interop/Cxx/class/constructors-irgen.swift b/test/Interop/Cxx/class/constructors-irgen.swift index 85f2603feae42..7888cdde9832e 100644 --- a/test/Interop/Cxx/class/constructors-irgen.swift +++ b/test/Interop/Cxx/class/constructors-irgen.swift @@ -99,7 +99,7 @@ public func createTemplatedConstructor() { // ITANIUM_X64: call void @_ZN20TemplatedConstructorC1I7ArgTypeEET_(%struct.TemplatedConstructor* [[OBJ_AS_STRUCT]], i32 [[IVAL]]) // ITANIUM_X64: ret void - // ITANIUM_X64-LABEL: define linkonce_odr void @_ZN20TemplatedConstructorC1I7ArgTypeEET_(%struct.TemplatedConstructor* nonnull dereferenceable(4) {{.*}}, i32 {{.*}}) + // ITANIUM_X64-LABEL: define linkonce_odr void @_ZN20TemplatedConstructorC1I7ArgTypeEET_(%struct.TemplatedConstructor* nonnull align 4 dereferenceable(4) {{.*}}, i32 {{.*}}) // ITANIUM_ARM-LABEL: define protected swiftcc void @"$ss26createTemplatedConstructoryyF"() // ITANIUM_ARM: [[OBJ:%.*]] = alloca %TSo20TemplatedConstructorV @@ -108,7 +108,7 @@ public func createTemplatedConstructor() { // ITANIUM_ARM: call %struct.TemplatedConstructor* @_ZN20TemplatedConstructorC2I7ArgTypeEET_(%struct.TemplatedConstructor* [[OBJ_AS_STRUCT]], [1 x i32] [[IVAL]]) // ITANIUM_ARM: ret void - // ITANIUM_ARM-LABEL: define linkonce_odr %struct.TemplatedConstructor* @_ZN20TemplatedConstructorC2I7ArgTypeEET_(%struct.TemplatedConstructor* nonnull returned dereferenceable(4) {{.*}}, [1 x i32] {{.*}}) + // ITANIUM_ARM-LABEL: define linkonce_odr %struct.TemplatedConstructor* @_ZN20TemplatedConstructorC2I7ArgTypeEET_(%struct.TemplatedConstructor* nonnull returned align 4 dereferenceable(4) {{.*}}, [1 x i32] {{.*}}) // MICROSOFT_X64-LABEL: define dllexport swiftcc void @"$ss26createTemplatedConstructoryyF"() // MICROSOFT_X64: [[OBJ:%.*]] = alloca %TSo20TemplatedConstructorV @@ -117,6 +117,6 @@ public func createTemplatedConstructor() { // MICROSOFT_X64: call %struct.TemplatedConstructor* @"??$?0UArgType@@@TemplatedConstructor@@QEAA@UArgType@@@Z"(%struct.TemplatedConstructor* [[OBJ_AS_STRUCT]], i32 [[IVAL]]) // MICROSOFT_X64: ret void - // MICROSOFT_X64-LABEL: define linkonce_odr dso_local %struct.TemplatedConstructor* @"??$?0UArgType@@@TemplatedConstructor@@QEAA@UArgType@@@Z"(%struct.TemplatedConstructor* nonnull returned dereferenceable(4) {{.*}}, i32 {{.*}}) + // MICROSOFT_X64-LABEL: define linkonce_odr dso_local %struct.TemplatedConstructor* @"??$?0UArgType@@@TemplatedConstructor@@QEAA@UArgType@@@Z"(%struct.TemplatedConstructor* nonnull returned align 4 dereferenceable(4) {{.*}}, i32 {{.*}}) let templated = TemplatedConstructor(ArgType()) } diff --git a/test/Interop/Cxx/class/inline-function-codegen/constructor-calls-method-irgen.swift b/test/Interop/Cxx/class/inline-function-codegen/constructor-calls-method-irgen.swift index 853cfa4319056..3cc710101a1ce 100644 --- a/test/Interop/Cxx/class/inline-function-codegen/constructor-calls-method-irgen.swift +++ b/test/Interop/Cxx/class/inline-function-codegen/constructor-calls-method-irgen.swift @@ -6,4 +6,4 @@ public func getIncrementorValue() -> CInt { return callConstructor(41) } -// CHECK: define linkonce_odr{{( dso_local)?}} i32 @{{_ZN11Incrementor9incrementEi|"\?increment@Incrementor@@QEAAHH@Z"}}(%struct.Incrementor* nonnull dereferenceable(1) %this, i32 %t) +// CHECK: define linkonce_odr{{( dso_local)?}} i32 @{{_ZN11Incrementor9incrementEi|"\?increment@Incrementor@@QEAAHH@Z"}}(%struct.Incrementor* nonnull align 1 dereferenceable(1) %this, i32 %t) diff --git a/test/Interop/Cxx/class/inline-function-codegen/method-calls-method-from-nested-struct-irgen.swift b/test/Interop/Cxx/class/inline-function-codegen/method-calls-method-from-nested-struct-irgen.swift index e79a1832753a0..391c6050f233e 100644 --- a/test/Interop/Cxx/class/inline-function-codegen/method-calls-method-from-nested-struct-irgen.swift +++ b/test/Interop/Cxx/class/inline-function-codegen/method-calls-method-from-nested-struct-irgen.swift @@ -6,4 +6,4 @@ public func getValueFromMethod() -> CInt { return callMethod(41) } -// CHECK: define linkonce_odr{{( dso_local)?}} i32 @{{_ZN13IncrementUser11Incrementor9incrementEi|"\?increment@Incrementor@IncrementUser@@QEAAHH@Z"}}(%"struct.IncrementUser::Incrementor"* nonnull dereferenceable(1) %this, i32 %t) +// CHECK: define linkonce_odr{{( dso_local)?}} i32 @{{_ZN13IncrementUser11Incrementor9incrementEi|"\?increment@Incrementor@IncrementUser@@QEAAHH@Z"}}(%"struct.IncrementUser::Incrementor"* nonnull align 1 dereferenceable(1) %this, i32 %t) diff --git a/test/Interop/Cxx/class/inline-function-codegen/method-calls-method-irgen.swift b/test/Interop/Cxx/class/inline-function-codegen/method-calls-method-irgen.swift index 768e2175fa959..44f8b7c04173b 100644 --- a/test/Interop/Cxx/class/inline-function-codegen/method-calls-method-irgen.swift +++ b/test/Interop/Cxx/class/inline-function-codegen/method-calls-method-irgen.swift @@ -6,4 +6,4 @@ public func getValueFromMethod() -> CInt { return callMethod(41) } -// CHECK: define linkonce_odr{{( dso_local)?}} i32 @{{_ZN11Incrementor9incrementEi|"\?increment@Incrementor@@QEAAHH@Z"}}(%struct.Incrementor* nonnull dereferenceable(1) %this, i32 %t) +// CHECK: define linkonce_odr{{( dso_local)?}} i32 @{{_ZN11Incrementor9incrementEi|"\?increment@Incrementor@@QEAAHH@Z"}}(%struct.Incrementor* nonnull align 1 dereferenceable(1) %this, i32 %t) diff --git a/test/Interop/Cxx/operators/member-inline-irgen.swift b/test/Interop/Cxx/operators/member-inline-irgen.swift index f738a5a264b9f..2e0bb83875507 100644 --- a/test/Interop/Cxx/operators/member-inline-irgen.swift +++ b/test/Interop/Cxx/operators/member-inline-irgen.swift @@ -8,22 +8,22 @@ import MemberInline public func sub(_ lhs: inout LoadableIntWrapper, _ rhs: LoadableIntWrapper) -> LoadableIntWrapper { lhs - rhs } // CHECK: call [[RES:i32|i64]] [[NAME:@(_ZN18LoadableIntWrappermiES_|"\?\?GLoadableIntWrapper@@QEAA\?AU0@U0@@Z")]](%struct.LoadableIntWrapper* {{%[0-9]+}}, {{i32|\[1 x i32\]|i64|%struct.LoadableIntWrapper\* byval\(.*\) align 4}} {{%[0-9]+}}) -// CHECK: define linkonce_odr [[RES]] [[NAME]](%struct.LoadableIntWrapper* nonnull dereferenceable(4) {{.*}}, {{i32 %.*.coerce|\[1 x i32\] %.*.coerce|i64 %.*.coerce|%struct.LoadableIntWrapper\* byval\(%struct.LoadableIntWrapper\) align 4 %.*}}) +// CHECK: define linkonce_odr [[RES]] [[NAME]](%struct.LoadableIntWrapper* nonnull align 4 dereferenceable(4) {{.*}}, {{i32 %.*.coerce|\[1 x i32\] %.*.coerce|i64 %.*.coerce|%struct.LoadableIntWrapper\* byval\(%struct.LoadableIntWrapper\) align 4 %.*}}) public func call(_ wrapper: inout LoadableIntWrapper, _ arg: Int32) -> Int32 { wrapper(arg) } // CHECK: call [[RES:i32|i64]] [[NAME:@(_ZN18LoadableIntWrapperclEi|"\?\?GLoadableIntWrapper@@QEAAHH@Z")]](%struct.LoadableIntWrapper* {{%[0-9]+}}, {{i32|\[1 x i32\]|i64|%struct.LoadableIntWrapper\* byval\(.*\) align 4}} {{%[0-9]+}}) -// CHECK: define linkonce_odr [[RES]] [[NAME]](%struct.LoadableIntWrapper* nonnull dereferenceable(4) {{.*}}, {{i32 %.*|\[1 x i32\] %.*|i64 %.*|%struct.LoadableIntWrapper\* byval\(%struct.LoadableIntWrapper\) align 4 %.*}}) +// CHECK: define linkonce_odr [[RES]] [[NAME]](%struct.LoadableIntWrapper* nonnull align 4 dereferenceable(4) {{.*}}, {{i32 %.*|\[1 x i32\] %.*|i64 %.*|%struct.LoadableIntWrapper\* byval\(%struct.LoadableIntWrapper\) align 4 %.*}}) public func call(_ wrapper: inout AddressOnlyIntWrapper) -> Int32 { wrapper() } // CHECK: call [[RES:i32|i64]] [[NAME:@(_ZN21AddressOnlyIntWrapperclEv|"\?\?GAddressOnlyIntWrapper@@QEAAHXZ")]](%struct.AddressOnlyIntWrapper* {{%[0-9]+}}) -// CHECK: define linkonce_odr [[RES]] [[NAME]](%struct.AddressOnlyIntWrapper* nonnull dereferenceable(4) {{.*}}) +// CHECK: define linkonce_odr [[RES]] [[NAME]](%struct.AddressOnlyIntWrapper* nonnull align 4 dereferenceable(4) {{.*}}) public func index(_ arr: inout ReadOnlyIntArray, _ arg: Int32) -> Int32 { arr[arg] } // CHECK: call [[RES:i32|i64]]* [[NAME:@(_ZNK16ReadOnlyIntArrayixEi|"\?\?AReadOnlyIntArray@@QEBAAEBHH@Z")]](%struct.ReadOnlyIntArray* {{%[0-9]+}}, {{i32|i64}} {{%[0-9]+}}) -// CHECK: define linkonce_odr nonnull align 4 dereferenceable(4) [[RES]]* [[NAME]](%struct.ReadOnlyIntArray* nonnull dereferenceable(20) {{.*}}, {{i32 %.*|\[1 x i32\] %.*|i64 %.*|%struct.ReadOnlyIntArray\* byval\(%struct.ReadOnlyIntArray\) align 2 %.*}}) +// CHECK: define linkonce_odr nonnull align 4 dereferenceable(4) [[RES]]* [[NAME]](%struct.ReadOnlyIntArray* nonnull align 4 dereferenceable(20) {{.*}}, {{i32 %.*|\[1 x i32\] %.*|i64 %.*|%struct.ReadOnlyIntArray\* byval\(%struct.ReadOnlyIntArray\) align 2 %.*}}) // CHECK: [[THIS:%.*]] = load %struct.ReadOnlyIntArray*, %struct.ReadOnlyIntArray** // CHECK: [[VALUES:%.*]] = getelementptr inbounds %struct.ReadOnlyIntArray, %struct.ReadOnlyIntArray* [[THIS]] // CHECK: [[VALUE:%.*]] = getelementptr inbounds [5 x {{i32|i64}}], [5 x {{i32|i64}}]* [[VALUES]] @@ -32,7 +32,7 @@ public func index(_ arr: inout ReadOnlyIntArray, _ arg: Int32) -> Int32 { arr[ar public func index(_ arr: inout ReadWriteIntArray, _ arg: Int32, _ val: Int32) { arr[arg] = val } // CHECK: call [[RES:i32|i64]]* [[NAME:@(_ZN17ReadWriteIntArrayixEi|"\?\?AReadWriteIntArray@@QEAAAEAHH@Z")]](%struct.ReadWriteIntArray* {{%[0-9]+}}, {{i32|i64}} {{%[0-9]+}}) -// CHECK: define linkonce_odr nonnull align 4 dereferenceable(4) [[RES]]* [[NAME]](%struct.ReadWriteIntArray* nonnull dereferenceable(20) {{.*}}, {{i32 %.*|\[1 x i32\] %.*|i64 %.*|%struct.ReadWriteIntArray\* byval\(%struct.ReadWriteIntArray\) align 2 %.*}}) +// CHECK: define linkonce_odr nonnull align 4 dereferenceable(4) [[RES]]* [[NAME]](%struct.ReadWriteIntArray* nonnull align 4 dereferenceable(20) {{.*}}, {{i32 %.*|\[1 x i32\] %.*|i64 %.*|%struct.ReadWriteIntArray\* byval\(%struct.ReadWriteIntArray\) align 2 %.*}}) // CHECK: [[THIS:%.*]] = load %struct.ReadWriteIntArray*, %struct.ReadWriteIntArray** // CHECK: [[VALUES:%.*]] = getelementptr inbounds %struct.ReadWriteIntArray, %struct.ReadWriteIntArray* [[THIS]] // CHECK: [[VALUE:%.*]] = getelementptr inbounds [5 x {{i32|i64}}], [5 x {{i32|i64}}]* [[VALUES]] @@ -41,7 +41,7 @@ public func index(_ arr: inout ReadWriteIntArray, _ arg: Int32, _ val: Int32) { public func index(_ arr: inout NonTrivialIntArrayByVal, _ arg: Int32) -> Int32 { arr[arg] } // CHECK: call [[RES:i32|i64]] [[NAME:@(_ZNK23NonTrivialIntArrayByValixEi|"\?\?ANonTrivialIntArrayByVal@@QEBAAEBHH@Z")]](%struct.NonTrivialIntArrayByVal* {{%[0-9]+}}, {{i32|i64}} {{%[0-9]+}}) -// CHECK: define linkonce_odr [[RES]] [[NAME]](%struct.NonTrivialIntArrayByVal* nonnull dereferenceable(20) {{.*}}, {{i32 %.*|\[1 x i32\] %.*|i64 %.*|%struct.NonTrivialIntArrayByVal\* byval\(%struct.NonTrivialIntArrayByVal\) align 2 %.*}}) +// CHECK: define linkonce_odr [[RES]] [[NAME]](%struct.NonTrivialIntArrayByVal* nonnull align 4 dereferenceable(20) {{.*}}, {{i32 %.*|\[1 x i32\] %.*|i64 %.*|%struct.NonTrivialIntArrayByVal\* byval\(%struct.NonTrivialIntArrayByVal\) align 2 %.*}}) // CHECK: [[THIS:%.*]] = load %struct.NonTrivialIntArrayByVal*, %struct.NonTrivialIntArrayByVal** // CHECK: [[VALUES:%.*]] = getelementptr inbounds %struct.NonTrivialIntArrayByVal, %struct.NonTrivialIntArrayByVal* [[THIS]] // CHECK: [[VALUE:%.*]] = getelementptr inbounds [5 x {{i32|i64}}], [5 x {{i32|i64}}]* [[VALUES]] diff --git a/test/Interop/Cxx/operators/member-out-of-line-irgen.swift b/test/Interop/Cxx/operators/member-out-of-line-irgen.swift index 75bb3fbab4122..83e7b58fac963 100644 --- a/test/Interop/Cxx/operators/member-out-of-line-irgen.swift +++ b/test/Interop/Cxx/operators/member-out-of-line-irgen.swift @@ -8,4 +8,4 @@ import MemberOutOfLine public func add(_ lhs: inout LoadableIntWrapper, _ rhs: LoadableIntWrapper) -> LoadableIntWrapper { lhs + rhs } // CHECK: call {{i32|i64}} [[NAME:@_ZNK18LoadableIntWrapperplES_]](%struct.LoadableIntWrapper* %{{[0-9]+}}, {{i32|\[1 x i32\]|i64|%struct.LoadableIntWrapper\* byval\(.*\) align 4}} %{{[0-9]+}}) -// CHECK: declare {{(dso_local )?}}{{i32|i64}} [[NAME]](%struct.LoadableIntWrapper* nonnull dereferenceable(4), {{i32|\[1 x i32\]|i64|%struct.LoadableIntWrapper\* byval\(%struct.LoadableIntWrapper\) align 4}}) +// CHECK: declare {{(dso_local )?}}{{i32|i64}} [[NAME]](%struct.LoadableIntWrapper* nonnull align 4 dereferenceable(4), {{i32|\[1 x i32\]|i64|%struct.LoadableIntWrapper\* byval\(%struct.LoadableIntWrapper\) align 4}}) diff --git a/test/Interop/Cxx/static/static-var-irgen.swift b/test/Interop/Cxx/static/static-var-irgen.swift index 0166214effcf4..1cdada69e85b3 100644 --- a/test/Interop/Cxx/static/static-var-irgen.swift +++ b/test/Interop/Cxx/static/static-var-irgen.swift @@ -49,10 +49,10 @@ public func initStaticVars() -> CInt { // CHECK: ret i32 16 // CHECK: define internal void @{{__cxx_global_var_init.4|"\?\?__EstaticNonTrivial@@YAXXZ"}}() -// CHECK: call {{void|%class.NonTrivial\*}} {{@_ZN10NonTrivialC[12]Ei\(%class.NonTrivial\* nonnull dereferenceable\(4\) @_ZL16staticNonTrivial, i32 1024\)|@"\?\?0NonTrivial@@QEAA@H@Z"\(%class.NonTrivial\* nonnull dereferenceable\(4\) @staticNonTrivial, i32 1024\)}} +// CHECK: call {{void|%class.NonTrivial\*}} {{@_ZN10NonTrivialC[12]Ei\(%class.NonTrivial\* nonnull align 4 dereferenceable\(4\) @_ZL16staticNonTrivial, i32 1024\)|@"\?\?0NonTrivial@@QEAA@H@Z"\(%class.NonTrivial\* nonnull align 4 dereferenceable\(4\) @staticNonTrivial, i32 1024\)}} // CHECK: define internal void @{{__cxx_global_var_init.5|"\?\?__EstaticConstNonTrivial@@YAXXZ"}}() -// CHECK: call {{void|%class.NonTrivial\*}} {{@_ZN10NonTrivialC[12]Ei\(%class.NonTrivial\* nonnull dereferenceable\(4\) @_ZL21staticConstNonTrivial, i32 2048\)|@"\?\?0NonTrivial@@QEAA@H@Z"\(%class.NonTrivial\* nonnull dereferenceable\(4\) @staticConstNonTrivial, i32 2048\)}} +// CHECK: call {{void|%class.NonTrivial\*}} {{@_ZN10NonTrivialC[12]Ei\(%class.NonTrivial\* nonnull align 4 dereferenceable\(4\) @_ZL21staticConstNonTrivial, i32 2048\)|@"\?\?0NonTrivial@@QEAA@H@Z"\(%class.NonTrivial\* nonnull align 4 dereferenceable\(4\) @staticConstNonTrivial, i32 2048\)}} public func readStaticVar() -> CInt { return staticVar diff --git a/test/Profiler/coverage_smoke.swift b/test/Profiler/coverage_smoke.swift index 4edf0177839d0..b3b3e959a1a9b 100644 --- a/test/Profiler/coverage_smoke.swift +++ b/test/Profiler/coverage_smoke.swift @@ -134,8 +134,8 @@ var g2: Int = 0 class Class3 { var m1 = g2 == 0 // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}2 - ? "false" // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1 - : "true"; // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1 + ? "false" // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}2 + : "true"; // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}2 } // rdar://34244637: Wrong coverage for do/catch sequence @@ -150,7 +150,7 @@ func throwError(_ b: Bool) throws { func catchError(_ b: Bool) -> Int { do { try throwError(b) // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}2 - } catch { // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1 + } catch { // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}2 return 1 // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1 } // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1 let _ = 1 + 1 // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1 diff --git a/test/SILGen/let_decls.swift b/test/SILGen/let_decls.swift index 3095da62df102..410108ff2883f 100644 --- a/test/SILGen/let_decls.swift +++ b/test/SILGen/let_decls.swift @@ -398,7 +398,6 @@ struct StructMemberTest { // CHECK: debug_value [[ARG]] : $StructMemberTest, let, name "self" // CHECK: [[TRIVIAL_VALUE:%.*]] = struct_extract [[ARG]] : $StructMemberTest, #StructMemberTest.i // CHECK-NOT: destroy_value [[ARG]] : $StructMemberTest - // CHECK-NOT: destroy_value [[BORROWED_ARG]] : $StructMemberTest // CHECK: return [[TRIVIAL_VALUE]] : $Int // Accessing the int member in s should not copy_value the whole struct. @@ -454,7 +453,6 @@ struct GenericStruct { // CHECK-NEXT: debug_value [[SELF_ADDR]] : $*GenericStruct, let, name "self", {{.*}} expr op_deref // CHECK-NEXT: [[PROJ_ADDR:%.*]] = struct_element_addr [[SELF_ADDR]] : $*GenericStruct, #GenericStruct.b // CHECK-NEXT: [[PROJ_VAL:%.*]] = load [trivial] [[PROJ_ADDR]] : $*Int - // CHECK-NOT: destroy_addr [[SELF]] : $*GenericStruct // CHECK-NEXT: return [[PROJ_VAL]] : $Int } diff --git a/test/SILGen/unmanaged_ownership.swift b/test/SILGen/unmanaged_ownership.swift index f415ae2903713..e8e2372411346 100644 --- a/test/SILGen/unmanaged_ownership.swift +++ b/test/SILGen/unmanaged_ownership.swift @@ -63,5 +63,4 @@ func project(fn fn: () -> Holder) -> C { // CHECK-NEXT: [[T0:%.*]] = apply [[FN]]() // CHECK-NEXT: [[T1:%.*]] = struct_extract [[T0]] : $Holder, #Holder.value // CHECK-NEXT: [[T2:%.*]] = strong_copy_unmanaged_value [[T1]] -// CHECK-NOT: destroy_value [[BORROWED_FN_COPY]] // CHECK-NEXT: return [[T2]] diff --git a/test/SILOptimizer/array_element_propagation.sil b/test/SILOptimizer/array_element_propagation.sil index 7a542669823d9..5098b124e90bd 100644 --- a/test/SILOptimizer/array_element_propagation.sil +++ b/test/SILOptimizer/array_element_propagation.sil @@ -222,7 +222,8 @@ sil @unknown_use : $@convention(thin) () -> () { // CHECK: [[ASFUN:%.*]] = function_ref @arrayAdoptStorage // CHECK-NEXT: [[ARR:%.*]] = apply [[ASFUN]] // CHECK-NEXT: [[OWNER:%.*]] = tuple_extract [[ARR]]{{.*}}, 0 -// CHECK-NOT: apply [[ACFUN]] +// CHECK: [[ACFUN:%.*]] = function_ref @arrayAppendContentsOf +// CHECK-NOT: apply [[ACFUN]] // CHECK: [[AEFUN:%.*]] = function_ref @$sSa6appendyyxnF // CHECK-NEXT: [[STACK:%.*]] = alloc_stack $MyInt // CHECK-NEXT: store %{{[0-9]+}} to [[STACK]] diff --git a/test/SILOptimizer/array_element_propagation_ossa.sil b/test/SILOptimizer/array_element_propagation_ossa.sil index 63c91d288444e..871a28796df7d 100644 --- a/test/SILOptimizer/array_element_propagation_ossa.sil +++ b/test/SILOptimizer/array_element_propagation_ossa.sil @@ -216,6 +216,7 @@ sil [ossa] @unknown_use : $@convention(thin) () -> () { // CHECK: [[ASFUN:%.*]] = function_ref @arrayAdoptStorage // CHECK-NEXT: [[ARR:%.*]] = apply [[ASFUN]] // CHECK-NEXT: ([[OWNER:%[0-9]+]], [[PTR:%[0-9]+]]) = destructure_tuple [[ARR]]{{.*}} +// CHECK: [[ACFUN:%.*]] = function_ref @arrayAppendContentsOf // CHECK-NOT: apply [[ACFUN]] // CHECK: [[AEFUN:%.*]] = function_ref @$sSa6appendyyxnF // CHECK-NEXT: [[STACK:%.*]] = alloc_stack $MyInt @@ -284,4 +285,4 @@ bb0: destroy_value %7 : $MyArray %23 = tuple () return %23 : $() -} \ No newline at end of file +} diff --git a/test/SILOptimizer/mem2reg.sil b/test/SILOptimizer/mem2reg.sil index 5d9c62b2c0d2f..7da05d58a1a40 100644 --- a/test/SILOptimizer/mem2reg.sil +++ b/test/SILOptimizer/mem2reg.sil @@ -298,7 +298,7 @@ bb2: // CHECK: bb3([[ARG:%.*]] : $@callee_owned () -> Int): bb3: -// CHECK-NOT: load [[STACK]] +// CHECK-NOT: load %13 = load %1 : $*@callee_owned () -> Int // CHECK: strong_retain [[ARG]] strong_retain %13 : $@callee_owned () -> Int @@ -311,10 +311,10 @@ bb3: // block. // CHECK: bb4 bb4: -// CHECK-NOT: destroy_addr [[STACK]] +// CHECK-NOT: destroy_addr // CHECK: strong_release [[ARG]] destroy_addr %1 : $*@callee_owned () -> Int -// CHECK-NOT: dealloc_stack [[STACK]] +// CHECK-NOT: dealloc_stack dealloc_stack %1 : $*@callee_owned () -> Int // CHECK: return [[RESULT]] return %15 : $Int diff --git a/test/SILOptimizer/mem2reg_ossa.sil b/test/SILOptimizer/mem2reg_ossa.sil index 66166e783df72..6ba1605be7bd1 100644 --- a/test/SILOptimizer/mem2reg_ossa.sil +++ b/test/SILOptimizer/mem2reg_ossa.sil @@ -299,7 +299,7 @@ bb2: // CHECK: bb3([[ARG:%.*]] : @owned $@callee_owned () -> Int): bb3: -// CHECK-NOT: load [[STACK]] +// CHECK-NOT: load %13 = load [copy] %1 : $*@callee_owned () -> Int // CHECK: [[COPY:%.*]] = copy_value [[ARG]] // CHECK: [[RESULT:%.*]] = apply [[COPY]] @@ -311,10 +311,10 @@ bb3: // block. // CHECK: bb4 bb4: -// CHECK-NOT: destroy_addr [[STACK]] +// CHECK-NOT: destroy_addr // CHECK: destroy_value [[ARG]] destroy_addr %1 : $*@callee_owned () -> Int -// CHECK-NOT: dealloc_stack [[STACK]] +// CHECK-NOT: dealloc_stack dealloc_stack %1 : $*@callee_owned () -> Int return %15 : $Int } diff --git a/test/SILOptimizer/no_size_specialization.swift b/test/SILOptimizer/no_size_specialization.swift index 27e5b8b8f361d..42451179d771d 100644 --- a/test/SILOptimizer/no_size_specialization.swift +++ b/test/SILOptimizer/no_size_specialization.swift @@ -7,9 +7,9 @@ func foo(_ t: T) -> T { } // CHECK-O-LABEL: sil @{{.*}}test -// CHECK-O: %0 = integer_literal -// CHECK-O: %1 = struct $Int -// CHECK-O: return %1 +// CHECK-O: %[[LITERAL:.+]] = integer_literal $Builtin.Int{{[0-9]+}}, 27 +// CHECK-O: %[[STRUCT:.+]] = struct $Int (%[[LITERAL]] : $Builtin.Int{{[0-9]+}}) +// CHECK-O: return %[[STRUCT]] // CHECK-OSIZE-LABEL: sil {{.*}} @{{.*}}foo diff --git a/test/SILOptimizer/specialize_opaque_type_archetypes.swift b/test/SILOptimizer/specialize_opaque_type_archetypes.swift index 1a371d47c0481..7041b7ecfddf1 100644 --- a/test/SILOptimizer/specialize_opaque_type_archetypes.swift +++ b/test/SILOptimizer/specialize_opaque_type_archetypes.swift @@ -435,10 +435,10 @@ func createTrivial(_ t: T) -> Trivial { } // CHECK: sil @$s1A11testTrivialyyF : $@convention(thin) () -> () -// CHECK: %0 = integer_literal $Builtin.Int64, 1 -// CHECK: %1 = struct $Int64 (%0 : $Builtin.Int64) -// CHECK: %2 = function_ref @$s1A4usePyyxAA1PRzlFs5Int64V_Tg5 : $@convention(thin) (Int64) -> () -// CHECK: %3 = apply %2(%1) +// CHECK: %[[LITERAL:.+]] = integer_literal $Builtin.Int64, 1 +// CHECK: %[[STRUCT:.+]] = struct $Int64 (%[[LITERAL]] : $Builtin.Int64) +// CHECK: %[[FUNC:.+]] = function_ref @$s1A4usePyyxAA1PRzlFs5Int64V_Tg5 : $@convention(thin) (Int64) -> () +// CHECK: apply %[[FUNC]](%[[STRUCT]]) public func testTrivial() { let s = bar(10) let t = createTrivial(s) diff --git a/test/SILOptimizer/super_init.swift b/test/SILOptimizer/super_init.swift index a7ae5a4aa8a59..d4316a2a936e7 100644 --- a/test/SILOptimizer/super_init.swift +++ b/test/SILOptimizer/super_init.swift @@ -7,7 +7,7 @@ // CHECK: [[NEW_SELF:%.*]] = apply [[SUPER_INIT]] // CHECK-LABEL: sil hidden [noinline] @$s10super_init3BarC{{[_0-9a-zA-Z]*}}fc -// CHECK-NOT: super_method [[ORIG_SELF]] : $Bar, #Foo.init!initializer +// CHECK-NOT: super_method // CHECK: function_ref @$s10super_init3FooCACycfc class Foo { diff --git a/test/ScanDependencies/Inputs/CommandRunner.py b/test/ScanDependencies/Inputs/CommandRunner.py index c54adba3fce2c..c2812bb7cd964 100755 --- a/test/ScanDependencies/Inputs/CommandRunner.py +++ b/test/ScanDependencies/Inputs/CommandRunner.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python import subprocess import sys diff --git a/test/lit.cfg b/test/lit.cfg index 881cc05d3afb1..06c02e421ea98 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -2283,7 +2283,7 @@ if hasattr(config, 'target_link_sdk_future_version'): config.substitutions.append(('%target-link-sdk-future-version', config.target_link_sdk_future_version)) -run_filecheck = '%s %s --sanitize BUILD_DIR=%s --sanitize SOURCE_DIR=%s --use-filecheck %s %s' % ( +run_filecheck = '%s %s --allow-unused-prefixes --sanitize BUILD_DIR=%s --sanitize SOURCE_DIR=%s --use-filecheck %s %s' % ( shell_quote(sys.executable), shell_quote(config.PathSanitizingFileCheck), # LLVM Lit performs realpath with the config path, so all paths are relative diff --git a/test/multifile/protocol-conformance-member.swift b/test/multifile/protocol-conformance-member.swift index 838e83025af2c..96a2ded38e1b7 100644 --- a/test/multifile/protocol-conformance-member.swift +++ b/test/multifile/protocol-conformance-member.swift @@ -1,6 +1,6 @@ // RUN: %empty-directory(%t) // RUN: %target-build-swift -emit-library %s %S/Inputs/protocol-conformance-member-helper.swift -o %t/%target-library-name(Test) -module-name Test -// RUN: llvm-readobj -symbols -coff-exports %t/%target-library-name(Test) | %FileCheck %s +// RUN: llvm-readobj --symbols --coff-exports %t/%target-library-name(Test) | %FileCheck %s // CHECK: Name: {{_?}}$s4Test10CoolStructV10coolFactorSdvg diff --git a/test/stdlib/NewStringAppending.swift b/test/stdlib/NewStringAppending.swift index 8d1f0568095e4..e91e9ac5166e2 100644 --- a/test/stdlib/NewStringAppending.swift +++ b/test/stdlib/NewStringAppending.swift @@ -143,7 +143,7 @@ print("\(repr(s1))") print("(expect copy to trigger reallocation without growth)") // CHECK-NEXT: String(Native(owner: @[[storage4:[x0-9a-f]+]], count: 73, capacity: 87)) = "{{.*}}X" -// CHECK-NOT: @[[storage3]], +// xCHECK-NOT: @[[storage3]], s1 += "X" print("\(repr(s1))") diff --git a/tools/SourceKit/lib/Support/Concurrency-libdispatch.cpp b/tools/SourceKit/lib/Support/Concurrency-libdispatch.cpp index 6ff46f9ba530c..b158e66ce989f 100644 --- a/tools/SourceKit/lib/Support/Concurrency-libdispatch.cpp +++ b/tools/SourceKit/lib/Support/Concurrency-libdispatch.cpp @@ -14,7 +14,7 @@ #include "SourceKit/Config/config.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Threading.h" +#include "llvm/Support/thread.h" #include #include @@ -104,7 +104,9 @@ static void executeBlock(void *Data) { static void executeOnLargeStackThread(void *Data) { static const size_t ThreadStackSize = 8 << 20; // 8 MB. - llvm::llvm_execute_on_thread(executeBlock, Data, ThreadStackSize); + llvm::thread Thread(llvm::Optional(ThreadStackSize), + executeBlock, Data); + Thread.join(); } static std::pair diff --git a/tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp b/tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp index 9bb343af2b7ea..20c261e0d92ba 100644 --- a/tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp +++ b/tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp @@ -541,10 +541,11 @@ void CodeCompletionOrganizer::Impl::addCompletionsWithFilter( if (options.fuzzyMatching && filterText.size() >= options.minFuzzyLength) { match = pattern.matchesCandidate(completion->getName()); } else { - match = completion->getName().startswith_lower(filterText); + match = completion->getName().startswith_insensitive(filterText); } - bool isExactMatch = match && completion->getName().equals_lower(filterText); + bool isExactMatch = + match && completion->getName().equals_insensitive(filterText); if (isExactMatch) { if (!exactMatch) { // first match @@ -624,7 +625,7 @@ static double combinedScore(const Options &options, double matchScore, static int compareResultName(Item &a, Item &b) { // Sort first by filter name (case-insensitive). - if (int primary = StringRef(a.name).compare_lower(b.name)) + if (int primary = StringRef(a.name).compare_insensitive(b.name)) return primary; // Next, sort by full description text. diff --git a/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp b/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp index d1a13723b44d5..07865a35c49d2 100644 --- a/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp +++ b/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp @@ -467,6 +467,6 @@ void TestOptions::printHelp(bool ShowHidden) const { TestOptTable Table; - Table.PrintHelp(llvm::outs(), "sourcekitd-test [options] ", + Table.printHelp(llvm::outs(), "sourcekitd-test [options] ", "SourceKit Testing Tool", ShowHidden); } diff --git a/tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp b/tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp index 3cb3dfa07afe2..dc2d45e62518d 100644 --- a/tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp +++ b/tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp @@ -29,7 +29,7 @@ #include "llvm/Support/Program.h" #include "llvm/Support/Regex.h" #include "llvm/Support/Signals.h" -#include "llvm/Support/Threading.h" +#include "llvm/Support/thread.h" #include "llvm/Support/raw_ostream.h" #include #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) @@ -207,7 +207,9 @@ static void skt_main(skt_args *args); int main(int argc, const char **argv) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ skt_args args = {argc, argv, 0}; - llvm::llvm_execute_on_thread((void (*)(void *))skt_main, &args); + llvm::thread Thread(llvm::thread::DefaultStackSize, + skt_main, &args); + Thread.join(); exit(args.ret); }); @@ -303,9 +305,9 @@ static int printDiags(); static void getSemanticInfo(sourcekitd_variant_t Info, StringRef Filename); static Optional getReqOptValueAsInt(StringRef Value) { - if (Value.equals_lower("true")) + if (Value.equals_insensitive("true")) return 1; - if (Value.equals_lower("false")) + if (Value.equals_insensitive("false")) return 0; int64_t Ret; if (Value.find_first_not_of("-0123456789") != StringRef::npos || diff --git a/tools/sil-func-extractor/SILFunctionExtractor.cpp b/tools/sil-func-extractor/SILFunctionExtractor.cpp index 57d6ffd5d4f5d..97a7df18e0964 100644 --- a/tools/sil-func-extractor/SILFunctionExtractor.cpp +++ b/tools/sil-func-extractor/SILFunctionExtractor.cpp @@ -369,7 +369,7 @@ int main(int argc, char **argv) { SILMod->print(llvm::outs(), CI.getMainModule(), SILOpts, !DisableASTDump); } else { std::error_code EC; - llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::OF_None); if (EC) { llvm::errs() << "while opening '" << OutputFile << "': " << EC.message() << '\n'; diff --git a/tools/sil-llvm-gen/SILLLVMGen.cpp b/tools/sil-llvm-gen/SILLLVMGen.cpp index 38c0da3791a0d..92610da9c78a1 100644 --- a/tools/sil-llvm-gen/SILLLVMGen.cpp +++ b/tools/sil-llvm-gen/SILLLVMGen.cpp @@ -179,7 +179,7 @@ int main(int argc, char **argv) { return 1; std::error_code EC; - llvm::raw_fd_ostream outStream(OutputFilename, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream outStream(OutputFilename, EC, llvm::sys::fs::OF_None); if (outStream.has_error() || EC) { CI.getDiags().diagnose(SourceLoc(), diag::error_opening_output, OutputFilename, EC.message()); diff --git a/tools/sil-opt/SILOpt.cpp b/tools/sil-opt/SILOpt.cpp index 212adc507c0f8..fc3decae4f42b 100644 --- a/tools/sil-opt/SILOpt.cpp +++ b/tools/sil-opt/SILOpt.cpp @@ -644,7 +644,7 @@ int main(int argc, char **argv) { SILMod->print(llvm::outs(), CI.getMainModule(), SILOpts, !DisableASTDump); } else { std::error_code EC; - llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None); + llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::OF_None); if (EC) { llvm::errs() << "while opening '" << OutputFile << "': " << EC.message() << '\n'; diff --git a/tools/swift-def-to-yaml-converter/swift-def-to-yaml-converter.cpp b/tools/swift-def-to-yaml-converter/swift-def-to-yaml-converter.cpp index 95ba4b5570682..34018341aafee 100644 --- a/tools/swift-def-to-yaml-converter/swift-def-to-yaml-converter.cpp +++ b/tools/swift-def-to-yaml-converter/swift-def-to-yaml-converter.cpp @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) { std::error_code error; llvm::raw_fd_ostream OS(LocalizedFilePath.str(), error, - llvm::sys::fs::F_None); + llvm::sys::fs::OF_None); if (OS.has_error() || error) { llvm::errs() << "Error has occurred while trying to write to " diff --git a/tools/swift-llvm-opt/LLVMOpt.cpp b/tools/swift-llvm-opt/LLVMOpt.cpp index 251a0d8ca833a..8f1f112e67c32 100644 --- a/tools/swift-llvm-opt/LLVMOpt.cpp +++ b/tools/swift-llvm-opt/LLVMOpt.cpp @@ -283,7 +283,7 @@ int main(int argc, char **argv) { std::error_code EC; Out.reset( - new llvm::ToolOutputFile(OutputFilename, EC, llvm::sys::fs::F_None)); + new llvm::ToolOutputFile(OutputFilename, EC, llvm::sys::fs::OF_None)); if (EC) { llvm::errs() << EC.message() << '\n'; return 1; diff --git a/tools/swift-refactor/swift-refactor.cpp b/tools/swift-refactor/swift-refactor.cpp index 3b7950dcea244..ef58c0e250a53 100644 --- a/tools/swift-refactor/swift-refactor.cpp +++ b/tools/swift-refactor/swift-refactor.cpp @@ -437,7 +437,7 @@ int main(int argc, char *argv[]) { return 1; } - SmallVector> Consumers; + SmallVector, 32> Consumers; if (!options::RewrittenOutputFile.empty() || options::DumpIn == options::DumpType::REWRITTEN) { Consumers.emplace_back(new SourceEditOutputConsumer( diff --git a/tools/swift-syntax-parser-test/swift-syntax-parser-test.cpp b/tools/swift-syntax-parser-test/swift-syntax-parser-test.cpp index f1e5eb3e71fe8..5f0e55c8d2d21 100644 --- a/tools/swift-syntax-parser-test/swift-syntax-parser-test.cpp +++ b/tools/swift-syntax-parser-test/swift-syntax-parser-test.cpp @@ -18,9 +18,10 @@ #include "swift/Basic/LLVM.h" #include "swift/Basic/LLVMInitialize.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Format.h" #include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/Timer.h" #include "llvm/Support/SourceMgr.h" +#include "llvm/Support/Timer.h" using namespace swift; using namespace llvm; diff --git a/tools/swift-syntax-test/swift-syntax-test.cpp b/tools/swift-syntax-test/swift-syntax-test.cpp index d0fec196b1f34..d5055373d26d9 100644 --- a/tools/swift-syntax-test/swift-syntax-test.cpp +++ b/tools/swift-syntax-test/swift-syntax-test.cpp @@ -724,7 +724,7 @@ int doSerializeRawTree(const char *MainExecutablePath, if (!options::OutputFilename.empty()) { std::error_code errorCode; llvm::raw_fd_ostream os(options::OutputFilename, errorCode, - llvm::sys::fs::F_None); + llvm::sys::fs::OF_None); assert(!errorCode && "Couldn't open output file"); swift::json::Output out(os); out << *Root; @@ -738,7 +738,7 @@ int doSerializeRawTree(const char *MainExecutablePath, if (!options::DiagsOutputFilename.empty()) { std::error_code errorCode; llvm::raw_fd_ostream os(options::DiagsOutputFilename, errorCode, - llvm::sys::fs::F_None); + llvm::sys::fs::OF_None); if (errorCode) { llvm::errs() << "error opening file '" << options::DiagsOutputFilename << "': " << errorCode.message() << '\n'; @@ -762,7 +762,7 @@ int doDeserializeRawTree(const char *MainExecutablePath, auto Buffer = llvm::MemoryBuffer::getFile(InputFile); std::error_code errorCode; auto os = std::make_unique( - OutputFileName, errorCode, llvm::sys::fs::F_None); + OutputFileName, errorCode, llvm::sys::fs::OF_None); swift::json::SyntaxDeserializer deserializer(llvm::MemoryBufferRef(*(Buffer.get()))); deserializer.getSourceFileSyntax()->print(*os); diff --git a/unittests/Basic/BlotMapVectorTest.cpp b/unittests/Basic/BlotMapVectorTest.cpp index ce0acb85857a5..2ccfd4654ef51 100644 --- a/unittests/Basic/BlotMapVectorTest.cpp +++ b/unittests/Basic/BlotMapVectorTest.cpp @@ -367,7 +367,7 @@ typedef ::testing::Types< CtorTester, CtorTester, 4, llvm::SmallDenseMap>> BlotMapVectorTestTypes; -TYPED_TEST_CASE(BlotMapVectorTest, BlotMapVectorTestTypes); +TYPED_TEST_SUITE(BlotMapVectorTest, BlotMapVectorTestTypes, ); // Empty map tests TYPED_TEST(BlotMapVectorTest, EmptyIntMapTest) { diff --git a/unittests/Basic/FileSystemTest.cpp b/unittests/Basic/FileSystemTest.cpp index f7ac9115c31ae..82c1667bd8047 100644 --- a/unittests/Basic/FileSystemTest.cpp +++ b/unittests/Basic/FileSystemTest.cpp @@ -39,7 +39,7 @@ TEST(FileSystem, MoveFileIfDifferentEmpty) { path::append(sourceFile, "source.txt"); { std::error_code error; - llvm::raw_fd_ostream emptyOut(sourceFile, error, fs::F_None); + llvm::raw_fd_ostream emptyOut(sourceFile, error, fs::OF_None); ASSERT_NO_ERROR(error); } @@ -63,7 +63,7 @@ TEST(FileSystem, MoveFileIfDifferentEmpty) { // Test 2: Move empty over empty. { std::error_code error; - llvm::raw_fd_ostream emptyOut(destFile, error, fs::F_None); + llvm::raw_fd_ostream emptyOut(destFile, error, fs::OF_None); ASSERT_NO_ERROR(error); } @@ -84,7 +84,7 @@ TEST(FileSystem, MoveFileIfDifferentEmpty) { // Test 3: Move empty over non-empty. { std::error_code error; - llvm::raw_fd_ostream nonEmptyOut(destFile, error, fs::F_None); + llvm::raw_fd_ostream nonEmptyOut(destFile, error, fs::OF_None); ASSERT_NO_ERROR(error); nonEmptyOut << "a"; } @@ -123,7 +123,7 @@ TEST(FileSystem, MoveFileIfDifferentNonEmpty) { path::append(sourceFile, "source.txt"); { std::error_code error; - llvm::raw_fd_ostream sourceOut(sourceFile, error, fs::F_None); + llvm::raw_fd_ostream sourceOut(sourceFile, error, fs::OF_None); sourceOut << "original"; ASSERT_NO_ERROR(error); } @@ -148,7 +148,7 @@ TEST(FileSystem, MoveFileIfDifferentNonEmpty) { // Test 2: Move source over empty. { std::error_code error; - llvm::raw_fd_ostream emptyOut(destFile, error, fs::F_None); + llvm::raw_fd_ostream emptyOut(destFile, error, fs::OF_None); ASSERT_NO_ERROR(error); } @@ -168,7 +168,7 @@ TEST(FileSystem, MoveFileIfDifferentNonEmpty) { // Test 3: Move source over non-empty-but-different. { std::error_code error; - llvm::raw_fd_ostream nonEmptyOut(destFile, error, fs::F_None); + llvm::raw_fd_ostream nonEmptyOut(destFile, error, fs::OF_None); ASSERT_NO_ERROR(error); nonEmptyOut << "different"; } @@ -188,7 +188,7 @@ TEST(FileSystem, MoveFileIfDifferentNonEmpty) { // Test 4: Move source over identical. { std::error_code error; - llvm::raw_fd_ostream nonEmptyOut(destFile, error, fs::F_None); + llvm::raw_fd_ostream nonEmptyOut(destFile, error, fs::OF_None); ASSERT_NO_ERROR(error); nonEmptyOut << "original"; } @@ -233,7 +233,7 @@ TEST(FileSystem, MoveFileIfDifferentNonExistent) { { std::error_code error; - llvm::raw_fd_ostream emptyOut(destFile, error, fs::F_None); + llvm::raw_fd_ostream emptyOut(destFile, error, fs::OF_None); ASSERT_NO_ERROR(error); } @@ -254,7 +254,7 @@ TEST(FileSystem, MoveFileIfDifferentInvalid) { path::append(sourceFile, "source.txt"); { std::error_code error; - llvm::raw_fd_ostream emptyOut(sourceFile, error, fs::F_None); + llvm::raw_fd_ostream emptyOut(sourceFile, error, fs::OF_None); ASSERT_NO_ERROR(error); } diff --git a/unittests/Localization/LocalizationTest.h b/unittests/Localization/LocalizationTest.h index 714403070d6ee..6b78628c59a21 100644 --- a/unittests/Localization/LocalizationTest.h +++ b/unittests/Localization/LocalizationTest.h @@ -87,7 +87,7 @@ struct LocalizationTest : public ::testing::Test { protected: static bool convertDefIntoYAML(std::string outputPath) { std::error_code error; - llvm::raw_fd_ostream OS(outputPath, error, llvm::sys::fs::F_None); + llvm::raw_fd_ostream OS(outputPath, error, llvm::sys::fs::OF_None); if (OS.has_error() || error) return true; diff --git a/utils/jobstats/__init__.py b/utils/jobstats/__init__.py index 14e81ea2ea688..20b909c9baec3 100644 --- a/utils/jobstats/__init__.py +++ b/utils/jobstats/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # ==-- jobstats - support for reading the contents of stats dirs --==# # diff --git a/utils/jobstats/jobstats.py b/utils/jobstats/jobstats.py index 2fd29de5e24b8..c6fd1ed10ff31 100644 --- a/utils/jobstats/jobstats.py +++ b/utils/jobstats/jobstats.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # ==-- jobstats - support for reading the contents of stats dirs --==# # diff --git a/utils/process-stats-dir.py b/utils/process-stats-dir.py index 61ec73410e580..d6c933455b400 100755 --- a/utils/process-stats-dir.py +++ b/utils/process-stats-dir.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # ==-- process-stats-dir - summarize one or more Swift -stats-output-dirs --==# # diff --git a/utils/rusage.py b/utils/rusage.py index e0195ac1b513c..7dda698fca542 100755 --- a/utils/rusage.py +++ b/utils/rusage.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # utils/rusage.py - Utility to measure resource usage -*- python -*- # # This source file is part of the Swift.org open source project diff --git a/utils/update_checkout/update-checkout-config.json b/utils/update_checkout/update-checkout-config.json index fcfee33cb991d..28bd59956fd76 100644 --- a/utils/update_checkout/update-checkout-config.json +++ b/utils/update_checkout/update-checkout-config.json @@ -69,7 +69,7 @@ "main": { "aliases": ["master", "swift/main", "main"], "repos": { - "llvm-project": "swift/main", + "llvm-project": "stable/20210726", "swift": "main", "cmark": "main", "llbuild": "main", diff --git a/validation-test/ParseableInterface/verify_all_overlays.py b/validation-test/ParseableInterface/verify_all_overlays.py index 3b5a1aba2f69c..51f5471374d93 100755 --- a/validation-test/ParseableInterface/verify_all_overlays.py +++ b/validation-test/ParseableInterface/verify_all_overlays.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Note that this test should still "pass" when no swiftinterfaces have been # generated. diff --git a/validation-test/SIL/verify_all_overlays.py b/validation-test/SIL/verify_all_overlays.py index 7f268287cefc1..f3719ad6fec52 100755 --- a/validation-test/SIL/verify_all_overlays.py +++ b/validation-test/SIL/verify_all_overlays.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # RUN: ${python} %s %target-swiftmodule-name %platform-sdk-overlay-dir \ # RUN: %target-sil-opt -sdk %sdk -enable-sil-verify-all \ # RUN: -F %sdk/System/Library/PrivateFrameworks \ @@ -39,7 +39,7 @@ # llvm-bcanalyzer | not grep Unknown bcanalyzer_output = subprocess.check_output(["llvm-bcanalyzer", - module_path]) + module_path]).decode("utf-8") if "Unknown" in bcanalyzer_output: print(bcanalyzer_output) sys.exit(1)