Skip to content

Commit 512ac6c

Browse files
authored
Merge pull request #72860 from Snowy1803/salvage-debug-info-tuple
[DebugInfo] Salvage debug info for tuples
2 parents 2de6442 + 1e7dc51 commit 512ac6c

40 files changed

+166
-139
lines changed

docs/SIL.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4297,7 +4297,6 @@ less verbose.
42974297
debug-var-attr ::= 'let'
42984298
debug-var-attr ::= 'name' string-literal
42994299
debug-var-attr ::= 'argno' integer-literal
4300-
debug-var-attr ::= 'implicit'
43014300

43024301
There are a number of attributes that provide details about the source
43034302
variable that is being described, including the name of the

include/swift/SIL/SILDebugVariable.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ struct SILDebugVariable {
3838
StringRef Name;
3939
unsigned ArgNo : 16;
4040
unsigned Constant : 1;
41-
unsigned Implicit : 1;
4241
unsigned isDenseMapSingleton : 2;
4342
std::optional<SILType> Type;
4443
std::optional<SILLocation> Loc;
@@ -58,17 +57,17 @@ struct SILDebugVariable {
5857
}
5958

6059
SILDebugVariable()
61-
: ArgNo(0), Constant(false), Implicit(false), isDenseMapSingleton(0),
60+
: ArgNo(0), Constant(false), isDenseMapSingleton(0),
6261
Scope(nullptr) {}
6362
SILDebugVariable(bool Constant, uint16_t ArgNo)
64-
: ArgNo(ArgNo), Constant(Constant), Implicit(false),
63+
: ArgNo(ArgNo), Constant(Constant),
6564
isDenseMapSingleton(0), Scope(nullptr) {}
6665
SILDebugVariable(StringRef Name, bool Constant, unsigned ArgNo,
67-
bool IsImplicit = false, std::optional<SILType> AuxType = {},
66+
std::optional<SILType> AuxType = {},
6867
std::optional<SILLocation> DeclLoc = {},
6968
const SILDebugScope *DeclScope = nullptr,
7069
llvm::ArrayRef<SILDIExprElement> ExprElements = {})
71-
: Name(Name), ArgNo(ArgNo), Constant(Constant), Implicit(IsImplicit),
70+
: Name(Name), ArgNo(ArgNo), Constant(Constant),
7271
isDenseMapSingleton(0), Type(AuxType), Loc(DeclLoc), Scope(DeclScope),
7372
DIExpr(ExprElements) {}
7473

@@ -85,9 +84,8 @@ struct SILDebugVariable {
8584
// it in this class so that's it's easier to carry DIExpr around.
8685
bool operator==(const SILDebugVariable &V) const {
8786
return ArgNo == V.ArgNo && Constant == V.Constant && Name == V.Name &&
88-
Implicit == V.Implicit && Type == V.Type && Loc == V.Loc &&
89-
Scope == V.Scope && isDenseMapSingleton == V.isDenseMapSingleton &&
90-
DIExpr == V.DIExpr;
87+
Type == V.Type && Loc == V.Loc && Scope == V.Scope &&
88+
isDenseMapSingleton == V.isDenseMapSingleton && DIExpr == V.DIExpr;
9189
}
9290

9391
SILDebugVariable withoutDIExpr() const {
@@ -103,7 +101,7 @@ struct SILDebugVariable {
103101

104102
/// Returns the hashcode for the new projection path.
105103
inline llvm::hash_code hash_value(const SILDebugVariable &P) {
106-
return llvm::hash_combine(P.ArgNo, P.Constant, P.Name, P.Implicit,
104+
return llvm::hash_combine(P.ArgNo, P.Constant, P.Name,
107105
P.isDenseMapSingleton, P.Type, P.Loc, P.Scope,
108106
P.DIExpr);
109107
}

include/swift/SIL/SILInstruction.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,12 +1849,10 @@ class TailAllocatedDebugVariable {
18491849
int_type HasValue : 1;
18501850
/// True if this is a let-binding.
18511851
int_type Constant : 1;
1852-
/// True if this variable is created by compiler
1853-
int_type Implicit : 1;
18541852
/// When this is nonzero there is a tail-allocated string storing
18551853
/// variable name present. This typically only happens for
18561854
/// instructions that were created from parsing SIL assembler.
1857-
int_type NameLength : 13;
1855+
int_type NameLength : 14;
18581856
/// The source function argument position from left to right
18591857
/// starting with 1 or 0 if this is a local variable.
18601858
int_type ArgNo : 16;
@@ -1876,9 +1874,6 @@ class TailAllocatedDebugVariable {
18761874
StringRef getName(const char *buf) const;
18771875
bool isLet() const { return Bits.Data.Constant; }
18781876

1879-
bool isImplicit() const { return Bits.Data.Implicit; }
1880-
void setImplicit(bool V = true) { Bits.Data.Implicit = V; }
1881-
18821877
std::optional<SILDebugVariable>
18831878
get(VarDecl *VD, const char *buf, std::optional<SILType> AuxVarType = {},
18841879
std::optional<SILLocation> DeclLoc = {},
@@ -1890,8 +1885,8 @@ class TailAllocatedDebugVariable {
18901885
StringRef name = getName(buf);
18911886
if (VD && name.empty())
18921887
name = VD->getName().str();
1893-
return SILDebugVariable(name, isLet(), getArgNo(), isImplicit(), AuxVarType,
1894-
DeclLoc, DeclScope, DIExprElements);
1888+
return SILDebugVariable(name, isLet(), getArgNo(), AuxVarType, DeclLoc,
1889+
DeclScope, DIExprElements);
18951890
}
18961891
};
18971892
static_assert(sizeof(TailAllocatedDebugVariable) == 4,

lib/SIL/IR/SILInstructions.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ TailAllocatedDebugVariable::TailAllocatedDebugVariable(
175175
Bits.Data.HasValue = true;
176176
Bits.Data.Constant = Var->Constant;
177177
Bits.Data.ArgNo = Var->ArgNo;
178-
Bits.Data.Implicit = Var->Implicit;
179178
Bits.Data.NameLength = Var->Name.size();
180179
assert(Bits.Data.ArgNo == Var->ArgNo && "Truncation");
181180
assert(Bits.Data.NameLength == Var->Name.size() && "Truncation");
@@ -256,10 +255,6 @@ AllocStackInst::AllocStackInst(
256255
assert(sharedUInt32().AllocStackInst.numOperands ==
257256
TypeDependentOperands.size() &&
258257
"Truncation");
259-
auto *VD = Loc.getLocation().getAsASTNode<VarDecl>();
260-
if (Var && VD) {
261-
VarInfo.setImplicit(VD->isImplicit() || VarInfo.isImplicit());
262-
}
263258
TrailingOperandsList::InitOperandsList(getAllOperands().begin(), this,
264259
TypeDependentOperands);
265260
}
@@ -454,8 +449,6 @@ DebugValueInst::DebugValueInst(
454449
getTrailingObjects<SILLocation>(),
455450
getTrailingObjects<const SILDebugScope *>(),
456451
getTrailingObjects<SILDIExprElement>()) {
457-
if (auto *VD = DebugLoc.getLocation().getAsASTNode<VarDecl>())
458-
VarInfo.setImplicit(VD->isImplicit() || VarInfo.isImplicit());
459452
setPoisonRefs(poisonRefs);
460453
if (usesMoveableValueDebugInfo || Operand->getType().isMoveOnly())
461454
setUsesMoveableValueDebugInfo();

lib/SIL/IR/SILPrinter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,8 +1424,6 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
14241424

14251425
if (Var->ArgNo)
14261426
*this << ", argno " << Var->ArgNo;
1427-
if (Var->Implicit)
1428-
*this << ", implicit";
14291427
if (Var->Type) {
14301428
*this << ", type ";
14311429
Var->Type->print(PrintState.OS, PrintState.ASTOptions);

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,8 +1677,6 @@ bool SILParser::parseSILDebugVar(SILDebugVariable &Var) {
16771677
Var.Constant = false;
16781678
} else if (Key == "loc") {
16791679
Var.Constant = false;
1680-
} else if (Key == "implicit") {
1681-
Var.Implicit = true;
16821680
} else {
16831681
P.diagnose(P.Tok, diag::sil_dbg_unknown_key, Key);
16841682
return true;

lib/SILOptimizer/Utils/InstOptUtils.cpp

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,7 @@ bool swift::hasOnlyEndOfScopeOrEndOfLifetimeUses(SILInstruction *inst) {
238238
// Include debug uses only in Onone mode.
239239
if (isDebugUser && inst->getFunction()->getEffectiveOptimizationMode() <=
240240
OptimizationMode::NoOptimization)
241-
if (auto DbgVarInst = DebugVarCarryingInst(user)) {
242-
auto VarInfo = DbgVarInst.getVarInfo();
243-
if (VarInfo && !VarInfo->Implicit)
244-
return false;
245-
}
241+
return false;
246242
}
247243
}
248244
return true;
@@ -1848,8 +1844,8 @@ void swift::salvageDebugInfo(SILInstruction *I) {
18481844
}
18491845
// If a `struct` SIL instruction is "unwrapped" and removed,
18501846
// for instance, in favor of using its enclosed value directly,
1851-
// we need to make sure any of its related `debug_value` instruction
1852-
// is preserved.
1847+
// we need to make sure any of its related `debug_value` instructions
1848+
// are preserved.
18531849
if (auto *STI = dyn_cast<StructInst>(I)) {
18541850
auto STVal = STI->getResult(0);
18551851
llvm::ArrayRef<VarDecl *> FieldDecls =
@@ -1875,6 +1871,31 @@ void swift::salvageDebugInfo(SILInstruction *I) {
18751871
}
18761872
}
18771873
}
1874+
// Similarly, if a `tuple` SIL instruction is "unwrapped" and removed,
1875+
// we need to make sure any of its related `debug_value` instructions
1876+
// are preserved.
1877+
if (auto *TTI = dyn_cast<TupleInst>(I)) {
1878+
auto TTVal = TTI->getResult(0);
1879+
for (Operand *U : getDebugUses(TTVal)) {
1880+
auto *DbgInst = cast<DebugValueInst>(U->getUser());
1881+
auto VarInfo = DbgInst->getVarInfo();
1882+
if (!VarInfo)
1883+
continue;
1884+
TupleType *TT = TTI->getTupleType();
1885+
for (auto i : indices(TT->getElements())) {
1886+
SILDebugVariable NewVarInfo = *VarInfo;
1887+
auto FragDIExpr = SILDebugInfoExpression::createTupleFragment(TT, i);
1888+
NewVarInfo.DIExpr.append(FragDIExpr);
1889+
1890+
if (!NewVarInfo.Type)
1891+
NewVarInfo.Type = TTI->getType();
1892+
1893+
// Create a new debug_value
1894+
SILBuilder(TTI, DbgInst->getDebugScope())
1895+
.createDebugValue(DbgInst->getLoc(), TTI->getElement(i), NewVarInfo);
1896+
}
1897+
}
1898+
}
18781899

18791900
if (auto *IA = dyn_cast<IndexAddrInst>(I)) {
18801901
if (IA->getBase() && IA->getIndex())

test/AutoDiff/compiler_crashers_fixed/58660-conflicting-debug-info-inlining.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ struct MyModel: Differentiable {
4545
@differentiable(reverse)
4646
mutating func member4() {
4747
// CHECK-LABEL: // pullback of MyModel.member4()
48-
// CHECK-NOT: debug_value %{{.*}} : $MyModel.TangentVector, var, name %{{.*}}, argno 1, implicit, scope
48+
// CHECK-NOT: debug_value %{{.*}} : $MyModel.TangentVector, var, name %{{.*}}, argno 1, scope
4949
// CHECK: bb0(%{{.*}} : $_AD__$s4main7MyModelV7member4yyF_bb3__Pred__src_0_wrt_0):
50-
// CHECK: debug_value %{{.*}} : $MyModel.TangentVector, var, name "derivative of 'self' in scope at {{.*}} (scope #1)", implicit, scope
50+
// CHECK: debug_value %{{.*}} : $MyModel.TangentVector, var, name "derivative of 'self' in scope at {{.*}} (scope #1)", scope
5151
// Must be a differentiable type.
5252
var localVar: Float = 0
5353

test/Concurrency/transfernonsendable.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ bb3(%4 : @owned $FakeOptional<NonSendableKlass>):
287287

288288
sil [ossa] @warningIfCallingGetter : $@convention(method) @async (@sil_isolated @guaranteed MyActor) -> () {
289289
bb0(%0 : @guaranteed $MyActor):
290-
debug_value %0 : $MyActor, let, name "self", argno 1, implicit
290+
debug_value %0 : $MyActor, let, name "self", argno 1
291291
hop_to_executor %0 : $MyActor
292292
%3 = class_method %0 : $MyActor, #MyActor.klass!getter : (isolated MyActor) -> () -> NonSendableKlass, $@convention(method) (@sil_isolated @guaranteed MyActor) -> @owned NonSendableKlass
293293
%4 = apply %3(%0) : $@convention(method) (@sil_isolated @guaranteed MyActor) -> @owned NonSendableKlass
@@ -301,7 +301,7 @@ bb0(%0 : @guaranteed $MyActor):
301301

302302
sil [ossa] @assignIntoSetter : $@convention(method) @async (@sil_isolated @guaranteed MyActor) -> () {
303303
bb0(%0 : @guaranteed $MyActor):
304-
debug_value %0 : $MyActor, let, name "self", argno 1, implicit
304+
debug_value %0 : $MyActor, let, name "self", argno 1
305305
hop_to_executor %0 : $MyActor
306306
%4 = function_ref @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
307307
%5 = apply %4() : $@convention(thin) () -> @owned NonSendableKlass

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ bb0(%arg : $Builtin.Word):
16801680

16811681
sil hidden [ossa] @test_unconditional_checked_cast : $@convention(method) (@guaranteed ChildClass) -> @owned ChildClass {
16821682
bb0(%0 : @guaranteed $ChildClass):
1683-
debug_value %0 : $ChildClass, let, name "self", argno 1, implicit
1683+
debug_value %0 : $ChildClass, let, name "self", argno 1
16841684
%2 = copy_value %0 : $ChildClass
16851685
%3 = upcast %2 : $ChildClass to $ParentClass
16861686
%4 = function_ref @copyParentClass : $@convention(thin) (@guaranteed ParentClass) -> @owned ParentClass
@@ -1693,4 +1693,4 @@ bb0(%0 : @guaranteed $ChildClass):
16931693
%11 = copy_value %8 : $ChildClass
16941694
destroy_value %8 : $ChildClass
16951695
return %11 : $ChildClass
1696-
}
1696+
}

test/DebugInfo/catch_error.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ open class Cache<T> {
1010
let value = try creationBlock()
1111
return value
1212
} catch {
13-
// CHECK: debug_value {{.*}} : $any Error, let, name "error", implicit, loc "{{.*}}":[[@LINE-1]]:13, scope [[SCOPE:[0-9]+]]
13+
// CHECK: debug_value {{.*}} : $any Error, let, name "error", loc "{{.*}}":[[@LINE-1]]:13, scope [[SCOPE:[0-9]+]]
1414
// CHECK: alloc_stack $@opened({{.*}}, any Error) Self, loc{{.*}}, scope [[SCOPE]]
1515

1616
_negativeCache.setObject(error, forKey: NSNumber(1))
Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,57 @@
11
// RUN: %target-sil-opt -enable-sil-verify-all -sil-print-debuginfo -diagnostic-constant-propagation %s | %FileCheck %s
2-
// REQUIRES: CPU=arm64 || CPU=x86_64
32

43
sil_stage canonical
54

65
import Builtin
76
import Swift
87
import SwiftShims
98

10-
func foo(x: Int, y: Int) -> Int
11-
12-
sil_scope 1 { loc "file.swift":1:6 parent @foo : $@convention(thin) (Int, Int) -> Int }
9+
sil_scope 1 { loc "file.swift":1:6 parent @foo : $@convention(thin) (Int64, Int64) -> Int64 }
1310

1411
// Test if debug_value got preserved when %16 is removed in favor of directly using %13
1512
// CHECK-LABEL: sil {{.*}} @foo
16-
sil hidden @foo : $@convention(thin) (Int, Int) -> Int {
17-
bb0(%0 : $Int, %1 : $Int):
13+
sil hidden @foo : $@convention(thin) (Int64, Int64) -> Int64 {
14+
bb0(%0 : $Int64, %1 : $Int64):
1815
%4 = integer_literal $Builtin.Int64, 87, loc "file.swift":2:17, scope 1
19-
%9 = struct_extract %0 : $Int, #Int._value, loc "file.swift":2:15, scope 1
16+
%9 = struct_extract %0 : $Int64, #Int64._value, loc "file.swift":2:15, scope 1
2017
%11 = integer_literal $Builtin.Int1, -1, loc "file.swift":2:15, scope 1
2118
// CHECK: %[[ADD:.+]] = builtin "sadd_with_overflow
2219
%12 = builtin "sadd_with_overflow_Int64"(%9 : $Builtin.Int64, %4 : $Builtin.Int64, %11 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1), loc "file.swift":2:15, scope 1
2320
// CHECK: (%[[RESULT:.+]], %{{.*}}) = destructure_tuple %[[ADD]]
2421
(%13, %14) = destructure_tuple %12 : $(Builtin.Int64, Builtin.Int1), loc "file.swift":2:15, scope 1
25-
%16 = struct $Int (%13 : $Builtin.Int64), loc "file.swift":2:15, scope 1
22+
%16 = struct $Int64 (%13 : $Builtin.Int64), loc "file.swift":2:15, scope 1
2623
// In addition to checking if `op_fragment` is generated, we're also checking if "z"'s declared
2724
// source location, as well as `debug_value`'s instruction source location are preserved.
28-
// CHECK: debug_value %[[RESULT]] : $Builtin.Int{{[0-9]+}}, let, name "z"
29-
// CHECK-SAME: type $Int
30-
// CHECK-SAME: expr op_fragment:#Int._value
25+
// CHECK: debug_value %[[RESULT]] : $Builtin.Int64, let, name "z"
26+
// CHECK-SAME: type $Int64
27+
// CHECK-SAME: expr op_fragment:#Int64._value
3128
// CHECK-SAME: loc "file.swift":2:9, scope 1
32-
debug_value %16 : $Int, let, name "z", loc "file.swift":2:9, scope 1
33-
%19 = struct_extract %16 : $Int, #Int._value, loc "file.swift":3:14, scope 1
34-
%20 = struct_extract %1 : $Int, #Int._value, loc "file.swift":3:14, scope 1
29+
debug_value %16 : $Int64, let, name "z", loc "file.swift":2:9, scope 1
30+
%19 = struct_extract %16 : $Int64, #Int64._value, loc "file.swift":3:14, scope 1
31+
%20 = struct_extract %1 : $Int64, #Int64._value, loc "file.swift":3:14, scope 1
3532
%21 = integer_literal $Builtin.Int1, -1, loc "file.swift":3:14, scope 1
3633
%22 = builtin "sadd_with_overflow_Int64"(%19 : $Builtin.Int64, %20 : $Builtin.Int64, %21 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1), loc "file.swift":3:14, scope 1
3734
(%23, %24) = destructure_tuple %22 : $(Builtin.Int64, Builtin.Int1), loc "file.swift":3:14, scope 1
38-
%26 = struct $Int (%23 : $Builtin.Int64), loc "file.swift":3:14, scope 1
39-
return %26 : $Int, loc "file.swift":3:5, scope 1
35+
%26 = struct $Int64 (%23 : $Builtin.Int64), loc "file.swift":3:14, scope 1
36+
return %26 : $Int64, loc "file.swift":3:5, scope 1
4037
} // end sil function 'foo'
4138

39+
sil_scope 2 { loc "file.swift":1:6 parent @bar : $@convention(thin) (Int64, Int64) -> Int64 }
40+
41+
// Test if debug_value got preserved when %5 is folded into %0, and %3 removed
42+
// CHECK-LABEL: sil {{.*}} @bar
43+
sil hidden @bar : $@convention(thin) (Int64, Int64) -> Int64 {
44+
bb0(%0 : $Int64, %1 : $Int64):
45+
%3 = tuple $(low: Int64, high: Int64) (%0, %1), loc "file.swift":14:5, scope 2
46+
// CHECK: debug_value %0 : $Int64, let, name "newValue"
47+
// CHECK-SAME: type $(low: Int64, high: Int64)
48+
// CHECK-SAME: expr op_tuple_fragment:$(low: Int64, high: Int64):0
49+
// CHECK-SAME: "file.swift":14:5, scope 2
50+
// CHECK: debug_value %1 : $Int64, let, name "newValue"
51+
// CHECK-SAME: type $(low: Int64, high: Int64)
52+
// CHECK-SAME: expr op_tuple_fragment:$(low: Int64, high: Int64):1
53+
// CHECK-SAME: "file.swift":14:5, scope 2
54+
debug_value %3 : $(low: Int64, high: Int64), let, name "newValue", argno 1, loc "file.swift":14:5, scope 2
55+
(%5, %6) = destructure_tuple %3 : $(low: Int64, high: Int64), loc "file.swift":15:5, scope 2
56+
return %5 : $Int64, loc "file.swift":15:5, scope 2
57+
} // end sil function 'bar'

test/DebugInfo/debug_value_addr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func use<T>(_ t : T) {}
2828
// CHECK-SIL: sil hidden @$s16debug_value_addr11GenericSelfV1xACyxGx_tcfC : $@convention(method) <T> (@in T, @thin GenericSelf<T>.Type) -> GenericSelf<T> {
2929
// CHECK-SIL: bb0(%0 : $*T, %1 : $@thin GenericSelf<T>.Type):
3030
//
31-
// CHECK-SIL-NEXT: alloc_stack [var_decl] $GenericSelf<T>, var, name "self", implicit, loc {{.*}}
31+
// CHECK-SIL-NEXT: alloc_stack [var_decl] $GenericSelf<T>, var, name "self", loc {{.*}}
3232
// CHECK-SIL-NEXT: debug_value %0 : $*T, let, name "x", argno 1, expr op_deref, loc {{.*}}
3333
struct GenericSelf<T> {
3434
init(x: T) {

test/DebugInfo/implicit_variable.swift

Lines changed: 0 additions & 12 deletions
This file was deleted.

test/DebugInfo/nested_salvage_struct.sil

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sil private @pop : $@convention(method) (UInt64, Wrapper) -> Wrapper {
1919
[global: ]
2020
bb0(%0 : $UInt64, %1 : $Wrapper):
2121
debug_value %0 : $UInt64, let, name "numBits", argno 1, scope 3
22-
debug_value %1 : $Wrapper, let, name "self", argno 2, implicit, scope 3
22+
debug_value %1 : $Wrapper, let, name "self", argno 2, scope 3
2323
%4 = struct_extract %1 : $Wrapper, #Wrapper.bytes, scope 3
2424
%5 = struct_extract %4 : $UInt64, #UInt64._value, scope 3
2525
%6 = struct_extract %0 : $UInt64, #UInt64._value, scope 3
@@ -46,15 +46,15 @@ sil hidden @maker : $@convention(method) (UInt64, @thin Wrapper.Type) -> Wrapper
4646
bb0(%0 : $UInt64, %1 : $@thin Wrapper.Type):
4747
// CHECK: debug_value %0 : $UInt64, let, name "bits", argno 1
4848
debug_value %0 : $UInt64, let, name "bits", argno 1, scope 7
49-
// CHECK: debug_value %1 : $@thin Wrapper.Type, let, name "self", argno 2, implicit
50-
debug_value %1 : $@thin Wrapper.Type, let, name "self", argno 2, implicit, scope 7
49+
// CHECK: debug_value %1 : $@thin Wrapper.Type, let, name "self", argno 2
50+
debug_value %1 : $@thin Wrapper.Type, let, name "self", argno 2, scope 7
5151
%4 = integer_literal $Builtin.Int64, 3735928559, scope 7
5252
%5 = struct $UInt64 (%4 : $Builtin.Int64), scope 7
5353
%6 = struct $Wrapper (%5 : $UInt64), loc * "e.swift":3:8
5454
// CHECK-DAG: debug_value %0 : $UInt64, let, name "numBits", argno 1
5555
debug_value %0 : $UInt64, let, name "numBits", argno 1, scope 11
56-
// CHECK-DAG: debug_value %{{.*}} : $Builtin.Int64, let, name "self", {{.*}}, implicit, type $Wrapper, expr op_fragment:#Wrapper.bytes:op_fragment:#UInt64._value
57-
debug_value %6 : $Wrapper, let, name "self", argno 2, implicit, scope 11
56+
// CHECK-DAG: debug_value %{{.*}} : $Builtin.Int64, let, name "self", {{.*}}, type $Wrapper, expr op_fragment:#Wrapper.bytes:op_fragment:#UInt64._value
57+
debug_value %6 : $Wrapper, let, name "self", argno 2, scope 11
5858
%9 = struct_extract %6 : $Wrapper, #Wrapper.bytes, scope 11
5959
%10 = struct_extract %9 : $UInt64, #UInt64._value, scope 11
6060
%11 = struct_extract %0 : $UInt64, #UInt64._value, scope 11
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
2+
3+
// This is a test for rdar://125939953 (Implicit variables are removed at Onone)
4+
5+
struct UInt128 {
6+
var low: UInt64
7+
var high: UInt64
8+
9+
var components: (low: UInt64, high: UInt64) {
10+
get {
11+
return (low, high)
12+
}
13+
// CHECK-LABEL: define {{.+}} @"$s4main7UInt128V10componentss6UInt64V3low_AF4hightvs"
14+
set {
15+
// CHECK: call void @llvm.dbg.declare(metadata ptr {{.+}}, metadata ![[NEW_VALUE:[0-9]+]]
16+
(self.low, self.high) = (newValue.high, newValue.low)
17+
}
18+
}
19+
}
20+
21+
//CHECK: ![[NEW_VALUE]] = !DILocalVariable(name: "newValue", arg: 1

0 commit comments

Comments
 (0)