diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -777,7 +777,8 @@ if (!FromFunc && !ToFunc) return false; - if (FromFunc == ToFunc) { + // Treat recursive control transfers as inter-branches. + if (FromFunc == ToFunc && (To != ToFunc->getAddress())) { recordBranch(*FromFunc, From - FromFunc->getAddress(), To - FromFunc->getAddress(), Count, Mispreds); return doIntraBranch(*FromFunc, From, To, Count, Mispreds); diff --git a/bolt/test/X86/Inputs/pre-aggregated.txt b/bolt/test/X86/Inputs/pre-aggregated.txt --- a/bolt/test/X86/Inputs/pre-aggregated.txt +++ b/bolt/test/X86/Inputs/pre-aggregated.txt @@ -6,3 +6,4 @@ B 4011a0 4011a9 33 4 B 4011ad 401180 58 0 F 401170 4011b2 22 +B 400dae 400d90 1 0 diff --git a/bolt/test/X86/pre-aggregated-perf.test b/bolt/test/X86/pre-aggregated-perf.test --- a/bolt/test/X86/pre-aggregated-perf.test +++ b/bolt/test/X86/pre-aggregated-perf.test @@ -43,6 +43,11 @@ PERF2BOLT: 1 usqrt 3d 1 usqrt 3f 0 22 PERF2BOLT: 1 usqrt a 1 usqrt 10 0 22 +NEWFORMAT: - name: 'frame_dummy/1' +NEWFORMAT: fid: 3 +NEWFORMAT: hash: 0x24496F7F9594E89F +NEWFORMAT: exec: 1 + NEWFORMAT: - name: usqrt NEWFORMAT: fid: 7 NEWFORMAT: exec: 0