Index: lib/IR/Verifier.cpp =================================================================== --- lib/IR/Verifier.cpp +++ lib/IR/Verifier.cpp @@ -1054,24 +1054,6 @@ Attribute::Builtin), "Attribute 'builtin' can only be applied to a callsite.", &F); - // Check that this function meets the restrictions on this calling convention. - switch (F.getCallingConv()) { - default: - break; - case CallingConv::C: - break; - case CallingConv::Fast: - case CallingConv::Cold: - case CallingConv::X86_FastCall: - case CallingConv::X86_ThisCall: - case CallingConv::Intel_OCL_BI: - case CallingConv::PTX_Kernel: - case CallingConv::PTX_Device: - Assert1(!F.isVarArg(), - "Varargs functions must have C calling conventions!", &F); - break; - } - bool isLLVMdotName = F.getName().size() >= 5 && F.getName().substr(0, 5) == "llvm."; Index: test/Verifier/musttail-valid.ll =================================================================== --- test/Verifier/musttail-valid.ll +++ test/Verifier/musttail-valid.ll @@ -14,3 +14,21 @@ %w = bitcast i8* %v to i32* ret i32* %w } + +declare x86_thiscallcc void @varargs_thiscall(i8*, ...) +define x86_thiscallcc void @varargs_thiscall_thunk(i8* %this, ...) { + musttail call x86_thiscallcc void (i8*, ...)* @varargs_thiscall(i8* %this, ...) + ret void +} + +declare x86_fastcallcc void @varargs_fastcall(i8*, ...) +define x86_fastcallcc void @varargs_fastcall_thunk(i8* %this, ...) { + musttail call x86_fastcallcc void (i8*, ...)* @varargs_fastcall(i8* %this, ...) + ret void +} + +; The verifier checks shouldn't be looking for musttail in the function. The +; function might just abort. Doing a normal return is just UB. +define x86_thiscallcc void @varargs_thiscall_unreachable(i8* %this, ...) { + unreachable +}