r226764 - InstrProf: Avoid creating profile names for symbols in system headers
Justin Bogner
mail at justinbogner.com
Wed Jan 21 18:17:23 PST 2015
Author: bogner
Date: Wed Jan 21 20:17:23 2015
New Revision: 226764
URL: http://llvm.org/viewvc/llvm-project?rev=226764&view=rev
Log:
InstrProf: Avoid creating profile names for symbols in system headers
We don't emit any coverage mapping for uncovered functions that come
from system headers, but we were creating a GlobalVariable with each
of their names. This is wasteful since the linker will need to dead
strip the unused symbols, and it can lead to issues when merging
coverage with others TUs that do have coverage for those functions.
Added:
cfe/trunk/test/CoverageMapping/unused_names.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=226764&r1=226763&r2=226764&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Wed Jan 21 20:17:23 2015
@@ -732,8 +732,6 @@ CodeGenPGO::emitEmptyCounterMapping(cons
llvm::GlobalValue::LinkageTypes Linkage) {
if (SkipCoverageMapping)
return;
- setFuncName(FuncName, Linkage);
-
// Don't map the functions inside the system headers
auto Loc = D->getBody()->getLocStart();
if (CGM.getContext().getSourceManager().isInSystemHeader(Loc))
@@ -750,6 +748,7 @@ CodeGenPGO::emitEmptyCounterMapping(cons
if (CoverageMapping.empty())
return;
+ setFuncName(FuncName, Linkage);
CGM.getCoverageMapping()->addFunctionMappingRecord(
FuncNameVar, FuncName, FunctionHash, CoverageMapping);
}
Added: cfe/trunk/test/CoverageMapping/unused_names.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/unused_names.c?rev=226764&view=auto
==============================================================================
--- cfe/trunk/test/CoverageMapping/unused_names.c (added)
+++ cfe/trunk/test/CoverageMapping/unused_names.c Wed Jan 21 20:17:23 2015
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -emit-llvm -o - %s | FileCheck %s
+
+// Since foo is never emitted, there should not be a profile name for it.
+
+// CHECK-NOT: @__llvm_profile_name_foo =
+// CHECK: @__llvm_profile_name_bar =
+// CHECK-NOT: @__llvm_profile_name_foo =
+
+#ifdef IS_SYSHEADER
+
+#pragma clang system_header
+inline int foo() { return 0; }
+
+#else
+
+#define IS_SYSHEADER
+#include __FILE__
+
+int bar() { return 0; }
+
+#endif
More information about the cfe-commits
mailing list