When working out which instruction defines a value, the instruction-referencing variable location code has a few special cases for physical registers:
- Arguments are never defined by instructions,
- Constant physical registers always read the same value and are never def'd.
This patch adds a third case for the llvm.frameaddress intrinsics: you can read the framepointer in any block if you so choose, and use it as a variable location, as shown in the attached patch.
This rather violates one of the assumptions behind instruction referencing, that llvm-ir shouldn't be able to read from an arbitrary register at some arbitrary point in the program. The solution for now is to just emit a DBG_PHI that reads the register value: this works, but if we wanted to do something clever with DBG_PHIs in the future then this would probably get in the way. As it stands, this patch avoids a crash.
The empty if body looks a little odd but makes sense to me. I don't think you need the ; though, unless this is to match prior art? No strong opinion.