The test added in D97533 (and modified by this patch) has some overly strict printed metadata ordering requirements, specifically the interleaving of DILocalVariable nodes and DILocation nodes. Unfortunately our downstream changes alter this order, which causes us trouble.
The patch below reduces the need for ordering: it picks out the DILocalVariable nodes being sought, in any order (CHECK-DAG), and doesn't examine any DILocations. The subsequent CHECK-NOTs are what's important: the test seeks to ensure a duplicate set of DILocalVariables aren't emitted in the same scope.
I've tested that this fails before 3a6a80b641bcf and passes afterwards.