Work-in-progess rewrite of thunks: move thunk generation outside of vtable
generation, and make sure we generate thunks when the function is defined
rather than when the vtable is defined.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90722 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 8fb03b2..5f822f5 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -621,8 +621,13 @@
Context.getSourceManager(),
"Generating code for declaration");
- if (isa<CXXMethodDecl>(D))
+ if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
getVtableInfo().MaybeEmitVtable(GD);
+ if (MD->isVirtual() && MD->isOutOfLine() &&
+ (!isa<CXXDestructorDecl>(D) || GD.getDtorType() != Dtor_Base)) {
+ BuildThunksForVirtual(GD);
+ }
+ }
if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D))
EmitCXXConstructor(CD, GD.getCtorType());