[PATCH] D19612: Use the new path for coverage related headers and update CMakeLists.txt
eraman created this revision. eraman added a reviewer: vsk. eraman added subscribers: cfe-commits, davidxl. http://reviews.llvm.org/D19612 Files: lib/CodeGen/CMakeLists.txt lib/CodeGen/CoverageMappingGen.cpp Index: lib/CodeGen/CoverageMappingGen.cpp === --- lib/CodeGen/CoverageMappingGen.cpp +++ lib/CodeGen/CoverageMappingGen.cpp @@ -18,9 +18,9 @@ #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Optional.h" -#include "llvm/ProfileData/CoverageMapping.h" -#include "llvm/ProfileData/CoverageMappingReader.h" -#include "llvm/ProfileData/CoverageMappingWriter.h" +#include "llvm/ProfileData/Coverage/CoverageMapping.h" +#include "llvm/ProfileData/Coverage/CoverageMappingReader.h" +#include "llvm/ProfileData/Coverage/CoverageMappingWriter.h" #include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/FileSystem.h" Index: lib/CodeGen/CMakeLists.txt === --- lib/CodeGen/CMakeLists.txt +++ lib/CodeGen/CMakeLists.txt @@ -3,6 +3,7 @@ BitReader BitWriter Core + Coverage IPO IRReader InstCombine Index: lib/CodeGen/CoverageMappingGen.cpp === --- lib/CodeGen/CoverageMappingGen.cpp +++ lib/CodeGen/CoverageMappingGen.cpp @@ -18,9 +18,9 @@ #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Optional.h" -#include "llvm/ProfileData/CoverageMapping.h" -#include "llvm/ProfileData/CoverageMappingReader.h" -#include "llvm/ProfileData/CoverageMappingWriter.h" +#include "llvm/ProfileData/Coverage/CoverageMapping.h" +#include "llvm/ProfileData/Coverage/CoverageMappingReader.h" +#include "llvm/ProfileData/Coverage/CoverageMappingWriter.h" #include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/FileSystem.h" Index: lib/CodeGen/CMakeLists.txt === --- lib/CodeGen/CMakeLists.txt +++ lib/CodeGen/CMakeLists.txt @@ -3,6 +3,7 @@ BitReader BitWriter Core + Coverage IPO IRReader InstCombine ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19612: Use the new path for coverage related headers and update CMakeLists.txt
This revision was automatically updated to reflect the committed changes. Closed by commit rL268090: Use the new path for coverage related headers and update CMakeLists.txt (authored by eraman). Changed prior to commit: http://reviews.llvm.org/D19612?vs=55279&id=55643#toc Repository: rL LLVM http://reviews.llvm.org/D19612 Files: cfe/trunk/lib/CodeGen/CMakeLists.txt cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Index: cfe/trunk/lib/CodeGen/CMakeLists.txt === --- cfe/trunk/lib/CodeGen/CMakeLists.txt +++ cfe/trunk/lib/CodeGen/CMakeLists.txt @@ -3,6 +3,7 @@ BitReader BitWriter Core + Coverage IPO IRReader InstCombine Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp === --- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp +++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp @@ -18,9 +18,9 @@ #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Optional.h" -#include "llvm/ProfileData/CoverageMapping.h" -#include "llvm/ProfileData/CoverageMappingReader.h" -#include "llvm/ProfileData/CoverageMappingWriter.h" +#include "llvm/ProfileData/Coverage/CoverageMapping.h" +#include "llvm/ProfileData/Coverage/CoverageMappingReader.h" +#include "llvm/ProfileData/Coverage/CoverageMappingWriter.h" #include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/FileSystem.h" Index: cfe/trunk/lib/CodeGen/CMakeLists.txt === --- cfe/trunk/lib/CodeGen/CMakeLists.txt +++ cfe/trunk/lib/CodeGen/CMakeLists.txt @@ -3,6 +3,7 @@ BitReader BitWriter Core + Coverage IPO IRReader InstCombine Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp === --- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp +++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp @@ -18,9 +18,9 @@ #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Optional.h" -#include "llvm/ProfileData/CoverageMapping.h" -#include "llvm/ProfileData/CoverageMappingReader.h" -#include "llvm/ProfileData/CoverageMappingWriter.h" +#include "llvm/ProfileData/Coverage/CoverageMapping.h" +#include "llvm/ProfileData/Coverage/CoverageMappingReader.h" +#include "llvm/ProfileData/Coverage/CoverageMappingWriter.h" #include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/FileSystem.h" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r268090 - Use the new path for coverage related headers and update CMakeLists.txt
Author: eraman Date: Fri Apr 29 13:53:16 2016 New Revision: 268090 URL: http://llvm.org/viewvc/llvm-project?rev=268090&view=rev Log: Use the new path for coverage related headers and update CMakeLists.txt Differential Revision: http://reviews.llvm.org/D19612 Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=268090&r1=268089&r2=268090&view=diff == --- cfe/trunk/lib/CodeGen/CMakeLists.txt (original) +++ cfe/trunk/lib/CodeGen/CMakeLists.txt Fri Apr 29 13:53:16 2016 @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS BitReader BitWriter Core + Coverage IPO IRReader InstCombine Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=268090&r1=268089&r2=268090&view=diff == --- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original) +++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Fri Apr 29 13:53:16 2016 @@ -18,9 +18,9 @@ #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Optional.h" -#include "llvm/ProfileData/CoverageMapping.h" -#include "llvm/ProfileData/CoverageMappingReader.h" -#include "llvm/ProfileData/CoverageMappingWriter.h" +#include "llvm/ProfileData/Coverage/CoverageMapping.h" +#include "llvm/ProfileData/Coverage/CoverageMappingReader.h" +#include "llvm/ProfileData/Coverage/CoverageMappingWriter.h" #include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/FileSystem.h" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19184: Remove MaxFunctionCount module flag annotation
eraman created this revision. eraman added a reviewer: vsk. eraman added subscribers: cfe-commits, davidxl. Step 2 of MaxFunctionCount removal. It is superseded by ProfileSummary flag. http://reviews.llvm.org/D19184 Files: lib/CodeGen/CodeGenModule.cpp test/Profile/max-function-count.c Index: test/Profile/max-function-count.c === --- test/Profile/max-function-count.c +++ /dev/null @@ -1,24 +0,0 @@ -// Test that maximum function counts are set correctly. - -// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata -// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s -// -int begin(int i) { - if (i) -return 0; - return 1; -} - -int end(int i) { - if (i) -return 0; - return 1; -} - -int main(int argc, const char *argv[]) { - begin(0); - end(1); - end(1); - return 0; -} -// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 2} Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -393,7 +393,6 @@ OpenMPRuntime->emitRegistrationFunction()) AddGlobalCtor(OpenMPRegistrationFunction, 0); if (PGOReader) { -getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext)); if (PGOStats.hasDiagnostics()) PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); Index: test/Profile/max-function-count.c === --- test/Profile/max-function-count.c +++ /dev/null @@ -1,24 +0,0 @@ -// Test that maximum function counts are set correctly. - -// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata -// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s -// -int begin(int i) { - if (i) -return 0; - return 1; -} - -int end(int i) { - if (i) -return 0; - return 1; -} - -int main(int argc, const char *argv[]) { - begin(0); - end(1); - end(1); - return 0; -} -// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 2} Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -393,7 +393,6 @@ OpenMPRuntime->emitRegistrationFunction()) AddGlobalCtor(OpenMPRegistrationFunction, 0); if (PGOReader) { -getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext)); if (PGOStats.hasDiagnostics()) PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19184: Remove MaxFunctionCount module flag annotation
eraman added a comment. This patch and the one in http://reviews.llvm.org/D19185 are now ready to land as the inliner now uses ProfileSummaryInfo. I will check them in. http://reviews.llvm.org/D19184 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273198 - Remove MaxFunctionCount module flag annotation.
Author: eraman Date: Mon Jun 20 15:48:32 2016 New Revision: 273198 URL: http://llvm.org/viewvc/llvm-project?rev=273198&view=rev Log: Remove MaxFunctionCount module flag annotation. Differential revision: http://reviews.llvm.org/D19184 Removed: cfe/trunk/test/Profile/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=273198&r1=273197&r2=273198&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jun 20 15:48:32 2016 @@ -393,7 +393,6 @@ void CodeGenModule::Release() { OpenMPRuntime->emitRegistrationFunction()) AddGlobalCtor(OpenMPRegistrationFunction, 0); if (PGOReader) { -getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext)); if (PGOStats.hasDiagnostics()) PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); Removed: cfe/trunk/test/Profile/max-function-count.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/max-function-count.c?rev=273197&view=auto == --- cfe/trunk/test/Profile/max-function-count.c (original) +++ cfe/trunk/test/Profile/max-function-count.c (removed) @@ -1,24 +0,0 @@ -// Test that maximum function counts are set correctly. - -// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata -// RUN: %clang_cc1 %s -o - -disable-llvm-optzns -emit-llvm -fprofile-instrument-use-path=%t.profdata | FileCheck %s -// -int begin(int i) { - if (i) -return 0; - return 1; -} - -int end(int i) { - if (i) -return 0; - return 1; -} - -int main(int argc, const char *argv[]) { - begin(0); - end(1); - end(1); - return 0; -} -// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 2} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19184: Remove MaxFunctionCount module flag annotation
This revision was automatically updated to reflect the committed changes. Closed by commit rL273198: Remove MaxFunctionCount module flag annotation. (authored by eraman). Changed prior to commit: http://reviews.llvm.org/D19184?vs=53969&id=61302#toc Repository: rL LLVM http://reviews.llvm.org/D19184 Files: cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/test/Profile/max-function-count.c Index: cfe/trunk/test/Profile/max-function-count.c === --- cfe/trunk/test/Profile/max-function-count.c +++ cfe/trunk/test/Profile/max-function-count.c @@ -1,24 +0,0 @@ -// Test that maximum function counts are set correctly. - -// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata -// RUN: %clang_cc1 %s -o - -disable-llvm-optzns -emit-llvm -fprofile-instrument-use-path=%t.profdata | FileCheck %s -// -int begin(int i) { - if (i) -return 0; - return 1; -} - -int end(int i) { - if (i) -return 0; - return 1; -} - -int main(int argc, const char *argv[]) { - begin(0); - end(1); - end(1); - return 0; -} -// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 2} Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp === --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp @@ -393,7 +393,6 @@ OpenMPRuntime->emitRegistrationFunction()) AddGlobalCtor(OpenMPRegistrationFunction, 0); if (PGOReader) { -getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext)); if (PGOStats.hasDiagnostics()) PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); Index: cfe/trunk/test/Profile/max-function-count.c === --- cfe/trunk/test/Profile/max-function-count.c +++ cfe/trunk/test/Profile/max-function-count.c @@ -1,24 +0,0 @@ -// Test that maximum function counts are set correctly. - -// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata -// RUN: %clang_cc1 %s -o - -disable-llvm-optzns -emit-llvm -fprofile-instrument-use-path=%t.profdata | FileCheck %s -// -int begin(int i) { - if (i) -return 0; - return 1; -} - -int end(int i) { - if (i) -return 0; - return 1; -} - -int main(int argc, const char *argv[]) { - begin(0); - end(1); - end(1); - return 0; -} -// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 2} Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp === --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp @@ -393,7 +393,6 @@ OpenMPRuntime->emitRegistrationFunction()) AddGlobalCtor(OpenMPRegistrationFunction, 0); if (PGOReader) { -getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext)); if (PGOStats.hasDiagnostics()) PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D18289: Attach profile summary information to module
eraman created this revision. eraman added a reviewer: vsk. eraman added subscribers: cfe-commits, davidxl. This allows optimization passes to make use of detailed profile summary. Once this is in and the optimization passes are made to use this, the "MaxFunctionCount" flag will be removed as the profile summary supersedes that. http://reviews.llvm.org/D18289 Files: lib/CodeGen/CodeGenModule.cpp test/Profile/Inputs/profile-summary.proftext test/Profile/profile-summary.c Index: test/Profile/profile-summary.c === --- /dev/null +++ test/Profile/profile-summary.c @@ -0,0 +1,60 @@ +// Test that profile summary is set correctly. + +// RUN: llvm-profdata merge %S/Inputs/profile-summary.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s +// +int begin(int i) { + if (!(i % 400)) +i++; + if (!(i % 300)) +i++; + if (!(i % 200)) +i++; + if (!(i % 100)) +i++; + if (!(i % 10)) +i++; + if (!(i % 1)) +i++; + if (!(i % 1000)) +i++; + if (!(i % 100)) +i++; + if (!(i % 10)) +i++; + return 0; +} + +int main(int argc, const char *argv[]) { + for (int i = 0; i <= 400; i++) { +begin(i); +begin(100 - i); + } + return 0; +} +// CHECK: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}} +// CHECK: {{![0-9]+}} = !{!"ProfileFormat", !"InstrProf"} +// CHECK: {{![0-9]+}} = !{!"TotalCount", i64 1286} +// CHECK: {{![0-9]+}} = !{!"MaxBlockCount", i64 802} +// CHECK: {{![0-9]+}} = !{!"MaxInternalBlockCount", i64 401} +// CHECK: {{![0-9]+}} = !{!"MaxFunctionCount", i64 802} +// CHECK: {{![0-9]+}} = !{!"NumBlocks", i64 12} +// CHECK: {{![0-9]+}} = !{!"NumFunctions", i64 2} +// CHECK: {{![0-9]+}} = !{!"DetailedSummary", [[DETAILS:![0-9]+]]} +// CHECK: [[DETAILS]] = !{{{(![0-9]+, )+}}{{![0-9]+}}} +// CHECK: {{![0-9]+}} = !{i32 1, i64 802, i32 1} +// CHECK: {{![0-9]+}} = !{i32 10, i64 802, i32 1} +// CHECK: {{![0-9]+}} = !{i32 20, i64 802, i32 1} +// CHECK: {{![0-9]+}} = !{i32 30, i64 802, i32 1} +// CHECK: {{![0-9]+}} = !{i32 40, i64 802, i32 1} +// CHECK: {{![0-9]+}} = !{i32 50, i64 802, i32 1} +// CHECK: {{![0-9]+}} = !{i32 60, i64 802, i32 1} +// CHECK: {{![0-9]+}} = !{i32 70, i64 401, i32 2} +// CHECK: {{![0-9]+}} = !{i32 80, i64 401, i32 2} +// CHECK: {{![0-9]+}} = !{i32 90, i64 401, i32 2} +// CHECK: {{![0-9]+}} = !{i32 95, i64 72, i32 3} +// CHECK: {{![0-9]+}} = !{i32 99, i64 72, i32 3} +// CHECK: {{![0-9]+}} = !{i32 999000, i64 72000, i32 4} +// CHECK: {{![0-9]+}} = !{i32 00, i64 7200, i32 5} +// CHECK: {{![0-9]+}} = !{i32 90, i64 720, i32 6} +// CHECK: {{![0-9]+}} = !{i32 99, i64 72, i32 7} Index: test/Profile/Inputs/profile-summary.proftext === --- /dev/null +++ test/Profile/Inputs/profile-summary.proftext @@ -0,0 +1,26 @@ +begin +# Func Hash: +2859428334838410 +# Num Counters: +10 +# Counter Values: +802 +3 +2 +2 +3 +72 +720 +7200 +72000 +72 + +main +# Func Hash: +4 +# Num Counters: +2 +# Counter Values: +1 +401 + Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -396,6 +396,10 @@ AddGlobalCtor(OpenMPRegistrationFunction, 0); if (PGOReader) { getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +auto *SummaryMD = PGOReader->getSummary().getMD(getModule().getContext()); +// Make sure returned metadata is non-null; +assert(SummaryMD); +getModule().setProfileSummary(SummaryMD); if (PGOStats.hasDiagnostics()) PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18289: Attach profile summary information to module
eraman updated this revision to Diff 51342. eraman added a comment. Address Vedant's comments http://reviews.llvm.org/D18289 Files: lib/CodeGen/CodeGenModule.cpp test/Profile/Inputs/profile-summary.proftext test/Profile/profile-summary.c Index: test/Profile/profile-summary.c === --- /dev/null +++ test/Profile/profile-summary.c @@ -0,0 +1,25 @@ +// Test that maximum function counts are set correctly. + +// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s +// +int begin(int i) { + if (i) +return 0; + return 1; +} + +int end(int i) { + if (i) +return 0; + return 1; +} + +int main(int argc, const char *argv[]) { + begin(0); + end(1); + end(1); + return 0; +} +// CHECK: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}} +// CHECK: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}} Index: test/Profile/Inputs/profile-summary.proftext === --- /dev/null +++ test/Profile/Inputs/profile-summary.proftext @@ -0,0 +1,26 @@ +begin +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +1 +0 + +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 + +end +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +2 +2 + Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -396,6 +396,7 @@ AddGlobalCtor(OpenMPRegistrationFunction, 0); if (PGOReader) { getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext)); if (PGOStats.hasDiagnostics()) PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); } Index: test/Profile/profile-summary.c === --- /dev/null +++ test/Profile/profile-summary.c @@ -0,0 +1,25 @@ +// Test that maximum function counts are set correctly. + +// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s +// +int begin(int i) { + if (i) +return 0; + return 1; +} + +int end(int i) { + if (i) +return 0; + return 1; +} + +int main(int argc, const char *argv[]) { + begin(0); + end(1); + end(1); + return 0; +} +// CHECK: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}} +// CHECK: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}} Index: test/Profile/Inputs/profile-summary.proftext === --- /dev/null +++ test/Profile/Inputs/profile-summary.proftext @@ -0,0 +1,26 @@ +begin +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +1 +0 + +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 + +end +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +2 +2 + Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -396,6 +396,7 @@ AddGlobalCtor(OpenMPRegistrationFunction, 0); if (PGOReader) { getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext)); if (PGOStats.hasDiagnostics()) PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18289: Attach profile summary information to module
eraman marked 2 inline comments as done. Comment at: lib/CodeGen/CodeGenModule.cpp:398-399 @@ -397,3 +397,4 @@ if (PGOReader) { getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext)); if (PGOStats.hasDiagnostics()) The previous line? Yes. Comment at: test/Profile/profile-summary.c:6 @@ +5,3 @@ +// +int begin(int i) { + if (i) I didn't see David's comment and your subseqquent response. I have changed the test to only check for the presence of Profilesummary and DetailedSummary fields. http://reviews.llvm.org/D18289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18289: Attach profile summary information to module
eraman added a comment. Since test case tests this change - that profile summary is attached to the module - I think it is sufficient. David and Vedant, does this sound reasonable? http://reviews.llvm.org/D18289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r264342 - Attach profile summary information to Module.
Author: eraman Date: Thu Mar 24 16:32:25 2016 New Revision: 264342 URL: http://llvm.org/viewvc/llvm-project?rev=264342&view=rev Log: Attach profile summary information to Module. Differential Revision: http://reviews.llvm.org/D18289 Added: cfe/trunk/test/Profile/Inputs/profile-summary.proftext cfe/trunk/test/Profile/profile-summary.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=264342&r1=264341&r2=264342&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Mar 24 16:32:25 2016 @@ -396,6 +396,7 @@ void CodeGenModule::Release() { AddGlobalCtor(OpenMPRegistrationFunction, 0); if (PGOReader) { getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext)); if (PGOStats.hasDiagnostics()) PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); } Added: cfe/trunk/test/Profile/Inputs/profile-summary.proftext URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/profile-summary.proftext?rev=264342&view=auto == --- cfe/trunk/test/Profile/Inputs/profile-summary.proftext (added) +++ cfe/trunk/test/Profile/Inputs/profile-summary.proftext Thu Mar 24 16:32:25 2016 @@ -0,0 +1,26 @@ +begin +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +1 +0 + +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 + +end +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +2 +2 + Added: cfe/trunk/test/Profile/profile-summary.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/profile-summary.c?rev=264342&view=auto == --- cfe/trunk/test/Profile/profile-summary.c (added) +++ cfe/trunk/test/Profile/profile-summary.c Thu Mar 24 16:32:25 2016 @@ -0,0 +1,25 @@ +// Test that profile summary is set correctly. + +// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s +// +int begin(int i) { + if (i) +return 0; + return 1; +} + +int end(int i) { + if (i) +return 0; + return 1; +} + +int main(int argc, const char *argv[]) { + begin(0); + end(1); + end(1); + return 0; +} +// CHECK: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}} +// CHECK: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18289: Attach profile summary information to module
This revision was automatically updated to reflect the committed changes. Closed by commit rL264342: Attach profile summary information to Module. (authored by eraman). Changed prior to commit: http://reviews.llvm.org/D18289?vs=51342&id=51604#toc Repository: rL LLVM http://reviews.llvm.org/D18289 Files: cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/test/Profile/Inputs/profile-summary.proftext cfe/trunk/test/Profile/profile-summary.c Index: cfe/trunk/test/Profile/Inputs/profile-summary.proftext === --- cfe/trunk/test/Profile/Inputs/profile-summary.proftext +++ cfe/trunk/test/Profile/Inputs/profile-summary.proftext @@ -0,0 +1,26 @@ +begin +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +1 +0 + +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 + +end +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +2 +2 + Index: cfe/trunk/test/Profile/profile-summary.c === --- cfe/trunk/test/Profile/profile-summary.c +++ cfe/trunk/test/Profile/profile-summary.c @@ -0,0 +1,25 @@ +// Test that profile summary is set correctly. + +// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s +// +int begin(int i) { + if (i) +return 0; + return 1; +} + +int end(int i) { + if (i) +return 0; + return 1; +} + +int main(int argc, const char *argv[]) { + begin(0); + end(1); + end(1); + return 0; +} +// CHECK: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}} +// CHECK: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}} Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp === --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp @@ -396,6 +396,7 @@ AddGlobalCtor(OpenMPRegistrationFunction, 0); if (PGOReader) { getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext)); if (PGOStats.hasDiagnostics()) PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); } Index: cfe/trunk/test/Profile/Inputs/profile-summary.proftext === --- cfe/trunk/test/Profile/Inputs/profile-summary.proftext +++ cfe/trunk/test/Profile/Inputs/profile-summary.proftext @@ -0,0 +1,26 @@ +begin +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +1 +0 + +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 + +end +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +2 +2 + Index: cfe/trunk/test/Profile/profile-summary.c === --- cfe/trunk/test/Profile/profile-summary.c +++ cfe/trunk/test/Profile/profile-summary.c @@ -0,0 +1,25 @@ +// Test that profile summary is set correctly. + +// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s +// +int begin(int i) { + if (i) +return 0; + return 1; +} + +int end(int i) { + if (i) +return 0; + return 1; +} + +int main(int argc, const char *argv[]) { + begin(0); + end(1); + end(1); + return 0; +} +// CHECK: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}} +// CHECK: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}} Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp === --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp @@ -396,6 +396,7 @@ AddGlobalCtor(OpenMPRegistrationFunction, 0); if (PGOReader) { getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext)); if (PGOStats.hasDiagnostics()) PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256793 - Remove setting of inlinehint and cold attributes based on profile data
Author: eraman Date: Mon Jan 4 17:32:28 2016 New Revision: 256793 URL: http://llvm.org/viewvc/llvm-project?rev=256793&view=rev Log: Remove setting of inlinehint and cold attributes based on profile data NFC. These hints are only used for inlining and the inliner now uses the same criteria to identify hot and cold callees and set appropriate thresholds without relying on these hints. Hence this removed code is superfluous. Differential Revision: http://reviews.llvm.org/D15726 Removed: cfe/trunk/test/Profile/c-attributes.c Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp cfe/trunk/test/Profile/func-entry.c Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=256793&r1=256792&r2=256793&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Mon Jan 4 17:32:28 2016 @@ -721,17 +721,7 @@ CodeGenPGO::applyFunctionAttributes(llvm if (!haveRegionCounts()) return; - uint64_t MaxFunctionCount = PGOReader->getMaximumFunctionCount(); uint64_t FunctionCount = getRegionCount(nullptr); - if (FunctionCount >= (uint64_t)(0.3 * (double)MaxFunctionCount)) -// Turn on InlineHint attribute for hot functions. -// FIXME: 30% is from preliminary tuning on SPEC, it may not be optimal. -Fn->addFnAttr(llvm::Attribute::InlineHint); - else if (FunctionCount <= (uint64_t)(0.01 * (double)MaxFunctionCount)) -// Turn on Cold attribute for cold functions. -// FIXME: 1% is from preliminary tuning on SPEC, it may not be optimal. -Fn->addFnAttr(llvm::Attribute::Cold); - Fn->setEntryCount(FunctionCount); } Removed: cfe/trunk/test/Profile/c-attributes.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-attributes.c?rev=256792&view=auto == --- cfe/trunk/test/Profile/c-attributes.c (original) +++ cfe/trunk/test/Profile/c-attributes.c (removed) @@ -1,48 +0,0 @@ -// Test that instrumentation based profiling sets function attributes correctly. - -// RUN: llvm-profdata merge %S/Inputs/c-attributes.proftext -o %t.profdata -// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s - -extern int atoi(const char *); - -// CHECK: hot_100_percent(i32{{.*}}%i) [[HOT:#[0-9]+]] -void hot_100_percent(int i) { - while (i > 0) -i--; -} - -// CHECK: hot_40_percent(i32{{.*}}%i) [[HOT]] -void hot_40_percent(int i) { - while (i > 0) -i--; -} - -// CHECK: normal_func(i32{{.*}}%i) [[NORMAL:#[0-9]+]] -void normal_func(int i) { - while (i > 0) -i--; -} - -// CHECK: cold_func(i32{{.*}}%i) [[COLD:#[0-9]+]] -void cold_func(int i) { - while (i > 0) -i--; -} - -// CHECK: attributes [[HOT]] = { inlinehint nounwind {{.*}} } -// CHECK: attributes [[NORMAL]] = { nounwind {{.*}} } -// CHECK: attributes [[COLD]] = { cold nounwind {{.*}} } - -int main(int argc, const char *argv[]) { - int max = atoi(argv[1]); - int i; - for (i = 0; i < max; i++) -hot_100_percent(i); - for (i = 0; i < max * 4 / 10; i++) -hot_40_percent(i); - for (i = 0; i < max * 2 / 10; i++) -normal_func(i); - for (i = 0; i < max / 200; i++) -cold_func(i); - return 0; -} Modified: cfe/trunk/test/Profile/func-entry.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/func-entry.c?rev=256793&r1=256792&r2=256793&view=diff == --- cfe/trunk/test/Profile/func-entry.c (original) +++ cfe/trunk/test/Profile/func-entry.c Mon Jan 4 17:32:28 2016 @@ -5,10 +5,10 @@ void foo(void); -// CHECK: @foo() #0 !prof [[FOO:![0-9]+]] +// CHECK: @foo() #{{[0-9]}} !prof [[FOO:![0-9]+]] void foo() { return; } -// CHECK: @main() #1 !prof [[MAIN:![0-9]+]] +// CHECK: @main() #{{[0-9]}} !prof [[MAIN:![0-9]+]] int main() { int i; for (i = 0; i < 1; i++) foo(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15726: Remove setting of inlinehint and cold attributes based on profile data
This revision was automatically updated to reflect the committed changes. Closed by commit rL256793: Remove setting of inlinehint and cold attributes based on profile data (authored by eraman). Changed prior to commit: http://reviews.llvm.org/D15726?vs=43479&id=43937#toc Repository: rL LLVM http://reviews.llvm.org/D15726 Files: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp cfe/trunk/test/Profile/c-attributes.c cfe/trunk/test/Profile/func-entry.c Index: cfe/trunk/test/Profile/func-entry.c === --- cfe/trunk/test/Profile/func-entry.c +++ cfe/trunk/test/Profile/func-entry.c @@ -5,10 +5,10 @@ void foo(void); -// CHECK: @foo() #0 !prof [[FOO:![0-9]+]] +// CHECK: @foo() #{{[0-9]}} !prof [[FOO:![0-9]+]] void foo() { return; } -// CHECK: @main() #1 !prof [[MAIN:![0-9]+]] +// CHECK: @main() #{{[0-9]}} !prof [[MAIN:![0-9]+]] int main() { int i; for (i = 0; i < 1; i++) foo(); Index: cfe/trunk/test/Profile/c-attributes.c === --- cfe/trunk/test/Profile/c-attributes.c +++ cfe/trunk/test/Profile/c-attributes.c @@ -1,48 +0,0 @@ -// Test that instrumentation based profiling sets function attributes correctly. - -// RUN: llvm-profdata merge %S/Inputs/c-attributes.proftext -o %t.profdata -// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s - -extern int atoi(const char *); - -// CHECK: hot_100_percent(i32{{.*}}%i) [[HOT:#[0-9]+]] -void hot_100_percent(int i) { - while (i > 0) -i--; -} - -// CHECK: hot_40_percent(i32{{.*}}%i) [[HOT]] -void hot_40_percent(int i) { - while (i > 0) -i--; -} - -// CHECK: normal_func(i32{{.*}}%i) [[NORMAL:#[0-9]+]] -void normal_func(int i) { - while (i > 0) -i--; -} - -// CHECK: cold_func(i32{{.*}}%i) [[COLD:#[0-9]+]] -void cold_func(int i) { - while (i > 0) -i--; -} - -// CHECK: attributes [[HOT]] = { inlinehint nounwind {{.*}} } -// CHECK: attributes [[NORMAL]] = { nounwind {{.*}} } -// CHECK: attributes [[COLD]] = { cold nounwind {{.*}} } - -int main(int argc, const char *argv[]) { - int max = atoi(argv[1]); - int i; - for (i = 0; i < max; i++) -hot_100_percent(i); - for (i = 0; i < max * 4 / 10; i++) -hot_40_percent(i); - for (i = 0; i < max * 2 / 10; i++) -normal_func(i); - for (i = 0; i < max / 200; i++) -cold_func(i); - return 0; -} Index: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp === --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp @@ -721,17 +721,7 @@ if (!haveRegionCounts()) return; - uint64_t MaxFunctionCount = PGOReader->getMaximumFunctionCount(); uint64_t FunctionCount = getRegionCount(nullptr); - if (FunctionCount >= (uint64_t)(0.3 * (double)MaxFunctionCount)) -// Turn on InlineHint attribute for hot functions. -// FIXME: 30% is from preliminary tuning on SPEC, it may not be optimal. -Fn->addFnAttr(llvm::Attribute::InlineHint); - else if (FunctionCount <= (uint64_t)(0.01 * (double)MaxFunctionCount)) -// Turn on Cold attribute for cold functions. -// FIXME: 1% is from preliminary tuning on SPEC, it may not be optimal. -Fn->addFnAttr(llvm::Attribute::Cold); - Fn->setEntryCount(FunctionCount); } Index: cfe/trunk/test/Profile/func-entry.c === --- cfe/trunk/test/Profile/func-entry.c +++ cfe/trunk/test/Profile/func-entry.c @@ -5,10 +5,10 @@ void foo(void); -// CHECK: @foo() #0 !prof [[FOO:![0-9]+]] +// CHECK: @foo() #{{[0-9]}} !prof [[FOO:![0-9]+]] void foo() { return; } -// CHECK: @main() #1 !prof [[MAIN:![0-9]+]] +// CHECK: @main() #{{[0-9]}} !prof [[MAIN:![0-9]+]] int main() { int i; for (i = 0; i < 1; i++) foo(); Index: cfe/trunk/test/Profile/c-attributes.c === --- cfe/trunk/test/Profile/c-attributes.c +++ cfe/trunk/test/Profile/c-attributes.c @@ -1,48 +0,0 @@ -// Test that instrumentation based profiling sets function attributes correctly. - -// RUN: llvm-profdata merge %S/Inputs/c-attributes.proftext -o %t.profdata -// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s - -extern int atoi(const char *); - -// CHECK: hot_100_percent(i32{{.*}}%i) [[HOT:#[0-9]+]] -void hot_100_percent(int i) { - while (i > 0) -i--; -} - -// CHECK: hot_40_percent(i32{{.*}}%i) [[HOT]] -void hot_40_percent(int i) { - while (i > 0) -i--; -} - -// CHECK: normal_func(i32{{.*}}%i) [[NORMAL:#[0-9]+]] -void normal_func(int i) { - while (i > 0) -i--; -} - -// CHECK: cold_func(i32{{.*}}%i) [[COLD:#[0-9]+]] -void cold_func(int i) { - while (i > 0) -i--; -} - -// CHECK: attributes [[HOT]] = { inlinehint nounwind {{.*}} } -// CHECK: attributes [[NORMAL]] = { nounwind {{.*}} } -// CHECK: attributes [[COLD]]
Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.
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
Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.
eraman marked an inline comment as done. eraman added a comment. I've added a test case to check for the presence of MaxFunctionCount module flag. I'll check in this patch soon. Repository: rL LLVM http://reviews.llvm.org/D15163 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r255397 - Attach maximum function count to Module when using PGO mode
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} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.
This revision was automatically updated to reflect the committed changes. Closed by commit rL255397: Attach maximum function count to Module when using PGO mode (authored by eraman). Changed prior to commit: http://reviews.llvm.org/D15163?vs=42549&id=42604#toc Repository: rL LLVM http://reviews.llvm.org/D15163 Files: cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/test/CodeGen/pgo-max-function-count.c Index: cfe/trunk/test/CodeGen/pgo-max-function-count.c === --- cfe/trunk/test/CodeGen/pgo-max-function-count.c +++ cfe/trunk/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: cfe/trunk/lib/CodeGen/CodeGenModule.cpp === --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/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: cfe/trunk/test/CodeGen/pgo-max-function-count.c === --- cfe/trunk/test/CodeGen/pgo-max-function-count.c +++ cfe/trunk/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: cfe/trunk/lib/CodeGen/CodeGenModule.cpp === --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/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
r255416 - Revert r254647.
Author: eraman Date: Fri Dec 11 19:11:09 2015 New Revision: 255416 URL: http://llvm.org/viewvc/llvm-project?rev=255416&view=rev Log: Revert r254647. Reason: The testcase fails in many architectures. Differential Revision: http://reviews.llvm.org/D15163 Removed: 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=255416&r1=255415&r2=255416&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Dec 11 19:11:09 2015 @@ -376,9 +376,6 @@ 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(); Removed: 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=255415&view=auto == --- cfe/trunk/test/CodeGen/pgo-max-function-count.c (original) +++ cfe/trunk/test/CodeGen/pgo-max-function-count.c (removed) @@ -1,9 +0,0 @@ -// 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} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.
eraman added a comment. I have reverted the commit in r255416 because the test failed in many architectures. In many cases the linker is not able to find libclang_rt.profile-$ARCH.a file. There are also other errors. Here is one: 0. Program arguments: /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/clang -cc1 -triple hexagon-unknown--elf -emit-obj -disable-free -main-file-name pgo-max-function-count.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu hexagonv4 -mqdsp6-compat -Wreturn-type -fshort-enums -mllvm -machine-sink-split=0 -target-linker-version 2.25 -dwarf-column-info -fprofile-instr-generate -resource-dir /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../lib/clang/3.8.0 -internal-externc-isystem /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../../gnu/lib/gcc/hexagon/0.0.0/include -internal-externc-isystem /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../../gnu/lib/gcc/hexagon/0.0.0/include-fixed -internal-externc-isystem /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../../gnu/hexagon/include -O2 -fdebug-compilation-dir /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/tools/clang/test/CodeGen -ferror-limit 19 -fmessage-length 0 -fshort-enums -fno-signed-char -fno-use-cxa-atexit -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o /tmp/pgo-max-function-count-816195.o -x c /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.src/tools/clang/test/CodeGen/pgo-max-function-count.c Target: hexagon-unknown--elf Seems like the command line is messed up (I assume there should be a space between hexagon-unknown and --elf). Any suggestions on how to fix this test case? AFAICT, there are no PGO related tests in clang and I based this on PGO tests in compiler-rt/ Repository: rL LLVM http://reviews.llvm.org/D15163 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.
On Fri, Dec 11, 2015 at 6:12 PM, Justin Bogner wrote: > Easwaran Raman writes: > > eraman added a comment. > > > > I have reverted the commit in r255416 because the test failed in many > > architectures. > > You also committed without waiting for further review, despite that > David said "LGTM but please wait for other reviewers". Please don't do > that in the future. > Sorry about that. I waited for a few days, but the right thing to do would have been to explicitly ping the reviewers. Will do so in the future. - Easwaran > > In many cases the linker is not able to find > > libclang_rt.profile-$ARCH.a file. There are also other errors. Here is > > one: > > > > 0. Program arguments: > > > /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/clang > > -cc1 -triple hexagon-unknown--elf -emit-obj -disable-free > > -main-file-name pgo-max-function-count.c -mrelocation-model static > > -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose > > -mconstructor-aliases -target-cpu hexagonv4 -mqdsp6-compat > > -Wreturn-type -fshort-enums -mllvm -machine-sink-split=0 > > -target-linker-version 2.25 -dwarf-column-info > > -fprofile-instr-generate -resource-dir > > > /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../lib/clang/3.8.0 > > -internal-externc-isystem > > > /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../../gnu/lib/gcc/hexagon/0.0.0/include > > -internal-externc-isystem > > > /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../../gnu/lib/gcc/hexagon/0.0.0/include-fixed > > -internal-externc-isystem > > > /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../../gnu/hexagon/include > > -O2 -fdebug-compilation-dir > > > /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/tools/clang/test/CodeGen > > -ferror-limit 19 -fmessage-length 0 -fshort-enums -fno-signed-char > > -fno-use-cxa-atexit -fobjc-runtime=gcc -fdiagnostics-show-option > > -vectorize-loops -vectorize-slp -o > > /tmp/pgo-max-function-count-816195.o -x c > > > /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.src/tools/clang/test/CodeGen/pgo-max-function-count.c > > > > > > > > Target: hexagon-unknown--elf > > > > Seems like the command line is messed up (I assume there should be a > > space between hexagon-unknown and --elf). > > > > Any suggestions on how to fix this test case? AFAICT, there are no PGO > > related tests in clang and I based this on PGO tests in compiler-rt/ > > I'll comment on the patch, but you can't write tests in clang that > attempt to compile and run the compiled binary. > > > > > Repository: > > rL LLVM > > > > http://reviews.llvm.org/D15163 > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.
On Mon, Dec 14, 2015 at 3:26 PM, Xinliang David Li wrote: > On Fri, Dec 11, 2015 at 6:19 PM, Justin Bogner > wrote: > > Easwaran Raman writes: > >> 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 > > > > The clang tests are run in environments where the generated binaries > > can't run on the host system, so you can't do this. Instead of this kind > > of full integration test you should provide handwritten profile data to > > feed into the test. See the tests in test/Profile for examples, and also > > consider putting this test in that directory with the others. > > > >> +// 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. > > > > This comment isn't helpful - it's just stating exactly what the code > > that follows does. > > > >> + if (PGOReader) > >> + > getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); > > > > It would read better to fold the two `if (PGOReader)` checks > > together. ie: > > > > if (PGOReader) { > > > getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); > > if (PGOStats.hasDiagnostics()) > > PGOStats.reportDiagnostics(getDiags(), > getCodeGenOpts().MainFileName); > > } > > > > That said, wouldn't it make more sense to set this within PGOReader > > itself? It feels pretty awkward for this to be happening in > > CodeGenModule::Release(). > > The reader does not know about module context. I think it is better to > put this in CodeGenModule constructor when PGOReader is created. > The reason I chose to do it here is because CodeGenModule::Release() is where other module flags get added. > > David > > > > > >>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
Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.
eraman updated this revision to Diff 42797. eraman added a comment. Updated the patch addressing Justin's comments and a new test case. (Should I open a new review thread since phabricator thinks this has been submitted?) Repository: rL LLVM http://reviews.llvm.org/D15163 Files: lib/CodeGen/CodeGenModule.cpp test/Profile/Inputs/max-function-count.proftext test/Profile/max-function-count.c Index: test/Profile/max-function-count.c === --- /dev/null +++ test/Profile/max-function-count.c @@ -0,0 +1,9 @@ +// Test that maximum function counts are set correctly. + +// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s +// +int main() { + return 0; +} +// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 1} Index: test/Profile/Inputs/max-function-count.proftext === --- /dev/null +++ test/Profile/Inputs/max-function-count.proftext @@ -0,0 +1,7 @@ +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -374,8 +374,11 @@ if (llvm::Function *CudaDtorFunction = CUDARuntime->makeModuleDtorFunction()) AddGlobalDtor(CudaDtorFunction); } - if (PGOReader && PGOStats.hasDiagnostics()) -PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + if (PGOReader) { +getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +if (PGOStats.hasDiagnostics()) + PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + } EmitCtorList(GlobalCtors, "llvm.global_ctors"); EmitCtorList(GlobalDtors, "llvm.global_dtors"); EmitGlobalAnnotations(); Index: test/Profile/max-function-count.c === --- /dev/null +++ test/Profile/max-function-count.c @@ -0,0 +1,9 @@ +// Test that maximum function counts are set correctly. + +// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s +// +int main() { + return 0; +} +// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 1} Index: test/Profile/Inputs/max-function-count.proftext === --- /dev/null +++ test/Profile/Inputs/max-function-count.proftext @@ -0,0 +1,7 @@ +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -374,8 +374,11 @@ if (llvm::Function *CudaDtorFunction = CUDARuntime->makeModuleDtorFunction()) AddGlobalDtor(CudaDtorFunction); } - if (PGOReader && PGOStats.hasDiagnostics()) -PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + if (PGOReader) { +getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +if (PGOStats.hasDiagnostics()) + PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + } 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
Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.
eraman updated this revision to Diff 42801. eraman added a comment. Fix the comment in the test case Repository: rL LLVM http://reviews.llvm.org/D15163 Files: lib/CodeGen/CodeGenModule.cpp test/Profile/Inputs/max-function-count.proftext test/Profile/max-function-count.c Index: test/Profile/max-function-count.c === --- /dev/null +++ test/Profile/max-function-count.c @@ -0,0 +1,8 @@ +// Test that maximum function count is set correctly. + +// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S +// -fprofile-instr-use=%t.profdata | FileCheck %s +// +int main() { return 0; } +// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 1} Index: test/Profile/Inputs/max-function-count.proftext === --- /dev/null +++ test/Profile/Inputs/max-function-count.proftext @@ -0,0 +1,7 @@ +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -374,8 +374,11 @@ if (llvm::Function *CudaDtorFunction = CUDARuntime->makeModuleDtorFunction()) AddGlobalDtor(CudaDtorFunction); } - if (PGOReader && PGOStats.hasDiagnostics()) -PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + if (PGOReader) { +getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +if (PGOStats.hasDiagnostics()) + PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + } EmitCtorList(GlobalCtors, "llvm.global_ctors"); EmitCtorList(GlobalDtors, "llvm.global_dtors"); EmitGlobalAnnotations(); Index: test/Profile/max-function-count.c === --- /dev/null +++ test/Profile/max-function-count.c @@ -0,0 +1,8 @@ +// Test that maximum function count is set correctly. + +// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S +// -fprofile-instr-use=%t.profdata | FileCheck %s +// +int main() { return 0; } +// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 1} Index: test/Profile/Inputs/max-function-count.proftext === --- /dev/null +++ test/Profile/Inputs/max-function-count.proftext @@ -0,0 +1,7 @@ +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -374,8 +374,11 @@ if (llvm::Function *CudaDtorFunction = CUDARuntime->makeModuleDtorFunction()) AddGlobalDtor(CudaDtorFunction); } - if (PGOReader && PGOStats.hasDiagnostics()) -PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + if (PGOReader) { +getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +if (PGOStats.hasDiagnostics()) + PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + } 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
Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.
eraman updated this revision to Diff 43089. eraman added a comment. Updated the test case. Repository: rL LLVM http://reviews.llvm.org/D15163 Files: lib/CodeGen/CodeGenModule.cpp test/Profile/Inputs/max-function-count.proftext test/Profile/max-function-count.c Index: test/Profile/max-function-count.c === --- /dev/null +++ test/Profile/max-function-count.c @@ -0,0 +1,24 @@ +// Test that maximum function counts are set correctly. + +// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s +// +int begin(int i) { + if (i) +return 0; + return 1; +} + +int end(int i) { + if (i) +return 0; + return 1; +} + +int main(int argc, const char *argv[]) { + begin(0); + end(1); + end(1); + return 0; +} +// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 2} Index: test/Profile/Inputs/max-function-count.proftext === --- /dev/null +++ test/Profile/Inputs/max-function-count.proftext @@ -0,0 +1,26 @@ +begin +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +1 +0 + +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 + +end +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +2 +2 + Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -375,8 +375,11 @@ if (llvm::Function *CudaDtorFunction = CUDARuntime->makeModuleDtorFunction()) AddGlobalDtor(CudaDtorFunction); } - if (PGOReader && PGOStats.hasDiagnostics()) -PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + if (PGOReader) { +getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +if (PGOStats.hasDiagnostics()) + PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + } EmitCtorList(GlobalCtors, "llvm.global_ctors"); EmitCtorList(GlobalDtors, "llvm.global_dtors"); EmitGlobalAnnotations(); Index: test/Profile/max-function-count.c === --- /dev/null +++ test/Profile/max-function-count.c @@ -0,0 +1,24 @@ +// Test that maximum function counts are set correctly. + +// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s +// +int begin(int i) { + if (i) +return 0; + return 1; +} + +int end(int i) { + if (i) +return 0; + return 1; +} + +int main(int argc, const char *argv[]) { + begin(0); + end(1); + end(1); + return 0; +} +// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 2} Index: test/Profile/Inputs/max-function-count.proftext === --- /dev/null +++ test/Profile/Inputs/max-function-count.proftext @@ -0,0 +1,26 @@ +begin +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +1 +0 + +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 + +end +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +2 +2 + Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -375,8 +375,11 @@ if (llvm::Function *CudaDtorFunction = CUDARuntime->makeModuleDtorFunction()) AddGlobalDtor(CudaDtorFunction); } - if (PGOReader && PGOStats.hasDiagnostics()) -PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + if (PGOReader) { +getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +if (PGOStats.hasDiagnostics()) + PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + } 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
Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.
eraman added a comment. Justin, does this patch look ok? Repository: rL LLVM http://reviews.llvm.org/D15163 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r255918 - Attach maximum function count to Module when using PGO mode.
Author: eraman Date: Thu Dec 17 13:14:27 2015 New Revision: 255918 URL: http://llvm.org/viewvc/llvm-project?rev=255918&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/Profile/Inputs/max-function-count.proftext cfe/trunk/test/Profile/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=255918&r1=255917&r2=255918&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Dec 17 13:14:27 2015 @@ -375,8 +375,11 @@ void CodeGenModule::Release() { if (llvm::Function *CudaDtorFunction = CUDARuntime->makeModuleDtorFunction()) AddGlobalDtor(CudaDtorFunction); } - if (PGOReader && PGOStats.hasDiagnostics()) -PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + if (PGOReader) { +getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount()); +if (PGOStats.hasDiagnostics()) + PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); + } EmitCtorList(GlobalCtors, "llvm.global_ctors"); EmitCtorList(GlobalDtors, "llvm.global_dtors"); EmitGlobalAnnotations(); Added: cfe/trunk/test/Profile/Inputs/max-function-count.proftext URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/max-function-count.proftext?rev=255918&view=auto == --- cfe/trunk/test/Profile/Inputs/max-function-count.proftext (added) +++ cfe/trunk/test/Profile/Inputs/max-function-count.proftext Thu Dec 17 13:14:27 2015 @@ -0,0 +1,26 @@ +begin +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +1 +0 + +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 + +end +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +2 +2 + Added: cfe/trunk/test/Profile/max-function-count.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/max-function-count.c?rev=255918&view=auto == --- cfe/trunk/test/Profile/max-function-count.c (added) +++ cfe/trunk/test/Profile/max-function-count.c Thu Dec 17 13:14:27 2015 @@ -0,0 +1,24 @@ +// Test that maximum function counts are set correctly. + +// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata +// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s +// +int begin(int i) { + if (i) +return 0; + return 1; +} + +int end(int i) { + if (i) +return 0; + return 1; +} + +int main(int argc, const char *argv[]) { + begin(0); + end(1); + end(1); + return 0; +} +// CHECK: !{{[0-9]+}} = !{i32 1, !"MaxFunctionCount", i32 2} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D15726: Remove setting of inlinehint and cold attributes based on profile data
eraman created this revision. eraman added reviewers: bogner, davidxl. eraman added a subscriber: cfe-commits. NFC. These hints are only used for inlining and the inliner now uses the same criteria to identify hot and cold callees and set appropriate thresholds without relying on these hints. Hence this removed code is superfluous. http://reviews.llvm.org/D15726 Files: lib/CodeGen/CodeGenPGO.cpp test/Profile/c-attributes.c test/Profile/func-entry.c Index: test/Profile/func-entry.c === --- test/Profile/func-entry.c +++ test/Profile/func-entry.c @@ -5,10 +5,10 @@ void foo(void); -// CHECK: @foo() #0 !prof [[FOO:![0-9]+]] +// CHECK: @foo() #{{[0-9]}} !prof [[FOO:![0-9]+]] void foo() { return; } -// CHECK: @main() #1 !prof [[MAIN:![0-9]+]] +// CHECK: @main() #{{[0-9]}} !prof [[MAIN:![0-9]+]] int main() { int i; for (i = 0; i < 1; i++) foo(); Index: test/Profile/c-attributes.c === --- test/Profile/c-attributes.c +++ /dev/null @@ -1,48 +0,0 @@ -// Test that instrumentation based profiling sets function attributes correctly. - -// RUN: llvm-profdata merge %S/Inputs/c-attributes.proftext -o %t.profdata -// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s - -extern int atoi(const char *); - -// CHECK: hot_100_percent(i32{{.*}}%i) [[HOT:#[0-9]+]] -void hot_100_percent(int i) { - while (i > 0) -i--; -} - -// CHECK: hot_40_percent(i32{{.*}}%i) [[HOT]] -void hot_40_percent(int i) { - while (i > 0) -i--; -} - -// CHECK: normal_func(i32{{.*}}%i) [[NORMAL:#[0-9]+]] -void normal_func(int i) { - while (i > 0) -i--; -} - -// CHECK: cold_func(i32{{.*}}%i) [[COLD:#[0-9]+]] -void cold_func(int i) { - while (i > 0) -i--; -} - -// CHECK: attributes [[HOT]] = { inlinehint nounwind {{.*}} } -// CHECK: attributes [[NORMAL]] = { nounwind {{.*}} } -// CHECK: attributes [[COLD]] = { cold nounwind {{.*}} } - -int main(int argc, const char *argv[]) { - int max = atoi(argv[1]); - int i; - for (i = 0; i < max; i++) -hot_100_percent(i); - for (i = 0; i < max * 4 / 10; i++) -hot_40_percent(i); - for (i = 0; i < max * 2 / 10; i++) -normal_func(i); - for (i = 0; i < max / 200; i++) -cold_func(i); - return 0; -} Index: lib/CodeGen/CodeGenPGO.cpp === --- lib/CodeGen/CodeGenPGO.cpp +++ lib/CodeGen/CodeGenPGO.cpp @@ -721,17 +721,7 @@ if (!haveRegionCounts()) return; - uint64_t MaxFunctionCount = PGOReader->getMaximumFunctionCount(); uint64_t FunctionCount = getRegionCount(nullptr); - if (FunctionCount >= (uint64_t)(0.3 * (double)MaxFunctionCount)) -// Turn on InlineHint attribute for hot functions. -// FIXME: 30% is from preliminary tuning on SPEC, it may not be optimal. -Fn->addFnAttr(llvm::Attribute::InlineHint); - else if (FunctionCount <= (uint64_t)(0.01 * (double)MaxFunctionCount)) -// Turn on Cold attribute for cold functions. -// FIXME: 1% is from preliminary tuning on SPEC, it may not be optimal. -Fn->addFnAttr(llvm::Attribute::Cold); - Fn->setEntryCount(FunctionCount); } Index: test/Profile/func-entry.c === --- test/Profile/func-entry.c +++ test/Profile/func-entry.c @@ -5,10 +5,10 @@ void foo(void); -// CHECK: @foo() #0 !prof [[FOO:![0-9]+]] +// CHECK: @foo() #{{[0-9]}} !prof [[FOO:![0-9]+]] void foo() { return; } -// CHECK: @main() #1 !prof [[MAIN:![0-9]+]] +// CHECK: @main() #{{[0-9]}} !prof [[MAIN:![0-9]+]] int main() { int i; for (i = 0; i < 1; i++) foo(); Index: test/Profile/c-attributes.c === --- test/Profile/c-attributes.c +++ /dev/null @@ -1,48 +0,0 @@ -// Test that instrumentation based profiling sets function attributes correctly. - -// RUN: llvm-profdata merge %S/Inputs/c-attributes.proftext -o %t.profdata -// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s - -extern int atoi(const char *); - -// CHECK: hot_100_percent(i32{{.*}}%i) [[HOT:#[0-9]+]] -void hot_100_percent(int i) { - while (i > 0) -i--; -} - -// CHECK: hot_40_percent(i32{{.*}}%i) [[HOT]] -void hot_40_percent(int i) { - while (i > 0) -i--; -} - -// CHECK: normal_func(i32{{.*}}%i) [[NORMAL:#[0-9]+]] -void normal_func(int i) { - while (i > 0) -i--; -} - -// CHECK: cold_func(i32{{.*}}%i) [[COLD:#[0-9]+]] -void cold_func(int i) { - while (i > 0) -i--; -} - -// CHECK: attributes [[HOT]] = { inlinehint nounwind {{.*}} } -// CHECK: attributes [[NORMAL]] = { nounwind {{.*}} } -// CHECK: attributes [[COLD]] = { cold nounwind {{.*}} } - -int main(int argc, const char *argv[]) { - int max = atoi(argv[1]); - int i; - for (i = 0; i < max; i++) -hot_100_percent(i); - for (i = 0;