debug_loc for params not used in entry block need to be computed with the section start as the base label.
The attached test will not assemble without the patch as the assembler will complain that we are trying to compute a label difference from 2 different sections.
If the basic block containing the first mention of the param is not in the same section as the entry basic block, we cannot use the CurrentFnBegin label. To fix it, we use the Section begin label instead. Using the Section Label will result in loss of debug loc fidelity as we do not capture the basic blocks before the start of this section.
Right now, LabelsBeforeInsn just stores one label for each insn. We can fix the fidelity problem by storing all the basic block section labels that appear before the insn and generating a difference for each of them. Hence, I have made this as a FIXME.
Is this alright? I am not very familiar with debug_loc, other better suggestions are much appreciated here.
Presumably this happens also when StartLabel isn't the function begin symbol - but could be inside but not at the start of the first BB, or in some other BB - but where the end is in some other BB?
(the test cases are all simple enough/happen to have the interesting location range start in the first BB, but it's not a requirement)