mirror of
https://github.com/intel/llvm.git
synced 2026-02-09 01:34:21 +08:00
Don't crash when generating code for __attribute__((naked)) member functions.
Summary: Previously this crashed inside EmitThisParam(). There should be no prelude for naked functions, so just skip the whole thing. Reviewers: majnemer Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D22715 llvm-svn: 276925
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
13
clang/test/CodeGenCXX/naked.cpp
Normal file
13
clang/test/CodeGenCXX/naked.cpp
Normal file
@@ -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("");
|
||||
}
|
||||
Reference in New Issue
Block a user