3 Commits

Author SHA1 Message Date
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