SCC annotation behavior differs between toplevel and non-toplevel
I'm not sure if this is a bug, but using ghc -prof -auto-all and manual SCC annotations for non-toplevel functions produces very different results from moving the same function to toplevel:
fib n = nfib' n
where
nfib' n = {-# SCC "nfib'" #-} nfib n -- %time: 0 (both individual and inherited)
where
nfib n = if n < 2 then 1 else nfib (n-1) + nfib (n-2)
fib n = nfib' n
nfib' n = nfib n -- %time: 100 (both individual and inherited)
where
nfib n = if n < 2 then 1 else nfib (n-1) + nfib (n-2)
This happens with both -O0 and -O2, even when these functions are not exported. Adding a NOINLINE for nfib' doesn't change anything.
Computing the correct inherited time for the SCC would be useful to pinpoint the cost centres inside a more complex function. Currently one needs to move them to toplevel to get the same effect. Given that the toplevel route works, it's also counterintuitive that manual SCC annotations don't.
Trac metadata
Trac field | Value |
---|---|
Version | 6.8.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |