From 13d6898f89ad1b044d650d01d81176089a5ab363 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 24 Mar 2010 00:35:44 +0000 Subject: [PATCH] Minor cleanup. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99364 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGVtable.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp index 9204e4e565..fae0f362b1 100644 --- a/lib/CodeGen/CGVtable.cpp +++ b/lib/CodeGen/CGVtable.cpp @@ -3668,22 +3668,20 @@ llvm::Constant *CodeGenModule::GetAddrOfThunk(GlobalDecl GD, void CodeGenVTables::EmitThunk(GlobalDecl GD, const ThunkInfo &Thunk) { - llvm::Constant *ThunkFn = CGM.GetAddrOfThunk(GD, Thunk); + llvm::Constant *Entry = CGM.GetAddrOfThunk(GD, Thunk); const CXXMethodDecl *MD = cast(GD.getDecl()); // Strip off a bitcast if we got one back. - if (llvm::ConstantExpr *CE = dyn_cast(ThunkFn)) { + if (llvm::ConstantExpr *CE = dyn_cast(Entry)) { assert(CE->getOpcode() == llvm::Instruction::BitCast); - ThunkFn = CE->getOperand(0); + Entry = CE->getOperand(0); } - const llvm::Type *ThunkFnTy = - cast(ThunkFn)->getType()->getElementType(); - // There's already a declaration with the same name, check if it has the same // type or if we need to replace it. - if (ThunkFnTy != CGM.getTypes().GetFunctionTypeForVtable(MD)) { - llvm::GlobalValue *OldThunkFn = cast(ThunkFn); + if (cast(Entry)->getType()->getElementType() != + CGM.getTypes().GetFunctionTypeForVtable(MD)) { + llvm::GlobalValue *OldThunkFn = cast(Entry); // If the types mismatch then we have to rewrite the definition. assert(OldThunkFn->isDeclaration() && @@ -3691,12 +3689,12 @@ 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()); - ThunkFn = CGM.GetAddrOfThunk(GD, Thunk); + Entry = CGM.GetAddrOfThunk(GD, Thunk); // If needed, replace the old thunk with a bitcast. if (!OldThunkFn->use_empty()) { llvm::Constant *NewPtrForOldDecl = - llvm::ConstantExpr::getBitCast(ThunkFn, OldThunkFn->getType()); + llvm::ConstantExpr::getBitCast(Entry, OldThunkFn->getType()); OldThunkFn->replaceAllUsesWith(NewPtrForOldDecl); } -- 2.40.0