[PATCH] D19095: [BPI] Consider deoptimize calls as "unreachable"

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 18 12:07:11 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL266654: [BPI] Consider deoptimize calls as "unreachable" (authored by sanjoy).

Changed prior to commit:
  http://reviews.llvm.org/D19095?vs=53661&id=54092#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19095

Files:
  llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
  llvm/trunk/test/Analysis/BranchProbabilityInfo/deopt-intrinsic.ll

Index: llvm/trunk/test/Analysis/BranchProbabilityInfo/deopt-intrinsic.ll
===================================================================
--- llvm/trunk/test/Analysis/BranchProbabilityInfo/deopt-intrinsic.ll
+++ llvm/trunk/test/Analysis/BranchProbabilityInfo/deopt-intrinsic.ll
@@ -0,0 +1,20 @@
+; RUN: opt -analyze -branch-prob < %s | FileCheck %s
+
+declare i32 @llvm.experimental.deoptimize.i32(...)
+
+define i32 @test1(i32 %a, i32 %b) {
+; CHECK-LABEL: Printing analysis 'Branch Probability Analysis' for function 'test1':
+entry:
+  %cond = icmp eq i32 %a, 42
+  br i1 %cond, label %exit, label %deopt
+
+; CHECK:  edge entry -> exit probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
+; CHECK:  edge entry -> deopt probability is 0x00000800 / 0x80000000 = 0.00%
+
+deopt:
+  %rval = call i32(...) @llvm.experimental.deoptimize.i32() [ "deopt"() ]
+  ret i32 %rval
+
+exit:
+  ret i32 %b
+}
Index: llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
===================================================================
--- llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
+++ llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
@@ -115,7 +115,12 @@
 bool BranchProbabilityInfo::calcUnreachableHeuristics(const BasicBlock *BB) {
   const TerminatorInst *TI = BB->getTerminator();
   if (TI->getNumSuccessors() == 0) {
-    if (isa<UnreachableInst>(TI))
+    if (isa<UnreachableInst>(TI) ||
+        // If this block is terminated by a call to
+        // @llvm.experimental.deoptimize then treat it like an unreachable since
+        // the @llvm.experimental.deoptimize call is expected to practically
+        // never execute.
+        BB->getTerminatingDeoptimizeCall())
       PostDominatedByUnreachable.insert(BB);
     return false;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19095.54092.patch
Type: text/x-patch
Size: 1758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160418/3c0b3863/attachment.bin>


More information about the llvm-commits mailing list