diff options
| author | Wolfgang Pieb <Wolfgang.Pieb@sony.com> | 2019-04-15 17:36:29 +0000 |
|---|---|---|
| committer | Wolfgang Pieb <Wolfgang.Pieb@sony.com> | 2019-04-15 17:36:29 +0000 |
| commit | 4fe42214e24227906c2d2be723465b8bef063ee8 (patch) | |
| tree | 60c553aed9361cb30ad4f2cea6319722553598a3 /llvm | |
| parent | 3929c432e65c7d382e2d996f1d17c70fc66eabca (diff) | |
| download | bcm5719-llvm-4fe42214e24227906c2d2be723465b8bef063ee8.tar.gz bcm5719-llvm-4fe42214e24227906c2d2be723465b8bef063ee8.zip | |
[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
llvm-svn: 358431
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 9 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/cast-mul-select.ll | 9 |
2 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 3110322b314..65d5928e99c 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1666,11 +1666,10 @@ DIExpression *llvm::salvageDebugInfoImpl(Instruction &I, }; 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()); diff --git a/llvm/test/Transforms/InstCombine/cast-mul-select.ll b/llvm/test/Transforms/InstCombine/cast-mul-select.ll index b140dfa2229..c501fd8d04c 100644 --- a/llvm/test/Transforms/InstCombine/cast-mul-select.ll +++ b/llvm/test/Transforms/InstCombine/cast-mul-select.ll @@ -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 +} |

