Discussed in this thread:
https://lists.llvm.org/pipermail/llvm-dev/2021-January/148139.html
DwarfDebug::collectEntityInfo accidentally distinguishes between variable locations that never have a location specified, and variable locations that have an empty location specified. The latter leads to the creation of an empty variable referring to the abstract origin:
DW_TAG_formal_parameter DW_AT_abstract_origin (0x0000005a "bar")
Which is needless and potentially misleading. This patch makes collectEntityInfo behave the same way for both ways an empty variable can be represented, by only emitting a concrete variable if it actually has a location. The added test exercises this, and checks variables are created for "normal" functions too.
The NVPTX tests fail with this; this is because they were compiled to LLVM-IR before retainedNodes was correctly tracked, apparently. I've made the following changes to reflect changes in output:
- debug-addr-class.ll: Added the list of retained nodes to the input. This causes two types to shift position in the output for reasons I don't understand.
- debug-info.ll: The size of the unit changes because we cease emitting two parameters with abstract-origins as a result of this patch
- debug-loc-offset.ll: adding retainedNodes to this makes the abbrev numbering change, and one new variable to be emitted.
Can we refactor this into a predicate function (according to the CodingStandards)?