aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGVTables.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGVTables.cpp')
-rw-r--r--lib/CodeGen/CGVTables.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp
index e36051c2053b..1b7f1d76042d 100644
--- a/lib/CodeGen/CGVTables.cpp
+++ b/lib/CodeGen/CGVTables.cpp
@@ -56,6 +56,21 @@ static void setThunkVisibility(CodeGenModule &CGM, const CXXMethodDecl *MD,
CGM.setGlobalVisibility(Fn, MD);
}
+static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo &Thunk,
+ llvm::Function *ThunkFn, bool ForVTable,
+ GlobalDecl GD) {
+ CGM.setFunctionLinkage(GD, ThunkFn);
+ CGM.getCXXABI().setThunkLinkage(ThunkFn, ForVTable, GD,
+ !Thunk.Return.isEmpty());
+
+ // Set the right visibility.
+ const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
+ setThunkVisibility(CGM, MD, Thunk, ThunkFn);
+
+ if (CGM.supportsCOMDAT() && ThunkFn->isWeakForLinker())
+ ThunkFn->setComdat(CGM.getModule().getOrInsertComdat(ThunkFn->getName()));
+}
+
#ifndef NDEBUG
static bool similar(const ABIArgInfo &infoL, CanQualType typeL,
const ABIArgInfo &infoR, CanQualType typeR) {
@@ -429,8 +444,7 @@ void CodeGenVTables::emitThunk(GlobalDecl GD, const ThunkInfo &Thunk,
return;
}
- // Change the linkage.
- CGM.setFunctionLinkage(GD, ThunkFn);
+ setThunkProperties(CGM, Thunk, ThunkFn, ForVTable, GD);
return;
}
@@ -451,16 +465,7 @@ void CodeGenVTables::emitThunk(GlobalDecl GD, const ThunkInfo &Thunk,
CodeGenFunction(CGM).generateThunk(ThunkFn, FnInfo, GD, Thunk);
}
- CGM.setFunctionLinkage(GD, ThunkFn);
- CGM.getCXXABI().setThunkLinkage(ThunkFn, ForVTable, GD,
- !Thunk.Return.isEmpty());
-
- // Set the right visibility.
- const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
- setThunkVisibility(CGM, MD, Thunk, ThunkFn);
-
- if (CGM.supportsCOMDAT() && ThunkFn->isWeakForLinker())
- ThunkFn->setComdat(CGM.getModule().getOrInsertComdat(ThunkFn->getName()));
+ setThunkProperties(CGM, Thunk, ThunkFn, ForVTable, GD);
}
void CodeGenVTables::maybeEmitThunkForVTable(GlobalDecl GD,