[cfe-commits] r126863 - in /cfe/trunk: include/clang/AST/Type.h include/clang/Basic/TargetInfo.h lib/AST/DumpXML.cpp lib/AST/MicrosoftMangle.cpp lib/AST/Type.cpp lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGCall.cpp lib/CodeGen/CGDeclCXX.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGExprCXX.cpp lib/CodeGen/CGObjC.cpp lib/CodeGen/CGVTables.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/CodeGenFunction.h lib/CodeGen/CodeGenTypes.h lib/CodeGen/TargetInfo.cpp
Tilmann Scheller
tilmann.scheller at googlemail.com
Wed Mar 2 11:36:23 PST 2011
Author: tilmann
Date: Wed Mar 2 13:36:23 2011
New Revision: 126863
URL: http://llvm.org/viewvc/llvm-project?rev=126863&view=rev
Log:
Add CC_Win64ThisCall and set it in the necessary places.
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/DumpXML.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenTypes.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Mar 2 13:36:23 2011
@@ -354,7 +354,8 @@
CC_X86StdCall, // __attribute__((stdcall))
CC_X86FastCall, // __attribute__((fastcall))
CC_X86ThisCall, // __attribute__((thiscall))
- CC_X86Pascal // __attribute__((pascal))
+ CC_X86Pascal, // __attribute__((pascal))
+ CC_Win64ThisCall
};
typedef std::pair<const Type*, Qualifiers> SplitQualType;
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Mar 2 13:36:23 2011
@@ -530,6 +530,12 @@
virtual const char *getStaticInitSectionSpecifier() const {
return 0;
}
+
+ // isWin64 - Whether the target is MSVC Win64.
+ bool isWin64() const {
+ return (Triple.getArch() == llvm::Triple::x86_64)
+ && (Triple.getOS() == llvm::Triple::Win32);
+ }
protected:
virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
return PointerWidth;
Modified: cfe/trunk/lib/AST/DumpXML.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DumpXML.cpp?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DumpXML.cpp (original)
+++ cfe/trunk/lib/AST/DumpXML.cpp Wed Mar 2 13:36:23 2011
@@ -911,6 +911,7 @@
case CC_X86StdCall: return set("cc", "x86_stdcall");
case CC_X86ThisCall: return set("cc", "x86_thiscall");
case CC_X86Pascal: return set("cc", "x86_pascal");
+ case CC_Win64ThisCall: return set("cc", "win64_thiscall");
}
}
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed Mar 2 13:36:23 2011
@@ -879,6 +879,9 @@
case CC_X86ThisCall: Out << 'E'; break;
case CC_X86StdCall: Out << 'G'; break;
case CC_X86FastCall: Out << 'I'; break;
+ case CC_Win64ThisCall:
+ assert(false && "Don't know how to mangle Win64 thiscall cc yet!");
+ break;
}
}
void MicrosoftCXXNameMangler::mangleThrowSpecification(
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Wed Mar 2 13:36:23 2011
@@ -1157,6 +1157,7 @@
case CC_X86FastCall: return "fastcall";
case CC_X86ThisCall: return "thiscall";
case CC_X86Pascal: return "pascal";
+ case CC_Win64ThisCall: return "win64_thiscall";
}
llvm_unreachable("Invalid calling convention.");
Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Wed Mar 2 13:36:23 2011
@@ -922,7 +922,7 @@
// Begin generating the function.
StartFunction(blockDecl, fnType->getResultType(), fn, args,
- blockInfo.getBlockExpr()->getBody()->getLocEnd());
+ blockInfo.getBlockExpr()->getBody()->getLocEnd(), CC_Default);
CurFuncDecl = outerFnDecl; // StartFunction sets this to blockDecl
// Okay. Undo some of what StartFunction did.
@@ -1078,7 +1078,7 @@
SC_None,
false,
true);
- StartFunction(FD, C.VoidTy, Fn, args, SourceLocation());
+ StartFunction(FD, C.VoidTy, Fn, args, SourceLocation(), CC_Default);
const llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
@@ -1167,7 +1167,7 @@
SC_Static,
SC_None,
false, true);
- StartFunction(FD, C.VoidTy, Fn, args, SourceLocation());
+ StartFunction(FD, C.VoidTy, Fn, args, SourceLocation(), CC_Default);
const llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
@@ -1270,7 +1270,7 @@
SC_Static,
SC_None,
false, true);
- StartFunction(FD, R, Fn, Args, SourceLocation());
+ StartFunction(FD, R, Fn, Args, SourceLocation(), CC_Default);
// dst->x
llvm::Value *V = GetAddrOfLocalVar(Dst);
@@ -1340,7 +1340,7 @@
SC_Static,
SC_None,
false, true);
- StartFunction(FD, R, Fn, Args, SourceLocation());
+ StartFunction(FD, R, Fn, Args, SourceLocation(), CC_Default);
llvm::Value *V = GetAddrOfLocalVar(Src);
V = Builder.CreateBitCast(V, llvm::PointerType::get(T, 0));
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Mar 2 13:36:23 2011
@@ -36,6 +36,7 @@
case CC_X86StdCall: return llvm::CallingConv::X86_StdCall;
case CC_X86FastCall: return llvm::CallingConv::X86_FastCall;
case CC_X86ThisCall: return llvm::CallingConv::X86_ThisCall;
+ case CC_Win64ThisCall: return llvm::CallingConv::Win64_ThisCall;
// TODO: add support for CC_X86Pascal to llvm
}
}
@@ -75,19 +76,23 @@
static const CGFunctionInfo &getFunctionInfo(CodeGenTypes &CGT,
llvm::SmallVectorImpl<CanQualType> &ArgTys,
CanQual<FunctionProtoType> FTP,
+ CallingConv CC,
bool IsRecursive = false) {
// FIXME: Kill copy.
for (unsigned i = 0, e = FTP->getNumArgs(); i != e; ++i)
ArgTys.push_back(FTP->getArgType(i));
CanQualType ResTy = FTP->getResultType().getUnqualifiedType();
- return CGT.getFunctionInfo(ResTy, ArgTys, FTP->getExtInfo(), IsRecursive);
+
+ return CGT.getFunctionInfo(ResTy, ArgTys,
+ FTP->getExtInfo().withCallingConv(CC),
+ IsRecursive);
}
const CGFunctionInfo &
CodeGenTypes::getFunctionInfo(CanQual<FunctionProtoType> FTP,
bool IsRecursive) {
llvm::SmallVector<CanQualType, 16> ArgTys;
- return ::getFunctionInfo(*this, ArgTys, FTP, IsRecursive);
+ return ::getFunctionInfo(*this, ArgTys, FTP, CC_Default, IsRecursive);
}
static CallingConv getCallingConventionForDecl(const Decl *D) {
@@ -114,8 +119,10 @@
// Add the 'this' pointer.
ArgTys.push_back(GetThisType(Context, RD));
+ CallingConv CC = Context.Target.isWin64() ? CC_Win64ThisCall : CC_Default;
+
return ::getFunctionInfo(*this, ArgTys,
- FTP->getCanonicalTypeUnqualified().getAs<FunctionProtoType>());
+ FTP->getCanonicalTypeUnqualified().getAs<FunctionProtoType>(), CC);
}
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const CXXMethodDecl *MD) {
@@ -128,7 +135,9 @@
if (MD->isInstance())
ArgTys.push_back(GetThisType(Context, MD->getParent()));
- return ::getFunctionInfo(*this, ArgTys, GetFormalType(MD));
+ CallingConv CC = Context.Target.isWin64() ? CC_Win64ThisCall : CC_Default;
+
+ return ::getFunctionInfo(*this, ArgTys, GetFormalType(MD), CC);
}
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const CXXConstructorDecl *D,
@@ -145,7 +154,9 @@
for (unsigned i = 0, e = FTP->getNumArgs(); i != e; ++i)
ArgTys.push_back(FTP->getArgType(i));
- return getFunctionInfo(ResTy, ArgTys, FTP->getExtInfo());
+ CallingConv CC = Context.Target.isWin64() ? CC_Win64ThisCall : CC_Default;
+
+ return getFunctionInfo(ResTy, ArgTys, FTP->getExtInfo().withCallingConv(CC));
}
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const CXXDestructorDecl *D,
@@ -159,7 +170,9 @@
CanQual<FunctionProtoType> FTP = GetFormalType(D);
assert(FTP->getNumArgs() == 0 && "dtor with formal parameters");
- return getFunctionInfo(ResTy, ArgTys, FTP->getExtInfo());
+ CallingConv CC = Context.Target.isWin64() ? CC_Win64ThisCall : CC_Default;
+
+ return getFunctionInfo(ResTy, ArgTys, FTP->getExtInfo().withCallingConv(CC));
}
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionDecl *FD) {
@@ -250,8 +263,8 @@
return *FI;
// Construct the function info.
- FI = new CGFunctionInfo(CC, Info.getNoReturn(), Info.getRegParm(), ResTy,
- ArgTys.data(), ArgTys.size());
+ FI = new CGFunctionInfo(CC, Info.getNoReturn(), Info.getRegParm(),
+ ResTy, ArgTys.data(), ArgTys.size());
FunctionInfos.InsertNode(FI, InsertPos);
// Compute ABI information.
Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Mar 2 13:36:23 2011
@@ -261,7 +261,7 @@
const VarDecl *D,
llvm::GlobalVariable *Addr) {
StartFunction(GlobalDecl(), getContext().VoidTy, Fn, FunctionArgList(),
- SourceLocation());
+ SourceLocation(), CC_Default);
// Use guarded initialization if the global variable is weak due to
// being a class template's static data member.
@@ -278,7 +278,7 @@
llvm::Constant **Decls,
unsigned NumDecls) {
StartFunction(GlobalDecl(), getContext().VoidTy, Fn, FunctionArgList(),
- SourceLocation());
+ SourceLocation(), CC_Default);
for (unsigned i = 0; i != NumDecls; ++i)
if (Decls[i])
@@ -290,8 +290,10 @@
void CodeGenFunction::GenerateCXXGlobalDtorFunc(llvm::Function *Fn,
const std::vector<std::pair<llvm::WeakVH, llvm::Constant*> >
&DtorsAndObjects) {
+ const bool IsWin64 = getContext().Target.isWin64();
+
StartFunction(GlobalDecl(), getContext().VoidTy, Fn, FunctionArgList(),
- SourceLocation());
+ SourceLocation(), IsWin64 ? CC_Win64ThisCall : CC_Default);
// Emit the dtors, in reverse order from construction.
for (unsigned i = 0, e = DtorsAndObjects.size(); i != e; ++i) {
@@ -327,7 +329,8 @@
llvm::Function *Fn =
CreateGlobalInitOrDestructFunction(CGM, FTy, "__cxx_global_array_dtor");
- StartFunction(GlobalDecl(), getContext().VoidTy, Fn, Args, SourceLocation());
+ StartFunction(GlobalDecl(), getContext().VoidTy, Fn, Args, SourceLocation(),
+ CC_Default);
QualType BaseElementTy = getContext().getBaseElementType(Array);
const llvm::Type *BasePtr = ConvertType(BaseElementTy)->getPointerTo();
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Mar 2 13:36:23 2011
@@ -2121,7 +2121,7 @@
CallArgList Args;
EmitCallArgs(Args, dyn_cast<FunctionProtoType>(FnType), ArgBeg, ArgEnd);
- return EmitCall(CGM.getTypes().getFunctionInfo(Args, FnType),
+ return EmitCall(CGM.getTypes().getFunctionInfo(Args, FnType, CC_Default),
Callee, ReturnValue, Args, TargetDecl);
}
Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Wed Mar 2 13:36:23 2011
@@ -48,8 +48,13 @@
EmitCallArgs(Args, FPT, ArgBeg, ArgEnd);
QualType ResultType = FPT->getResultType();
- return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args,
- FPT->getExtInfo()),
+ FunctionType::ExtInfo Info = FPT->getExtInfo();
+
+ if (getContext().Target.isWin64()) {
+ Info = Info.withCallingConv(CC_Win64ThisCall);
+ }
+
+ return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args, Info),
Callee, ReturnValue, Args, MD);
}
@@ -292,8 +297,11 @@
// And the rest of the call args
EmitCallArgs(Args, FPT, E->arg_begin(), E->arg_end());
const FunctionType *BO_FPT = BO->getType()->getAs<FunctionProtoType>();
- return EmitCall(CGM.getTypes().getFunctionInfo(Args, BO_FPT), Callee,
- ReturnValue, Args);
+
+ const CGFunctionInfo &FI = CGM.getTypes().getFunctionInfo(Args, BO_FPT,
+ CGM.getContext().Target.isWin64() ? CC_Win64ThisCall : CC_Default);
+
+ return EmitCall(FI , Callee, ReturnValue, Args);
}
RValue
@@ -810,8 +818,10 @@
for (unsigned I = 0; I != NumPlacementArgs; ++I)
DeleteArgs.push_back(std::make_pair(getPlacementArgs()[I], *AI++));
+ // FIXME Check whether this needs thiscall on Win64.
// Call 'operator delete'.
- CGF.EmitCall(CGF.CGM.getTypes().getFunctionInfo(DeleteArgs, FPT),
+ CGF.EmitCall(CGF.CGM.getTypes().getFunctionInfo(DeleteArgs, FPT,
+ CC_Default),
CGF.CGM.GetAddrOfFunction(OperatorDelete),
ReturnValueSlot(), DeleteArgs, OperatorDelete);
}
@@ -871,8 +881,10 @@
DeleteArgs.push_back(std::make_pair(RV, *AI++));
}
+ // FIXME Check whether this needs thiscall on Win64.
// Call 'operator delete'.
- CGF.EmitCall(CGF.CGM.getTypes().getFunctionInfo(DeleteArgs, FPT),
+ CGF.EmitCall(CGF.CGM.getTypes().getFunctionInfo(DeleteArgs, FPT,
+ CC_Default),
CGF.CGM.GetAddrOfFunction(OperatorDelete),
ReturnValueSlot(), DeleteArgs, OperatorDelete);
}
@@ -976,7 +988,7 @@
// Emit the call to new.
RValue RV =
- EmitCall(CGM.getTypes().getFunctionInfo(NewArgs, NewFTy),
+ EmitCall(CGM.getTypes().getFunctionInfo(NewArgs, NewFTy, CC_Default),
CGM.GetAddrOfFunction(NewFD), ReturnValueSlot(), NewArgs, NewFD);
// If an allocation function is declared with an empty exception specification
@@ -1086,7 +1098,7 @@
DeleteArgs.push_back(std::make_pair(RValue::get(Size), SizeTy));
// Emit the call to delete.
- EmitCall(CGM.getTypes().getFunctionInfo(DeleteArgs, DeleteFTy),
+ EmitCall(CGM.getTypes().getFunctionInfo(DeleteArgs, DeleteFTy, CC_Default),
CGM.GetAddrOfFunction(DeleteFD), ReturnValueSlot(),
DeleteArgs, DeleteFD);
}
@@ -1207,7 +1219,7 @@
}
// Emit the call to delete.
- CGF.EmitCall(CGF.getTypes().getFunctionInfo(Args, DeleteFTy),
+ CGF.EmitCall(CGF.getTypes().getFunctionInfo(Args, DeleteFTy, CC_Default),
CGF.CGM.GetAddrOfFunction(OperatorDelete),
ReturnValueSlot(), Args, OperatorDelete);
}
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Wed Mar 2 13:36:23 2011
@@ -140,7 +140,8 @@
CurGD = OMD;
- StartFunction(OMD, OMD->getResultType(), Fn, Args, OMD->getLocStart());
+ StartFunction(OMD, OMD->getResultType(), Fn, Args, OMD->getLocStart(),
+ CC_Default);
}
void CodeGenFunction::GenerateObjCGetterBody(ObjCIvarDecl *Ivar,
Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Mar 2 13:36:23 2011
@@ -2582,8 +2582,11 @@
FunctionArgs.push_back(std::make_pair(Param, Param->getType()));
}
-
- StartFunction(GlobalDecl(), ResultType, Fn, FunctionArgs, SourceLocation());
+
+ const bool IsWin64 = CGM.getContext().Target.isWin64();
+
+ StartFunction(GlobalDecl(), ResultType, Fn, FunctionArgs, SourceLocation(),
+ IsWin64 ? CC_Win64ThisCall : CC_Default);
CGM.getCXXABI().EmitInstanceFunctionProlog(*this);
@@ -2614,9 +2617,14 @@
FPT->isVariadic());
llvm::Value *Callee = CGM.GetAddrOfFunction(GD, Ty, /*ForVTable=*/true);
+ FunctionType::ExtInfo Info = FPT->getExtInfo();
+
+ if (IsWin64) {
+ Info = Info.withCallingConv(CC_Win64ThisCall);
+ }
+
const CGFunctionInfo &FnInfo =
- CGM.getTypes().getFunctionInfo(ResultType, CallArgs,
- FPT->getExtInfo());
+ CGM.getTypes().getFunctionInfo(ResultType, CallArgs, Info);
// Determine whether we have a return value slot to use.
ReturnValueSlot Slot;
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Mar 2 13:36:23 2011
@@ -211,7 +211,8 @@
void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
llvm::Function *Fn,
const FunctionArgList &Args,
- SourceLocation StartLoc) {
+ SourceLocation StartLoc,
+ CallingConv CC) {
const Decl *D = GD.getDecl();
DidCallStackSave = false;
@@ -278,7 +279,7 @@
// FIXME: Leaked.
// CC info is ignored, hopefully?
CurFnInfo = &CGM.getTypes().getFunctionInfo(FnRetTy, Args,
- FunctionType::ExtInfo());
+ FunctionType::ExtInfo().withCallingConv(CC));
if (RetTy->isVoidType()) {
// Void type; nothing to return.
@@ -359,7 +360,7 @@
if (Stmt *Body = FD->getBody()) BodyRange = Body->getSourceRange();
// Emit the standard function prologue.
- StartFunction(GD, ResTy, Fn, Args, BodyRange.getBegin());
+ StartFunction(GD, ResTy, Fn, Args, BodyRange.getBegin(), CC_Default);
// Generate the body of the function.
if (isa<CXXDestructorDecl>(FD))
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Mar 2 13:36:23 2011
@@ -1126,7 +1126,8 @@
void StartFunction(GlobalDecl GD, QualType RetTy,
llvm::Function *Fn,
const FunctionArgList &Args,
- SourceLocation StartLoc);
+ SourceLocation StartLoc,
+ CallingConv CC);
void EmitConstructorBody(FunctionArgList &Args);
void EmitDestructorBody(FunctionArgList &Args);
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Wed Mar 2 13:36:23 2011
@@ -161,9 +161,11 @@
CXXDtorType Type);
const CGFunctionInfo &getFunctionInfo(const CallArgList &Args,
- const FunctionType *Ty) {
- return getFunctionInfo(Ty->getResultType(), Args,
- Ty->getExtInfo());
+ const FunctionType *Ty,
+ CallingConv CC) {
+ FunctionType::ExtInfo Info = Ty->getExtInfo().withCallingConv(CC);
+
+ return getFunctionInfo(Ty->getResultType(), Args, Info);
}
const CGFunctionInfo &getFunctionInfo(CanQual<FunctionProtoType> Ty,
Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=126863&r1=126862&r2=126863&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Mar 2 13:36:23 2011
@@ -942,6 +942,26 @@
return false;
}
+
+ void SetTargetAttributes(const Decl *D,
+ llvm::GlobalValue *GV,
+ CodeGen::CodeGenModule &M) const {
+ if (M.getContext().Target.isWin64()) {
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(FD);
+
+ if ((M && M->isInstance())
+ || dyn_cast<CXXConstructorDecl>(FD)
+ || dyn_cast<CXXDestructorDecl>(FD)) {
+ // When using the MSVC Win64 ABI, methods/constructors/destructors
+ // use the Win64 thiscall calling convention.
+ llvm::Function *F = cast<llvm::Function>(GV);
+ F->setCallingConv(llvm::CallingConv::Win64_ThisCall);
+ }
+ }
+ }
+ }
+
};
}
More information about the cfe-commits
mailing list