This change tweaks debug locations for the local variables moved onto the unsafe stack so that they don't get "optimized out".
Instead of describing these locations via an IR temp that is likely to be optimized out (even at -O0!), we base the locations off the unsafe stack pointer which is always present. This required a few tweaks in other parts of LLVM:
- The location expression changed from *tmp to *tmp - offset, hence the need to support DW_OP_minus in the AsmPrinter.
- SDAG plainly refuses to emit debug locations on anything other that an alloca or a function parameter. I could not find any adverse effects from allowing those on any IR temps, and it works perfectly in our case, when the temp is a load from some thread-local variable. FastISel already supports that.
With this, debug locations for the unsafe allocas seem to reliably survive -O2.
Please elaborate what's actually going on - whether you rewrite expr to be (*orig + offset), or *(orig + offset) - it's not entirely clear from comment