Skip to content

[DebugInfo] Fix dynamic self debug loc #71888

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/GenHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,9 @@ llvm::Value *IRGenFunction::getDynamicSelfMetadata() {
cast<llvm::Instruction>(SelfValue)))
: CurFn->getEntryBlock().begin();
Builder.SetInsertPoint(&CurFn->getEntryBlock(), insertPt);
// Do not inherit the debug location of this insertion point, it could be
// anything (e.g. the location of a dbg.declare).
Builder.SetCurrentDebugLocation(llvm::DebugLoc());

switch (SelfKind) {
case SwiftMetatype:
Expand Down
24 changes: 24 additions & 0 deletions test/DebugInfo/DynamicSelfLocation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// RUN: %target-swift-frontend -disable-availability-checking %s -emit-irgen -g -o - | %FileCheck %s
// REQUIRES: concurrency

func some_func(_: () -> Void) async {}

class Model {
static func SelfFunction() {}

func foo() async -> () {
let somevar = 10

return await some_func {
Self.SelfFunction()
}
}
}

// Check that the load of DynamicSelf in foo does not have any debug information, as
// this is hoisted to the start of the function.
// CHECK: define {{.*}} @"$s19DynamicSelfLocation5ModelC3fooyyYaF"({{.*}}, ptr swiftself %[[Self:.*]])
// CHECK-NEXT: entry:
// CHECK-NEXT: %2 = load ptr, ptr %[[Self]]
// CHECK-NOT: !dbg
// CHECK-NEXT: call void @llvm.dbg.declare