[llvm-dev] Why does a DISubprogram need to be distinct?

Adrian Prantl via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 25 16:07:58 PDT 2020


First — thanks for fixing the test for me!

We have two kinds of DISubprograms: 
- uniqued DISubprograms are part of the type system and describe function *types*. They don't have a unit: field, because they want to be uniqued across compile units.
- distinct DISubprograms describe one specific function definition. They belong to a compile unit and thus have a unit: field.

You are only supposed to attach distinct DISubprograms to function definitions. Several places in CodeGen will unconditionally dereference the unit: field and crash if it isn't there.

We actually had a weaker form of the check I added to Verifier already in place (https://github.com/llvm/llvm-project/blob/51cad041e0cb26597c7ccc0fbfaa349b8fffbcda/llvm/lib/IR/Verifier.cpp#L1186), but it didn't cover the specific testcase I added in https://reviews.llvm.org/rGe17f52d623cc146b7d9bf5a2e02965043508b4c4.

-- adrian


More information about the llvm-dev mailing list