Skip to content

Harden the inlining plugin: registry thread-safety, JIT hook safety, tests#246

Open
PhilippGrulich wants to merge 1 commit intomainfrom
claude/improve-inlining-plugin-AWTC2
Open

Harden the inlining plugin: registry thread-safety, JIT hook safety, tests#246
PhilippGrulich wants to merge 1 commit intomainfrom
claude/improve-inlining-plugin-AWTC2

Conversation

@PhilippGrulich
Copy link
Copy Markdown
Member

Correctness & safety:

  • Registry: snapshot-by-value semantics for getSymbolTable(); optional
    return type for getBitcode() so callers distinguish "missing" from
    "empty"; make all accessors const with proper locking; switch
    string params to std::string_view.
  • LLVM JIT hook: replace throw RuntimeException on duplicate symbol
    with a log+skip so one bad candidate no longer aborts JIT.
  • LLVM JIT hook: snapshot symbol table once per inlineFunctions() call;
    cap the fixed-point loop at 32 iterations to prevent infinite loops.
  • Pass: null-check v2vInverted lookups so fresh globals introduced by
    ExtractGVPass don't crash in getUniqueName.
  • proxyCallNameOverride now uses ptrToHex for format consistency with
    jitSymbolContributor (prevents silent ABI drift).

API hygiene & perf:

  • CMake: remove dead INTERFACE_ property on InliningPass; cache the
    is_inlining_supported() detector; fix misleading warning message.
  • Pass: disentangle CrashRecoveryContext success/serialized booleans.
  • Pass: name the 65535 ctor priority with a documented constant.
  • Pass: SymbolMap is now unordered_map (iteration order was never used).
  • Pre-populate a StringSet for fixFunctionNameConflicts (O(n) instead
    of O(n^2)).

Tests:

  • Rename RunctimeCallFunctions.hpp -> RuntimeCallFunctions.hpp (typo).
  • Extract shared helper anchors into InliningTestAnchors.hpp.
  • Generalize the LLVM-IR smoke test across all five test functions
    with regex-based @runtimeFunc detection and RAII temp-dir cleanup.
  • Tighten InliningExecutionTest registry assertions: on supported
    toolchains (Clang 19-21, non-ARM) both bitcodes are required.
  • Add coverage for proxyCallNameOverride hook, the non-inlined
    fallback path, and miss-semantics of the registry.
  • Add RegistryThreadSafetyTest (4-thread reader/writer smoke, TSAN-ready).

…tests

Correctness & safety:
- Registry: snapshot-by-value semantics for getSymbolTable(); optional
  return type for getBitcode() so callers distinguish "missing" from
  "empty"; make all accessors const with proper locking; switch
  string params to std::string_view.
- LLVM JIT hook: replace `throw RuntimeException` on duplicate symbol
  with a log+skip so one bad candidate no longer aborts JIT.
- LLVM JIT hook: snapshot symbol table once per inlineFunctions() call;
  cap the fixed-point loop at 32 iterations to prevent infinite loops.
- Pass: null-check v2vInverted lookups so fresh globals introduced by
  ExtractGVPass don't crash in getUniqueName.
- proxyCallNameOverride now uses ptrToHex for format consistency with
  jitSymbolContributor (prevents silent ABI drift).

API hygiene & perf:
- CMake: remove dead `INTERFACE_` property on InliningPass; cache the
  is_inlining_supported() detector; fix misleading warning message.
- Pass: disentangle CrashRecoveryContext success/serialized booleans.
- Pass: name the 65535 ctor priority with a documented constant.
- Pass: SymbolMap is now unordered_map (iteration order was never used).
- Pre-populate a StringSet for fixFunctionNameConflicts (O(n) instead
  of O(n^2)).

Tests:
- Rename RunctimeCallFunctions.hpp -> RuntimeCallFunctions.hpp (typo).
- Extract shared helper anchors into InliningTestAnchors.hpp.
- Generalize the LLVM-IR smoke test across all five test functions
  with regex-based @runtimeFunc detection and RAII temp-dir cleanup.
