[compiler-rt] [profile] Implement a non-mmap path when reading profile files from a non-local filesystem (PR #131177)
Hubert Tong via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 15 10:01:02 PDT 2025
================
@@ -16,17 +20,23 @@ __attribute__((noinline)) void func1() {}
__attribute__((noinline)) void func2() {}
int main(void) {
- // child | parent
- int status; // func1 func2 | func1 func2
- func1(); // +1 | +1 (*)
- pid_t pid = fork(); // |
- if (pid == -1) // |
- return 1; // |
- if (pid == 0) // |
- func2(); // +1 |
- func1(); // +1 | +1
- if (pid) // ------------+------------
- wait(&status); // 2 1 | 2 0
- return 0; // (*) the child inherits counter values prior to fork
- // from the parent in non-continuous mode.
+ // child | parent
+ // func1 func2 | func1 func2
+ func1(); // +10 | +1 (*)
+ int i = 10; // |
+ while (i-- > 0) { // |
+ pid_t pid = fork(); // |
+ if (pid == -1) // |
+ return 1; // |
+ if (pid == 0) { // |
+ func2(); // +10 |
+ func1(); // +10 |
+ return 0; // |
+ } // |
+ } // ------------+------------
+ int status; // 20 10 | 1 0
+ i = 10;
+ while (i-- > 0)
+ wait(&status); // (*) the child inherits counter values prior to fork
+ return 0; // from the parent in non-continuous mode.
----------------
hubert-reinterpretcast wrote:
My bad for splitting the comment block in my previous suggestion.
```suggestion
i = 10; // (*) the child inherits counter values prior to fork
while (i-- > 0) // from the parent in non-continuous mode.
wait(&status);
return 0;
```
https://github.com/llvm/llvm-project/pull/131177
More information about the llvm-commits
mailing list