This past days I focused on some missing Debug Loc that occurred at
at the function prologue.
Preserving the scope
Instructions on the function prologue are auto-generated and do not correspond the "real" code. Thus the Debug Location can't have a valid line number.
But the Debug Location metadata contains scope information as well, witch is useful. Especially after the passes mix and mash the code to form the optimized module.
While investigating the SROA pass for missing DI occurrences, there was a test with a
induction that was missing Debug Loc. The problem was then narrowed down to a mem2reg call
from SROA. As it turned out the mem2reg was correctly sourcing the
phi debug location
from the combined stores, so the problem had to be that there was to DI present at all.
Hence this patch was posted in phab.
There is some talk about whether this change is wanted or not, since the DI in the instructions of the function prologue is intended to be missing.
test1 clearly shows a phi with missing debug Loc that after the patch is
applied no longer has this problem.