From e03f6a16317625b97e9332eed7c6875fae6b1d94 Mon Sep 17 00:00:00 2001 From: Guozhi Wei Date: Fri, 16 Aug 2019 16:26:12 +0000 Subject: [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 --- llvm/lib/CodeGen/Analysis.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'llvm/lib/CodeGen/Analysis.cpp') diff --git a/llvm/lib/CodeGen/Analysis.cpp b/llvm/lib/CodeGen/Analysis.cpp index e72938ba9be..f1bbb341df1 100644 --- a/llvm/lib/CodeGen/Analysis.cpp +++ b/llvm/lib/CodeGen/Analysis.cpp @@ -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(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(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)) -- cgit v1.2.3