Don't generate Clambda constants during Cmmgen, etc.#2280
Don't generate Clambda constants during Cmmgen, etc.#2280mshinwell merged 2 commits intoocaml:trunkfrom
Conversation
|
The patch looks fine, except for a few small issues:
|
…s per code review
|
Well spotted. I've pushed a patch that should cause Closure to lift empty arrays and then share the resulting constants. As far as I can see Flambda already does this (see Regarding other constants not shared in Cmmgen, I am minded not to worry about this, as any potential size increase seems likely to be minor (especially given what you say about the relevant optimisation being difficult to trigger)---and in any case, we have a medium-term story for doing unboxing in a more principled manner inside the next version of Flambda. I've reinstated the variables instead of strings for the boxed integer operations symbols. (All of the symbol strings turn into variables in a later patch, actually...) |
lthls
left a comment
There was a problem hiding this comment.
There are still a few places where the strings "caml_*_ops" could be replaced by a variable, but it's not particularly important. I'm in favour of merging this PR as it stands now.
|
Right, those references will be sorted out by a later patch anyway. Let's merge this once CI passes. Thanks for the review. |
This patch is a prerequisite of a forthcoming patch that improves the types used to represent symbols (names of statically-allocated entities) throughout the middle end and backend. This in turn is needed for the
Asm_directiveslayer on which the DWARF support is based.I think a good general principle, when writing a pass that operates on some particular IR, is to avoid generating constructs from previous IRs and sending them back through part of the current pass. Instead, it is better to refactor the current pass so that the constructs you want can be generated directly in your current language.
This patch changes
Cmmgento follow this principle for constants. The reason this is necessary is because, with the forthcoming patch, it is not always possible to construct a value of the type that describes middle-end symbols (such as will appear inClambda) duringCmmgen. I would rather not get into the details here, but in summary, this relates to the fact that duringCmmgenwe may be generating code (e.g. for a startup file) that does not stem from an OCaml compilation unit.There are a couple of other related changes that I thought reasonable to include with this patch, since our workflow management becomes difficult if there are just too many pull requests. One of them passes the list of constants, for the classic Closure mode, through from
Asmgenrather than reading theCompilenvglobal state inCmmgen; this is consistent with what Flambda does. The other pulls the global state fromCmmgen, much of which is to do with constants, into a separate file. Warning 40 is suppressed to increase code legibility (e.g. withLocalandGlobal) and reduce proliferation of "open".@lthls Could you please look at this? (Some amount of this is just moving code upwards in
cmmgen.ml; you might want to diff that separately.)