aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2021-07-01 10:59:22 +0100
committerJeremy Morse <jeremy.morse@sony.com>2021-07-01 11:19:27 +0100
commit47c3fe2a22cf753fd55d08d367fbd817b4dd4a1c (patch)
treebd836808e5c7d625cb9e9761e23f4482da3f45b5 /llvm/lib/CodeGen/MachineInstr.cpp
parent7d2d5a3a6d7aaa40468c30250bf6b0938ef02c08 (diff)
downloadllvm-47c3fe2a22cf753fd55d08d367fbd817b4dd4a1c.zip
llvm-47c3fe2a22cf753fd55d08d367fbd817b4dd4a1c.tar.gz
llvm-47c3fe2a22cf753fd55d08d367fbd817b4dd4a1c.tar.bz2
[DebugInfo][InstrRef][1/4] Support transformations that widen values
Very late in compilation, backends like X86 will perform optimisations like this: $cx = MOV16rm $rax, ... -> $rcx = MOV64rm $rax, ... Widening the load from 16 bits to 64 bits. SEeing how the lower 16 bits remain the same, this doesn't affect execution. However, any debug instruction reference to the defined operand now refers to a 64 bit value, nto a 16 bit one, which might be unexpected. Elsewhere in codegen, there's often this pattern: CALL64pcrel32 @foo, implicit-def $rax %0:gr64 = COPY $rax %1:gr32 = COPY %0.sub_32bit Where we want to refer to the definition of $eax by the call, but don't want to refer the copies (they don't define values in the way LiveDebugValues sees it). To solve this, add a subregister field to the existing "substitutions" facility, so that we can describe a field within a larger value definition. I would imagine that this would be used most often when a value is widened, and we need to refer to the original, narrower definition. Differential Revision: https://reviews.llvm.org/D88891
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineInstr.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index 6a3bb0e..20d6ab8 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -2374,3 +2374,9 @@ unsigned MachineInstr::getDebugInstrNum() {
DebugInstrNum = getParent()->getParent()->getNewDebugInstrNum();
return DebugInstrNum;
}
+
+unsigned MachineInstr::getDebugInstrNum(MachineFunction &MF) {
+ if (DebugInstrNum == 0)
+ DebugInstrNum = MF.getNewDebugInstrNum();
+ return DebugInstrNum;
+}