The backend requires that any subprogram definition belongs to some compile unit that is declared in the llvm.dbg.cu named metadata node. Check this, by going through all of them at the very beginning of module Verification, and adding them to the MDNodes set. After this initial pass, getting to any subprogram definition again is an error, because it means that such a subprogram was not referenced from llvm.dbg.cu.
Details
Diff Detail
Event Timeline
Diego: I /think/ this isn't true when we're attaching debug info just for
backend diagnostic purposes, right? Do we have some test cases covering
that?
Some extra test cases need chainging for the case when the llvm.dbg.cu metadata node does not exist.
Found a case where my new verfier check wasn't working + Whole load of new test case fixes.
The only cases I've found in the test cases that intentionally omit compile units from the .cu node are the AddDiscriminator tests. Are those the ones you are thinking about. For now, I made them all isDefinition: false. However, if this is something we want to support (creating debug info, but not codegening it), how about we just create a different global named metadata llvm.dbg.cu.noemit (bad name, please suggest something better), into which we pull all compile units we don't want to emit, but the Verifier could still look at it.