aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe
AgeCommit message (Collapse)Author
2016-11-16hipe_x86: Fix encoding of test instr w/ neg immMagnus Lång
Also, use byte form for immediates up to 255, since there's no sign extension in byte form. HiPE seems to never generate negative test immediates currently, but we should at least not output incorrect encodings.
2016-11-16hipe_tagscheme: Simplify test_two_fixnums with immMagnus Lång
test_two_fixnums would previously only check its right-hand argument for immediates, but not it's left. Now, test_two_fixnums reduces to test_fixnum if either argument is an immediate.
2016-11-16hipe_icode: Always const-propagate if&call argsMagnus Lång
2016-11-16hipe_tagscheme: x86 lea+test for mask_and_compareMagnus Lång
By changing mask_and_compare from and,sub to sub,and, x86 can use a 3-address LEA immediate add, saving a mov. The RISC backends should see no change in sequence length. We make test_(heap_|sub)binary use mask_and_compare so they will benefit too.
2016-11-16hipe_tagscheme: Improve fixnum_addsub with immMagnus Lång
The addsub sequence was suboptimal when one of the arguments was immediate, because it became an immediate alu followed by an immediate alub, and the optimisers would not combine them due to the risk of altering the branch. However, in this case we know that such a rewrite is safe, and do it directly in hipe_tagscheme:fixnum_addsub/5 instead.
2016-11-16hipe: Make realloc_binary fast case true branchMagnus Lång
This makes the fast case a fallthrough and the slow case a branch, hopefully improving cache locality.
2016-11-16hipe_x86_postpass: Negate conditions in goto elimMagnus Lång
2016-11-16hipe_tagscheme: Improve fixnum add on x86Magnus Lång
With the introduction of immediate adds encoded as 'LEA' on x86, it is now possible to do a fixnum add in two instructions and one branch by commuting the addition and reusing the result register as a temporary, which makes the 'alub' a 2-address add, saving a move instruction.
2016-11-15hipe_rtl_to_x86: Use LEA only for immediate addsMagnus Lång
It seems that most 3-address adds of temps can be move coalesced. Therefore, we limit the behaviour added by 1567585dda8 to only affect immediate adds. Also, add conversion of immediate mov+sub to lea.
2016-11-15hipe_x86: LeaToAdd peephole ruleMagnus Lång
Although LEA is useful for three-address form adds, sometimes it is used where a normal add would have sufficed (due to the addition being the last use of one of the operands; but RTL lowering does not know that as it does not have liveness information). As a workaround, we convert LEA back to ADD when the destination is the same as one of the operands.
2016-11-15hipe_sparc: move coalescingMagnus Lång
2016-11-15hipe_ppc: better rlwinm ppMagnus Lång
2016-11-15hipe_ppc: move coalescingMagnus Lång
2016-11-15hipe_rtl: drop alub dest when unusedMagnus Lång
2016-11-15hipe_rtl: unify branch and alubMagnus Lång
branch and alub overlap in their use cases, but the backends rely on knowing that the result is unused in their lowering of branch. By extending alub so that the destination is optional, it can fully replace branch. This simplifies rtl by reducing code duplication and the number of instructions. Also, in the x86 and arm backends, we can now use 'test' and {'tst','mvn','teq'} to lower some alubs without destinations. This is particularly good for x86, as sequences such as 'is_boxed' type tests now get shorter (both from not needing a mov to copy the variable, but also from the fact that 'testb' encodes shorter than 'andq').
2016-11-15hipe_x86: Fix&activate ElimCmp0 peephole ruleMagnus Lång
2016-11-15hipe_{x86,amd64}: Finish test instr implementationMagnus Lång
2016-11-10Merge branch 'maint'Sverker Eriksson
# Conflicts: # lib/hipe/llvm/hipe_rtl_to_llvm.erl
2016-11-10Merge branch 'margnus1/hipe_llvm39_bugs/PR-1237/OTP-14027/OTP-14028' into maintSverker Eriksson
* margnus1/hipe_llvm39_bugs/PR-1237: hipe_rtl_to_llvm: Constants for bits per byte/word hipe_llvm: Work around LLVM 3.9 sdesc bug hipe_llvm: Fix incorrect atom alignment assumption
2016-11-08hipe_rtl_to_llvm: Constants for bits per byte/wordMagnus Lång
The constant ?WORD_WIDTH is renamed ?BITS_IN_WORD, and a new constant ?BITS_IN_BYTE is introduced. Additionally, a bug in a currently unused case clause of llvm_type_from_size/1 is fixed (the size of a word was hardcoded to 64 bits).
2016-11-07hipe_llvm: Work around LLVM 3.9 sdesc bugMagnus Lång
As of LLVM 3.9, the x86-call-frame-opt pass in LLVM's X86 backend causes the stack descriptors to contain incorrect (or even negative) frame sizes or root slot offsets. This might cause LLVM-compiled modules to be rejected during loading with a badarg exception in hipe_bifs:enter_sdecs/1 (which additionally prints a "hipe_bifs_enter_sdesc_1: bad sdesc!" message to stderr), or it might cause corruption or segmentation faults when walking stacks (f.ex. during GC) containing frames compiled with ErLLVM. As a workaround, we pass the -no-x86-call-frame-opt flag to llc when the version is at least 3.9
2016-11-07hipe_llvm: Fix incorrect atom alignment assumptionMagnus Lång
ErLLVM was declaring atoms in the following manner: @atom_ok = external constant i64 ; Used inside a function like this %var = ptrtoint i64* @atom_ok to i64 However, doing so makes LLVM think the `atom_ok` is 8-byte aligned, since it refers to a i64 value. This resulted in LLVM occasionally incorrectly optimising away type tests on atoms, causing incorrect behaviour or even segfaults. One such case is in bs_match_compiler:coverage_apply/2, in which an is_boxed test on a literal atom was optimised away, causing the code to try and load the "header" of an atom. This problem reproduces with LLVM versions 3.7 through 3.9. By declaring atoms as i8 (byte) constants instead, LLVM no longer makes these alignment assumptions, and the bug is fixed.
2016-11-07Merge branch 'maint'Sverker Eriksson
2016-11-03Add a test case that should now workKostis Sagonas
2016-11-03Fix the native code translation of bs_match_stringKostis Sagonas
This fixes a HiPE bug reported on erlang-questions on 2/11/2016. The BEAM to ICode tranaslation of the bs_match_string instruction, written long ago for binaries (i.e., with byte-sized strings), tried to do a `clever' translation of even bit-sized strings using a HiPE primop that took a `Size' argument expressed in *bytes*. ICode is not really the place to do such a thing, and moreover there is really no reason for the HiPE primop not to take a Size argument expressed in *bits* instead. This commit changes the `Size' argument to be in bits, postpones the translation of the bs_match_string primop Fixed in a pair-programming/debugging session with @margnus1. until RTL and does a proper translation using bit-sized quantities there.
2016-10-24Merge branch 'sverker/hipe-llvm-remote-call/OTP-13983'Sverker Eriksson
2016-10-21hipe,llvm: Change inc_stack_0 bif call to not_remoteSverker Eriksson
Seems to work either way, it just seem more correct as all other 'bif' calls are 'not_remote'.
2016-10-21hipe: Remove redundant assertionSverker Eriksson
2016-10-18hipe_llvm: Use different symbols for remote callsMagnus Lång
2016-10-18Change the return type of hipe_bifs:add_ref/2Kostis Sagonas
2016-10-17kernel,hipe: Fix dialyzer warningsSverker Eriksson
2016-10-14Merge branch 'master' into sverker/hipe-code-loadnpurgeSverker Eriksson
Conflicts: erts/emulator/beam/beam_bif_load.c erts/emulator/beam/beam_load.c and added macro DBG_TRACE_MFA_P in beam_load.h
2016-10-14hipe: TRY fix llvm external calls to own moduleSverker Eriksson
to not be transformed to local calls. code_SUITE:uprade still fails if run with compile option {hipe,to_llvm}
2016-10-14hipe,erts: Remove cached fun 'native_address'Sverker Eriksson
Did not work with purge and made worse by new purge strategy. Did yield terrible performance when fun thing is created *before* fun code is loaded. Like when receiving not yet loaded fun from other node. The cached 'native_address' in ErlFunThing will not be updated leading to mode switch and error_handler being called for every call to the fun from native code.
2016-10-14erts: Fix early hipe patch loadingSverker Eriksson
by introducing hipe_bifs:commit_patch_load/1 that creates the HipeModule.
2016-10-14erts: Move new hipe ref and sdesc lists to loader stateSverker Eriksson
2016-10-14Add a loader state for HiPE code loadingMagnus Lång
Just like the BEAM loader state (as returned by erlang:prepare_loading/2), the HiPE loader state is contained in a magic binary. Eventually, we will separate HiPE loading into a prepare and a finalise phase, like the BEAM loader, where the prepare phase will be implemented by hipe_unified_loader and the finalise phase be implemented in C by hipe_load.c and beam_load.c, making prepare side-effect free and finalise atomic. The finalise phase will be exposed through the erlang:finish_loading/1 API, just like the BEAM loader, as this will allow HiPE and BEAM modules to be mixed in the same atomic "commit". The usage of a loader state makes it easier to keep track of all resources allocated during loading, and will not only make it easy to prevent leaks when hipe_unified_loader crashes, but also paves the way for proper, leak-free, unloading of HiPE modules.
2016-10-13Merge branch 'maint'Hans Bolinder
* maint: dialyzer: Fix opaque bug dialyzer: Fix opaque bugs
2016-10-10erts: Remove unused hipe_bifs:code_sizeSverker Eriksson
and hipe_bifs:update_code_size
2016-10-10erts: Improve hipe load/upgrade/purge machinerySverker Eriksson
A step toward better integration of hipe load and purge Highlights: * code_server no longer needs to call hipe_unified_loader:post_beam_load/1 Instead new internal function hipe_redirect_to_module() is called by loading BIFs to patch native call sites if needed. * hipe_purge_module() is called by erts_internal:purge_module/2 to purge any native code. * struct hipe_mfa_info redesigned and only used for exported functions that are called from or implemented by native code. A list of native call sites (struct hipe_ref) are kept for each hipe_mfa_info. * struct hipe_sdesc used by hipe_find_mfa_from_ra() to build native stack traces.
2016-10-06dialyzer: Fix opaque bugHans Bolinder
The "decoration" of opaque types works better than before when opaque types are used by other opaque types.
2016-10-06dialyzer: Fix opaque bugsHans Bolinder
t_from_form() sometimes returned a more general type than it should have done due to a bug in from_form_loop(): it stopped when the limit was exceeded, which could mean a collapsed type. Returning a type with smaller depth should fix this. is_specialization() now handles opaque types before unions, which should fix another problem. The bugs reported by Kostis.
2016-09-29Merge branch 'rickard/time-unit/OTP-13831'Rickard Green
* rickard/time-unit/OTP-13831: Replace usage of deprecated time units
2016-09-21Merge tag 'OTP-19.1'Henrik Nord
=== OTP-19.1 === Changed Applications: - asn1-4.0.4 - common_test-1.12.3 - compiler-7.0.2 - crypto-3.7.1 - debugger-4.2.1 - dialyzer-3.0.2 - diameter-1.12.1 - edoc-0.8 - erl_docgen-0.6 - erl_interface-3.9.1 - erts-8.1 - eunit-2.3.1 - gs-1.6.2 - hipe-3.15.2 - ic-4.4.2 - inets-6.3.3 - jinterface-1.7.1 - kernel-5.1 - mnesia-4.14.1 - observer-2.2.2 - odbc-2.11.3 - parsetools-2.1.3 - reltool-0.7.2 - runtime_tools-1.10.1 - sasl-3.0.1 - snmp-5.2.4 - ssh-4.3.2 - ssl-8.0.2 - stdlib-3.1 - syntax_tools-2.1 - tools-2.8.6 - wx-1.7.1 - xmerl-1.3.12 Unchanged Applications: - cosEvent-2.2.1 - cosEventDomain-1.2.1 - cosFileTransfer-1.2.1 - cosNotification-1.2.2 - cosProperty-1.2.1 - cosTime-1.2.2 - cosTransactions-1.3.2 - eldap-1.2.2 - et-1.6 - megaco-3.18.1 - orber-3.8.2 - os_mon-2.4.1 - otp_mibs-1.1.1 - percept-0.9 - public_key-1.2 - typer-0.9.11 Conflicts: OTP_VERSION lib/gs/doc/src/notes.xml lib/gs/vsn.mk
2016-09-20Prepare releaseErlang/OTP
2016-09-12Merge branch 'maint'Hans Bolinder
* maint: erl_bif_types: Properly unopaque maps:merge/2 args
2016-09-12Merge branch 'margnus1/dialyzer/fix_maps_opaque/ERL-249/PR-1161/OTP-13878' ↵Hans Bolinder
into maint * margnus1/dialyzer/fix_maps_opaque/ERL-249/PR-1161/OTP-13878: erl_bif_types: Properly unopaque maps:merge/2 args
2016-09-09Merge branch 'sverker/hipe-speedy-reg-alloc/PR-1159/OTP-13879'Sverker Eriksson
* sverker/hipe-speedy-reg-alloc/PR-1159: hipe: Refactor ra callbacks to accept context arg hipe: Reuse liveness between regalloc iterations hipe: Add ra_partitioned to o1 and up hipe_regalloc_prepass: Change splitting heuristic hipe: Make sure prepass temps are below SpillLimit hipe_regalloc_prepass: Rename coloring collisions hipe_ppc: Add code rewrite RA callbacks hipe_sparc: Add code rewrite RA callbacks hipe_arm: Add code rewrite RA callbacks hipe_x86: Add code rewrite RA callbacks hipe: Remove defun_to_cfg/1 RA callback Add new sanity assertion to hipe_regalloc_prepass Simplify hipe_x86_ra_finalise:conv_ra_maplet/3 hipe_x86: Simplify ra_postconditions is_mem_opnd hipe_x86: Fix pseudo_tailcall prettyprinting hipe_x86: Extra sanity assertions hipe: clean up unnecessary catches hipe: Remove temp reuse from call_fun hipe: Add IG partitioning to hipe_regalloc_prepass hipe: Add hipe_regalloc_prepass
2016-09-07erl_bif_types: Properly unopaque maps:merge/2 argsMagnus Lång
erl_bif_types:type/5 was calling erl_types:map_pairwise_merge/3 directly with its (potentially opaque) arguments, causing Dialyzer crashes. Bug (ERL-249) reported and minimised test case provided by Felipe Ripoll.
2016-09-07Merge branch 'maint'Björn-Egil Dahlberg