[PATCH] D66096: [CodeGen/Analysis] Intrinsic llvm.assume should not block tail call optimization

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 15:50:55 PDT 2019


Carrot updated this revision to Diff 214729.
Carrot marked an inline comment as done.
Carrot added a comment.

Will commit this version.


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

https://reviews.llvm.org/D66096

Files:
  lib/CodeGen/Analysis.cpp
  test/CodeGen/X86/tailcall-assume.ll


Index: test/CodeGen/X86/tailcall-assume.ll
===================================================================
--- test/CodeGen/X86/tailcall-assume.ll
+++ test/CodeGen/X86/tailcall-assume.ll
@@ -0,0 +1,15 @@
+; RUN: llc -mtriple=x86_64-linux < %s | FileCheck %s
+
+; Intrinsic call to @llvm.assume should not prevent tail call optimization.
+; CHECK-LABEL: foo:
+; CHECK:       jmp bar # TAILCALL
+define i8* @foo() {
+  %1 = tail call i8* @bar()
+  %2 = icmp ne i8* %1, null
+  tail call void @llvm.assume(i1 %2)
+  ret i8* %1
+}
+
+declare i8* @bar()
+declare void @llvm.assume(i1)
+
Index: lib/CodeGen/Analysis.cpp
===================================================================
--- lib/CodeGen/Analysis.cpp
+++ lib/CodeGen/Analysis.cpp
@@ -536,9 +536,11 @@
       // Debug info intrinsics do not get in the way of tail call optimization.
       if (isa<DbgInfoIntrinsic>(BBI))
         continue;
-      // A lifetime end intrinsic should not stop tail call optimization.
+      // A lifetime end or assume intrinsic should not stop tail call
+      // optimization.
       if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(BBI))
-        if (II->getIntrinsicID() == Intrinsic::lifetime_end)
+        if (II->getIntrinsicID() == Intrinsic::lifetime_end ||
+            II->getIntrinsicID() == Intrinsic::assume)
           continue;
       if (BBI->mayHaveSideEffects() || BBI->mayReadFromMemory() ||
           !isSafeToSpeculativelyExecute(&*BBI))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66096.214729.patch
Type: text/x-patch
Size: 1461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190812/dbe9e725/attachment.bin>


More information about the llvm-commits mailing list