-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Disable SROA debug info for variables with expressions #61168
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
Changes from all commits
Commits
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
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
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
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,55 @@ | ||
// RUN: %target-sil-opt -enable-sil-verify-all -sil-print-debuginfo -sroa %s | %FileCheck --check-prefix=CHECK-SROA %s | ||
sil_stage canonical | ||
|
||
import Builtin | ||
import Swift | ||
|
||
struct MyStruct { | ||
@_hasStorage var x: Int64 { get set } | ||
@_hasStorage var y: Int64 { get set } | ||
init(x: Int64, y: Int64) | ||
} | ||
|
||
struct MyContainer { | ||
@_hasStorage var z: MyStruct { get set } | ||
} | ||
|
||
sil_scope 1 { loc "sroa.swift":2:8 parent @MyStructInit : $@convention(method) (Int64, Int64, @thin MyStruct.Type) -> MyStruct } | ||
|
||
// MyStruct.init(x:y:) | ||
sil hidden @MyStructInit : $@convention(method) (Int64, Int64, @thin MyStruct.Type) -> MyStruct { | ||
bb0(%0 : $Int64, %1 : $Int64, %2 : $@thin MyStruct.Type): | ||
%3 = struct $MyStruct (%0 : $Int64, %1 : $Int64), loc "sroa.swift":2:8, scope 1 | ||
return %3 : $MyStruct, loc "sroa.swift":2:8, scope 1 | ||
} // end sil function 'MyStructInit' | ||
|
||
sil_scope 2 { loc "sroa.swift":7:6 parent @foo : $@convention(thin) (Int64, Int64) -> Int64 } | ||
|
||
// foo(in_x:in_y:) | ||
sil hidden @foo : $@convention(thin) (Int64, Int64) -> Int64 { | ||
bb0(%0 : $Int64, %1 : $Int64): | ||
debug_value %0 : $Int64, let, name "in_x", argno 1, loc "sroa.swift":7:10, scope 2 | ||
debug_value %1 : $Int64, let, name "in_y", argno 2, loc "sroa.swift":7:21, scope 2 | ||
%4 = alloc_stack $MyStruct, var, name "my_struct", type $*MyContainer, expr op_fragment:#MyContainer.z, loc "sroa.swift":8:9, scope 2 | ||
// Recursive SROA of already SROA-ed aggregates is not yet supported. | ||
// CHECK-SROA: alloc_stack $Int64 | ||
// CHECK-SROA-NOT: var, | ||
// CHECK-SROA: alloc_stack $Int64 | ||
// CHECK-SROA-NOT: var, | ||
// CHECK-SROA: metatype | ||
%5 = metatype $@thin MyStruct.Type, loc "sroa.swift":8:21, scope 2 | ||
%6 = integer_literal $Builtin.Int64, 0, loc "sroa.swift":8:33, scope 2 | ||
%7 = struct $Int64 (%6 : $Builtin.Int64), loc "sroa.swift":8:33, scope 2 | ||
%8 = integer_literal $Builtin.Int64, 0, loc "sroa.swift":8:39, scope 2 | ||
%9 = struct $Int64 (%8 : $Builtin.Int64), loc "sroa.swift":8:39, scope 2 | ||
// function_ref MyStruct.init(x:y:) | ||
%10 = function_ref @MyStructInit : $@convention(method) (Int64, Int64, @thin MyStruct.Type) -> MyStruct, loc "sroa.swift":8:21, scope 2 | ||
%11 = apply %10(%7, %9, %5) : $@convention(method) (Int64, Int64, @thin MyStruct.Type) -> MyStruct, loc "sroa.swift":8:21, scope 2 | ||
store %11 to %4 : $*MyStruct, loc "sroa.swift":8:21, scope 2 | ||
%13 = struct_element_addr %4 : $*MyStruct, #MyStruct.x, loc "sroa.swift":9:17, scope 2 | ||
store %0 to %13 : $*Int64, loc "sroa.swift":9:17, scope 2 | ||
%15 = struct_element_addr %4 : $*MyStruct, #MyStruct.y, loc "sroa.swift":10:17, scope 2 | ||
store %1 to %15 : $*Int64, loc "sroa.swift":10:17, scope 2 | ||
dealloc_stack %4 : $*MyStruct, loc "sroa.swift":8:9, scope 2 | ||
return %0 : $Int64, loc "sroa.swift":11:5, scope 2 | ||
} // end sil function 'foo' |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking: what if we don't clear out DIExpr from the existing VarInfo in SILDebugVariable::createFromAllocation so that this line will append fragment of the inner member. But then I realized we can't have more than one fragment inside a single DIExpression, right? If that's the case, then I do think this is the best solution we have now (until we have the infrastructure to merge two fragments inside a DIExpression)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right — just appending the fragments would be the right thing to do, but it's currently not actually supported. I don't think there's much missing from making this work though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! then I think this LGTM.