Index: lib/CodeGen/XRayInstrumentation.cpp =================================================================== --- lib/CodeGen/XRayInstrumentation.cpp +++ lib/CodeGen/XRayInstrumentation.cpp @@ -95,7 +95,13 @@ { for (auto &MBB : MF) { for (auto &T : MBB.terminators()) { - if (T.isReturn()) { + if (T.isReturn() + // So far we handle tail calls as normal function exits. No special + // sleds are emitted, and XRayEntryType::TAIL is not passed to the + // handler. This leads to an effect that A()-->B()-->C() tail calls + // look in XRay tracing like A(),B(),C() calls from the caller of + // function A. + || TII->isTailCall(T)) { // Prepend the return instruction with PATCHABLE_FUNCTION_EXIT BuildMI(MBB, T, T.getDebugLoc(), TII->get(TargetOpcode::PATCHABLE_FUNCTION_EXIT));