Various llvm backend bugfixes
commitaf105195ea61c3c2c34539112da98a06863b855c
authorBrett Simmers <bsimmers@fb.com>
Mon, 8 Dec 2014 21:34:29 +0000 (8 13:34 -0800)
committerhhvm-bot <hhvm-bot@fb.com>
Wed, 10 Dec 2014 00:30:35 +0000 (9 16:30 -0800)
tree9766437c5e09ff15c732d4fb497db9661d03fa08
parent36c4abb80e13e58977466e9edac39a318796282b
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
23 files changed:
hphp/doc/hackers-guide/jit-core.md
hphp/runtime/vm/jit/arg-group.cpp
hphp/runtime/vm/jit/arg-group.h
hphp/runtime/vm/jit/back-end-x64.cpp
hphp/runtime/vm/jit/code-gen-arm.cpp
hphp/runtime/vm/jit/code-gen-helpers-x64.cpp
hphp/runtime/vm/jit/code-gen-helpers-x64.h
hphp/runtime/vm/jit/code-gen-x64.cpp
hphp/runtime/vm/jit/cpp-call.h
hphp/runtime/vm/jit/llvm-locrecs.cpp
hphp/runtime/vm/jit/llvm-locrecs.h
hphp/runtime/vm/jit/mc-generator-internal.h
hphp/runtime/vm/jit/reg-alloc.cpp
hphp/runtime/vm/jit/region-tracelet.cpp
hphp/runtime/vm/jit/vasm-dead.cpp
hphp/runtime/vm/jit/vasm-fold-imms.cpp
hphp/runtime/vm/jit/vasm-llvm.cpp
hphp/runtime/vm/jit/vasm-llvm.h
hphp/runtime/vm/jit/vasm-print.cpp
hphp/runtime/vm/jit/vasm-reg.h [new file with mode: 0644]
hphp/runtime/vm/jit/vasm-x64.cpp
hphp/runtime/vm/jit/vasm-x64.h
hphp/runtime/vm/jit/vasm-xls.cpp