aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineFunction.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2021-07-27 13:15:42 +0100
committerJeremy Morse <jeremy.morse@sony.com>2021-07-27 13:44:37 +0100
commit7dc9d7373186827a92d6ca08ad7192208dfea389 (patch)
treefb2e66e2f18187507c6282a6b18df4f9d7c81308 /llvm/lib/CodeGen/MachineFunction.cpp
parent1930c4410d6b48645b7b7c58cf4403a2a0e3836d (diff)
downloadllvm-7dc9d7373186827a92d6ca08ad7192208dfea389.zip
llvm-7dc9d7373186827a92d6ca08ad7192208dfea389.tar.gz
llvm-7dc9d7373186827a92d6ca08ad7192208dfea389.tar.bz2
[DebugInfo][InstrRef] Handle llvm.frameaddress intrinsics gracefully
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, 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 added test. 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. Differential Revision: https://reviews.llvm.org/D106659
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index dc4b1a6..0a454b6 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -1139,6 +1139,14 @@ auto MachineFunction::salvageCopySSA(MachineInstr &MI)
// We can produce a DBG_PHI that identifies the constant physreg. Doesn't
// matter where we put it, as it's constant valued.
assert(CurInst->isCopy());
+ } else if (State.first == TRI.getFrameRegister(*this)) {
+ // LLVM IR is allowed to read the framepointer by calling a
+ // llvm.frameaddress.* intrinsic. We can support this by emitting a
+ // DBG_PHI $fp. This isn't ideal, because it extends the behaviours /
+ // position that DBG_PHIs appear at, limiting what can be done later.
+ // TODO: see if there's a better way of expressing these variable
+ // locations.
+ ;
} else {
// Assert that this is the entry block. If it isn't, then there is some
// code construct we don't recognise that deals with physregs across