4 Commits

Author SHA1 Message Date
Mircea Trofin
f2d827c444
[profcheck] Require unknown metadata have an origin parameter (#157594)
Rather than passes using `!prof = !{!”unknown”}`​for cases where don’t have enough information to emit profile values, this patch captures the pass (or some other information) that can help diagnostics - i.e. `!{!”unknown”, !”some-pass-name”}`​.

For example, suppose we emitted a `select`​ with the unknown metadata, and, later, end up needing to lower that to a conditional branch. If we observe (via sample profiling, for example) that the branch is biased and would have benefitted from a valid profile, the extra information can help speed up debugging.

We can also (in a subsequent pass) generate optimization remarks about such lowered selects, with a similar aim - identify patterns lowering to `select`​ that may be worth some extra investment in extracting a more precise profile.
2025-09-10 15:34:35 -07:00
Mircea Trofin
b8d74ad2b3
[JTS] Use common branch weight downscaling (#153738)
This also fixes a bug introduced accidentally in #153651, whereby the
`JumpTableToSwitch`​ would convert all the branch weights to 0 except
for one. It didn't trip the test because `update_test_checks`​ wasn't
run with `-check-globals`​. It is now. This also made noticeable that
the direct calls promoted from the indirect call inherited the
`VP`​metadata, which should be dropped as it makes no more sense now.
2025-08-15 07:30:43 +00:00
Mircea Trofin
f5d284309f
[JTS] Propagate profile info (#153305)
If the indirect call target being recognized as a jump table has profile info, we can accurately synthesize the branch weights of the switch that replaces the indirect call.

Otherwise we insert the "unknown" `MD_prof` to indicate this is the best we can do here.

Part of Issue #147390
2025-08-14 11:17:57 -07:00
Alexander Shaposhnikov
d26b43ff4f
Add JumpTableToSwitch pass (#77709)
Add a pass to convert jump tables to switches.
The new pass replaces an indirect call with a switch + direct calls if all the functions in the jump table are smaller than the provided threshold.
The pass is currently disabled by default and can be enabled by -enable-jump-table-to-switch.

Test plan: ninja check-all
2024-02-10 01:12:46 -08:00