Fix several bugs in minstr post, and modernize its side exits

Summary: It had decref order differing from the interpreter in several cases,
and TryEndCatch had control flow that was hidden from the refcount optimizer
(bsimmers debugged that one).  This also makes its side exit creation easier to
understand from a state-management perspective, and removes the manual
SpillStack creation and such things (which bypass state updates at gen time).

We also get to get rid of BlockPauser and TryEndCatch.  (I'll be making
startBlock assert that blocks aren't already started in a later diff, which was
the reason not using a pauser would cause things like null fps.)

Reviewed By: @alexmalyshev

Differential Revision: D1712308
Restructure how catch blocks are normally created

Summary: Changes things so that whenever you generate an instruction that can
throw, normally we automatically make a catch block for it (using the state at
that program point).  Adds a variety of assertions try to verify that nothing
has changed the stack before we can throw unintentionally, since we're going to
spill the stack to look like it did before the HHBC opcode started executing by
default.  These assertions are also on for custom catch blocks, which are
needed in irgen-minstr and irgen-builtin, so they have to inform IRBuilder if
they want to modify the stack before a PEI.

This should fix catch blocks to get the correct frame-state as their block in
state in, generally (except for the stacks-states-arent-merged issue).  This
should also make it possible to fix those simplify.cpp issues where we needed
extra catch blocks and didn't have them, but this diff doesn't do that (after
this diff we should figure out whether simplify should be allowed to reuse
catch blocks at all---I am thinking it probably shouldn't be allowed to,
because the block could need a totally different in-state for the new position
we're generating the instruction, and if it made decisions at gen time based on
the previous state it could be wrong).

Reviewed By: @swtaarrs

Differential Revision: D1715225
Enable a few more assertions for catch trace states and startBlock

Summary: Now we should never be calling startBlock on a non-empty block, and we
can assert that catch traces have in-states that are the same as what they
would be at the instruction that has them as a taken() block.

We can't make this assertion for exit blocks yet (emitSetL fails it, for
example, but only because it's done loads of locals before the instructions
that might exit).

Reviewed By: @alexmalyshev

Differential Revision: D1717822
Tiny amount of easy NormalizedInstruction-removal in irgen-minstr

Summary: Everything easy, so not ni.inputs and ni.imm, and the call to
getPropertyOffset (uses ni.inputs).  It seems like ni.inputs is actually harder
to use than manually running through the mvector to me these days (it has to
build a hashtable for stack offsets and stuff), but removing that use is going
to need a little more restructuring of the code.  Also ni.imm is a tad
inconvenient to remove at the moment because the final op functions don't get
the unpacked immediates...

Reviewed By: @alexmalyshev

Differential Revision: D1715895

Signature: t1:1715895:1417640171:c13ac5ba6e4f1b27fa668789b82f8e841993feb5
Remove the rest of insertPhis for now

Summary: Go back to doing a DefSP at the new location, so we don't have a stack
threading dependency here.

Reviewed By: @swtaarrs

Differential Revision: D1717183
Rename IRBuilder's nextMarker to curMarker

Reviewed By: @edwinsmith

Differential Revision: D1719041

Signature: t1:1719041:1417712558:a320317a945d6102f64cc75550b9bc0b1ef00eb4
Disable IRBuilder CSE at gen time

Summary: Only do it during the reoptimizes for now.  This code is about to be
deleted in favor of the new GVN pass, too.  (I want to remove gen time support
for now so I can make cond(), ifThen(), etc not need DisableCseGuard.)

Reviewed By: @alexmalyshev

Differential Revision: D1719537

Signature: t1:1719537:1417724270:01b9a8500c5860123d7dabfed8ad0ee45dd5906f
Remove IRBuilder::makeExit; just talk to IRUnit::defBlock

Summary: It seems reasonable to let making a block via IRUnit also take a hint,
although the default needs to be Neither.  After this, IRBuilder::makeExit is
pretty redundant (and potentially confusing, because it does something
different from "makeExit" in other contexts).

