This is replacement for patch in https://reviews.llvm.org/D49460.
When we fork, the counters are duplicate as they're and so the values are finally wrong when writing gcda for parent and child.
So just before to fork, we flush the counters and so the parent and the child have new counters set to zero.
For exec** functions, we need to flush before the call to have some data.
Details
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 24093 Build 24092: arc lint + arc unit
Event Timeline
Don't you just want to reset the counters in the child process?
lib/Transforms/Instrumentation/GCOVProfiling.cpp | ||
---|---|---|
535 | See InstIterator.h. The instructions() range helper might be more convenient. | |
541 | Take a look at TargetLibraryInfo.{h, def}. It might be cleaner to define fork() there, then check if you see a LibFunc_fork. | |
556 | Why is this needed? |
lib/Transforms/Instrumentation/GCOVProfiling.cpp | ||
---|---|---|
556 | The line after the fork is executed 2 times: 1 time with the parent and 1 time with the child. So if we don't split the block the counter for this line (and the next ones in the same block as the fork) is only 1. So in putting a new block here and so a new counter in it we can reflect that the lines after the fork are executed two times. |
include/llvm/Analysis/TargetLibraryInfo.def | ||
---|---|---|
588 ↗ | (On Diff #172800) | There's also execve. |
lib/Transforms/Instrumentation/GCOVProfiling.cpp | ||
473 | We should do the flushing before fork/exec when we are cross-compiling from Windows to a target that supports fork/exec.
|
We should do the flushing before fork/exec when we are cross-compiling from Windows to a target that supports fork/exec.
We have two options: