-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[Coroutines] Fix debug info scoping for nested structs in coroutine frames #147622
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
Open
grigorypas
wants to merge
2
commits into
llvm:main
Choose a base branch
from
grigorypas:coro_split_dbg_nested_struct
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
llvm/test/Transforms/Coroutines/coro-split-dbg-nested-struct.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
; RUN: opt < %s -passes='cgscc(coro-split)' -S | FileCheck %s | ||
|
||
; Test that nested structs in coroutine frames have correct debug info scoping. | ||
|
||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
grigorypas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
; Minimal nested struct types that trigger the scoping issue | ||
vogelsgesang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
%"struct.Inner" = type { i32, ptr } | ||
%"struct.Outer" = type { %"struct.Inner", i64 } | ||
%"class.Promise" = type { %"struct.Outer" } | ||
|
||
define void @test_coro_function() presplitcoroutine !dbg !10 { | ||
entry: | ||
%__promise = alloca %"class.Promise", align 8 | ||
%0 = call token @llvm.coro.id(i32 0, ptr %__promise, ptr null, ptr null) | ||
%1 = call ptr @llvm.coro.begin(token %0, ptr null) | ||
%2 = call token @llvm.coro.save(ptr null) | ||
ret void | ||
} | ||
|
||
; The test passes if the debug info is generated without crashing | ||
; CHECK: define void @test_coro_function() | ||
|
||
; Check that frame debug info is generated | ||
; CHECK: ![[FRAME_TYPE:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{{.*}}.coro_frame_ty" | ||
vogelsgesang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
; Key validation: Check that nested structs have the correct scope hierarchy | ||
; 1. Promise should be scoped to the frame | ||
; CHECK: ![[PROMISE:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "class_Promise", scope: ![[FRAME_TYPE]] | ||
|
||
; 2. Outer should be scoped to Promise (not the frame!) | ||
; CHECK: ![[OUTER:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "struct_Outer", scope: ![[PROMISE]] | ||
|
||
; 3. Inner should be scoped to Outer (proper nesting) | ||
; CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "struct_Inner", scope: ![[OUTER]] | ||
|
||
declare token @llvm.coro.id(i32, ptr readnone, ptr readonly, ptr) | ||
declare ptr @llvm.coro.begin(token, ptr writeonly) | ||
declare token @llvm.coro.save(ptr) | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!9} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) | ||
!1 = !DIFile(filename: "test.cpp", directory: ".") | ||
!9 = !{i32 2, !"Debug Info Version", i32 3} | ||
!10 = distinct !DISubprogram(name: "test_coro_function", scope: !1, file: !1, line: 1, type: !11, spFlags: DISPFlagDefinition, unit: !0) | ||
!11 = !DISubroutineType(types: !12) | ||
!12 = !{null} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.