aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
diff options
context:
space:
mode:
authorFelipe de Azevedo Piovezan <fpiovezan@apple.com>2023-04-04 09:35:23 -0400
committerFelipe de Azevedo Piovezan <fpiovezan@apple.com>2023-04-05 08:21:00 -0400
commit79a1e32915631469b4ea50c0e00ccd7ecc828d00 (patch)
tree9e8550b56a317e3b484ba8ddca8271071e635c26 /llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
parent0d022e7d1ff94aaf51e8ac1cea9ce0b827c92814 (diff)
downloadllvm-79a1e32915631469b4ea50c0e00ccd7ecc828d00.zip
llvm-79a1e32915631469b4ea50c0e00ccd7ecc828d00.tar.gz
llvm-79a1e32915631469b4ea50c0e00ccd7ecc828d00.tar.bz2
[GlobalISel] Improve stack slot tracking in dbg.values
For IR like: ``` %alloca = alloca ... dbg.value(%alloca, !myvar, OP_deref(<other_ops>)) ``` GlobalISel lowers it to MIR: ``` %some_reg = G_FRAME_INDEX <stack_slot> DBG_VALUE %some_reg, !myvar, OP_deref(<other_ops>) ``` In other words, if the value of `!myvar` can be obtained by dereferencing an alloca, in MIR we say that the _location_ of a variable is obtained by dereferencing register %some_reg (plus some `<other_ops>`). We can instead remove the use of `%some_reg`: the location of `!myvar` _is_ `<stack_slot>` (plus some `<other_ops>`). This patch implements this transformation, which improves debug information handling in O0, as these registers hardly ever survive register allocation. A note about testing: similar to what was done in D76934 (f24e2e9eebde4b7a1d), this patch exposed a bug in the Builder class when using `-debug`, where we tried to print an incomplete instruction. The changes in `MachineIRBuilder.cpp` address that. Differential Revision: https://reviews.llvm.org/D147536
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
index c26f737..d64a20b 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
@@ -80,11 +80,11 @@ MachineInstrBuilder MachineIRBuilder::buildFIDbgValue(int FI,
assert(
cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(getDL()) &&
"Expected inlined-at fields to agree");
- return buildInstr(TargetOpcode::DBG_VALUE)
- .addFrameIndex(FI)
- .addImm(0)
- .addMetadata(Variable)
- .addMetadata(Expr);
+ return insertInstr(buildInstrNoInsert(TargetOpcode::DBG_VALUE)
+ .addFrameIndex(FI)
+ .addImm(0)
+ .addMetadata(Variable)
+ .addMetadata(Expr));
}
MachineInstrBuilder MachineIRBuilder::buildConstDbgValue(const Constant &C,