This is an archive of the discontinued LLVM Phabricator instance.

[Verifier] Fix !dbg validation if Scope is the Subprogram
ClosedPublic

Authored by loladiro on Nov 16 2015, 2:46 AM.

Details

Summary

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

Diff Detail

Repository
rL LLVM

Event Timeline

loladiro updated this revision to Diff 40263.Nov 16 2015, 2:46 AM
loladiro updated this revision to Diff 40264.
loladiro retitled this revision from to [Verifier] Fix !dbg validation if Scope is the Subprogram.
loladiro updated this object.
loladiro added reviewers: pcc, dblaikie, dexonsmith.
loladiro added a subscriber: llvm-commits.

Small formatting fix

dblaikie edited edge metadata.Nov 16 2015, 8:30 AM
dblaikie added a subscriber: dblaikie.

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.

This revision was automatically updated to reflect the committed changes.