diff --git a/docs/SIL.rst b/docs/SIL.rst index a941ec7b86b..e6442bb9b5c 100644 --- a/docs/SIL.rst +++ b/docs/SIL.rst @@ -1624,18 +1624,6 @@ TODO: ``builtin_zero`` is a temporary hack to support our current AST-level default initialization implementation. Definitive assignment analysis in SIL will supersede this. -module -`````` -:: - - sil-instruction ::= 'module' sil-decl-ref - - %1 = module #M - // #M must be a module name - // %1 has type $module - -Creates a module value for the module ``M``. - Dynamic Dispatch ~~~~~~~~~~~~~~~~ diff --git a/include/swift/SIL/SILBuilder.h b/include/swift/SIL/SILBuilder.h index 5139e74c085..e1d73cf41e7 100644 --- a/include/swift/SIL/SILBuilder.h +++ b/include/swift/SIL/SILBuilder.h @@ -594,10 +594,6 @@ public: return insert(new (F.getModule()) ProtocolMetatypeInst(Loc, Metatype,Base)); } - ModuleInst *createModule(SILLocation Loc, SILType ModuleType) { - return insert(new (F.getModule()) ModuleInst(Loc, ModuleType)); - } - StrongRetainInst *createStrongRetain(SILLocation Loc, SILValue Operand) { return insert(new (F.getModule()) StrongRetainInst(Loc, Operand)); } diff --git a/include/swift/SIL/SILCloner.h b/include/swift/SIL/SILCloner.h index 9c851b640e4..4b5986bc5d9 100644 --- a/include/swift/SIL/SILCloner.h +++ b/include/swift/SIL/SILCloner.h @@ -621,14 +621,6 @@ SILCloner::visitProtocolMetatypeInst(ProtocolMetatypeInst *Inst) { getOpValue(Inst->getOperand()))); } -template -void -SILCloner::visitModuleInst(ModuleInst *Inst) { - doPostProcess(Inst, - Builder.createModule(getOpLocation(Inst->getLoc()), - getOpType(Inst->getType()))); -} - template void SILCloner::visitTupleExtractInst(TupleExtractInst *Inst) { diff --git a/include/swift/SIL/SILInstruction.h b/include/swift/SIL/SILInstruction.h index d726063acb7..7c15528ba1b 100644 --- a/include/swift/SIL/SILInstruction.h +++ b/include/swift/SIL/SILInstruction.h @@ -1344,23 +1344,6 @@ public: : UnaryInstructionBase(Loc, Base, Metatype) {} }; -/// ModuleInst - Represents a reference to a module as a value. -class ModuleInst : public SILInstruction { -public: - - ModuleInst(SILLocation Loc, SILType ModuleType); - - /// getType() is ok since this is known to only have one type. - SILType getType(unsigned i = 0) const { return ValueBase::getType(i); } - - ArrayRef getAllOperands() const { return {}; } - MutableArrayRef getAllOperands() { return {}; } - - static bool classof(const ValueBase *V) { - return V->getKind() == ValueKind::ModuleInst; - } -}; - /// Extract a numbered element out of a value of tuple type. class TupleExtractInst : public UnaryInstructionBase diff --git a/include/swift/SIL/SILNodes.def b/include/swift/SIL/SILNodes.def index 17e3ad693ba..25830f98cf7 100644 --- a/include/swift/SIL/SILNodes.def +++ b/include/swift/SIL/SILNodes.def @@ -106,7 +106,6 @@ ABSTRACT_VALUE(SILInstruction, ValueBase) INST(FloatLiteralInst, SILInstruction, None) INST(StringLiteralInst, SILInstruction, None) INST(BuiltinZeroInst, SILInstruction, None) - INST(ModuleInst, SILInstruction, None) // Dynamic Dispatch ABSTRACT_VALUE(MethodInst, SILInstruction) diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index ac5f7752a20..d3582b21a2c 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -539,7 +539,6 @@ public: void visitStructExtractInst(StructExtractInst *i); void visitStructElementAddrInst(StructElementAddrInst *i); void visitRefElementAddrInst(RefElementAddrInst *i); - void visitModuleInst(ModuleInst *i); void visitClassMethodInst(ClassMethodInst *i); void visitSuperMethodInst(SuperMethodInst *i); @@ -2044,12 +2043,6 @@ void IRGenSILFunction::visitRefElementAddrInst(swift::RefElementAddrInst *i) { setLoweredAddress(SILValue(i, 0), field); } -void IRGenSILFunction::visitModuleInst(swift::ModuleInst *i) { - // Currently, module values are always empty. - Explosion empty(ExplosionKind::Maximal); - setLoweredExplosion(SILValue(i, 0), empty); -} - void IRGenSILFunction::visitLoadInst(swift::LoadInst *i) { Explosion lowered(ExplosionKind::Maximal); Address source = getLoweredAddress(i->getOperand()); diff --git a/lib/Parse/ParseSIL.cpp b/lib/Parse/ParseSIL.cpp index 2803c1c89e4..fa694e87c09 100644 --- a/lib/Parse/ParseSIL.cpp +++ b/lib/Parse/ParseSIL.cpp @@ -923,7 +923,6 @@ bool SILParser::parseSILOpcode(ValueKind &Opcode, SourceLoc &OpcodeLoc, .Case("mark_uninitialized", ValueKind::MarkUninitializedInst) .Case("mark_function_escape", ValueKind::MarkFunctionEscapeInst) .Case("metatype", ValueKind::MetatypeInst) - .Case("module", ValueKind::ModuleInst) .Case("object_pointer_to_ref", ValueKind::ObjectPointerToRefInst) .Case("partial_apply", ValueKind::PartialApplyInst) .Case("pointer_to_address", ValueKind::PointerToAddressInst) @@ -2100,21 +2099,6 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB) { ArrayRef()); break; } - case ValueKind::ModuleInst: { - Identifier ModuleName; - SourceLoc ModuleLoc; - // Parse reference to a module. - if (P.parseToken(tok::sil_pound, diag::expected_sil_constant) || - parseSILIdentifier(ModuleName, ModuleLoc, diag::expected_sil_constant)) - return true; - llvm::PointerUnion Res = lookupTopDecl(P, ModuleName); - assert(Res.is() && "Expect a module name in ModuleInst"); - auto Mod = Res.get(); - ResultVal = B.createModule(InstLoc, - SILType::getPrimitiveObjectType( - ModuleType::get(Mod)->getCanonicalType())); - break; - } case ValueKind::DynamicMethodBranchInst: { SILDeclRef Member; Identifier BBName, BBName2; diff --git a/lib/SIL/SILInstruction.cpp b/lib/SIL/SILInstruction.cpp index 464f99a0729..c1b7cc0b1dd 100644 --- a/lib/SIL/SILInstruction.cpp +++ b/lib/SIL/SILInstruction.cpp @@ -550,9 +550,6 @@ TupleInst::TupleInst(SILLocation Loc, SILType Ty, ArrayRef Elems) MetatypeInst::MetatypeInst(SILLocation Loc, SILType Metatype) : SILInstruction(ValueKind::MetatypeInst, Loc, Metatype) {} -ModuleInst::ModuleInst(SILLocation Loc, SILType ModuleType) - : SILInstruction(ValueKind::ModuleInst, Loc, ModuleType) {} - ProjectExistentialInst::ProjectExistentialInst(SILLocation Loc, SILValue Operand, SILType SelfTy) diff --git a/lib/SIL/SILPrinter.cpp b/lib/SIL/SILPrinter.cpp index 5d9d9a51975..7a7f69f434f 100644 --- a/lib/SIL/SILPrinter.cpp +++ b/lib/SIL/SILPrinter.cpp @@ -893,9 +893,6 @@ public: void visitMetatypeInst(MetatypeInst *MI) { OS << "metatype " << MI->getType(); } - void visitModuleInst(ModuleInst *MI) { - OS << "module #" << MI->getType().castTo()->getModule()->Name; - } void visitStrongRetainInst(StrongRetainInst *RI) { OS << "strong_retain " << getIDAndType(RI->getOperand()); diff --git a/lib/SIL/Verifier.cpp b/lib/SIL/Verifier.cpp index dfb0780723c..654ded4f1fa 100644 --- a/lib/SIL/Verifier.cpp +++ b/lib/SIL/Verifier.cpp @@ -586,10 +586,6 @@ public: CanType(MI->getType().castTo()->getInstanceType()), "protocol_metatype result must be metatype of operand type"); } - void checkModuleInst(ModuleInst *MI) { - require(MI->getType(0).is(), - "module instruction must be of module type"); - } void checkStrongRetainInst(StrongRetainInst *RI) { requireReferenceValue(RI->getOperand(), "Operand of strong_retain"); diff --git a/lib/SILGen/SILGenExpr.cpp b/lib/SILGen/SILGenExpr.cpp index 7bc92a9852d..7b9e546de1d 100644 --- a/lib/SILGen/SILGenExpr.cpp +++ b/lib/SILGen/SILGenExpr.cpp @@ -20,6 +20,7 @@ #include "swift/Basic/SourceManager.h" #include "swift/Basic/type_traits.h" #include "swift/SIL/SILArgument.h" +#include "swift/SIL/SILUndef.h" #include "swift/SIL/TypeLowering.h" #include "Initialization.h" #include "LValue.h" @@ -1167,8 +1168,9 @@ RValue RValueEmitter::visitDotSyntaxBaseIgnoredExpr( } RValue RValueEmitter::visitModuleExpr(ModuleExpr *E, SGFContext C) { - SILValue module = - SGF.B.createModule(E, SGF.getLoweredLoadableType(E->getType())); + // Produce an undef value. The module value should never actually be used. + SILValue module = SILUndef::get(SGF.getLoweredLoadableType(E->getType()), + SGF.SGM.M); return RValue(SGF, ManagedValue(module, ManagedValue::Unmanaged), E); } diff --git a/lib/Serialization/DeserializeSIL.cpp b/lib/Serialization/DeserializeSIL.cpp index e91f04c8ba7..1232f9e94f7 100644 --- a/lib/Serialization/DeserializeSIL.cpp +++ b/lib/Serialization/DeserializeSIL.cpp @@ -748,13 +748,6 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn, SILBasicBlock *BB, ResultVal = Builder.createMarkFunctionEscape(Loc, OpList); break; } - case ValueKind::ModuleInst: { - // Has IdentifierID for the module reference. Use SILOneTypeLayout. - auto Mod = MF->getModule(MF->getIdentifier(TyID)); - ResultVal = Builder.createModule(Loc, - getSILType(ModuleType::get(Mod), SILValueCategory::Object)); - break; - } // Checked Conversion instructions. case ValueKind::UnconditionalCheckedCastInst: { SILValue Val = getLocalValue(ValID, ValResNum, diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp index 96fba982ee9..05a5d693a26 100644 --- a/lib/Serialization/SerializeSIL.cpp +++ b/lib/Serialization/SerializeSIL.cpp @@ -663,16 +663,6 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) { (unsigned)MI->getType().getCategory()); break; } - case ValueKind::ModuleInst: { - // Has IdentifierID for the module reference. Use SILOneTypeLayout. - const ModuleInst *MI = cast(&SI); - ModuleType *MT = MI->getType().castTo(); - SILOneTypeLayout::emitRecord(Out, ScratchRecord, - SILAbbrCodes[SILOneTypeLayout::Code], - (unsigned)SI.getKind(), - S.addModuleRef(MT->getModule()), 0); - break; - } case ValueKind::ProjectExistentialInst: { const ProjectExistentialInst *PEI = cast(&SI); SILOneTypeOneOperandLayout::emitRecord(Out, ScratchRecord, diff --git a/test/SIL/Parser/basic.sil b/test/SIL/Parser/basic.sil index 559bebfb1fb..bb7725ebfe9 100644 --- a/test/SIL/Parser/basic.sil +++ b/test/SIL/Parser/basic.sil @@ -528,7 +528,6 @@ bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Int64): %3 = alloc_box $Builtin.Int64 // CHECK: alloc_box %4 = store %0 to %2#1 : $*Builtin.RawPointer %5 = store %1 to %3#1 : $*Builtin.Int64 - // %6 = module #Builtin %7 = load %2#1 : $*Builtin.RawPointer // CHECK: load %8 = load %3#1 : $*Builtin.Int64 // CHECK: load // CHECK: index_raw_pointer {{%.*}} : $Builtin.RawPointer, {{%.*}} : $Builtin.Int64 @@ -672,7 +671,6 @@ bb0(%0 : $Builtin.Int1, %1 : $Builtin.Int1): %3 = alloc_box $Builtin.Int1 store %0 to %2#1 : $*Builtin.Int1 store %1 to %3#1 : $*Builtin.Int1 - %6 = module #Builtin // CHECK: module #Builtin // CHECK: builtin_function_ref #Builtin.cmp_eq_Int1 : $@thin (Builtin.Int1, Builtin.Int1) -> Builtin.Int1 %7 = builtin_function_ref #Builtin.cmp_eq_Int1 : $@thin (Builtin.Int1, Builtin.Int1) -> Builtin.Int1 %8 = load %2#1 : $*Builtin.Int1 @@ -988,7 +986,6 @@ bb0(%0 : $Int64, %1 : $Int64, %2 : $Foo): %8 = alloc_stack $Foo // var self // users: %15, %14, %9 store %2 to %8#1 : $*Foo %10 = metatype $Int64.metatype - %11 = module #Builtin %12 = integer_literal $Builtin.Int64, 0 // user: %13 %13 = struct $Int64 (%12 : $Builtin.Int64) // user: %18 destroy_addr %8#1 : $*Foo diff --git a/test/Serialization/Inputs/def_basic.sil b/test/Serialization/Inputs/def_basic.sil index 3180fa7be05..7c5bb8a3e07 100644 --- a/test/Serialization/Inputs/def_basic.sil +++ b/test/Serialization/Inputs/def_basic.sil @@ -456,7 +456,6 @@ bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Int64): %3 = alloc_box $Builtin.Int64 %4 = store %0 to %2#1 : $*Builtin.RawPointer %5 = store %1 to %3#1 : $*Builtin.Int64 - // %6 = module #Builtin %7 = load %2#1 : $*Builtin.RawPointer %8 = load %3#1 : $*Builtin.Int64 // CHECK: index_raw_pointer {{%.*}} : $Builtin.RawPointer, {{%.*}} : $Builtin.Int64 @@ -666,7 +665,6 @@ bb0(%0 : $Builtin.Int1, %1 : $Builtin.Int1): %3 = alloc_box $Builtin.Int1 store %0 to %2#1 : $*Builtin.Int1 store %1 to %3#1 : $*Builtin.Int1 - %6 = module #Builtin // CHECK: module #Builtin // CHECK: builtin_function_ref #Builtin.cmp_eq_Int1 : $@thin (Builtin.Int1, Builtin.Int1) -> Builtin.Int1 %7 = builtin_function_ref #Builtin.cmp_eq_Int1 : $@thin (Builtin.Int1, Builtin.Int1) -> Builtin.Int1 %8 = load %2#1 : $*Builtin.Int1 @@ -953,7 +951,6 @@ bb0(%0 : $Int64, %1 : $Int64, %2 : $Foo): %8 = alloc_stack $Foo // var self // users: %15, %14, %9 store %2 to %8#1 : $*Foo %10 = metatype $Int64.metatype - %11 = module #Builtin %12 = integer_literal $Builtin.Int64, 0 // user: %13 %13 = struct $Int64 (%12 : $Builtin.Int64) // user: %18 destroy_addr %8#1 : $*Foo