summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-12-03 03:47:56 +0000
committerMike Stump <mrs@apple.com>2009-12-03 03:47:56 +0000
commite2d4a2c3a8a6869e088e9ad226bedf6a269b238b (patch)
tree14e2127e8b2a4b3e7e6eb61b94d1a2fc46a56c29 /clang/lib/CodeGen/CGCXX.cpp
parent0b6e2600667c5869ab703a6e77a2afb98667a74d (diff)
downloadbcm5719-llvm-e2d4a2c3a8a6869e088e9ad226bedf6a269b238b.tar.gz
bcm5719-llvm-e2d4a2c3a8a6869e088e9ad226bedf6a269b238b.zip
Add support for thunking dtors. Oh why does this make my head hurt?
llvm-svn: 90409
Diffstat (limited to 'clang/lib/CodeGen/CGCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGCXX.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index a575dbc4630..2fa13eb12d0 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -829,10 +829,10 @@ const char *CodeGenModule::getMangledCXXDtorName(const CXXDestructorDecl *D,
}
llvm::Constant *
-CodeGenFunction::GenerateThunk(llvm::Function *Fn, const CXXMethodDecl *MD,
+CodeGenFunction::GenerateThunk(llvm::Function *Fn, const GlobalDecl &GD,
bool Extern,
const ThunkAdjustment &ThisAdjustment) {
- return GenerateCovariantThunk(Fn, MD, Extern,
+ return GenerateCovariantThunk(Fn, GD, Extern,
CovariantThunkAdjustment(ThisAdjustment,
ThunkAdjustment()));
}
@@ -875,8 +875,10 @@ CodeGenFunction::DynamicTypeAdjust(llvm::Value *V,
llvm::Constant *
CodeGenFunction::GenerateCovariantThunk(llvm::Function *Fn,
- const CXXMethodDecl *MD, bool Extern,
+ const GlobalDecl &GD, bool Extern,
const CovariantThunkAdjustment &Adjustment) {
+
+ const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
QualType ResultType = MD->getType()->getAs<FunctionType>()->getResultType();
FunctionArgList Args;
@@ -906,7 +908,12 @@ CodeGenFunction::GenerateCovariantThunk(llvm::Function *Fn,
const llvm::Type *Ty =
CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
FPT->isVariadic());
- llvm::Value *Callee = CGM.GetAddrOfFunction(MD, Ty);
+ llvm::Value *Callee;
+ if (const CXXDestructorDecl *Dtor = dyn_cast<CXXDestructorDecl>(MD))
+ Callee = CGM.GetAddrOfCXXDestructor(Dtor, GD.getDtorType());
+ else
+ Callee = CGM.GetAddrOfFunction(MD, Ty);
+
CallArgList CallArgs;
bool ShouldAdjustReturnPointer = true;
@@ -922,7 +929,7 @@ CodeGenFunction::GenerateCovariantThunk(llvm::Function *Fn,
CovariantThunkAdjustment(ThunkAdjustment(),
Adjustment.ReturnAdjustment);
- Callee = CGM.BuildCovariantThunk(MD, Extern, ReturnAdjustment);
+ Callee = CGM.BuildCovariantThunk(GD, Extern, ReturnAdjustment);
Callee = Builder.CreateBitCast(Callee, OrigTy);
ShouldAdjustReturnPointer = false;
@@ -983,11 +990,15 @@ CodeGenFunction::GenerateCovariantThunk(llvm::Function *Fn,
}
llvm::Constant *
-CodeGenModule::BuildThunk(const CXXMethodDecl *MD, bool Extern,
+CodeGenModule::BuildThunk(const GlobalDecl &GD, bool Extern,
const ThunkAdjustment &ThisAdjustment) {
-
+ const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
llvm::SmallString<256> OutName;
- getMangleContext().mangleThunk(MD, ThisAdjustment, OutName);
+ if (const CXXDestructorDecl *D = dyn_cast<CXXDestructorDecl>(MD)) {
+ getMangleContext().mangleCXXDtorThunk(D, GD.getDtorType(), ThisAdjustment,
+ OutName);
+ } else
+ getMangleContext().mangleThunk(MD, ThisAdjustment, OutName);
llvm::GlobalVariable::LinkageTypes linktype;
linktype = llvm::GlobalValue::WeakAnyLinkage;
@@ -1001,14 +1012,15 @@ CodeGenModule::BuildThunk(const CXXMethodDecl *MD, bool Extern,
llvm::Function *Fn = llvm::Function::Create(FTy, linktype, OutName.str(),
&getModule());
- CodeGenFunction(*this).GenerateThunk(Fn, MD, Extern, ThisAdjustment);
+ CodeGenFunction(*this).GenerateThunk(Fn, GD, Extern, ThisAdjustment);
llvm::Constant *m = llvm::ConstantExpr::getBitCast(Fn, Ptr8Ty);
return m;
}
llvm::Constant *
-CodeGenModule::BuildCovariantThunk(const CXXMethodDecl *MD, bool Extern,
+CodeGenModule::BuildCovariantThunk(const GlobalDecl &GD, bool Extern,
const CovariantThunkAdjustment &Adjustment) {
+ const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
llvm::SmallString<256> OutName;
getMangleContext().mangleCovariantThunk(MD, Adjustment, OutName);
llvm::GlobalVariable::LinkageTypes linktype;
OpenPOWER on IntegriCloud