-
Notifications
You must be signed in to change notification settings - Fork 1.2k
excessive inlining of jump tables #7449
Description
Original bug ID: 7449
Reporter: markghayden
Assigned to: @chambart
Status: assigned (set by @chambart on 2017-01-03T20:59:28Z)
Resolution: open
Priority: normal
Severity: minor
Platform: AMD64
OS: MacOS
OS Version: 10.12.2
Version: 4.04.0
Category: middle end (typedtree to clambda)
Tags: flambda
Monitored by: @gasche @ygrek
Bug description
See the attached code. The [to_string] function is inlined at all call sites, even with no optimization specified at the command line (!?!). Note that each call site includes a full copy of the jump table and all the jump branches. The test case here has 30 items. I've seen this with larger cases (300 items). Maybe I'm missing something, but it seems this is really off here since this behavior can result in significant code growth. A work-around is to annotate with '[@inline never]'.
Steps to reproduce
Compile with 4.04.0 or 4.05.0.dev trunk. Note that for 4.05.0.dev, the lookup table is used if all the return values are constants and perhaps that is OK to inline. Added a [failwith] for one of the cases forces the use of jump tables, at least on AMD64.
ocamlopt -c -S du.ml
Additional information
See attached ML file. Assembler output will follow.