[PATCH] D60641: [DebugInfo at O2] Prevent Instcombine from dropping debug info when removing zexts (fixes PR41475)

Wolfgang Pieb via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 10:40:13 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL358431: [DEBUGINFO] Prevent Instcombine from dropping debuginfo when removing zexts (authored by wolfgangp, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D60641?vs=194968&id=195226#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60641/new/

https://reviews.llvm.org/D60641

Files:
  llvm/trunk/lib/Transforms/Utils/Local.cpp
  llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll


Index: llvm/trunk/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp
@@ -1666,11 +1666,10 @@
   };
 
   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());
Index: llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll
+++ llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll
@@ -170,3 +170,12 @@
   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
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60641.195226.patch
Type: text/x-patch
Size: 1291 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190415/eeefc64e/attachment.bin>


More information about the llvm-commits mailing list