Skip to content

Commit a532c53

Browse files
committed
[SIL-opaque] Don't override arg value category.
Previously, when emitting block arguments, the value category of the SILType was overridden to be address for indirect arguments. With opaque types, that distinction is made later during AddressLowering. So only do that when opaque types are disabled.
1 parent c6de808 commit a532c53

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/SILGen/SILGenProlog.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ class EmitBBArguments : public CanTypeVisitor<EmitBBArguments,
7878
SGF.SGM.Types.getLoweredType(t, TypeExpansionContext::minimal());
7979
argType = argType.getCategoryType(argTypeConv.getCategory());
8080

81-
if (isInOut
82-
|| orig.getParameterConvention(SGF.SGM.Types) == AbstractionPattern::Indirect)
81+
if (isInOut || (orig.getParameterConvention(SGF.SGM.Types) ==
82+
AbstractionPattern::Indirect &&
83+
SGF.SGM.M.useLoweredAddresses()))
8384
argType = argType.getCategoryType(SILValueCategory::Address);
8485

8586
// Pop the next parameter info.

test/SILGen/opaque_values_silgen.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,20 @@ public struct EnumSeq<Base : Seq> : Seq {
350350
return EnumIter(_base: _base.makeIterator())
351351
}
352352
}
353+
354+
extension Collection {
355+
func transformEachElement<U>(_ cl: (Element) -> U) -> [U] {
356+
return map(cl)
357+
}
358+
}
359+
360+
extension Array where Element == Int {
361+
// CHECK-LABEL: sil private [ossa] @$sSa20opaque_values_silgenSiRszlE20incrementEachElementSaySiGyFS2iXEfU_ : {{.*}} {
362+
// CHECK: {{bb[0-9]+}}({{%[^,]+}} : $Int):
363+
// CHECK-LABEL: } // end sil function '$sSa20opaque_values_silgenSiRszlE20incrementEachElementSaySiGyFS2iXEfU_'
364+
func incrementEachElement() -> [Int] {
365+
return transformEachElement { element in
366+
return element + 1
367+
}
368+
}
369+
}

0 commit comments

Comments
 (0)