[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 10:11:22 PDT 2018
gramanas created this revision.
gramanas added a reviewer: vsk.
Herald added subscribers: llvm-commits, JDevlieghere.
This patch tries to incorporate the new `replaceAllDbgUsersWith`
function while folding a cast into a phi instruction.
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,27 @@
+;; 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(i16 %a, i16 %c) {
+entry:
+ %tobool = icmp eq i16 %a, 0
+ br i1 %tobool, label %then, label %exit
+
+then:
+ %div = sdiv i16 %c, -1
+ %cmp = icmp ne i16 %div, 0
+ br label %exit
+
+exit:
+;; CHECK-LABEL: exit:
+;; CHECK: [[phi:%.*]] = phi i1 {{.*}}
+;; CHECK-NEXT: call void @llvm.dbg.value(metadata i1 [[phi]], {{.*}}, metadata !DIExpression())
+;; CHECK: [[zext:%.*]] = zext i1 %phi to i32
+;; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[zext]], {{.*}}, metadata !DIExpression())
+ %phi = phi i1 [ false, %entry ], [ %cmp, %then ]
+ call void asm sideeffect "", "i"(i1 %phi)
+ %zext = zext i1 %phi to i32
+ 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.156811.patch
Type: text/x-patch
Size: 1716 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180723/a66a2a3e/attachment.bin>
More information about the llvm-commits
mailing list