[LLVMbugs] [Bug 23525] New: Incorrect block frequency generated for entries of irregular loops
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu May 14 11:06:54 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23525
Bug ID: 23525
Summary: Incorrect block frequency generated for entries of
irregular loops
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: congh at google.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 14329
--> https://llvm.org/bugs/attachment.cgi?id=14329&action=edit
Test case
Normally the frequency of a basic block other than the function entry should be
equal to the sum of its incoming edge frequencies. However, this may not hold
for CFGs with irregular loops which have more than one loop entry. LLVM
incorrectly assigns the same frequency to those loop entries for the same loop.
To reproduce this issue, compile the given test case below using the following
instructions:
clang test.C -O2 -fprofile-instr-generate
./a.out
llvm-profdata merge -output=profdata default.profraw
clang test.C -O2 -fprofile-instr-use=profdata -emit-llvm -S
opt -analyze -block-freq -S test.ll
The output is:
Printing analysis 'Block Frequency Analysis' for function '_Z8hot_loopi':
block-frequency-info: _Z8hot_loopi
- entry: float = 1.0, int = 8
- for.cond: float = 25.52, int = 204
- for.body: float = 24.52, int = 196
- if.then4: float = 12.26499796, int = 98
- Next: float = 25.52, int = 204
- for.inc: float = 25.52, int = 204
- for.end: float = 1.0, int = 8
Printing analysis 'Block Frequency Analysis' for function 'main':
block-frequency-info: main
- entry: float = 1.0, int = 8
- for.body: float = 51.0, int = 407
- for.end: float = 1.0, int = 8
Note that in hot_loop(), Next shares the same frequency as for.inc, which is
incorrect. Next should have less frequency.
The test case:
int g;
__attribute__((noinline)) int hot_loop(int n) {
int i = n / 2;
if (n % 2 == 0) {
goto Next;
}
#pragma nounroll
for (; i < n; i++) {
if (i % 2 == 0) {
g *= 2;
} else {
Next:
g += n;
}
}
return g;
}
int main() {
for (int i = 1; i < 100; ++i)
hot_loop(i);
return 0;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150514/c6838cbe/attachment.html>
More information about the llvm-bugs
mailing list