[llvm] r339162 - [SampleFDO] Fix a bug in getOrCompHotCountThreshold/getOrCompColdCountThreshold

Wei Mi via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 7 11:13:11 PDT 2018


Author: wmi
Date: Tue Aug  7 11:13:10 2018
New Revision: 339162

URL: http://llvm.org/viewvc/llvm-project?rev=339162&view=rev
Log:
[SampleFDO] Fix a bug in getOrCompHotCountThreshold/getOrCompColdCountThreshold

getOrCompHotCountThreshold/getOrCompColdCountThreshold introduced in
https://reviews.llvm.org/D45377 contain a bad mistake and will only return 1 or 0
instead of the true hot/cold cutoff value. The patch fixes the mistake. But the
mistake seems not causing big performance difference according to internal server
benchmarks testing.

Differential Revision: https://reviews.llvm.org/D50370

Modified:
    llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp
    llvm/trunk/test/Transforms/SampleProfile/Inputs/function_metadata.prof
    llvm/trunk/test/Transforms/SampleProfile/function_metadata.ll

Modified: llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp?rev=339162&r1=339161&r2=339162&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp Tue Aug  7 11:13:10 2018
@@ -226,13 +226,13 @@ bool ProfileSummaryInfo::isColdCount(uin
 uint64_t ProfileSummaryInfo::getOrCompHotCountThreshold() {
   if (!HotCountThreshold)
     computeThresholds();
-  return HotCountThreshold && HotCountThreshold.getValue();
+  return HotCountThreshold ? HotCountThreshold.getValue() : UINT64_MAX;
 }
 
 uint64_t ProfileSummaryInfo::getOrCompColdCountThreshold() {
   if (!ColdCountThreshold)
     computeThresholds();
-  return ColdCountThreshold && ColdCountThreshold.getValue();
+  return ColdCountThreshold ? ColdCountThreshold.getValue() : 0;
 }
 
 bool ProfileSummaryInfo::isHotBB(const BasicBlock *B, BlockFrequencyInfo *BFI) {

Modified: llvm/trunk/test/Transforms/SampleProfile/Inputs/function_metadata.prof
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/Inputs/function_metadata.prof?rev=339162&r1=339161&r2=339162&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SampleProfile/Inputs/function_metadata.prof (original)
+++ llvm/trunk/test/Transforms/SampleProfile/Inputs/function_metadata.prof Tue Aug  7 11:13:10 2018
@@ -1,4 +1,6 @@
 test:10000:0
+ 2: 100
+ 3: 100
  3: foo:1000
   3: bar:200
    4: baz:10

Modified: llvm/trunk/test/Transforms/SampleProfile/function_metadata.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/function_metadata.ll?rev=339162&r1=339161&r2=339162&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SampleProfile/function_metadata.ll (original)
+++ llvm/trunk/test/Transforms/SampleProfile/function_metadata.ll Tue Aug  7 11:13:10 2018
@@ -27,8 +27,10 @@ define void @test_liveness() !dbg !12 {
 }
 
 ; GUIDs of foo, bar, foo1, foo2 and foo3 should be included in the metadata to
-; make sure hot inline stacks are imported.
-; CHECK: ![[ENTRY_TEST]] = !{!"function_entry_count", i64 1, i64 2494702099028631698, i64 6699318081062747564, i64 7546896869197086323, i64 7682762345278052905,  i64 -7908226060800700466, i64 -2012135647395072713}
+; make sure hot inline stacks are imported. The total count of baz is lower
+; than the hot cutoff threshold and its GUID should not be included in the
+; metadata.
+; CHECK: ![[ENTRY_TEST]] = !{!"function_entry_count", i64 1, i64 2494702099028631698, i64 6699318081062747564, i64 7682762345278052905,  i64 -7908226060800700466, i64 -2012135647395072713}
 
 ; Check GUIDs for both foo and foo_available are included in the metadata to
 ; make sure the liveness analysis can capture the dependency from test_liveness




More information about the llvm-commits mailing list