Reviewed By: @alexmalyshev

Differential Revision: D1719601

Signature: t1:1719601:1417736457:d2ae4ada520f70e6b38340930b087ac05af6aa67
Fix load-elim behavior with type reflows

Summary: Change it so it reflows types after the pass, and inserts AssertTypes
instead of Mov instructions.  Now we can eliminate loads as long as the tracked
type is a subtype of the type of the dst->type() of the instruction we want to
replace, and it shouldn't be able to run into the copyTV issue.

Reviewed By: @jasone

Differential Revision: D1720342

Signature: t1:1720342:1417734422:e0085c8c43aeeb3e8698d9c6e0e538b91c4033b3
Fix a bug in simplifyCoerceStack

Summary: You can't simplify an instruction with a destination into to a Nop.
(There's also typeMightRelax bugs here but I'm trying to fix that in a general
way if I can.)

Reviewed By: @alexmalyshev

Differential Revision: D1721036

Signature: t1:1721036:1417743584:9679237a1c2526c179c8d60a104b64b2adb9ba75
Fix issues with how simplifyMod handles its undefined inputs

Summary: Mod has undefined behavior for 0 or -1 in the rhs, but I don't think
this makes it ok for the optimization in simplifyMod to have undefined
behavior.  If we're in unreachable code, we may very legitimately create IR
that would have undefined behavior at runtime, but we shouldn't break while
analyzing or compiling it.  So we can't assert it's not -1 or 0, we have to do
something.  Also remove an old block of code that was working around some
IRBuilder::cond bug that was probably fixed ages ago.

Reviewed By: @ottoni

Differential Revision: D1721311

Signature: t1:1721311:1417816128:7d4152daf4625498edd60d3fe2d6f01766ab6f59
Remove a redundant trace in appendInstruction

Summary: The traces have gotten a little out of order, and now we trace about
appending twice.

Reviewed By: @alexmalyshev

Differential Revision: D1721318

Signature: t1:1721318:1417751362:70919be1e7ff974f6c14ac959b2844830be58d2d
Fix guard relaxation bugs in simplify{Cast,Coerce}Stk

Summary: We can't optimize it out if the type might relax.

Reviewed By: @ottoni

Differential Revision: D1722473

Signature: t1:1722473:1417816195:340b5335e7c349ed10fc752e760d87c3fd325d34
Remove FrameStateMgr's visited block bitset

Summary: This causes us to incorrectly clear states during reoptimize right
now, and is no longer necessary (it was from before we had the bool
isLoopHeader argument).

Reviewed By: @ottoni

Differential Revision: D1721244
Fix a type bug in emitFCallBuiltin

Summary: It takes CVUs as stack inputs, not cells.

Reviewed By: @ottoni

Differential Revision: D1723729

Signature: t1:1723729:1418065263:39e2e4a708abd1a868debafc6bb5993cd79bec85
Don't dump XLS intervals based on printir tracing

Summary: Use xls module.  (I tried to do this before but apparently messed it
up.)  kRegAllocLevel is probably not ideal but the next person to work on xls
can tweak that sort of thing.

Reviewed By: @edwinsmith

Differential Revision: D1723755

Signature: t1:1723755:1417831651:99daedce05074edb9d64c9d37c13051c94036aea
Remove dead collectStackValues code

Summary: We used to track a set of available values back when IRBuilder was
called TraceBuilder, and inlining used to mark the caller stack available in
the callee so it could change decrefs to DecRefNZ.  But now it's just dead
code.

Reviewed By: @ottoni

Differential Revision: D1720455

Signature: t1:1720455:1417765532:beda26db2cc044fa6701bbd789f5247295b63067
Remove implSpillStack and peekSpillValues

Summary: Single remaining caller can be simplified by not using these helpers
now.

Reviewed By: @ottoni

Differential Revision: D1723980

Signature: t1:1723980:1418027361:ce9a58ec4dd6bbd8a1ec73f2ba0dfab6e5dfc886