Produce direct calls instead of alias to linkonce_odr functions.

This is a small optimization on linux, but should help more on windows
where msvc only outputs one destructor if there would be two identical ones.

llvm-svn: 194095
This commit is contained in:
Rafael Espindola
2013-11-05 21:37:29 +00:00
parent f02287db27
commit 2e2995bf50
5 changed files with 51 additions and 28 deletions

View File

@@ -172,6 +172,20 @@ void CodeGenModule::createCUDARuntime() {
CUDARuntime = CreateNVCUDARuntime(*this);
}
void CodeGenModule::applyReplacements() {
for (ReplacementsTy::iterator I = Replacements.begin(),
E = Replacements.end();
I != E; ++I) {
StringRef MangledName = I->first();
llvm::Constant *Replacement = I->second;
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
if (!Entry)
continue;
Entry->replaceAllUsesWith(Replacement);
Entry->eraseFromParent();
}
}
void CodeGenModule::checkAliases() {
bool Error = false;
for (std::vector<GlobalDecl>::iterator I = Aliases.begin(),
@@ -207,6 +221,7 @@ void CodeGenModule::checkAliases() {
void CodeGenModule::Release() {
EmitDeferred();
applyReplacements();
checkAliases();
EmitCXXGlobalInitFunc();
EmitCXXGlobalDtorFunc();