Index: lib/CodeGen/ItaniumCXXABI.cpp =================================================================== --- lib/CodeGen/ItaniumCXXABI.cpp +++ lib/CodeGen/ItaniumCXXABI.cpp @@ -1390,6 +1390,10 @@ } void ItaniumCXXABI::EmitInstanceFunctionProlog(CodeGenFunction &CGF) { + // Naked functions have no prolog. + if (CGF.CurFuncDecl->hasAttr()) + return; + /// Initialize the 'this' slot. EmitThisParam(CGF); Index: lib/CodeGen/MicrosoftCXXABI.cpp =================================================================== --- lib/CodeGen/MicrosoftCXXABI.cpp +++ lib/CodeGen/MicrosoftCXXABI.cpp @@ -1417,6 +1417,10 @@ } void MicrosoftCXXABI::EmitInstanceFunctionProlog(CodeGenFunction &CGF) { + // Naked functions have no prolog. + if (CGF.CurFuncDecl->hasAttr()) + return; + EmitThisParam(CGF); /// If this is a function that the ABI specifies returns 'this', initialize Index: test/CodeGenCXX/naked.cpp =================================================================== --- /dev/null +++ test/CodeGenCXX/naked.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-windows -emit-llvm %s -o - | FileCheck %s + +class TestNaked { +public: + void NakedFunction(); +}; + +__attribute__((naked)) void TestNaked::NakedFunction() { + // CHECK-LABEL: define void @ + // CHECK: call void asm sideeffect + asm(""); +}