Zexts can be treated like no-op casts when it comes to assessing whether their
removal affects debug info.
Reviewer: aprantl
Differential Revision: https://reviews.llvm.org/D60641
llvm-svn: 358431
};
if (auto *CI = dyn_cast<CastInst>(&I)) {
- if (!CI->isNoopCast(DL))
- return nullptr;
-
- // No-op casts are irrelevant for debug info.
- return SrcDIExpr;
+ // No-op casts and zexts are irrelevant for debug info.
+ if (CI->isNoopCast(DL) || isa<ZExtInst>(&I))
+ return SrcDIExpr;
+ return nullptr;
} else if (auto *GEP = dyn_cast<GetElementPtrInst>(&I)) {
unsigned BitWidth =
M.getDataLayout().getIndexSizeInBits(GEP->getPointerAddressSpace());
unreachable
}
+; 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: ret i1 %b
+
+ %frombool = zext i1 %b to i8
+ ret i1 %b
+}