From 0293d540baafbe070c1035611787a81001a4118e Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 19 Nov 2008 06:15:35 +0000 Subject: [PATCH] Discard unused runtime function declarations (for readability). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59594 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 3e146215f4..dd46f91d74 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -72,6 +72,12 @@ void CodeGenModule::BindRuntimeFunctions() { llvm::Function *Fn = RuntimeFunctions[i].first; const std::string &Name = RuntimeFunctions[i].second; + // Discard unused runtime functions. + if (Fn->use_empty()) { + Fn->eraseFromParent(); + continue; + } + // See if there is a conflict against a function. llvm::Function *Conflict = TheModule.getFunction(Name); if (Conflict) {