-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduction of [Backend_var] #2056
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a step in the right direction.
This would indeed be nicer to separate backend_var from ident quickly.
What are the uses that would make it difficult ?
There are probably a few more modules that would benefit from the:
module V = Backend_var
module VP = Backend_var.With_provenance
It's probably better if it is a bit more uniformly used.
asmcomp/backend_var.ml
Outdated
type t = { | ||
var : backend_var; | ||
provenance : Provenance.t option; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could reduce a bit the memory usage by pushing the option out, given that this is always none right now:
type t =
| Without_provenance of backend_var
| With_provenance of {
var : backend_var;
provenance : Provenance.t option;
}
I think that the final version shouldn't have provenance as an option, as this should probably be the default. For other cases, it might be worth considering adding something saying: 'introduced by that transformation applied on the function coming from that location'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made this change, although the provenance isn't optional in the With_provenance
case. I agree that in future we might add something along the lines of what you suggest.
|
||
type environment = | ||
{ vars : Reg.t array Ident.Map.t; | ||
{ vars : (Reg.t array * Backend_var.Provenance.t option) V.Map.t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be better as a Backend_var.Provenance.Map.t
rather than adding one inside ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so -- for occurrences of variables not in binding position, you only have Backend_var.t
, not the version with provenance.
asmcomp/un_anf.ml
Outdated
loop let_bound_vars args | ||
| _::_, _::_ -> | ||
(* The [let] sequence has ceased to match the evaluation order | ||
or we have encountered some complicated argument. In this case | ||
we empty the stack to ensure that we do not end up moving an | ||
outer [let] across a side effect. *) | ||
outer [let] across a svare effect. *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a sed typo...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
asmcomp/un_anf.ml
Outdated
@@ -394,20 +399,20 @@ let let_bound_vars_that_can_be_moved ident_info (clam : Clambda.ulambda) = | |||
!can_move | |||
|
|||
(* Substitution of an expression for a let-moveable variable can cause the | |||
surrounding expression to become fixed. To avoid confusion, do the | |||
surrounding expression to become fixed. To avovar confusion, do the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
testsuite/tools/parsecmm.mly
Outdated
@@ -19,6 +19,8 @@ | |||
open Cmm | |||
open Parsecmmaux | |||
|
|||
module VP = Backend_var.With_provenance | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that required ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently not.
testsuite/tools/parsecmm.mly
Outdated
{fun_name = $3; fun_args = $5; fun_body = $7; | ||
{fun_name = $3; | ||
fun_args = $5; | ||
fun_body = $7; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
asmcomp/closure.ml
Outdated
|
||
(* Auxiliary for accessing globals. We change the name of the global | ||
to the name of the corresponding asm symbol. This is done here | ||
and no longer in Cmmgen so that approximations stored in .cmx files | ||
contain the right names if the -for-pack option is active. *) | ||
|
||
let getglobal dbg id = | ||
Uprim(Pgetglobal (Ident.create_persistent (Compilenv.symbol_for_global id)), | ||
Uprim(Pgetglobal ( | ||
V.create_persistent (Compilenv.symbol_for_global id)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably didn't need reindentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except the few typos, this looks good to me. This should essentially be a noop right now. Filling all those provenance will be tedious !
@chambart I'm afraid you'd better look at this again---it conflicted badly in places with the recent |
(@chambart Please squash+merge if you are happy with this, by the way.) |
28bcdc8
to
e97d88d
Compare
I've squashed this into a single changeset so it will be easier to manage other pull requests based on this one. |
e97d88d
to
4ce9180
Compare
Looks good to me. |
This patch replaces uses of
Ident
in the backend by two new types.Backend_var
is the direct replacement: currently this has a type equality toIdent
, but this should be removed in the future. There is also a second typeBackend_var.With_provenance
which is used when the corresponding value is in binding position (for example the bound variable in aClet
expression). This second type holds some extra information about the variable.This change serves two purposes: firstly, to enable the communication of information relating to bound variables (specifically about their module path, location and whether they are a renamed version of some original
Ident
) through to the points which need such information for debugging information emission; secondly, as a step on the road to providing better isolation between the various types used for variable-like entities throughout the compiler.