From 95af3aa7c8b860d765f3bcba8a0466e80fa3021c Mon Sep 17 00:00:00 2001 From: Hugh Bellamy Date: Thu, 22 Dec 2016 11:51:55 +0000 Subject: [PATCH 1/3] Fix errors and warnings building swift/SILGen on Windows using MSVC --- lib/SILGen/ArgumentSource.cpp | 2 ++ lib/SILGen/RValue.cpp | 2 ++ lib/SILGen/SILGenApply.cpp | 9 +++++++-- lib/SILGen/SILGenConvert.cpp | 2 ++ lib/SILGen/SILGenExpr.cpp | 2 ++ lib/SILGen/SILGenFunction.cpp | 2 ++ lib/SILGen/SILGenPattern.cpp | 4 ++++ lib/SILGen/SILGenPoly.cpp | 4 ++++ lib/SILGen/SILGenProfiling.cpp | 4 ++++ 9 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/SILGen/ArgumentSource.cpp b/lib/SILGen/ArgumentSource.cpp index c94b3188f7b29..954ab625dbeae 100644 --- a/lib/SILGen/ArgumentSource.cpp +++ b/lib/SILGen/ArgumentSource.cpp @@ -57,6 +57,8 @@ bool ArgumentSource::requiresCalleeToEvaluate() { case Kind::Expr: return isa(asKnownExpr()); } + + llvm_unreachable("Unhandled Kind in switch."); } RValue ArgumentSource::getAsRValue(SILGenFunction &gen, SGFContext C) && { diff --git a/lib/SILGen/RValue.cpp b/lib/SILGen/RValue.cpp index 82a13f8b6f2d2..bab7b1a227908 100644 --- a/lib/SILGen/RValue.cpp +++ b/lib/SILGen/RValue.cpp @@ -140,6 +140,8 @@ class ImplodeLoadableTupleValue case ImplodeKind::Copy: return v.copyUnmanaged(gen, l).forward(gen); } + + llvm_unreachable("Unhandled ImplodeKind in switch."); } ImplodeLoadableTupleValue(ArrayRef values, diff --git a/lib/SILGen/SILGenApply.cpp b/lib/SILGen/SILGenApply.cpp index a7d9b4e1366ad..42a06719b5a1a 100644 --- a/lib/SILGen/SILGenApply.cpp +++ b/lib/SILGen/SILGenApply.cpp @@ -427,6 +427,8 @@ class Callee { case Kind::DynamicMethod: return Constant.uncurryLevel; } + + llvm_unreachable("Unhandled Kind in switch."); } EnumElementDecl *getEnumElementDecl() { @@ -1487,7 +1489,7 @@ class SILGenApply : public Lowering::ExprVisitor { Callee getCallee() { assert(ApplyCallee && "did not find callee?!"); - return *std::move(ApplyCallee); + return std::move(*ApplyCallee); } /// Ignore parentheses and implicit conversions. @@ -3633,7 +3635,10 @@ void ArgEmitter::emitShuffle(Expr *inner, // fill out varargsAddrs if necessary. for (auto &extent : innerExtents) { assert(extent.Used && "didn't use all the inner tuple elements!"); - innerParams.append(extent.Params.begin(), extent.Params.end()); + + for (auto param : extent.Params) { + innerParams.push_back(param); + } // Fill in the special destinations array. if (innerSpecialDests) { diff --git a/lib/SILGen/SILGenConvert.cpp b/lib/SILGen/SILGenConvert.cpp index c0331d66dfa43..346ea84b310eb 100644 --- a/lib/SILGen/SILGenConvert.cpp +++ b/lib/SILGen/SILGenConvert.cpp @@ -667,6 +667,8 @@ ManagedValue SILGenFunction::emitExistentialErasure( return manageBufferForExprResult(existential, existentialTL, C); } } + + llvm_unreachable("Unhandled ExistentialRepresentation in switch."); } ManagedValue SILGenFunction::emitClassMetatypeToObject(SILLocation loc, diff --git a/lib/SILGen/SILGenExpr.cpp b/lib/SILGen/SILGenExpr.cpp index aeab1dccb97da..86bb384fe6346 100644 --- a/lib/SILGen/SILGenExpr.cpp +++ b/lib/SILGen/SILGenExpr.cpp @@ -2091,6 +2091,8 @@ visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E, SGFContext C) { return RValue(SGF, E, ManagedValue::forUnmanaged(UnsafeRawPtrStruct)); } } + + llvm_unreachable("Unhandled MagicIdentifierLiteralExpr in switch."); } RValue RValueEmitter::visitCollectionExpr(CollectionExpr *E, SGFContext C) { diff --git a/lib/SILGen/SILGenFunction.cpp b/lib/SILGen/SILGenFunction.cpp index fe2fb53de6def..4c16a8c6fac88 100644 --- a/lib/SILGen/SILGenFunction.cpp +++ b/lib/SILGen/SILGenFunction.cpp @@ -128,6 +128,8 @@ DeclName SILGenModule::getMagicFunctionName(SILDeclRef ref) { return getMagicFunctionName(cast(ref.getDecl()) ->getDeclContext()); } + + llvm_unreachable("Unhandled SILDeclRefKind in switch."); } SILValue SILGenFunction::emitGlobalFunctionRef(SILLocation loc, diff --git a/lib/SILGen/SILGenPattern.cpp b/lib/SILGen/SILGenPattern.cpp index 1ddc575e785d5..e83a6ed0a7143 100644 --- a/lib/SILGen/SILGenPattern.cpp +++ b/lib/SILGen/SILGenPattern.cpp @@ -222,6 +222,8 @@ static bool isWildcardPattern(const Pattern *p) { case PatternKind::Var: return isWildcardPattern(p->getSemanticsProvidingPattern()); } + + llvm_unreachable("Unhandled PatternKind in switch."); } /// Check to see if the given pattern is a specializing pattern, @@ -284,6 +286,8 @@ static Pattern *getSimilarSpecializingPattern(Pattern *p, Pattern *first) { case PatternKind::Typed: llvm_unreachable("not semantic"); } + + llvm_unreachable("Unhandled PatternKind in switch."); } namespace { diff --git a/lib/SILGen/SILGenPoly.cpp b/lib/SILGen/SILGenPoly.cpp index fff084b9ec4eb..1b061cc8c75fb 100644 --- a/lib/SILGen/SILGenPoly.cpp +++ b/lib/SILGen/SILGenPoly.cpp @@ -2788,6 +2788,8 @@ getWitnessFunctionType(SILGenModule &SGM, case WitnessDispatchKind::Class: return SGM.Types.getConstantOverrideType(witness); } + + llvm_unreachable("Unhandled WitnessDispatchKind in switch."); } static SILValue @@ -2808,6 +2810,8 @@ getWitnessFunctionRef(SILGenFunction &gen, SILValue selfPtr = witnessParams.back().getValue(); return gen.B.createClassMethod(loc, selfPtr, witness); } + + llvm_unreachable("Unhandled WitnessDispatchKind in switch."); } static CanType dropLastElement(CanType type) { diff --git a/lib/SILGen/SILGenProfiling.cpp b/lib/SILGen/SILGenProfiling.cpp index 4906c90038251..0bb69e26619db 100644 --- a/lib/SILGen/SILGenProfiling.cpp +++ b/lib/SILGen/SILGenProfiling.cpp @@ -226,6 +226,8 @@ class CounterExpr { case Kind::Ref: return LHS->expand(Builder, Counters); } + + llvm_unreachable("Unhandled Kind in switch."); } }; @@ -694,6 +696,8 @@ getEquivalentPGOLinkage(FormalLinkage Linkage) { case FormalLinkage::Private: return llvm::GlobalValue::PrivateLinkage; } + + llvm_unreachable("Unhandled FormalLinkage in switch."); } void SILGenProfiling::assignRegionCounters(Decl *Root) { From ac3b56a554488b002b2dec1554292711292a7589 Mon Sep 17 00:00:00 2001 From: Hugh Bellamy Date: Thu, 22 Dec 2016 11:52:35 +0000 Subject: [PATCH 2/3] Fix errors and warnings building swift/SILOptimizer on Windows using MSVC - https://connect.microsoft.com/VisualStudio/feedback/details/3116505/msvc-fails-to-compile-code-that-compiles-with-clang-reports-attempting-to-reference-a-deleted-function-error-from-destructor - https://connect.microsoft.com/VisualStudio/feedback/details/3116636/msvc-reports-ambiguous-symbol-error-for-friend-class-declaration-in-an-anonymous-namespace --- include/swift/SILOptimizer/PassManager/PassPipeline.h | 1 - lib/SILOptimizer/IPO/CapturePromotion.cpp | 2 +- lib/SILOptimizer/IPO/CapturePropagation.cpp | 2 +- lib/SILOptimizer/IPO/ClosureSpecializer.cpp | 2 +- lib/SILOptimizer/PassManager/Passes.cpp | 4 ++++ lib/SILOptimizer/Transforms/AllocBoxToStack.cpp | 2 +- lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp | 2 +- lib/SILOptimizer/Utils/SpecializationMangler.cpp | 2 +- 8 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/swift/SILOptimizer/PassManager/PassPipeline.h b/include/swift/SILOptimizer/PassManager/PassPipeline.h index 2422d514e4697..f17f0823f7543 100644 --- a/include/swift/SILOptimizer/PassManager/PassPipeline.h +++ b/include/swift/SILOptimizer/PassManager/PassPipeline.h @@ -48,7 +48,6 @@ class SILPassPipelinePlan final { SILPassPipelinePlan() = default; ~SILPassPipelinePlan() = default; SILPassPipelinePlan(const SILPassPipelinePlan &) = default; - SILPassPipelinePlan(SILPassPipelinePlan &&) = delete; // Each pass gets its own add-function. #define PASS(ID, NAME, DESCRIPTION) \ diff --git a/lib/SILOptimizer/IPO/CapturePromotion.cpp b/lib/SILOptimizer/IPO/CapturePromotion.cpp index 5cc039e901433..d96bddf43eb2b 100644 --- a/lib/SILOptimizer/IPO/CapturePromotion.cpp +++ b/lib/SILOptimizer/IPO/CapturePromotion.cpp @@ -387,7 +387,7 @@ static std::string getSpecializedName(SILFunction *F, IsFragile_t Fragile, IndicesSet &PromotableIndices) { Mangle::Mangler M; - auto P = SpecializationPass::CapturePromotion; + auto P = Demangle::SpecializationPass::CapturePromotion; FunctionSignatureSpecializationMangler OldFSSM(P, M, Fragile, F); NewMangling::FunctionSignatureSpecializationMangler NewFSSM(P, Fragile, F); CanSILFunctionType FTy = F->getLoweredFunctionType(); diff --git a/lib/SILOptimizer/IPO/CapturePropagation.cpp b/lib/SILOptimizer/IPO/CapturePropagation.cpp index c71adcc6991a7..f6365776a8875 100644 --- a/lib/SILOptimizer/IPO/CapturePropagation.cpp +++ b/lib/SILOptimizer/IPO/CapturePropagation.cpp @@ -72,7 +72,7 @@ static std::string getClonedName(PartialApplyInst *PAI, IsFragile_t Fragile, SILFunction *F) { Mangle::Mangler M; - auto P = SpecializationPass::CapturePropagation; + auto P = Demangle::SpecializationPass::CapturePropagation; FunctionSignatureSpecializationMangler OldMangler(P, M, Fragile, F); NewMangling::FunctionSignatureSpecializationMangler NewMangler(P, Fragile, F); diff --git a/lib/SILOptimizer/IPO/ClosureSpecializer.cpp b/lib/SILOptimizer/IPO/ClosureSpecializer.cpp index 374ab8d4099fb..71fd6ddec88b7 100644 --- a/lib/SILOptimizer/IPO/ClosureSpecializer.cpp +++ b/lib/SILOptimizer/IPO/ClosureSpecializer.cpp @@ -398,7 +398,7 @@ IsFragile_t CallSiteDescriptor::isFragile() const { std::string CallSiteDescriptor::createName() const { Mangle::Mangler M; - auto P = SpecializationPass::ClosureSpecializer; + auto P = Demangle::SpecializationPass::ClosureSpecializer; FunctionSignatureSpecializationMangler OldFSSM(P, M, isFragile(), getApplyCallee()); NewMangling::FunctionSignatureSpecializationMangler NewFSSM(P, isFragile(), diff --git a/lib/SILOptimizer/PassManager/Passes.cpp b/lib/SILOptimizer/PassManager/Passes.cpp index b39c0ccb375b0..1038274096054 100644 --- a/lib/SILOptimizer/PassManager/Passes.cpp +++ b/lib/SILOptimizer/PassManager/Passes.cpp @@ -146,6 +146,8 @@ StringRef swift::PassKindName(PassKind Kind) { case PassKind::invalidPassKind: llvm_unreachable("Invalid pass kind?!"); } + + llvm_unreachable("Unhandled PassKind in switch."); } StringRef swift::PassKindID(PassKind Kind) { @@ -157,4 +159,6 @@ StringRef swift::PassKindID(PassKind Kind) { case PassKind::invalidPassKind: llvm_unreachable("Invalid pass kind?!"); } + + llvm_unreachable("Unhandled PassKind in switch."); } diff --git a/lib/SILOptimizer/Transforms/AllocBoxToStack.cpp b/lib/SILOptimizer/Transforms/AllocBoxToStack.cpp index bf8334fabb66a..c72dc1829c9e8 100644 --- a/lib/SILOptimizer/Transforms/AllocBoxToStack.cpp +++ b/lib/SILOptimizer/Transforms/AllocBoxToStack.cpp @@ -521,7 +521,7 @@ static std::string getClonedName(SILFunction *F, IsFragile_t Fragile, ParamIndexList &PromotedParamIndices) { Mangle::Mangler M; - auto P = SpecializationPass::AllocBoxToStack; + auto P = Demangle::SpecializationPass::AllocBoxToStack; FunctionSignatureSpecializationMangler OldFSSM(P, M, Fragile, F); NewMangling::FunctionSignatureSpecializationMangler NewFSSM(P, Fragile, F); for (unsigned i : PromotedParamIndices) { diff --git a/lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp b/lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp index 5698680d4753a..b35aaf64f2eab 100644 --- a/lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp +++ b/lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp @@ -923,7 +923,7 @@ class FunctionSignatureOpts : public SILFunctionTransform { // going to change, make sure the mangler is aware of all the changes done // to the function. Mangle::Mangler M; - auto P = SpecializationPass::FunctionSignatureOpts; + auto P = Demangle::SpecializationPass::FunctionSignatureOpts; FunctionSignatureSpecializationMangler OldFM(P, M, F->isFragile(), F); NewMangling::FunctionSignatureSpecializationMangler NewFM(P, F->isFragile(), F); diff --git a/lib/SILOptimizer/Utils/SpecializationMangler.cpp b/lib/SILOptimizer/Utils/SpecializationMangler.cpp index afb8d786592ab..236f7b238bedd 100644 --- a/lib/SILOptimizer/Utils/SpecializationMangler.cpp +++ b/lib/SILOptimizer/Utils/SpecializationMangler.cpp @@ -95,7 +95,7 @@ std::string PartialSpecializationMangler::mangle() { //===----------------------------------------------------------------------===// FunctionSignatureSpecializationMangler:: -FunctionSignatureSpecializationMangler(SpecializationPass P, +FunctionSignatureSpecializationMangler(Demangle::SpecializationPass P, IsFragile_t Fragile, SILFunction *F) : SpecializationMangler(P, Fragile, F) { for (unsigned i = 0, e = F->getLoweredFunctionType()->getNumSILArguments(); From 63d6b151317678f1bcfad7fe1cb262f6aed9a121 Mon Sep 17 00:00:00 2001 From: Hugh Bellamy Date: Thu, 22 Dec 2016 11:52:50 +0000 Subject: [PATCH 3/3] Fix errors building swift/SIL on Windows with MSVC https://connect.microsoft.com/VisualStudio/feedback/details/3117167 --- include/swift/SIL/SILArgumentConvention.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/swift/SIL/SILArgumentConvention.h b/include/swift/SIL/SILArgumentConvention.h index e2ed244638e31..4607f62345f00 100644 --- a/include/swift/SIL/SILArgumentConvention.h +++ b/include/swift/SIL/SILArgumentConvention.h @@ -34,7 +34,7 @@ enum class InoutAliasingAssumption { /// By design, this is exactly the same as ParameterConvention, plus /// Indirect_Out. struct SILArgumentConvention { - enum : uint8_t { + enum ConventionType : uint8_t { Indirect_In, Indirect_In_Guaranteed, Indirect_Inout, @@ -79,7 +79,7 @@ struct SILArgumentConvention { llvm_unreachable("covered switch isn't covered?!"); } - operator decltype(Value)() const { return Value; } + operator ConventionType() const { return Value; } bool isIndirectConvention() const { return Value <= SILArgumentConvention::Indirect_Out;