diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -1139,9 +1139,8 @@ bool IsTailCall = CI->isTailCall(); if (IsTailCall && !isInTailCallPosition(*CI, TM)) IsTailCall = false; - if (IsTailCall && MF->getFunction() - .getFnAttribute("disable-tail-calls") - .getValueAsBool()) + if (IsTailCall && !CI->isMustTailCall() && + MF->getFunction().getFnAttribute("disable-tail-calls").getValueAsBool()) IsTailCall = false; CallLoweringInfo CLI; diff --git a/llvm/test/CodeGen/X86/fast-isel-disable-tail-calls.ll b/llvm/test/CodeGen/X86/fast-isel-disable-tail-calls.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/X86/fast-isel-disable-tail-calls.ll @@ -0,0 +1,9 @@ +; RUN: llc -O0 -fast-isel -mtriple=x86_64-unknown-unknown < %s | FileCheck %s + +; CHECK-NOT: retq +; CHECK: jmpq + +define void @f(ptr %this) "disable-tail-calls"="true" { + musttail call void %this(ptr %this) + ret void +}