summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEaswaran Raman <eraman@google.com>2015-12-12 00:31:02 +0000
committerEaswaran Raman <eraman@google.com>2015-12-12 00:31:02 +0000
commitd547e5e16842f13b4c78eb942d349c8f1c553148 (patch)
treef976aa654374ca9fd02a0c7eedb0b8720d8afef8
parent8f5549726408bec990b3a371cf8bcd8c4ff286fb (diff)
downloadbcm5719-llvm-d547e5e16842f13b4c78eb942d349c8f1c553148.tar.gz
bcm5719-llvm-d547e5e16842f13b4c78eb942d349c8f1c553148.zip
Attach maximum function count to Module when using PGO mode
This sets the maximum entry count among all functions in the program to the module using module flags. This allows the optimizer to use this information. Differential Revision: http://reviews.llvm.org/D15163 llvm-svn: 255397
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp3
-rw-r--r--clang/test/CodeGen/pgo-max-function-count.c9
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 29c5f3eed5a..8d7254904a9 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -376,6 +376,9 @@ void CodeGenModule::Release() {
}
if (PGOReader && PGOStats.hasDiagnostics())
PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName);
+ // In PGO mode, attach maximum function count to the module.
+ if (PGOReader)
+ getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount());
EmitCtorList(GlobalCtors, "llvm.global_ctors");
EmitCtorList(GlobalDtors, "llvm.global_dtors");
EmitGlobalAnnotations();
diff --git a/clang/test/CodeGen/pgo-max-function-count.c b/clang/test/CodeGen/pgo-max-function-count.c
new file mode 100644
index 00000000000..b60a4671eb1
--- /dev/null
+++ b/clang/test/CodeGen/pgo-max-function-count.c
@@ -0,0 +1,9 @@
+// RUN: %clang -fprofile-generate -o %t -O2 %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: %clang -fprofile-use=%t.profdata -o - -S -emit-llvm %s | FileCheck %s
+// Check
+int main() {
+ return 0;
+}
+// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 1}
OpenPOWER on IntegriCloud