eraman updated this revision to Diff 42549.
eraman added a comment.

Added a test case.


Repository:
  rL LLVM

http://reviews.llvm.org/D15163

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGen/pgo-max-function-count.c

Index: test/CodeGen/pgo-max-function-count.c
===================================================================
--- /dev/null
+++ 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}
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -376,6 +376,9 @@
   }
   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();


Index: test/CodeGen/pgo-max-function-count.c
===================================================================
--- /dev/null
+++ 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}
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -376,6 +376,9 @@
   }
   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();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to