Various llvm backend bugfixes
Summary: This gets us down from 354 failures in test/quick to 36, most of which
are unaligned native stack assertions. I turned some assertions into punts and
fixed a bunch of bugs - I think it's important to make sure the stuff we are
translating is solid before spending too much more time expanding coverage.
- Visit blocks in RPO instead of the codegen layout order. If a frozen block
branched to a cold block we'd previously see the cold successor first and try
to use values that weren't yet defined.
- Add a movretaddr to be used in the traceRet return assertion sequence,
avoiding a load into %rsp.
- Add loadzbq, loadzlq, and movzbq instructions to pass more precise type
information to llvm. Final codegen is unaffected; we still emit
loadzbl/loadl/movzbl in the x64 backend.
- Punt on unsupported ConditionCodes instead of asserting. We intend to support
them so it's not a bug if they're in the Vunit.
- bitcast all inputs to floating point operations to doubles. This works around
the fact that the vasm load instruction doesn't indicate the type of what
it's loading (just the size).
- Emit the stack adjustment from BeginCatch in the lowering phase instead of
code-gen-x64.cpp. llvm handles this kind of adjustment itself.
- Fix support for CppCall::Destructor calls - we were jumping to the jump table
instead of loading the address from it. I also cleaned up how we access it in
llvm, creating a properly typed GlobalVariable for it. Finally, rather than
directly referencing argNumToRegName[1] in the CppCall we create for it, use
a Vreg for the type register. This required moving Vreg to its own header
since vasm-x64.h needs to include cpp-call.h.
- Clean up how Bool values are dealt with in vasm, ensuring that they're always
i8 in llvm. Types are still i64; I may clean that up in the future. This also
required adding a CallDest::Bool type to make sure llvm zero-extends bool
helper return values when needed.
- Add a ldimmb instruction for byte-sized constants, and a corresponding
makeConst(bool) overload.
- Convert call in emitCheckSurpriseFlagsEnter to vcall.
- Reorganize LocRecs data structures to tolerate non-contiguous locrecs.
There are a few other minor issues I didn't call out in the list that should be
clear from the code changes.
Reviewed By: @edwinsmith
Differential Revision:
D1725756