[PATCH] D49677: [WIP][IC][DebugInfo] Preserve DI value when folding cast into phi

Anastasis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 23 11:32:08 PDT 2018


gramanas updated this revision to Diff 156845.
gramanas marked 3 inline comments as done.
gramanas added a comment.

- Update test according to comments.

The result of instcombine doesn't seem to be affected by the `asm sideeffect` or
by the `replaceAllDbgUsersWith` though.


Repository:
  rL LLVM

https://reviews.llvm.org/D49677

Files:
  lib/Transforms/InstCombine/InstCombineCasts.cpp
  test/Transforms/InstCombine/phi_cast.ll


Index: test/Transforms/InstCombine/phi_cast.ll
===================================================================
--- /dev/null
+++ test/Transforms/InstCombine/phi_cast.ll
@@ -0,0 +1,22 @@
+;; RUN: opt < %s -debugify -instcombine -S | FileCheck %s
+
+;; This is a sample test file for doing the testing while
+;; the patch is WIP. Once it's finished it will be incorporated
+;; in the debuginfo-variables.ll file.
+
+define i32 @icmp_div(i1 %condA, i1 %condB) {
+entry:
+  br i1 %condA, label %then, label %exit
+
+then:
+  br label %exit
+
+exit:
+;; CHECK-LABEL: exit:
+;; CHECK:         [[phi:%.*]] = phi i32 {{.*}}
+;; CHECK-NEXT:    call void @llvm.dbg.value(metadata i32 [[phi]], {{.*}}, metadata !DIExpression())
+  %phi = phi i1 [ false, %entry ], [ %condB, %then ]
+  %zext = zext i1 %phi to i32
+  call void asm sideeffect "", "r"(i32 %zext)
+  ret i32 %zext
+}
Index: lib/Transforms/InstCombine/InstCombineCasts.cpp
===================================================================
--- lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -294,8 +294,10 @@
     // legal type.
     if (!Src->getType()->isIntegerTy() || !CI.getType()->isIntegerTy() ||
         shouldChangeType(CI.getType(), Src->getType()))
-      if (Instruction *NV = foldOpIntoPhi(CI, PN))
+      if (Instruction *NV = foldOpIntoPhi(CI, PN)) {
+        replaceAllDbgUsesWith(*PN, *NV, CI, DT);
         return NV;
+      }
   }
 
   return nullptr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49677.156845.patch
Type: text/x-patch
Size: 1484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180723/3b3bd689/attachment.bin>


More information about the llvm-commits mailing list