[PATCH] D61184: [Salvage] Change salvage debug info implementation to use new DW_OP_LLVM_convert where needed
Stephen Tozer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 26 06:13:01 PDT 2019
StephenTozer updated this revision to Diff 196837.
StephenTozer added a comment.
As per the previous comment, ZExt is equivalent to a Noop on the DWARF expression stack, so can be caught by the same early exit.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61184/new/
https://reviews.llvm.org/D61184
Files:
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/DebugInfo/salvage-cast-debug-info.ll
llvm/test/Transforms/InstCombine/cast-mul-select.ll
Index: llvm/test/Transforms/InstCombine/cast-mul-select.ll
===================================================================
--- llvm/test/Transforms/InstCombine/cast-mul-select.ll
+++ llvm/test/Transforms/InstCombine/cast-mul-select.ll
@@ -13,6 +13,8 @@
; we preserve the debug information in the resulting
; instruction.
; DBGINFO-LABEL: @mul(
+; DBGINFO-NEXT: call void @llvm.dbg.value(metadata i32 %x
+; DBGINFO-NEXT: call void @llvm.dbg.value(metadata i32 %y
; DBGINFO-NEXT: [[C:%.*]] = mul i32 {{.*}}
; DBGINFO-NEXT: [[D:%.*]] = and i32 {{.*}}
; DBGINFO-NEXT: call void @llvm.dbg.value(metadata i32 [[C]]
Index: llvm/test/DebugInfo/salvage-cast-debug-info.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/salvage-cast-debug-info.ll
@@ -0,0 +1,25 @@
+; RUN: opt %s -debugify -early-cse -S | FileCheck %s
+define i32 @foo(i64 %nose, i32 %more) {
+; CHECK-LABEL: @foo(
+; CHECK: call void @llvm.dbg.value(metadata i64 %nose, metadata [[V1:![0-9]+]], metadata !DIExpression(DW_OP_LLVM_convert, 32
+; CHECK: call void @llvm.dbg.value(metadata i64 %nose.shift, metadata [[V2:![0-9]+]]
+; CHECK: call void @llvm.dbg.value(metadata i64 %nose.shift, metadata [[V3:![0-9]+]], metadata !DIExpression(DW_OP_LLVM_convert, 32
+
+entry:
+ %nose.trunc = trunc i64 %nose to i32
+ %nose.shift = lshr i64 %nose, 32
+ %nose.trunc.2 = trunc i64 %nose.shift to i32
+ %add = add nsw i32 %more, 1
+ ret i32 %add
+}
+
+!llvm.module.flags = !{!0, !1}
+!llvm.ident = !{!2}
+
+!0 = !{i32 1, !"wchar_size", i32 2}
+!1 = !{i32 7, !"PIC Level", i32 2}
+!2 = !{!"clang version 9.0.0 "}
+
+; CHECK: [[V1]] = !DILocalVariable(
+; CHECK: [[V2]] = !DILocalVariable(
+; CHECK: [[V3]] = !DILocalVariable(
Index: llvm/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1669,6 +1669,22 @@
// No-op casts and zexts are irrelevant for debug info.
if (CI->isNoopCast(DL) || isa<ZExtInst>(&I))
return SrcDIExpr;
+ Type *Type = CI->getType();
+ // There does not appear to be any op for vector casting.
+ if (Type->isVectorTy())
+ return nullptr;
+
+ if (isa<TruncInst>(&I) || isa<SExtInst>(&I)) {
+ unsigned TypeBitSize = Type->getScalarSizeInBits();
+
+ // The result of the cast will be sign extended iff the instruction is a
+ // SExt; signedness is otherwise irrelevant on the expression stack.
+ unsigned Encoding =
+ isa<SExtInst>(&I) ? dwarf::DW_ATE_signed : dwarf::DW_ATE_unsigned;
+
+ return applyOps({dwarf::DW_OP_LLVM_convert, TypeBitSize, Encoding});
+ }
+
return nullptr;
} else if (auto *GEP = dyn_cast<GetElementPtrInst>(&I)) {
unsigned BitWidth =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61184.196837.patch
Type: text/x-patch
Size: 2829 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190426/f7d14f06/attachment.bin>
More information about the llvm-commits
mailing list