1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

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

In function Analysis.cpp:isInTailCallPosition, instructions between call and ret are checked to see if they block tail call optimization. If an instruction is an intrinsic call, only llvm.lifetime_end is allowed and other intrinsic functions block tail call. When compiling tcmalloc, we found llvm.assume between a hot function call and ret, it blocks the optimization. But llvm.assume doesn't generate instructions, it should not block tail call.

Differential Revision: https://reviews.llvm.org/D66096

llvm-svn: 369125
This commit is contained in:
Guozhi Wei 2019-08-16 16:26:12 +00:00
parent 99e8ed2949
commit 2020af31f5
2 changed files with 19 additions and 2 deletions

View File

@ -536,9 +536,11 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM) {
// 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))

View File

@ -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)