r255397 - Attach maximum function count to Module when using PGO mode
Easwaran Raman via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 11 16:31:03 PST 2015
Author: eraman
Date: Fri Dec 11 18:31:02 2015
New Revision: 255397
URL: http://llvm.org/viewvc/llvm-project?rev=255397&view=rev
Log:
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
Added:
cfe/trunk/test/CodeGen/pgo-max-function-count.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=255397&r1=255396&r2=255397&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Dec 11 18:31:02 2015
@@ -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();
Added: cfe/trunk/test/CodeGen/pgo-max-function-count.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-max-function-count.c?rev=255397&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/pgo-max-function-count.c (added)
+++ cfe/trunk/test/CodeGen/pgo-max-function-count.c Fri Dec 11 18:31:02 2015
@@ -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}
More information about the cfe-commits
mailing list