Wip ssa

WDYT kbarone and dpino?

Here I paste some unformatted chat:

awingo 09:29:19 PM
so i was doing some work on that language of do and labels and what-not
kbarone 09:29:25 PM
ooh, cool
awingo 09:29:31 PM
and it turns out that some of the transformations that we did were incorrect
specifically the inlining singly-used labels
kbarone 09:29:41 PM
I've made some little pipeline graphs in dot and started an 'inside pflua' post at the office this morning
ah-hah.... I wondered
what was wrong with that one? control flow?
awingo 09:30:02 PM
because it's not the case that "an block wrapped by a label" is really one expression
because it could have fallthrough afterwards
we caught the fallthrough before case i think
but not the after case
kbarone 09:30:27 PM
ah-hah, yes, indeed
awingo 09:30:49 PM
so after poking that for quite some time i thought that maybe that wasn't the right language
and that a more traditional graph-of-basic-blocks thing was the right thing
kbarone 09:31:35 PM
I failed friday to update the submodule in pflua-quickcheck (I only had a few minutes until the Gigantic Video appeared and sucked up my time), so hadn't gotten around to testing the old and new code for regressions wrt each other
awingo 09:31:37 PM
i tried that out today and it seems ok, though it's silly going through all of these langauges
kbarone 09:31:42 PM
hmmm, sounds plausible
awingo 09:31:48 PM
yeah we haven't tried actually loading strings yet 
kbarone 09:32:01 PM
on one hand, a bit; on the other hand, if it makes it nicer, it's kinda ok? 
awingo 09:32:03 PM
i was just trying and ran into a couple difficulties
heh yeah
kbarone 09:32:17 PM
loading strings of what?
awingo 09:32:29 PM
loadstring i mean
so
the thing is, once you have a graph, it's not clear how to get back to lua
kbarone 09:32:47 PM
yes, but on what, our generated lua?
ah, that's a bit of a thorn
awingo 09:33:03 PM
the graph optimizations are easy in ssa but going back to lua is irritating
so it turns out that our lua language is fine for representing lua
– clopez has left the room
awingo 09:33:16 PM
just not for optimizations
– rego has left the room
kbarone 09:33:19 PM
makes sense
awingo 09:33:24 PM
so you use the ssa for optimizations
– clopez has joined the room
– rego has joined the room
awingo 09:33:31 PM
and then lower to lua
kbarone 09:33:34 PM
even with ssa, don't we have ugly register pressure things like usual, or is luajit smart enough that it's a non-issue?
hmmm, ok
awingo 09:33:50 PM
mmm, we do have some register pressure, but there aren't that many live variables
and in practice it's limited by trace size
and now that we do better cse the register pressure is less
and we don't have loops so register allocation is easier
anyway
ssa is all about "definitions dominate uses"
kbarone 09:34:30 PM
yeah, and when I think about it, that's really only a temporary small pass so it's not so important in that regard
awingo 09:34:34 PM
which is the essence of scope
kbarone 09:34:38 PM
*nod*
awingo 09:34:46 PM
you can only use values in the scope of the definitions
so that gets us closer
what i do in ssa.lua -- this is in the wip-ssa branch --
kbarone 09:35:09 PM
hm, closer to what exactly?
awingo 09:35:14 PM
is to compute a dominator tree
and then use the tree to re-create scopes
closer to the kind of lua we need to be creating
dominator computation is trivial because we don't have loops
and because it re-creates the tree of definitions that dominate uses, it re-creates scopes
kbarone 09:36:20 PM
ahh; what's wrong with the lua we're creating now? (inlining bug excepted)?
awingo 09:36:20 PM
kinda gnarly but it works ok
kbarone 09:36:33 PM
and yes, bpf's non-loopness is nice
awingo 09:37:09 PM
kbarone: the inlining bug.  we're not able to do good optimizations because we don't have the right ir
kbarone 09:37:17 PM
fair
awingo 09:37:29 PM
so we have three languages that we optimize over now 
kinda silly
kbarone 09:37:31 PM
this shall take thinking about 
kinda, perhaps; I really need to look at what the nanopass compiler does language-wise
any idea about how many languages it has? 
awingo 09:37:56 PM
the language of optimize.lua, and the language of anf (for cse), and the language of ssa
haha the nanopass compiler has like 30 languages 
each pass is a language 
some passes work on the same language but in general they are different
soooooo
kbarone 09:38:50 PM
kbaronenods
I'm not opposed to doing things that way, in theory
but only if we gain something from it to kinda balance the complexity!
and yeah, i've been calling one of those just 'pflua-IR', which is a bad bad name 
awingo 09:39:35 PM
i am going to submit a pr for wip-ssa once loadstring works.  seems like not a bad option, but feedback appreciated 
haha yeah we need a name for that
compilers are all about names 
kbarone 09:39:53 PM
sure, send me a link to the code to look at 
– clopez has left the room
awingo 09:40:05 PM
np.  currently in wip-ssa branch on github.
– clopez has joined the room
kbarone 09:40:16 PM
yep! which is part of why I have two shiny new dot diagrams to help me remember what's where in what order doing what 
ok, cool