mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01: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:
parent
99e8ed2949
commit
2020af31f5
@ -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))
|
||||
|
15
test/CodeGen/X86/tailcall-assume.ll
Normal file
15
test/CodeGen/X86/tailcall-assume.ll
Normal 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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user