[llvm] r317880 - [RegisterCoalescer] Move debug value after rematerialize trivial def
Karl-Johan Karlsson via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 10 01:48:40 PST 2017
Author: karka
Date: Fri Nov 10 01:48:40 2017
New Revision: 317880
URL: http://llvm.org/viewvc/llvm-project?rev=317880&view=rev
Log:
[RegisterCoalescer] Move debug value after rematerialize trivial def
Summary:
The associated debug value is updated when the virtual source register
of a copy is completely eliminated and replaced with a rematerialize
value in the defed register of the copy. As the debug value now is
associated with another register it also need to be moved, otherwise
the debug value isn't valid.
Reviewers: aprantl
Reviewed By: aprantl
Subscribers: MatzeB, llvm-commits, qcolombet
Differential Revision: https://reviews.llvm.org/D38024
Added:
llvm/trunk/test/DebugInfo/MIR/X86/regcoalescer.mir
Modified:
llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp
Modified: llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp?rev=317880&r1=317879&r2=317880&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp Fri Nov 10 01:48:40 2017
@@ -1337,6 +1337,9 @@ bool RegisterCoalescer::reMaterializeTri
MachineInstr *UseMI = UseMO.getParent();
if (UseMI->isDebugValue()) {
UseMO.setReg(DstReg);
+ // Move the debug value directly after the def of the rematerialized
+ // value in DstReg.
+ MBB->splice(std::next(NewMI.getIterator()), UseMI->getParent(), UseMI);
DEBUG(dbgs() << "\t\tupdated: " << *UseMI);
}
}
Added: llvm/trunk/test/DebugInfo/MIR/X86/regcoalescer.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/MIR/X86/regcoalescer.mir?rev=317880&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/MIR/X86/regcoalescer.mir (added)
+++ llvm/trunk/test/DebugInfo/MIR/X86/regcoalescer.mir Fri Nov 10 01:48:40 2017
@@ -0,0 +1,50 @@
+# RUN: llc -O1 -filetype=asm -mtriple x86_64-unknown-linux-gnu -mcpu=x86-64 -o - %s -start-before=simple-register-coalescing -stop-after=simple-register-coalescing | FileCheck %s
+
+--- |
+ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+ target triple = "x86_64-unknown-linux-gnu"
+
+ define i32 @main() local_unnamed_addr !dbg !14 {
+ entry:
+ %shl = shl i32 undef, undef, !dbg !19
+ tail call void @llvm.dbg.value(metadata i32 %shl, metadata !18, metadata !DIExpression()), !dbg !20
+ ret i32 %shl, !dbg !21
+ }
+
+ declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+ !llvm.dbg.cu = !{!0}
+ !llvm.module.flags = !{!12, !13}
+
+ !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !2)
+ !1 = !DIFile(filename: "bar.c", directory: "")
+ !2 = !{}
+ !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+ !12 = !{i32 2, !"Debug Info Version", i32 3}
+ !13 = !{i32 1, !"wchar_size", i32 4}
+ !14 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 12, type: !15, isLocal: false, isDefinition: true, scopeLine: 12, isOptimized: true, unit: !0, variables: !17)
+ !15 = !DISubroutineType(types: !16)
+ !16 = !{!7}
+ !17 = !{!18}
+ !18 = !DILocalVariable(name: "bazinga", scope: !14, file: !1, line: 13, type: !7)
+ !19 = !DILocation(line: 14, column: 11, scope: !14)
+ !20 = !DILocation(line: 13, column: 7, scope: !14)
+ !21 = !DILocation(line: 16, column: 3, scope: !14)
+
+...
+---
+name: main
+alignment: 4
+registers:
+ - { id: 0, class: gr32, preferred-register: '' }
+body: |
+ bb.0.entry:
+ %0 = MOV32r0 implicit-def dead %eflags, debug-location !19
+ DBG_VALUE debug-use %0, debug-use _, !18, !DIExpression(), debug-location !20
+ %eax = COPY killed %0, debug-location !21
+ RET 0, killed %eax, debug-location !21
+
+...
+
+# CHECK: %eax = MOV32r0
+# CHECK-NEXT: DBG_VALUE debug-use %eax
More information about the llvm-commits
mailing list