- Tighten InliningExecutionTest registry assertions: on supported
  toolchains (Clang 19-21, non-ARM) both bitcodes are required.
- Add coverage for proxyCallNameOverride hook, the non-inlined
  fallback path, and miss-semantics of the registry.
- Add RegistryThreadSafetyTest (4-thread reader/writer smoke, TSAN-ready).
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracing Benchmark

Details
Benchmark suite Current: 89351dd Previous: 96ed9b5 Ratio
trace_add 2.38055 us (± 225.841) 2.55787 us (± 280.374) 0.93
completing_trace_add 2.29295 us (± 215.4) 2.57695 us (± 255.361) 0.89
trace_ifThenElse 11.0667 us (± 924.149) 11.6731 us (± 1.7665) 0.95
completing_trace_ifThenElse 4.92015 us (± 569.911) 5.38604 us (± 741.413) 0.91
trace_deeplyNestedIfElse 33.8192 us (± 3.52974) 35.187 us (± 5.50089) 0.96
completing_trace_deeplyNestedIfElse 21.6777 us (± 1.85173) 15.7582 us (± 2.02931) 1.38
trace_loop 10.8336 us (± 1.35013) 11.3838 us (± 1.05122) 0.95
completing_trace_loop 5.01288 us (± 477.683) 5.44889 us (± 684.888) 0.92
trace_ifInsideLoop 21.4647 us (± 1.80431) 23.2803 us (± 3.99668) 0.92
completing_trace_ifInsideLoop 9.10987 us (± 988.025) 10.5815 us (± 1.66246) 0.86
trace_loopDirectCall 11.1934 us (± 1.9571) 11.4594 us (± 1.0372) 0.98
completing_trace_loopDirectCall 4.94827 us (± 440.972) 5.89448 us (± 997.564) 0.84
trace_pointerLoop 16.2226 us (± 1.59355) 17.6992 us (± 3.66731) 0.92
completing_trace_pointerLoop 10.055 us (± 1.70386) 11.9341 us (± 1.71351) 0.84
trace_staticLoop 10.1576 us (± 1.07583) 9.23834 us (± 691.55) 1.10
completing_trace_staticLoop 10.3518 us (± 1.20467) 9.60517 us (± 1.19952) 1.08
trace_fibonacci 12.2931 us (± 1.67957) 13.0331 us (± 1.69398) 0.94
completing_trace_fibonacci 6.24037 us (± 628.706) 7.04913 us (± 690.345) 0.89
trace_gcd 10.3082 us (± 1.3737) 10.5333 us (± 1.11989) 0.98
completing_trace_gcd 4.34516 us (± 498.71) 4.58408 us (± 451.36) 0.95
trace_nestedIf10 57.6221 us (± 5.20442) 56.2881 us (± 5.22461) 1.02
completing_trace_nestedIf10 59.0859 us (± 5.0977) 54.6918 us (± 3.9734) 1.08
trace_nestedIf100 1.75546 ms (± 28.3155) 1.7812 ms (± 53.6987) 0.99
completing_trace_nestedIf100 1.86419 ms (± 225.429) 1.80389 ms (± 60.2836) 1.03
trace_chainedIf10 135.543 us (± 6.10254) 139.127 us (± 10.4893) 0.97
completing_trace_chainedIf10 68.2153 us (± 5.99108) 71.1941 us (± 7.8671) 0.96
trace_chainedIf100 5.08938 ms (± 44.9631) 5.15682 ms (± 41.2033) 0.99
completing_trace_chainedIf100 2.68589 ms (± 147.331) 2.78028 ms (± 58.1292) 0.97
ir_add 819.262 ns (± 62.0586) 862.485 ns (± 103.027) 0.95
ir_ifThenElse 3.39993 us (± 988.576) 2.5529 us (± 245.891) 1.33
ir_deeplyNestedIfElse 6.44062 us (± 787.726) 6.66598 us (± 494.661) 0.97
ir_loop 2.76456 us (± 215.412) 2.95148 us (± 278.627) 0.94
ir_ifInsideLoop 5.447 us (± 476.912) 5.83859 us (± 547.866) 0.93
ir_loopDirectCall 2.98818 us (± 206.242) 3.22491 us (± 302.891) 0.93
ir_pointerLoop 3.55327 us (± 265.735) 3.86931 us (± 376.396) 0.92
ir_staticLoop 2.11866 us (± 163.94) 2.32475 us (± 271.467) 0.91
ir_fibonacci 3.0338 us (± 530.623) 3.21184 us (± 244.39) 0.94
ir_gcd 2.45649 us (± 209.36) 2.647 us (± 183.576) 0.93
ir_nestedIf10 14.8167 us (± 1.03259) 19.0452 us (± 5.7067) 0.78
ir_nestedIf100 179.889 us (± 7.92103) 189.606 us (± 7.2231) 0.95
ir_chainedIf10 27.628 us (± 1.76009) 29.4602 us (± 2.17473) 0.94
ir_chainedIf100 371.08 us (± 16.3913) 361.182 us (± 12.1261) 1.03
exec_bc_addOne 34.0122 ns (± 3.05759) 35.7602 ns (± 6.48958) 0.95
exec_mlir_addOne 279.804 ns (± 4.1137) 284.771 ns (± 4.99289) 0.98
exec_cpp_addOne 3.99569 ns (± 0.653823) 3.98135 ns (± 0.519135) 1.00
exec_interpreted_addOne 37.9968 ns (± 1.78376) 38.0363 ns (± 1.85379) 1.00
ssa_add 198.794 ns (± 16.2909) 199.147 ns (± 21.4475) 1.00
ssa_ifThenElse 477.827 ns (± 29.3863) 504.66 ns (± 47.9459) 0.95
ssa_deeplyNestedIfElse 1.24702 us (± 151.808) 1.2275 us (± 167.177) 1.02
ssa_loop 517.951 ns (± 40.7233) 519.197 ns (± 42.3619) 1.00
ssa_ifInsideLoop 977.886 ns (± 90.8584) 931.812 ns (± 69.7894) 1.05
ssa_loopDirectCall 526.152 ns (± 28.4036) 551.594 ns (± 61.9431) 0.95
ssa_pointerLoop 628.17 ns (± 28.1026) 722.203 ns (± 186.528) 0.87
ssa_staticLoop 477.079 ns (± 38.3851) 523.131 ns (± 134.431) 0.91
ssa_fibonacci 523.326 ns (± 29.6871) 534.556 ns (± 33.5479) 0.98
ssa_gcd 485.24 ns (± 31.6881) 475.78 ns (± 38.8095) 1.02
tiered_compile_addOne 41.0941 us (± 8.60908) 43.2766 us (± 11.4443) 0.95
single_compile_mlir_addOne 6.2398 ms (± 141.169) 6.31668 ms (± 138.946) 0.99
single_compile_cpp_addOne 24.3166 ms (± 385.521) 24.8897 ms (± 440.83) 0.98
single_compile_bc_addOne 41.8457 us (± 7.52813) 43.8407 us (± 12.5365) 0.95
tiered_compile_sumLoop 60.8812 us (± 11.6974) 62.959 us (± 14.3374) 0.97
single_compile_mlir_sumLoop 8.28865 ms (± 182.191) 8.42973 ms (± 232.332) 0.98
single_compile_cpp_sumLoop 25.0959 ms (± 461.357) 26.4294 ms (± 1.11912) 0.95
single_compile_bc_sumLoop 60.9878 us (± 9.17528) 62.5466 us (± 10.7952) 0.98
exec_mlir_add 10.5665 ns (± 0.861169) 10.9408 ns (± 1.21636) 0.97
exec_mlir_fibonacci 13.5723 us (± 1.62248) 14.2478 us (± 1.44053) 0.95
exec_mlir_sum 518.807 us (± 17.4646) 539.726 us (± 25.0434) 0.96
exec_cpp_add 4.53354 ns (± 0.134193) 4.59718 ns (± 0.360787) 0.99
exec_cpp_fibonacci 96.2779 us (± 9.99362) 95.1825 us (± 5.9554) 1.01
exec_cpp_sum 35.9102 ms (± 106.191) 35.9485 ms (± 109.089) 1.00
exec_bc_add 44.2645 ns (± 5.39603) 43.8172 ns (± 3.18955) 1.01
exec_bc_fibonacci 928.831 us (± 3.51028) 931.163 us (± 6.10798) 1.00
exec_bc_sum 199.812 ms (± 283.831) 199.718 ms (± 393.476) 1.00
exec_asmjit_add 3.4449 ns (± 0.266559) 3.54045 ns (± 0.463524) 0.97
exec_asmjit_fibonacci 21.4298 us (± 1.99446) 22.2767 us (± 3.47363) 0.96
exec_asmjit_sum 4.59215 ms (± 17.2692) 4.6079 ms (± 30.6132) 1.00
e2e_tiered_bc_to_mlir 41.809 us (± 8.07657) 44.5811 us (± 6.46821) 0.94
e2e_single_mlir 8.13526 ms (± 126.674) 8.26837 ms (± 190.58) 0.98
comp_mlir_add 8.16398 ms (± 201.623) 8.27543 ms (± 135.515) 0.99
comp_mlir_ifThenElse 8.76506 ms (± 168.461) 8.93785 ms (± 169.585) 0.98
comp_mlir_deeplyNestedIfElse 7.69045 ms (± 94.8059) 7.80209 ms (± 148.719) 0.99
comp_mlir_loop 9.76523 ms (± 150.362) 9.8792 ms (± 173.505) 0.99
comp_mlir_ifInsideLoop 31.12 ms (± 411.651) 31.7209 ms (± 1.10182) 0.98
comp_mlir_loopDirectCall 14.3437 ms (± 169.082) 14.6824 ms (± 531.641) 0.98
comp_mlir_pointerLoop 30.0628 ms (± 231.308) 30.4354 ms (± 293.611) 0.99
comp_mlir_staticLoop 7.62389 ms (± 135.722) 7.73037 ms (± 116.041) 0.99
comp_mlir_fibonacci 13.244 ms (± 308.345) 13.2831 ms (± 198.605) 1.00
comp_mlir_gcd 12.1267 ms (± 301.216) 12.1845 ms (± 174.723) 1.00
comp_mlir_nestedIf10 13.0645 ms (± 160.121) 13.2105 ms (± 125.81) 0.99
comp_mlir_nestedIf100 26.9674 ms (± 260.5) 27.6043 ms (± 1.15372) 0.98
comp_mlir_chainedIf10 12.0537 ms (± 82.8247) 12.3135 ms (± 180.096) 0.98
comp_mlir_chainedIf100 22.5531 ms (± 237.997) 23.3436 ms (± 788.987) 0.97
comp_cpp_add 24.5644 ms (± 377.523) 25.4931 ms (± 583.907) 0.96
comp_cpp_ifThenElse 25.0615 ms (± 444.336) 26.7345 ms (± 596.22) 0.94
comp_cpp_deeplyNestedIfElse 26.404 ms (± 497.679) 26.7089 ms (± 430.784) 0.99
comp_cpp_loop 25.1632 ms (± 390.468) 25.8655 ms (± 444.271) 0.97
comp_cpp_ifInsideLoop 26.0283 ms (± 452.699) 26.6968 ms (± 972.474) 0.97
comp_cpp_loopDirectCall 25.4081 ms (± 402.232) 26.1726 ms (± 469.615) 0.97
comp_cpp_pointerLoop 25.627 ms (± 436.746) 26.5349 ms (± 1.09407) 0.97
comp_cpp_staticLoop 24.6565 ms (± 306.49) 25.6925 ms (± 687.706) 0.96
comp_cpp_fibonacci 25.3639 ms (± 439.74) 26.1195 ms (± 940.646) 0.97
comp_cpp_gcd 25.0747 ms (± 399.767) 25.7512 ms (± 509.825) 0.97
comp_cpp_nestedIf10 27.9175 ms (± 374.082) 28.6539 ms (± 367.429) 0.97
comp_cpp_nestedIf100 61.2001 ms (± 644.91) 62.8175 ms (± 704.344) 0.97
comp_cpp_chainedIf10 30.3638 ms (± 581.111) 31.1865 ms (± 404.865) 0.97
comp_cpp_chainedIf100 90.6556 ms (± 553.788) 92.4321 ms (± 1.5899) 0.98
comp_bc_add 14.9575 us (± 2.97216) 14.8308 us (± 2.67486) 1.01
comp_bc_ifThenElse 18.2291 us (± 4.633) 17.8054 us (± 2.20986) 1.02
comp_bc_deeplyNestedIfElse 22.29 us (± 3.69371) 23.5869 us (± 3.99499) 0.95
comp_bc_loop 17.6903 us (± 2.50074) 18.1179 us (± 2.66293) 0.98
comp_bc_ifInsideLoop 20.5768 us (± 3.24976) 20.4934 us (± 2.74752) 1.00
comp_bc_loopDirectCall 19.3786 us (± 6.40892) 19.4768 us (± 4.59656) 0.99
comp_bc_pointerLoop 19.4953 us (± 4.1001) 20.2048 us (± 3.3783) 0.96
comp_bc_staticLoop 16.3108 us (± 2.97926) 16.6552 us (± 2.87681) 0.98
comp_bc_fibonacci 17.9763 us (± 2.6677) 18.5558 us (± 2.75112) 0.97
comp_bc_gcd 16.7754 us (± 2.5546) 17.9638 us (± 2.84482) 0.93
comp_bc_nestedIf10 34.7978 us (± 4.57733) 35.9526 us (± 4.18966) 0.97
comp_bc_nestedIf100 187.536 us (± 43.7657) 184.176 us (± 10.9246) 1.02
comp_bc_chainedIf10 50.6011 us (± 7.02624) 51.4438 us (± 5.70023) 0.98
comp_bc_chainedIf100 285.255 us (± 14.9108) 289.297 us (± 14.9353) 0.99
comp_asmjit_add 21.5616 us (± 4.02022) 22.156 us (± 4.44352) 0.97
comp_asmjit_ifThenElse 34.3072 us (± 4.87594) 35.0102 us (± 4.89285) 0.98
comp_asmjit_deeplyNestedIfElse 58.8473 us (± 7.42005) 60.2064 us (± 9.55521) 0.98
comp_asmjit_loop 36.5722 us (± 4.84037) 42.9997 us (± 8.68072) 0.85
comp_asmjit_ifInsideLoop 59.1634 us (± 8.63433) 59.3964 us (± 12.6762) 1.00
comp_asmjit_loopDirectCall 47.6576 us (± 9.16336) 47.3865 us (± 8.18972) 1.01
comp_asmjit_pointerLoop 48.8316 us (± 6.9254) 49.729 us (± 8.09524) 0.98
comp_asmjit_staticLoop 28.411 us (± 3.56751) 29.1812 us (± 5.48838) 0.97
comp_asmjit_fibonacci 45.067 us (± 5.45356) 45.6535 us (± 7.43123) 0.99
comp_asmjit_gcd 35.6192 us (± 3.72318) 36.0628 us (± 5.29933) 0.99
comp_asmjit_nestedIf10 109.547 us (± 10.8366) 112.233 us (± 15.0337) 0.98
comp_asmjit_nestedIf100 1.15668 ms (± 23.0362) 1.16598 ms (± 24.3966) 0.99
comp_asmjit_chainedIf10 164.302 us (± 13.7786) 168.928 us (± 14.7516) 0.97
comp_asmjit_chainedIf100 2.27756 ms (± 104.487) 2.2876 ms (± 38.1379) 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants