Skip to content

Commit 454be38

Browse files
committed
WIP
1 parent f8c46d8 commit 454be38

33 files changed

+177
-136
lines changed

include/swift/AST/ASTScope.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,13 @@ class ASTScopeImpl : public ASTAllocated<ASTScopeImpl> {
280280

281281
/// Scopes that cannot bind variables may set this to true to create more
282282
/// compact scope tree in the debug info.
283-
virtual bool ignoreInDebugInfo() const { return false; }
283+
virtual bool ignoreInDebugInfo() const {
284+
// Collapse BraceStmtScopes whose parent is a .*BodyScope.
285+
if (auto parent = getParent().getPtrOrNull())
286+
return parent->getSourceRangeOfThisASTNode() ==
287+
getSourceRangeOfThisASTNode();
288+
return false;
289+
}
284290

285291
#pragma mark - - lookup- starting point
286292
private:
@@ -964,7 +970,6 @@ class PatternEntryInitializerScope final : public AbstractPatternEntryScope {
964970
std::string getClassName() const override;
965971
SourceRange
966972
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
967-
bool ignoreInDebugInfo() const override { return true; }
968973

969974
protected:
970975
bool lookupLocalsOrMembers(DeclConsumer) const override;

include/swift/SIL/SILBuilder.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ class SILBuilder {
258258
}
259259

260260
/// Convenience function for building a SILDebugLocation.
261-
virtual SILDebugLocation getSILDebugLocation(SILLocation Loc) {
261+
virtual SILDebugLocation
262+
getSILDebugLocation(SILLocation Loc, bool ForMetaInstruction = false) {
262263
// FIXME: Audit all uses and enable this assertion.
263264
// assert(getCurrentDebugScope() && "no debug scope");
264265
auto Scope = getCurrentDebugScope();
@@ -464,7 +465,7 @@ class SILBuilder {
464465
"location is a VarDecl, but SILDebugVariable is empty");
465466
#endif
466467
return insert(AllocStackInst::create(
467-
getSILDebugLocation(Loc), elementType, getFunction(),
468+
getSILDebugLocation(Loc, true), elementType, getFunction(),
468469
substituteAnonymousArgs(Name, Var, Loc), hasDynamicLifetime, isLexical,
469470
wasMoved));
470471
}
@@ -525,10 +526,10 @@ class SILBuilder {
525526
assert((skipVarDeclAssert ||
526527
!dyn_cast_or_null<VarDecl>(Loc.getAsASTNode<Decl>()) || Var) &&
527528
"location is a VarDecl, but SILDebugVariable is empty");
528-
return insert(AllocBoxInst::create(getSILDebugLocation(Loc), BoxType, *F,
529-
substituteAnonymousArgs(Name, Var, Loc),
530-
hasDynamicLifetime, reflection,
531-
usesMoveableValueDebugInfo));
529+
return insert(AllocBoxInst::create(
530+
getSILDebugLocation(Loc, true), BoxType, *F,
531+
substituteAnonymousArgs(Name, Var, Loc), hasDynamicLifetime, reflection,
532+
usesMoveableValueDebugInfo));
532533
}
533534

534535
AllocExistentialBoxInst *

include/swift/SIL/SILLocation.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,11 @@ class RegularLocation : public SILLocation {
501501
RegularLocation(Expr *E) : SILLocation(ASTNodeTy(E), RegularKind) {}
502502
RegularLocation(Decl *D) : SILLocation(ASTNodeTy(D), RegularKind) {}
503503
RegularLocation(Pattern *P) : SILLocation(ASTNodeTy(P), RegularKind) {}
504-
/// Used for bindings that nedd to be injected into a different scope than
504+
/// Used for bindings that need to be injected into a different scope than
505505
/// that of their VarDecls.
506506
RegularLocation(Decl *D, SILLocation LocForDebugging, SILModule &Module);
507+
/// Used for switch statements to avoid line table entries for trivial
508+
/// unsuccessful case comparisons.
507509
RegularLocation(Stmt *S, Pattern *P, SILModule &Module);
508510
RegularLocation(SILLocation ForDebuggingOrDiagnosticsOnly, SILModule &Module,
509511
bool isForDebugOnly = true);

lib/IRGen/AllocStackHoisting.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ void moveAllocStackToBeginningOfBlock(
155155
if (haveMovedElt) {
156156
if (auto varInfo = AS->getVarInfo()) {
157157
SILBuilderWithScope Builder(AS);
158+
// SILBuilderWithScope skips over meta instructions when picking a scope.
159+
Builder.setCurrentDebugScope(AS->getDebugScope());
158160
auto *DVI = Builder.createDebugValue(AS->getLoc(), AS, *varInfo);
159161
DVI->setUsesMoveableValueDebugInfo();
160162
DebugValueToBreakBlocksAt.push_back(DVI);

lib/SIL/IR/SILBuilder.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,10 @@ DebugValueInst *SILBuilder::createDebugValue(SILLocation Loc, SILValue src,
645645

646646
// Debug location overrides cannot apply to debug value instructions.
647647
DebugLocOverrideRAII LocOverride{*this, None};
648-
return insert(DebugValueInst::create(
649-
getSILDebugLocation(Loc), src, getModule(),
650-
*substituteAnonymousArgs(Name, Var, Loc), poisonRefs, operandWasMoved,
651-
trace));
648+
return insert(DebugValueInst::create(getSILDebugLocation(Loc, true), src,
649+
getModule(),
650+
*substituteAnonymousArgs(Name, Var, Loc),
651+
poisonRefs, operandWasMoved, trace));
652652
}
653653

654654
DebugValueInst *SILBuilder::createDebugValueAddr(SILLocation Loc, SILValue src,
@@ -662,7 +662,7 @@ DebugValueInst *SILBuilder::createDebugValueAddr(SILLocation Loc, SILValue src,
662662
// Debug location overrides cannot apply to debug addr instructions.
663663
DebugLocOverrideRAII LocOverride{*this, None};
664664
return insert(DebugValueInst::createAddr(
665-
getSILDebugLocation(Loc), src, getModule(),
665+
getSILDebugLocation(Loc, true), src, getModule(),
666666
*substituteAnonymousArgs(Name, Var, Loc), wasMoved, trace));
667667
}
668668

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6236,6 +6236,11 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
62366236
if (!VerifyDIHoles)
62376237
return;
62386238

6239+
// These transforms don't set everything they move to implicit.
6240+
if (M->getASTContext().LangOpts.Playground ||
6241+
M->getASTContext().LangOpts.PCMacro)
6242+
return;
6243+
62396244
// This check only makes sense at -Onone. Optimizations,
62406245
// e.g. inlining, can move scopes around.
62416246
llvm::DenseSet<const SILDebugScope *> AlreadySeenScopes;

lib/SILGen/SILGenBuilder.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,20 @@ SILGenBuilder::SILGenBuilder(SILGenFunction &SGF)
4141
: SILBuilder(SGF.F), SGF(SGF) {
4242
#ifndef NDEBUG
4343
EnableDIHoleVerification = true;
44+
if (SGF.F.getASTContext().LangOpts.Playground ||
45+
SGF.F.getASTContext().LangOpts.PCMacro)
46+
EnableDIHoleVerification = false;
4447
#endif
4548
}
4649

4750
SILGenBuilder::SILGenBuilder(SILGenFunction &SGF, SILBasicBlock *insertBB,
4851
SmallVectorImpl<SILInstruction *> *insertedInsts)
49-
: SILBuilder(insertBB, insertedInsts), SGF(SGF) {}
52+
: SILBuilder(insertBB, insertedInsts), SGF(SGF) {
5053
#ifndef NDEBUG
5154
EnableDIHoleVerification = true;
55+
if (SGF.F.getASTContext().LangOpts.Playground ||
56+
SGF.F.getASTContext().LangOpts.PCMacro)
57+
EnableDIHoleVerification = false;
5258
#endif
5359

5460
auto FirstInsn = insertBB->begin();
@@ -61,14 +67,19 @@ SILGenBuilder::SILGenBuilder(SILGenFunction &SGF, SILBasicBlock *insertBB,
6167
: SILBuilder(insertBB, insertInst), SGF(SGF) {
6268
#ifndef NDEBUG
6369
EnableDIHoleVerification = true;
70+
if (SGF.F.getASTContext().LangOpts.Playground ||
71+
SGF.F.getASTContext().LangOpts.PCMacro)
72+
EnableDIHoleVerification = false;
6473
#endif
6574

6675
if (insertInst != insertBB->end())
6776
setCurrentDebugScope(insertInst->getDebugScope());
6877
}
6978

70-
SILDebugLocation SILGenBuilder::getSILDebugLocation(SILLocation Loc) {
71-
return SGF.getSILDebugLocation(*this, Loc);
79+
SILDebugLocation SILGenBuilder::getSILDebugLocation(SILLocation Loc,
80+
bool ForMetaInstruction) {
81+
return SGF.getSILDebugLocation(*this, Loc, getCurrentDebugLocOverride(),
82+
ForMetaInstruction);
7283
}
7384

7485
//===----------------------------------------------------------------------===//

lib/SILGen/SILGenBuilder.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ class SILGenBuilder : public SILBuilder {
5757
/// Create a new builder, inheriting the given builder's context and debug
5858
/// scope.
5959
SILGenBuilder(SILGenBuilder &builder, SILBasicBlock *insertBB)
60-
: SILBuilder(insertBB, builder.getCurrentDebugScope(),
61-
builder.getBuilderContext()),
60+
: SILBuilder(insertBB, builder.getBuilderContext(),
61+
builder.getCurrentDebugScope()),
6262
SGF(builder.SGF) {
6363
#ifndef NDEBUG
6464
EnableDIHoleVerification = true;
@@ -68,7 +68,9 @@ class SILGenBuilder : public SILBuilder {
6868
SILGenModule &getSILGenModule() const;
6969
SILGenFunction &getSILGenFunction() const { return SGF; }
7070

71-
SILDebugLocation getSILDebugLocation(SILLocation Loc) override;
71+
SILDebugLocation
72+
getSILDebugLocation(SILLocation Loc,
73+
bool ForMetaInstruction = false) override;
7274

7375
using SILBuilder::createInitExistentialValue;
7476
ManagedValue

lib/SILGen/SILGenDecl.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,8 @@ class LetValueInitialization : public Initialization {
843843
if (!EmitDebugValueOnInit)
844844
return;
845845

846-
// Use the scope from loc and diagnostic location from vd.
847-
RegularLocation PrologueLoc(vd, loc, SGF.getModule());
846+
// // Use the scope from loc and diagnostic location from vd.
847+
RegularLocation PrologueLoc(vd);//, loc, SGF.getModule());
848848
PrologueLoc.markAsPrologue();
849849
SILDebugVariable DbgVar(vd->getName().str(), vd->isLet(), /*ArgNo=*/0);
850850
SGF.B.emitDebugDescription(PrologueLoc, value, DbgVar);
@@ -1439,10 +1439,12 @@ SILGenFunction::emitInitializationForVarDecl(VarDecl *vd, bool forceImmutable,
14391439
InitializationPtr Result;
14401440
if (!vd->getDeclContext()->isLocalContext()) {
14411441
auto *silG = SGM.getSILGlobalVariable(vd, NotForDefinition);
1442-
B.createAllocGlobal(vd, silG);
1443-
SILValue addr = B.createGlobalAddr(vd, silG);
1442+
RegularLocation loc(vd);
1443+
loc.markAutoGenerated();
1444+
B.createAllocGlobal(loc, silG);
1445+
SILValue addr = B.createGlobalAddr(loc, silG);
14441446
if (isUninitialized)
1445-
addr = B.createMarkUninitializedVar(vd, addr);
1447+
addr = B.createMarkUninitializedVar(loc, addr);
14461448

14471449
VarLocs[vd] = SILGenFunction::VarLoc::get(addr);
14481450
Result = InitializationPtr(new KnownAddressInitialization(addr));

lib/SILGen/SILGenFunction.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,21 @@ DeclName SILGenModule::getMagicFunctionName(SILDeclRef ref) {
167167
llvm_unreachable("Unhandled SILDeclRefKind in switch.");
168168
}
169169

170-
SILDebugLocation SILGenFunction::getSILDebugLocation(SILBuilder &B,
171-
SILLocation Loc) {
170+
SILDebugLocation
171+
SILGenFunction::getSILDebugLocation(SILBuilder &B, SILLocation Loc,
172+
Optional<SILLocation> CurDebugLocOverride,
173+
bool ForMetaInstruction) {
172174
const SILDebugScope *Scope = B.getCurrentDebugScope();
173175
if (!Scope)
174176
Scope = F.getDebugScope();
175177
if (auto *SILScope = getScopeOrNull(Loc))
176178
Scope = SILScope;
177-
B.setCurrentDebugScope(Scope);
178-
return SILDebugLocation(Loc, Scope);
179+
// Metainstructions such as a debug_value may break the flow of scopes and
180+
// should not change the state of the builder.
181+
if (!ForMetaInstruction)
182+
B.setCurrentDebugScope(Scope);
183+
auto overriddenLoc = CurDebugLocOverride ? *CurDebugLocOverride : Loc;
184+
return SILDebugLocation(overriddenLoc, Scope);
179185
}
180186

181187
const SILDebugScope *SILGenFunction::getScopeOrNull(SILLocation Loc) {
@@ -187,7 +193,7 @@ const SILDebugScope *SILGenFunction::getScopeOrNull(SILLocation Loc) {
187193
Loc.isAutoGenerated())
188194
return nullptr;
189195

190-
SourceLoc SLoc = Loc.getSourceLocForDebugging();
196+
SourceLoc SLoc = Loc.getSourceLoc();//ForDebugging();
191197
if (!SF || LastSourceLoc == SLoc)
192198
return nullptr;
193199
return getOrCreateScope(SLoc);
@@ -325,7 +331,7 @@ SILGenFunction::getOrCreateScope(const ast_scope::ASTScopeImpl *ASTScope)
325331
if (It != ScopeMap.end())
326332
return It->second;
327333

328-
// ASTScope->print(llvm::errs(), 0, false, false);
334+
// ASTScope->print(llvm::errs(), 0, false, false);
329335

330336
SILDebugScope *SILScope = nullptr;
331337

lib/SILGen/SILGenFunction.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,10 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
712712
StringRef getMagicFilePathString(SourceLoc loc);
713713
StringRef getMagicFunctionString();
714714

715-
SILDebugLocation getSILDebugLocation(SILBuilder &B, SILLocation Loc);
715+
SILDebugLocation
716+
getSILDebugLocation(SILBuilder &B, SILLocation Loc,
717+
Optional<SILLocation> CurDebugLocOverride,
718+
bool ForMetaInstruction);
716719

717720
const SILDebugScope *getScopeOrNull(SILLocation Loc);
718721

lib/SILGen/SILGenGlobalVariable.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ ManagedValue
7070
SILGenFunction::emitGlobalVariableRef(SILLocation loc, VarDecl *var,
7171
Optional<ActorIsolation> actorIso) {
7272
assert(!VarLocs.count(var));
73-
7473
if (var->isLazilyInitializedGlobal()) {
7574
// Call the global accessor to get the variable's address.
7675
SILFunction *accessorFn = SGM.getFunction(

lib/SILGen/SILGenPattern.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ void PatternMatchEmission::emitEnumElementObjectDispatch(
18951895
// Collect the cases and specialized rows.
18961896
CaseBlocks blocks{SGF, rows, sourceType, SGF.B.getInsertionBB()};
18971897

1898-
RegularLocation loc(PatternMatchStmt);// FIXME, rows[0].Pattern, SGF.SGM.M);
1898+
RegularLocation loc(PatternMatchStmt, rows[0].Pattern, SGF.SGM.M);
18991899
SILValue srcValue = src.getFinalManagedValue().forward(SGF);
19001900
auto *sei = SGF.B.createSwitchEnum(loc, srcValue, blocks.getDefaultBlock(),
19011901
blocks.getCaseBlocks(), blocks.getCounts(),
@@ -2025,7 +2025,7 @@ void PatternMatchEmission::emitEnumElementDispatch(
20252025
const SpecializationHandler &handleCase, const FailureHandler &outerFailure,
20262026
ProfileCounter defaultCaseCount) {
20272027
// Why do we need to do this here (I just cargo-culted this).
2028-
RegularLocation loc(PatternMatchStmt);//FIXME, rows[0].Pattern, SGF.SGM.M);
2028+
RegularLocation loc(PatternMatchStmt, rows[0].Pattern, SGF.SGM.M);
20292029

20302030
// If our source is an address that is loadable, perform a load_borrow.
20312031
if (src.getType().isAddress() && src.getType().isLoadable(SGF.F)) {
@@ -2336,7 +2336,7 @@ emitBoolDispatch(ArrayRef<RowToSpecialize> rows, ConsumableManagedValue src,
23362336
defaultBB = SGF.createBasicBlockAfter(curBB);
23372337

23382338
// Emit the switch_value
2339-
RegularLocation loc(PatternMatchStmt);//FIXME, rows[0].Pattern, SGF.SGM.M);
2339+
RegularLocation loc(PatternMatchStmt, rows[0].Pattern, SGF.SGM.M);
23402340
SILValue srcValue = src.getFinalManagedValue().forward(SGF);
23412341

23422342
// Extract the i1 from the Bool struct.

test/Backtracing/Crash.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ struct Crash {
155155
// OPTIMIZED-NEXT: 3 [inlined] 0x{{[0-9a-f]+}} level2() in CrashOpt at {{.*}}/Crash.swift:28:3
156156
// OPTIMIZED-NEXT: 4 [inlined] 0x{{[0-9a-f]+}} level1() in CrashOpt at {{.*}}/Crash.swift:24:3
157157
// OPTIMIZED-NEXT: 5 [inlined] 0x{{[0-9a-f]+}} static Crash.main() in CrashOpt at {{.*}}/Crash.swift:48:5
158-
// OPTIMIZED-NEXT: 6 [inlined] [system] 0x{{[0-9a-f]+}} static Crash.$main() in CrashOpt at {{.*}}/Crash.swift:45:1
158+
// OPTIMIZED-NEXT: 6 [inlined] [system] 0x{{[0-9a-f]+}} static Crash.$main() in CrashOpt at {{.*}}/<compiler-generated>
159159
// OPTIMIZED-NEXT: 7 [system] 0x{{[0-9a-f]+}} main + {{[0-9]+}} in CrashOpt at {{.*}}/Crash.swift
160160

161161
// OPTIMIZED: Registers:

test/DebugInfo/for-scope.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@ func sink<T>(_ t: T) {}
44

55
public func f(_ xs: [String?]) {
66
for x in xs {
7-
let x = x
7+
let x = x!
88
sink(x)
99
}
1010
}
1111
// CHECK: sil_scope [[F:[0-9]+]] { loc "{{.*}}":5:13 parent @$s1a1fyySaySSSgGF
1212
// CHECK: sil_scope [[S0:[0-9]+]] { loc "{{.*}}":6:3 parent [[F]] }
13-
// CHECK: sil_scope [[S1:[0-9]+]] { loc "{{.*}}":6:15 parent [[S0]] }
14-
// CHECK: sil_scope [[S2:[0-9]+]] { loc "{{.*}}":6:15 parent [[S1]] }
15-
// CHECK: sil_scope [[S3:[0-9]+]] { loc "{{.*}}":7:9 parent [[S2]] }
13+
// CHECK: sil_scope [[S3:[0-9]+]] { loc "{{.*}}":7:9 parent [[S0]] }
14+
// CHECK: sil_scope [[S4:[0-9]+]] { loc "{{.*}}":7:13 parent [[S3]] }
1615

17-
// CHECK: debug_value %[[X:.*]] : $Optional<String>, let, name "x", {{.*}}, scope [[S2]]
18-
// CHECK: retain_value %[[X]] : $Optional<String>, {{.*}}, scope [[S2]]
19-
// CHECK: debug_value %[[X]] : $Optional<String>, let, name "x", {{.*}}, scope [[S2]]
20-
// FIXME: Where is the extracted "x: String"?
21-
// CHECK: release_value %[[X]] : $Optional<String>, {{.*}}, scope [[S3]]
16+
// CHECK: debug_value %[[X:.*]] : $Optional<String>, let, name "x", {{.*}}, scope [[S0]]
17+
// CHECK: retain_value %[[X]] : $Optional<String>, {{.*}}, scope [[S4]]
18+
// CHECK: debug_value %[[X1:[0-9]+]] : $String, let, name "x", {{.*}}, scope [[S3]]
19+
// CHECK: release_value %[[X1]] : $String, {{.*}}, scope [[S3]]
2220
// CHECK: release_value %[[X]] : $Optional<String>, {{.*}}, scope [[S3]]

test/DebugInfo/guard-let-scope.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ func f(c: AnyObject?) {
77
// CHECK: sil_scope [[S2:[0-9]+]] { {{.*}} parent [[S1]] }
88
// CHECK: sil_scope [[S3:[0-9]+]] { loc "{{.*}}":5:3 parent [[S2]] }
99
// CHECK: sil_scope [[S4:[0-9]+]] { loc "{{.*}}":5:17 parent [[S3]] }
10-
// CHECK: debug_value %{{.*}} : $Optional<AnyObject>, let, name "x"{{.*}} scope [[S1]]
10+
// CHECK: debug_value %{{.*}} : $Optional<AnyObject>, let, name "x"{{.*}} scope [[S2]]
1111
// CHECK: debug_value %{{.*}} : $AnyObject, let, name "x", {{.*}} scope [[S3]]
1212
fatalError(".")
1313
}

test/DebugInfo/guard-let-scope2.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public func f(x: String?) throws {
1919
// CHECK: sil_scope [[S1:[0-9]+]] { {{.*}} parent @{{.*}}1f
2020
// CHECK: sil_scope [[S2:[0-9]+]] { {{.*}} parent [[S1]] }
2121
// CHECK: sil_scope [[S3:[0-9]+]] { {{.*}} parent [[S2]] }
22-
// CHECK: alloc_stack {{.*}} $SomeObject, let, name "s", {{.*}} scope [[S3]]
22+
// CHECK: sil_scope [[S4:[0-9]+]] { {{.*}} parent [[S2]] }
23+
// CHECK: alloc_stack {{.*}} $SomeObject, let, name "s", {{.*}} scope [[S4]]
2324
guard let s = s else {
2425
assert(false)
2526
return

test/DebugInfo/if.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ func yieldValue() -> Int64? { return 23 }
44

55
// Verify that variables bound in the while statements are in distinct scopes.
66
if let val = yieldValue() {
7-
// CHECK: !DILocalVariable(name: "val", scope: ![[SCOPE1:[0-9]+]]
8-
// CHECK: ![[SCOPE1]] = distinct !DILexicalBlock(scope: ![[MAIN:[0-9]+]]
7+
// CHECK-DAG: !DILocalVariable(name: "val", scope: ![[SCOPE1:[0-9]+]]
8+
// CHECK-DAG: ![[SCOPE1]] = distinct !DILexicalBlock(scope: ![[MAIN:[0-9]+]]
99
}
1010
if let val = yieldValue() {
11-
// CHECK: !DILocalVariable(name: "val", scope: ![[SCOPE2:[0-9]+]]
12-
// CHECK: ![[SCOPE2]] = distinct !DILexicalBlock(scope: ![[MAIN2:[0-9]+]]
11+
// CHECK-DAG: !DILocalVariable(name: "val", scope: ![[SCOPE2:[0-9]+]]
12+
// CHECK-DAG: ![[SCOPE2]] = distinct !DILexicalBlock(scope: ![[MAIN2:[0-9]+]]
1313
}

test/DebugInfo/inlinescopes.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ func transparent(_ x: Int64) -> Int64 { return noinline(x) }
2424

2525
@inline(__always)
2626
func inlined(_ x: Int64) -> Int64 {
27-
// CHECK-DAG: ![[CALL]] = !DILocation(line: [[@LINE+3]], column: {{.*}}, scope: ![[INLINED:.*]], inlinedAt: ![[INLINEDAT:.*]])
28-
// Check if the inlined and removed function still has the correct linkage name.
29-
// CHECK-DAG: ![[INLINED]] = distinct !DISubprogram(name: "inlined", linkageName: "$s4main7inlinedys5Int64VADF"
3027
let result = transparent(x)
28+
// CHECK-DAG: ![[CALL]] = !DILocation(line: [[@LINE-1]], column: {{.*}}, scope: ![[INLINED1:.*]], inlinedAt: ![[INLINEDAT:.*]])
29+
// CHECK-DAG: ![[INLINEDAT]] = !DILocation({{.*}}scope: ![[INLINEDAT1:[0-9]+]]
30+
// CHECK-DAG: ![[INLINED1]] = distinct !DILexicalBlock(scope: ![[INLINED2:[0-9]+]]
31+
// CHECK-DAG: ![[INLINED2]] = distinct !DILexicalBlock(scope: ![[INLINED3:[0-9]+]]
32+
// Check if the inlined and removed function still has the correct linkage name.
33+
// CHECK-DAG: ![[INLINED3]] = distinct !DISubprogram(name: "inlined", linkageName: "$s4main7inlinedys5Int64VADF"
3134
// TRANSPARENT-CHECK-NOT: !DISubprogram(name: "transparent"
3235
return result
3336
}

test/DebugInfo/linetable-codeview.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func foo() {
7373
// CHECK: call void @llvm.dbg.declare(metadata %TSa* %[[MYARRAY]],
7474
// CHECK-SAME: !dbg ![[ARRAY:[0-9]+]]
7575
// CHECK: call swiftcc { {{.*}} } @"${{.*}}_allocateUninitializedArray{{.*}}"
76-
// CHECK-SAME: !dbg ![[ARRAY]]
76+
// CHECK-SAME: !dbg ![[ARRAY_ALLOC:[0-9]+]]
7777
// CHECK: ret void
7878

7979
// CHECK-DAG: ![[ADD]] = !DILocation(line: 6, scope:
@@ -94,3 +94,4 @@ func foo() {
9494
// CHECK-DAG: ![[CASE]] = !DILocation(line: 24, scope:
9595
// CHECK-DAG: ![[DEFAULTCLEANUP]] = !DILocation(line: 27, scope:
9696
// CHECK-DAG: ![[ARRAY]] = !DILocation(line: 31, scope:
97+
// CHECK-DAG: ![[ARRAY_ALLOC]] = !DILocation(line: 31, scope:

0 commit comments

Comments
 (0)