[llvm] [LiveDebugVariables] Add basic verification (PR #68703)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 03:29:11 PDT 2023


jayfoad wrote:

> In principle this LGTM, although it's been a long time since I've looked at LiveDebugVariables. As far as I recall, we use `setUnchecked` to do manual maintenance of ranges but they should all coalesce in the end. And it doesn't make sense for there to be a zero-length range of variable location.

Stepping back a bit: I am trying to diagnose problems where the cached LiveDebugVariables analysis info refers to SlotIndexes for instructions that have been deleted. (Possibly this is caused by RegAlloc not updating LDV properly - I am still investigating that aspect of it.) I am pretty sure that this is not allowed, although currently it seems to be harmless because SlotIndexes does not actually delete or reuse those slots. #67038 tried to change SlotIndexes so that it no longer maintains these deleted slots and they can end up containing garbage values. The "zero-length range" issue that I check for here is just one possible consequence of depending on those garbage values.

It would be better if I could directly query SlotIndexes to ask "is this slot still live?" (under `#ifndef NDEBUG`). I'll work on implementing something like that.

> This does involve iterating over every range of every variable in the function, which might have compile-time performance implications. Is it worth putting this behind an EXPENSIVE_CHECKS ifdef? (I haven't followed the SlotIndex related problems you've mentioned, I don't know whether it needs running on every compilation)

I think generally acceptable performance-wise for `verifyAnalysis` to make a single pass over all information cached by an analysis.

https://github.com/llvm/llvm-project/pull/68703


More information about the llvm-commits mailing list