Skip to content

Commit 8d854f3

Browse files
committed
straighten out IRGen's @lvalue vs @inout handling. Since SILGen lowers all
@lvalue types, IRGen only needs to handle @inout. Swift SVN r11799
1 parent e808c36 commit 8d854f3

File tree

5 files changed

+8
-45
lines changed

5 files changed

+8
-45
lines changed

Diff for: lib/IRGen/GenDecl.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ llvm::Constant *IRGenModule::getAddrOfValueWitnessTable(CanType concreteType,
11931193
static CanType addOwnerArgument(DeclContext *DC, CanType resultType) {
11941194
Type argType = DC->getDeclaredTypeInContext();
11951195
if (!argType->hasReferenceSemantics())
1196-
argType = LValueType::get(argType);
1196+
argType = InOutType::get(argType);
11971197
if (auto params = DC->getGenericParamsOfContext())
11981198
return PolymorphicFunctionType::get(argType, resultType, params)
11991199
->getCanonicalType();
@@ -1247,7 +1247,7 @@ FormalType IRGenModule::getTypeOfGetter(ValueDecl *value) {
12471247
// (this clause is skipped for a non-subscript getter).
12481248
unsigned uncurryLevel = 0;
12491249
CanType formalType = CanType(FunctionType::get(TupleType::getEmpty(Context),
1250-
getObjectType(value)));
1250+
getObjectType(value)));
12511251
addIndexArgument(value, formalType, uncurryLevel);
12521252
AbstractCC cc = addOwnerArgument(value, formalType, uncurryLevel);
12531253

Diff for: lib/IRGen/GenFunc.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,6 @@ void irgen::emitFunctionPartialApplication(IRGenFunction &IGF,
22172217
hasSingleSwiftRefcountedContext = Maybe;
22182218

22192219
// Collect the type infos for the context types.
2220-
// FIXME: Keep LValueTypes out of this.
22212220
SmallVector<const TypeInfo *, 4> argTypeInfos;
22222221
for (SILType argType : argTypes) {
22232222
auto &ti = IGF.getTypeInfoForLowered(argType.getSwiftType());

Diff for: lib/IRGen/GenMeta.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,7 @@ namespace {
547547
}
548548

549549
llvm::Value *visitLValueType(CanLValueType type) {
550-
IGF.unimplemented(SourceLoc(), "metadata ref for l-value type");
551-
return llvm::UndefValue::get(IGF.IGM.TypeMetadataPtrTy);
550+
llvm_unreachable("should have been lowered by SILGen");
552551
}
553552
llvm::Value *visitInOutType(CanInOutType type) {
554553
IGF.unimplemented(SourceLoc(), "metadata ref for @inout type");

Diff for: lib/IRGen/GenPoly.cpp

+5-39
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,10 @@ namespace {
260260
// L-values go by the object type; note that we ask the ordinary
261261
// question, not the argument question.
262262
bool visitLValueType(CanLValueType origTy, CanLValueType substTy) {
263-
return differsByAbstractionInMemory(IGM,
264-
origTy.getObjectType(),
265-
substTy.getObjectType());
263+
llvm_unreachable("should have been lowered by SILGen");
266264
}
267-
// inout go by the object type; note that we ask the ordinary
265+
266+
// @inout go by the object type; note that we ask the ordinary
268267
// question, not the argument question.
269268
bool visitInOutType(CanInOutType origTy, CanInOutType substTy) {
270269
return differsByAbstractionInMemory(IGM,
@@ -552,24 +551,7 @@ namespace {
552551
}
553552

554553
void visitLValueType(CanLValueType origTy, CanLValueType substTy) {
555-
CanType origObjectTy = origTy.getObjectType();
556-
CanType substObjectTy = substTy.getObjectType();
557-
if (differsByAbstractionInMemory(IGF.IGM, origObjectTy, substObjectTy))
558-
IGF.unimplemented(SourceLoc(), "remapping l-values");
559-
560-
llvm::Value *substMV = In.claimNext();
561-
if (origObjectTy == substObjectTy)
562-
return Out.add(substMV);
563-
564-
// A bitcast will be sufficient.
565-
auto &origObjectTI = IGF.IGM.getTypeInfoForUnlowered(origObjectTy);
566-
auto origPtrTy = origObjectTI.getStorageType()->getPointerTo();
567-
568-
auto substValue = substMV;
569-
auto origValue =
570-
IGF.Builder.CreateBitCast(substValue, origPtrTy,
571-
substValue->getName() + ".reinterpret");
572-
Out.add(origValue);
554+
llvm_unreachable("should have been lowered by SILGen");
573555
}
574556

575557
void visitInOutType(CanInOutType origTy, CanInOutType substTy) {
@@ -734,23 +716,7 @@ namespace {
734716
}
735717

736718
void visitLValueType(CanLValueType origTy, CanLValueType substTy) {
737-
CanType origObjectTy = origTy.getObjectType();
738-
CanType substObjectTy = substTy.getObjectType();
739-
if (differsByAbstractionInMemory(IGF.IGM, origObjectTy, substObjectTy))
740-
IGF.unimplemented(SourceLoc(), "remapping l-values");
741-
742-
llvm::Value *origMV = In.claimNext();
743-
if (origObjectTy == substObjectTy)
744-
return Out.add(origMV);
745-
746-
// A bitcast will be sufficient.
747-
auto &substObjectTI = IGF.IGM.getTypeInfoForUnlowered(substObjectTy);
748-
auto substPtrTy = substObjectTI.getStorageType()->getPointerTo();
749-
750-
auto substValue =
751-
IGF.Builder.CreateBitCast(origMV, substPtrTy,
752-
origMV->getName() + ".reinterpret");
753-
Out.add(substValue);
719+
llvm_unreachable("should have been lowered by SILGen");
754720
}
755721
void visitInOutType(CanInOutType origTy, CanInOutType substTy) {
756722
CanType origObjectTy = origTy.getObjectType();

Diff for: lib/IRGen/GenType.h

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ namespace swift {
3131
class ClassDecl;
3232
class AnyFunctionType;
3333
class InOutType;
34-
class LValueType;
3534
class MetatypeType;
3635
class ModuleType;
3736
class NominalTypeDecl;

0 commit comments

Comments
 (0)