Skip to content

IRGen: Various minor fixes #64489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/IRGen/GenPack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ static void emitPackExpansionPack(
IGF.Builder.CreateCondBr(cond, loop, rest);

IGF.Builder.emitBlock(loop);
ConditionalDominanceScope condition(IGF);

auto *element = elementForIndex(phi);

Expand Down Expand Up @@ -824,6 +825,8 @@ llvm::Value *irgen::emitTypeMetadataPackElementRef(
// (1) Emit check_i {{
IGF.Builder.emitBlock(checkBounds);

ConditionalDominanceScope dominanceScope(IGF);

// The upper bound for the current pack expansion. Exclusive.
llvm::Value *upperBound = nullptr;
llvm::Value *condition = nullptr;
Expand Down
5 changes: 4 additions & 1 deletion lib/IRGen/GenTuple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,10 @@ Address irgen::projectTupleElementAddressByDynamicIndex(IRGenFunction &IGF,
llvm::Value *offset = loadTupleOffsetFromMetadata(IGF, metadata, index);
auto *gep =
IGF.emitByteOffsetGEP(tuple.getAddress(), offset, IGF.IGM.OpaqueTy);
return Address(gep, IGF.IGM.OpaqueTy, IGF.IGM.getPointerAlignment());
auto elementAddress = Address(gep, IGF.IGM.OpaqueTy,
IGF.IGM.getPointerAlignment());
return IGF.Builder.CreateElementBitCast(elementAddress,
IGF.IGM.getStorageType(elementType));
}

Optional<Size> irgen::getFixedTupleElementOffset(IRGenModule &IGM,
Expand Down
12 changes: 6 additions & 6 deletions lib/IRGen/GenType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1966,14 +1966,14 @@ const TypeInfo &TypeConverter::getCompleteTypeInfo(CanType T) {
}

ArchetypeType *TypeConverter::getExemplarArchetype(ArchetypeType *t) {
// Get the primary archetype.
auto root = t->getRoot();

// If there is no primary (IOW, it's an opened archetype), the archetype is
// an exemplar.
if (!isa<PrimaryArchetypeType>(root) && !isa<VariadicSequenceType>(root))
if (isa<LocalArchetypeType>(t) || isa<OpaqueTypeArchetypeType>(t))
return t;

assert(isa<PrimaryArchetypeType>(t) || isa<PackArchetypeType>(t));

// Get the root archetype.
auto root = t->getRoot();

// Retrieve the generic environment of the archetype.
auto genericEnv = root->getGenericEnvironment();

Expand Down
15 changes: 15 additions & 0 deletions test/IRGen/pack_archetype_canonicalization.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: %target-swift-frontend -emit-ir %s -enable-experimental-feature VariadicGenerics

// Because of -enable-experimental-feature VariadicGenerics
// REQUIRES: asserts

// This would crash.
public struct G<T> {}

public struct GG<each T> {
public var variables: (repeat G<each T>)

public init() {
fatalError()
}
}