[PATCH] D80034: [Local] Do not ignore zexts in salvageDebugInfo, PR45923
Vedant Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 15 14:10:03 PDT 2020
vsk created this revision.
vsk added reviewers: aprantl, jmorse, chrisjackson, davide.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
When salvaging a dead zext instruction, append a convert operation to
the DIExpressions of the debug uses of the instruction, to prevent the
salvaged value from being sign-extended.
I confirmed that lldb prints out the correct unsigned result for "f" in
the example from PR45923 with this changed applied.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80034
Files:
llvm/lib/Transforms/Utils/Local.cpp
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,8 +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: call void @llvm.dbg.value(metadata i32 %x, {{.*}} !DIExpression(DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_LLVM_convert, 8, DW_ATE_unsigned, DW_OP_stack_value))
+; DBGINFO-NEXT: call void @llvm.dbg.value(metadata i32 %y, {{.*}} !DIExpression(DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_LLVM_convert, 8, DW_ATE_unsigned, DW_OP_stack_value))
; DBGINFO-NEXT: [[C:%.*]] = mul i32 {{.*}}
; DBGINFO-NEXT: [[D:%.*]] = and i32 {{.*}}
; DBGINFO-NEXT: call void @llvm.dbg.value(metadata i32 [[C]]
@@ -175,7 +175,7 @@
; Check that we don't drop debug info when a zext is removed.
define i1 @foo(i1 zeroext %b) {
; DBGINFO-LABEL: @foo(
-; DBGINFO-NEXT: call void @llvm.dbg.value(metadata i1 %b
+; DBGINFO-NEXT: call void @llvm.dbg.value(metadata i1 %b, {{.*}} !DIExpression(DW_OP_LLVM_convert, 1, DW_ATE_unsigned, DW_OP_LLVM_convert, 8, DW_ATE_unsigned, DW_OP_stack_value))
; DBGINFO-NEXT: ret i1 %b
%frombool = zext i1 %b to i8
Index: llvm/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1698,13 +1698,14 @@
};
if (auto *CI = dyn_cast<CastInst>(&I)) {
- // No-op casts and zexts are irrelevant for debug info.
- if (CI->isNoopCast(DL) || isa<ZExtInst>(&I))
+ // No-op casts are irrelevant for debug info.
+ if (CI->isNoopCast(DL))
return SrcDIExpr;
Type *Type = CI->getType();
- // Casts other than Trunc or SExt to scalar types cannot be salvaged.
- if (Type->isVectorTy() || (!isa<TruncInst>(&I) && !isa<SExtInst>(&I)))
+ // Casts other than Trunc, SExt, or ZExt to scalar types cannot be salvaged.
+ if (Type->isVectorTy() ||
+ !(isa<TruncInst>(&I) || isa<SExtInst>(&I) || isa<ZExtInst>(&I)))
return nullptr;
Value *FromValue = CI->getOperand(0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80034.264337.patch
Type: text/x-patch
Size: 2371 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200515/dbc46106/attachment.bin>
More information about the llvm-commits
mailing list