Addresses https://github.com/llvm/llvm-project/issues/64093 , where instruction referencing is producing an over-sized DW_OP_deref_size expression.
When we describe the locations of variables that have been spilt to the stack, there are occasions where we need to use DW_OP_deref_size, to indicate "this 32 bit variable is the lower order bits of the 64 bit value at this location". This has a meaningful difference on big endian systems, because the consumer can't necessarily know that the smaller value it's looking for is at a different position in a large spill slot.
It's not completely clear to me that instruction referencing is doing this correctly; it also probably isn't useful on a little endian system like x86. Fix the most obvious problem first: the DWARF spec says that the size of DW_OP_deref_size must not exceed the natural address size of the machine, so don't try to produce a DW_OP_deref_size if the operand would be bigger than the pointer size. Test comes from the github bug. While we're at it, refactor the logic into a utility function.
Does a test for this part already exist? I assume so, since this patch is just narrowing the use cases rather than adding the functionally, but wanted to check to be sure.