Partially inlining a libcall that has the musttail attribute
leads to broken LLVM IR, triggering an assertion in the IR verifier.
Reviewed By: lebedev.ri
Differential Revision: https://reviews.llvm.org/D123116
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;
--- /dev/null
+; 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)