Update to licm for hoisting wide things

Because flattenFunctions does funky things, a variable that should be passed by
ref isn't always done so. As a result I also have to check if an argument is a
ref argument in addition to if it is passed by ref.