We are inserting both Scope and SP into the Seen map and check whether
it was already there in which case we skip the validation (the idea
being that we already checked this Subprogram before). However,
if (Scope == SP) as MDNodes, then inserting the Scope, will trigger
the Seen check causing us to incorrectly not validate this !dbg
attachment. Fix this by not performing the SP Seen check if Scope == SP
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
This seems like a slightly weird algorithm
We check if the debug location itself is seen, then if the immediate scope
is seen, then we walk the entire scope chain until we get to the top level
subprogram and check if that's already seen. Why not check the intermediate
scopes too, if checking the first and last are both worthwhile...
& if we actually check everything along the chain, then maybe this should
fall out more naturally?
I'm not sure the added complexity of walking the chain and checking everything would be worth it. It seems like that would just be manually inlining getInlinedAtScope + doing the memoization. It seems like a reasonable assumption that the scope declared on one instruction would also be declared on instructions nearby, while that's not necessarily the case for intermediate ones (plus if it is we'll put it in the list when we get there).
I would appreciate some guidance on how to go forward here. Walking and caching the intermediate chains doesn't make this significantly simpler, so the primary questions is whether the caching is worth it at all. Unfortunately, I don't have any large enough test cases with meaningfully nested inlining structures to be able to make such measurements here.