aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGVTables.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-03-09 04:27:21 +0000
committerJohn McCall <rjmccall@apple.com>2011-03-09 04:27:21 +0000
commitd26bc76c98006609002d9930f8840490e88ac5b5 (patch)
treef2a0c8ea750e38c4e98b006f171b137a0625f0f9 /lib/CodeGen/CGVTables.cpp
parenteecf5fa12d5426637c47d7072f0c193a8d7ff68b (diff)
Use the "undergoes default argument promotion" bit on parameters to
simplify the logic of initializing function parameters so that we don't need both a variable declaration and a type in FunctionArgList. This also means that we need to propagate the CGFunctionInfo down in a lot of places rather than recalculating it from the FAL. There's more we can do to eliminate redundancy here, and I've left FIXMEs behind to do it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127314 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGVTables.cpp')
-rw-r--r--lib/CodeGen/CGVTables.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp
index 891697f4cd..3a3e6cf234 100644
--- a/lib/CodeGen/CGVTables.cpp
+++ b/lib/CodeGen/CGVTables.cpp
@@ -2559,8 +2559,9 @@ static void setThunkVisibility(CodeGenModule &CGM, const CXXMethodDecl *MD,
Fn->setVisibility(llvm::GlobalValue::HiddenVisibility);
}
-void CodeGenFunction::GenerateThunk(llvm::Function *Fn, GlobalDecl GD,
- const ThunkInfo &Thunk) {
+void CodeGenFunction::GenerateThunk(llvm::Function *Fn,
+ const CGFunctionInfo &FnInfo,
+ GlobalDecl GD, const ThunkInfo &Thunk) {
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
QualType ResultType = FPT->getResultType();
@@ -2580,10 +2581,11 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn, GlobalDecl GD,
E = MD->param_end(); I != E; ++I) {
ParmVarDecl *Param = *I;
- FunctionArgs.push_back(std::make_pair(Param, Param->getType()));
+ FunctionArgs.push_back(Param);
}
- StartFunction(GlobalDecl(), ResultType, Fn, FunctionArgs, SourceLocation());
+ StartFunction(GlobalDecl(), ResultType, Fn, FnInfo, FunctionArgs,
+ SourceLocation());
CGM.getCXXABI().EmitInstanceFunctionProlog(*this);
@@ -2614,9 +2616,11 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn, GlobalDecl GD,
FPT->isVariadic());
llvm::Value *Callee = CGM.GetAddrOfFunction(GD, Ty, /*ForVTable=*/true);
- const CGFunctionInfo &FnInfo =
- CGM.getTypes().getFunctionInfo(ResultType, CallArgs,
- FPT->getExtInfo());
+#ifndef NDEBUG
+ const CGFunctionInfo &CallFnInfo =
+ CGM.getTypes().getFunctionInfo(ResultType, CallArgs, FPT->getExtInfo());
+ assert(&CallFnInfo == &FnInfo && "thunk has different CC from callee?");
+#endif
// Determine whether we have a return value slot to use.
ReturnValueSlot Slot;
@@ -2684,6 +2688,9 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn, GlobalDecl GD,
void CodeGenVTables::EmitThunk(GlobalDecl GD, const ThunkInfo &Thunk,
bool UseAvailableExternallyLinkage)
{
+ const CGFunctionInfo &FnInfo = CGM.getTypes().getFunctionInfo(GD);
+
+ // FIXME: re-use FnInfo in this computation.
llvm::Constant *Entry = CGM.GetAddrOfThunk(GD, Thunk);
// Strip off a bitcast if we got one back.
@@ -2735,7 +2742,7 @@ void CodeGenVTables::EmitThunk(GlobalDecl GD, const ThunkInfo &Thunk,
}
// Actually generate the thunk body.
- CodeGenFunction(CGM).GenerateThunk(ThunkFn, GD, Thunk);
+ CodeGenFunction(CGM).GenerateThunk(ThunkFn, FnInfo, GD, Thunk);
if (UseAvailableExternallyLinkage)
ThunkFn->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);