[llvm] r358431 - [DEBUGINFO] Prevent Instcombine from dropping debuginfo when removing zexts
Wolfgang Pieb via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 15 10:36:29 PDT 2019
Author: wolfgangp
Date: Mon Apr 15 10:36:29 2019
New Revision: 358431
URL: http://llvm.org/viewvc/llvm-project?rev=358431&view=rev
Log:
[DEBUGINFO] Prevent Instcombine from dropping debuginfo when removing zexts
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
Modified:
llvm/trunk/lib/Transforms/Utils/Local.cpp
llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=358431&r1=358430&r2=358431&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Mon Apr 15 10:36:29 2019
@@ -1666,11 +1666,10 @@ DIExpression *llvm::salvageDebugInfoImpl
};
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());
Modified: llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll?rev=358431&r1=358430&r2=358431&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll Mon Apr 15 10:36:29 2019
@@ -170,3 +170,12 @@ exit:
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
+}
More information about the llvm-commits
mailing list