-
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
Conversation
@swift-ci test |
FYI, this is in response to this build failure: https://ci.swift.org/job/swift-syntax-PR-macOS/609/consoleText |
// TODO: Handle DIExpr that is already attached | ||
NewDebugVarInfo->DIExpr = SILDebugInfoExpression::createFragment(VD); | ||
|
||
NewDebugVarInfo->DIExpr.append( |
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.
Currently the SROA just overwrites already-existing expressions on variables. When SROA is recursively run on a data structure this leads to nonsensical expressions such as type $*Outer, expr op_fragment:#Inner.x instead of type $*Outer, expr op_fragment:#Outer.inner op_fragment:#Inner.x The (nonsensical) LLVM IR generated from this violates some assumptions in LLVM for example, if a struct has multiple members of the same type, you can end up with multiple dbg.declare intrinsics claiming to describe the same variable). As a quick fix, this patch detects this situation and drops the debug info. A proper fix shouldn't be too difficult to implement though. rdar://99874371
763d9ff
to
90bbe51
Compare
@swift-ci test |
The windows build failure looks unrelated. |
Currently the SROA just overwrites already-existing expressions on variables. When SROA is recursively run on a data structure this leads to nonsensical expressions such as
type $*Outer, expr op_fragment:#Inner.x
instead of
type $*Outer, expr op_fragment:#Outer.inner op_fragment:#Inner.x
The (nonsensical) LLVM IR generated from this violates some assumptions in LLVM for example, if a struct has multiple members of the same type, you can end up with multiple dbg.declare intrinsics claiming to describe the same variable). As a quick fix, this patch detects this situation and drops the debug info. A proper fix shouldn't be too difficult to implement though.
rdar://99874371