From 2e2995bf506c4f971f20235f59e0ceed45b77770 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 5 Nov 2013 21:37:29 +0000 Subject: 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 --- clang/lib/CodeGen/CodeGenModule.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index c34f833..d7f33c9 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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::iterator I = Aliases.begin(), @@ -207,6 +221,7 @@ void CodeGenModule::checkAliases() { void CodeGenModule::Release() { EmitDeferred(); + applyReplacements(); checkAliases(); EmitCXXGlobalInitFunc(); EmitCXXGlobalDtorFunc(); -- cgit v1.1