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/X86/musttail.ll b/llvm/test/Transforms/PartiallyInlineLibCalls/X86/musttail.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/PartiallyInlineLibCalls/X86/musttail.ll @@ -0,0 +1,14 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; 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-LABEL: @foo( +; CHECK-NEXT: [[R:%.*]] = musttail call double @sqrt(double [[X:%.*]]) +; CHECK-NEXT: ret double [[R]] +; + %r = musttail call double @sqrt(double %x) + ret double %r +} + +declare double @sqrt(double)