};
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);
; 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]]
; 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