diff --git a/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp b/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp --- a/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp +++ b/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp @@ -125,6 +125,9 @@ if (Call->isNoBuiltin() || Call->isStrictFP()) continue; + if (Call->isMustTailCall()) + continue; + // Skip if function either has local linkage or is not a known library // function. LibFunc LF; diff --git a/llvm/test/Transforms/PartiallyInlineLibCalls/musttail.ll b/llvm/test/Transforms/PartiallyInlineLibCalls/musttail.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/PartiallyInlineLibCalls/musttail.ll @@ -0,0 +1,10 @@ +; RUN: opt -S -partially-inline-libcalls -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s +; RUN: opt -S -passes=partially-inline-libcalls -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s + +define double @foo(double %x) { + ; CHECK: call {{.*}} @sqrt + %r = musttail call double @sqrt(double %x) + ret double %r +} + +declare double @sqrt(double)