Debug Info Verifier: should we create a module pass for it?

Hi all,

Currently, debug info verifier is part of the IR verifier which is a function pass.

One part of the IR verifier that I don’t like is it verifies module-level data in doFinalization. If we have two verifier passes in a single module pass manager, doFinalization of the two passes will run on the same module data after all passes.

I followed the same model for debug info verifier: verifying debug info reachable from a function in runOnFunction and verifying module level debug info in doFinalization. But it can be time consuming (see email discussion in “Debug Info Slowing Things Down?!”), since each function can reach a lot of debug info MDNodes, some of them are shared between functions.

One possibility is to cache MDNodes verified by one function so other functions do not verify those MDNodes again. But this is a violation of Function Pass in my opinion, since other optimization passes can run between verifying one function and verifying another function, and the MDNodes verified by one function can be modified when verifying another function.

Another possibility is to separate debug info verifier into its own module pass. The disadvantage is that we have to run the IR verifier and the debug info verifier, each will traverse the module.

Comments and suggestions are welcome.

Thanks,
Manman

My off the cuff idea here is to make it a module pass, but we’ll split the verification a bit:

a) IR verification time -

Verify debug metadata attached to instructions (i.e. line information). Only check it for structure (i.e. do the various metadata nodes have the right number and kind of operands).

b) Module pass -

Walk down from the CUs in the file and verify everything we see. I think then the only duplication we’ll get are methods from classes as the context for functions. We’ll also need to check the contexts on the various metadata operands on the line numbers which is unfortunate as that probably involves a separate walk over the instructions, but then we could cache the information we’ve already seen.

Thoughts?

-eric

My off the cuff idea here is to make it a module pass, but we'll split the
verification a bit:

a) IR verification time -

Verify debug metadata attached to instructions (i.e. line information).
Only check it for structure (i.e. do the various metadata nodes have the
right number and kind of operands).

It makes things a little complicated by having verification in two places
(IR verifier and the module pass).
The advantage is we can verify more frequently on structures, comparing
against doing this in the module pass.

b) Module pass -

Walk down from the CUs in the file and verify everything we see.

This is DebugInfoFinder.processModule.

I think then the only duplication we'll get are methods from classes as
the context for functions. We'll also need to check the contexts on the
various metadata operands on the line numbers which is unfortunate as that
probably involves a separate walk over the instructions,

Yes, we need to walk over the instructions and call the various process
methods of DebugInfoFinder, i.e. moving things related to debug info
verifier from Verifier.cpp to its own module pass.
We can then verify everything stored in DebugInfoFinder, similar to the
current implementation of debug info verifier.

but then we could cache the information we've already seen.

Not sure what you mean here.

Thanks,
Manman

My off the cuff idea here is to make it a module pass, but we’ll split the verification a bit:

a) IR verification time -

Verify debug metadata attached to instructions (i.e. line information). Only check it for structure (i.e. do the various metadata nodes have the right number and kind of operands).

It makes things a little complicated by having verification in two places (IR verifier and the module pass).
The advantage is we can verify more frequently on structures, comparing against doing this in the module pass.

Sure.

b) Module pass -

Walk down from the CUs in the file and verify everything we see.

This is DebugInfoFinder.processModule.

Yep.

I think then the only duplication we’ll get are methods from classes as the context for functions. We’ll also need to check the contexts on the various metadata operands on the line numbers which is unfortunate as that probably involves a separate walk over the instructions,

Yes, we need to walk over the instructions and call the various process methods of DebugInfoFinder, i.e. moving things related to debug info verifier from Verifier.cpp to its own module pass.
We can then verify everything stored in DebugInfoFinder, similar to the current implementation of debug info verifier.

Agreed.

but then we could cache the information we’ve already seen.

Not sure what you mean here.

Figured if we walked over at the module level then we could verify that we didn’t walk over some metadata (like scopes, etc) more than once during a verify.

-eric