diff options
| -rw-r--r-- | clang/lib/CodeGen/ItaniumCXXABI.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/CodeGen/MicrosoftCXXABI.cpp | 4 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/naked.cpp | 13 |
3 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 6051594fb00..36eb40ef09c 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -1390,6 +1390,10 @@ void ItaniumCXXABI::addImplicitStructorParams(CodeGenFunction &CGF, } void ItaniumCXXABI::EmitInstanceFunctionProlog(CodeGenFunction &CGF) { + // Naked functions have no prolog. + if (CGF.CurFuncDecl && CGF.CurFuncDecl->hasAttr<NakedAttr>()) + return; + /// Initialize the 'this' slot. EmitThisParam(CGF); diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 6b919d16881..28312fce774 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1417,6 +1417,10 @@ llvm::Value *MicrosoftCXXABI::adjustThisParameterInVirtualFunctionPrologue( } void MicrosoftCXXABI::EmitInstanceFunctionProlog(CodeGenFunction &CGF) { + // Naked functions have no prolog. + if (CGF.CurFuncDecl && CGF.CurFuncDecl->hasAttr<NakedAttr>()) + return; + EmitThisParam(CGF); /// If this is a function that the ABI specifies returns 'this', initialize diff --git a/clang/test/CodeGenCXX/naked.cpp b/clang/test/CodeGenCXX/naked.cpp new file mode 100644 index 00000000000..7032823e44b --- /dev/null +++ b/clang/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(""); +} |

