Commit Graph

3 Commits

Author SHA1 Message Date
Hamish Knight
4e48db550b [Profiler] Improve region termination
We can terminate all the regions up to the last
AST node in the stack, since regions without AST
nodes are refinements of the region with the AST
node, and should be terminated the same. This
avoids leaving some regions that extend past e.g
the `return` of a function.

The region in the test case that changes here is:

```
[[@LINE+9]]:28 -> [[@LINE+12]]:4 : (0 - 1)
```

this was extending past the return. Now it is:

```
[[@LINE]]:6    -> [[@LINE+4]]:11 : (0 - 1)
```

Apologies, I also refactored the test case at the
same time which makes the difference harder to see,
but the main point is that this region now terminates
at the return, the same as the others.
2023-11-16 17:28:57 +00:00
Hamish Knight
b12015c343 [SIL] Introduce the increment_profiler_counter instruction
This is a dedicated instruction for incrementing a
profiler counter, which lowers to the
`llvm.instrprof.increment` intrinsic. This
replaces the builtin instruction that was
previously used, and ensures that its arguments
are statically known. This ensures that SIL
optimization passes do not invalidate the
instruction, fixing some code coverage cases in
`-O`.

rdar://39146527
2022-09-07 17:55:13 +01:00
Hamish Knight
d8bab13469 [Profiler] Fix counters following DoStmts
Previously we weren't compensating for label
jumps and returns, i.e we assumed the exit count
is the same as the entry count. Ensure we follow
the same logic that other labeled statements
follow such that control flow is accounted for.

rdar://98881045
2022-08-19 15:06:11 +01:00