Skip to content

Commit 1dcc53d

Browse files
committed
[NFC] Added Xllvm flag to control TypeLowering.
The new flag allows TypeLowering to be forced to behave as though -enable-sil-opaque-values was passed. That's needed in order to reasonably write tests on SIL which _notionally_ started out in opaque values mode and have since been address lowered.
1 parent c790171 commit 1dcc53d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/SIL/IR/TypeLowering.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@
4343
using namespace swift;
4444
using namespace Lowering;
4545

46+
// Necessary to straightforwardly write SIL tests that exercise
47+
// OpaqueValueTypeLowering (and MoveOnlyOpaqueValueTypeLowering): the tests can
48+
// be written as though opaque values were enabled to begin but have since been
49+
// lowered out of.
50+
llvm::cl::opt<bool> TypeLoweringForceOpaqueValueLowering(
51+
"type-lowering-force-opaque-value-lowering", llvm::cl::init(false),
52+
llvm::cl::desc("Force TypeLowering to behave as if building with opaque "
53+
"values enabled"));
54+
4655
namespace {
4756
/// A CRTP type visitor for deciding whether the metatype for a type
4857
/// is a singleton type, i.e. whether there can only ever be one
@@ -2066,7 +2075,8 @@ namespace {
20662075

20672076
TypeLowering *handleMoveOnlyAddressOnly(CanType type,
20682077
RecursiveProperties properties) {
2069-
if (!TC.Context.SILOpts.EnableSILOpaqueValues) {
2078+
if (!TC.Context.SILOpts.EnableSILOpaqueValues &&
2079+
!TypeLoweringForceOpaqueValueLowering) {
20702080
auto silType = SILType::getPrimitiveAddressType(type);
20712081
return new (TC)
20722082
MoveOnlyAddressOnlyTypeLowering(silType, properties, Expansion);
@@ -2084,7 +2094,8 @@ namespace {
20842094

20852095
TypeLowering *handleAddressOnly(CanType type,
20862096
RecursiveProperties properties) {
2087-
if (!TC.Context.SILOpts.EnableSILOpaqueValues) {
2097+
if (!TC.Context.SILOpts.EnableSILOpaqueValues &&
2098+
!TypeLoweringForceOpaqueValueLowering) {
20882099
auto silType = SILType::getPrimitiveAddressType(type);
20892100
return new (TC) AddressOnlyTypeLowering(silType, properties,
20902101
Expansion);

0 commit comments

Comments
 (0)