Index: lib/Transforms/Scalar/CallSiteSplitting.cpp =================================================================== --- lib/Transforms/Scalar/CallSiteSplitting.cpp +++ lib/Transforms/Scalar/CallSiteSplitting.cpp @@ -397,6 +397,14 @@ static bool tryToSplitCallSite(CallSite CS, TargetTransformInfo &TTI) { if (!CS.arg_size() || !canSplitCallSite(CS, TTI)) return false; + + // musttail calls can't be naively splitted. The split blocks must include + // not only the call instruction itself, but also (optional) bitcast and + // return instructions that follow it. + // + // TODO: Implement proper splitting + if (CS.isMustTailCall()) + return false; return tryToSplitOnPredicatedArgument(CS) || tryToSplitOnPHIPredicatedArgument(CS); } Index: test/Transforms/CallSiteSplitting/musttail.ll =================================================================== --- /dev/null +++ test/Transforms/CallSiteSplitting/musttail.ll @@ -0,0 +1,19 @@ +; RUN: opt < %s -callsite-splitting -S + +define i8* @caller(i8* %a, i8* %b) { + %c = icmp eq i8* %a, null + br i1 %c, label %Tail, label %TBB +TBB: + %c2 = icmp eq i8* %b, null + br i1 %c2, label %Tail, label %End +Tail: + %ca = musttail call i8* @callee(i8* %a, i8* %b) + %cb = bitcast i8* %ca to i8* + ret i8* %cb +End: + ret i8* null +} + +define i8* @callee(i8* %a, i8* %b) noinline { + ret i8* %a +}