From: Anders Carlsson Date: Sun, 6 Feb 2011 17:15:43 +0000 (+0000) Subject: Simplify thunks code. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84c49e4e4baeb4c30251fd72220efb344b033cf0;p=clang Simplify thunks code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124983 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index 27b4432920..e626be2871 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -2451,8 +2451,7 @@ CodeGenVTables::getAddressPoint(BaseSubobject Base, const CXXRecordDecl *RD) { } llvm::Constant *CodeGenModule::GetAddrOfThunk(GlobalDecl GD, - const ThunkInfo &Thunk, - bool ForVTable) { + const ThunkInfo &Thunk) { const CXXMethodDecl *MD = cast(GD.getDecl()); // Compute the mangled name. @@ -2464,7 +2463,7 @@ llvm::Constant *CodeGenModule::GetAddrOfThunk(GlobalDecl GD, getCXXABI().getMangleContext().mangleThunk(MD, Thunk, Name); const llvm::Type *Ty = getTypes().GetFunctionTypeForVTable(GD); - return GetOrCreateLLVMFunction(Name, Ty, GD, ForVTable); + return GetOrCreateLLVMFunction(Name, Ty, GD, /*ForVTable=*/true); } static llvm::Value *PerformTypeAdjustment(CodeGenFunction &CGF, @@ -2611,7 +2610,7 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn, GlobalDecl GD, const llvm::Type *Ty = CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(GD), FPT->isVariadic()); - llvm::Value *Callee = CGM.GetAddrOfFunction(GD, Ty); + llvm::Value *Callee = CGM.GetAddrOfFunction(GD, Ty, /*ForVTable=*/true); const CGFunctionInfo &FnInfo = CGM.getTypes().getFunctionInfo(ResultType, CallArgs, @@ -2682,7 +2681,7 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn, GlobalDecl GD, void CodeGenVTables::EmitThunk(GlobalDecl GD, const ThunkInfo &Thunk) { - llvm::Constant *Entry = CGM.GetAddrOfThunk(GD, Thunk, /*ForVTable=*/false); + llvm::Constant *Entry = CGM.GetAddrOfThunk(GD, Thunk); // Strip off a bitcast if we got one back. if (llvm::ConstantExpr *CE = dyn_cast(Entry)) { @@ -2702,7 +2701,7 @@ void CodeGenVTables::EmitThunk(GlobalDecl GD, const ThunkInfo &Thunk) // Remove the name from the old thunk function and get a new thunk. OldThunkFn->setName(llvm::StringRef()); - Entry = CGM.GetAddrOfThunk(GD, Thunk, /*ForVTable=*/false); + Entry = CGM.GetAddrOfThunk(GD, Thunk); // If needed, replace the old thunk with a bitcast. if (!OldThunkFn->use_empty()) { @@ -2913,7 +2912,7 @@ CodeGenVTables::CreateVTableInitializer(const CXXRecordDecl *RD, VTableThunks[NextVTableThunkIndex].first == I) { const ThunkInfo &Thunk = VTableThunks[NextVTableThunkIndex].second; - Init = CGM.GetAddrOfThunk(GD, Thunk, /*ForVTable=*/true); + Init = CGM.GetAddrOfThunk(GD, Thunk); NextVTableThunkIndex++; } else { diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 7b6e12358d..1ed56d5b92 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -325,8 +325,7 @@ public: llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false); /// GetAddrOfThunk - Get the address of the thunk for the given global decl. - llvm::Constant *GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk, - bool ForVTable); + llvm::Constant *GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk); /// GetWeakRefReference - Get a reference to the target of VD. llvm::Constant *GetWeakRefReference(const ValueDecl *VD);