[DebugInfo] Use debug blocks in PhiExpansion rather than fragments#89471
Conversation
Similarly to the getCompleteVarInfo function in DebugValueInst, this function returns a debug variable with location, scope and type.
Rather than defaulting to the SSA operand type, use getCompleteVarInfo which does this already. Also removes the optional from the VarInfo.
When the vartype isn't allocated in the debug_value instruction, and a debug reconstruction block is added to the instruction, the variable type should default to the debug reconstruction's returned value's type, rather than the SSA's operand's type.
When a struct is unwrapped in a phi node, only one field value can be salvaged at that point. Rather than using a fragment to express that, use a debug reconstruction basic block that sets all other fields to undef, which is an equivalent representation that supports existing debug reconstruction blocks.
|
@swift-ci test |
adrian-prantl
left a comment
There was a problem hiding this comment.
I like the more generic representation in the transform block. Looks good to me!
|
I have verified that on a program where PhiExpansion occurs on a debug value, the result is the same before the change (using fragments), and after the change (using a debug reconstruction block): struct Pt {
var x, y: Int
}
@inline(never)
func makeTrue(x: Int = 0) -> Bool {
print(x)
return true
}
func thing() {
let pt: Pt
if makeTrue() {
pt = Pt(x: 4, y: 7)
} else {
pt = Pt(x: 2, y: 8)
}
let z = pt // break
if makeTrue(x: z.x + 1) {
print("yay")
}
}
thing()Compiled with optimisations, |
|
The CI on the NFC pull request this one is based on is taking forever due to unrelated issues. This one passed CI, so I'll merge this one which will include the other one. |
Includes #89470
When a struct is unwrapped in a phi node, only one field value can be salvaged at that point. Rather than using a fragment to express that, use a debug reconstruction basic block that sets all other fields to undef, which is an equivalent representation that supports existing debug reconstruction blocks.