aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-10-24 15:19:08 +0200
committerSverker Eriksson <[email protected]>2016-10-24 15:19:08 +0200
commit0b5612f8770fa24081a7ce6a62190921c0478be4 (patch)
tree017efb58402769108eb46062f82661808294775b /lib
parent1a812284999c8f38d84f380775b88f7bdc1f1432 (diff)
parentf66a70f651c2889f69b938e7ad061bddb8fe2116 (diff)
downloadotp-0b5612f8770fa24081a7ce6a62190921c0478be4.tar.gz
otp-0b5612f8770fa24081a7ce6a62190921c0478be4.tar.bz2
otp-0b5612f8770fa24081a7ce6a62190921c0478be4.zip
Merge branch 'sverker/hipe-llvm-remote-call/OTP-13983'
Diffstat (limited to 'lib')
-rw-r--r--lib/hipe/llvm/hipe_llvm_main.erl3
-rw-r--r--lib/hipe/llvm/hipe_rtl_to_llvm.erl24
-rw-r--r--lib/kernel/test/code_SUITE.erl28
-rw-r--r--lib/kernel/test/code_SUITE_data/upgrade_client.erl28
4 files changed, 49 insertions, 34 deletions
diff --git a/lib/hipe/llvm/hipe_llvm_main.erl b/lib/hipe/llvm/hipe_llvm_main.erl
index 164ccf20ef..c8fc9cc856 100644
--- a/lib/hipe/llvm/hipe_llvm_main.erl
+++ b/lib/hipe/llvm/hipe_llvm_main.erl
@@ -276,8 +276,7 @@ fix_reloc(#elf_rel{symbol=#elf_sym{name=Name, section=#elf_shdr{name=?TEXT},
offset=Offset, type=?PCREL_T, addend=?PCREL_A},
RelocsDict, MFA) when Name =/= "" ->
case dict:fetch(Name, RelocsDict) of
- {call, not_remote, MFA} -> {?CALL_LOCAL, Offset, MFA};
- {call, remote, MFA} -> {?CALL_REMOTE, Offset, MFA}
+ {call, not_remote, MFA} -> {?CALL_LOCAL, Offset, MFA}
end;
fix_reloc(#elf_rel{symbol=#elf_sym{name=Name, section=#elf_shdr{name=?RODATA},
type=object},
diff --git a/lib/hipe/llvm/hipe_rtl_to_llvm.erl b/lib/hipe/llvm/hipe_rtl_to_llvm.erl
index 55ab6a3db1..53aa8c57b2 100644
--- a/lib/hipe/llvm/hipe_rtl_to_llvm.erl
+++ b/lib/hipe/llvm/hipe_rtl_to_llvm.erl
@@ -438,11 +438,7 @@ trans_call_name(RtlCallName, RtlCallType, Relocs, CallArgs, FinalArgs) ->
relocs_store(LlvmName, {call, not_remote, {bif, PrimOp, length(CallArgs)}}, Relocs),
{"@" ++ LlvmName, [], Relocs1};
{M, F, A} when is_atom(M), is_atom(F), is_integer(A) ->
- LlvmName = trans_mfa_name({M, F, A}),
- ok = case RtlCallType of
- not_remote -> ok;
- remote -> ok
- end,
+ LlvmName = trans_mfa_name({M, F, A}, RtlCallType),
Relocs1 =
relocs_store(LlvmName, {call, RtlCallType, {M, F, length(CallArgs)}}, Relocs),
{"@" ++ LlvmName, [], Relocs1};
@@ -1039,8 +1035,12 @@ llvm_id(C) ->
io_lib:format("_~2.16.0B_",[C]).
%% @doc Create an acceptable LLVM identifier for an MFA.
-trans_mfa_name({M,F,A}) ->
- N = atom_to_list(M) ++ "." ++ atom_to_list(F) ++ "." ++ integer_to_list(A),
+trans_mfa_name({M,F,A}, Linkage) ->
+ N0 = atom_to_list(M) ++ "." ++ atom_to_list(F) ++ "." ++ integer_to_list(A),
+ N = case Linkage of
+ not_remote -> N0;
+ remote -> "rem." ++ N0
+ end,
make_llvm_id(N).
%%------------------------------------------------------------------------------
@@ -1342,7 +1342,7 @@ llvm_type_from_size(Size) ->
%% precoloured registers that are passed as arguments must be stored to
%% the corresonding stack slots.
create_function_definition(Fun, Params, Code, LocalVars) ->
- FunctionName = trans_mfa_name(Fun),
+ FunctionName = trans_mfa_name(Fun, not_remote),
FixedRegs = fixed_registers(),
%% Reverse parameters to match with the Erlang calling convention
ReversedParams =
@@ -1461,7 +1461,7 @@ handle_relocations(Relocs, Data, Fun) ->
Relocs2 = lists:foldl(fun const_to_dict/2, Relocs1, ConstLabels),
%% Temporary Store inc_stack and llvm_fix_pinned_regs to Dictionary
%% TODO: Remove this
- Relocs3 = dict:store("inc_stack_0", {call, remote, {bif, inc_stack_0, 0}}, Relocs2),
+ Relocs3 = dict:store("inc_stack_0", {call, not_remote, {bif, inc_stack_0, 0}}, Relocs2),
Relocs4 = dict:store("hipe_bifs.llvm_fix_pinned_regs.0",
{call, remote, {hipe_bifs, llvm_fix_pinned_regs, 0}}, Relocs3),
BranchMetaData = [
@@ -1527,7 +1527,7 @@ load_closure({ClosureName, _})->
%% @doc Declaration of a local variable for a switch jump table.
declare_switches(JumpTableList, Fun) ->
- FunName = trans_mfa_name(Fun),
+ FunName = trans_mfa_name(Fun, not_remote),
[declare_switch_table(X, FunName) || X <- JumpTableList].
declare_switch_table({Name, {switch, {TableType, Labels, _, _}, _}}, FunName) ->
@@ -1543,7 +1543,7 @@ declare_switch_table({Name, {switch, {TableType, Labels, _, _}, _}}, FunName) ->
declare_closure_labels([], Relocs, _Fun) ->
{[], Relocs};
declare_closure_labels(ClosureLabels, Relocs, Fun) ->
- FunName = trans_mfa_name(Fun),
+ FunName = trans_mfa_name(Fun, not_remote),
{LabelList, ArityList} =
lists:unzip([{mk_jump_label(Label), A} ||
{_, {closure_label, Label, A}} <- ClosureLabels]),
@@ -1561,7 +1561,7 @@ declare_closure_labels(ClosureLabels, Relocs, Fun) ->
%% @doc A call is treated as non external only in a case of a local recursive
%% function.
-is_external_call({_, {call, _, MFA}}, MFA) -> false;
+is_external_call({_, {call, not_remote, MFA}}, MFA) -> false;
is_external_call(_, _) -> true.
%% @doc External declaration of a function.
diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl
index 96f8ff2c5f..29b3f7caaf 100644
--- a/lib/kernel/test/code_SUITE.erl
+++ b/lib/kernel/test/code_SUITE.erl
@@ -487,12 +487,21 @@ load_binary(Config) when is_list(Config) ->
upgrade(Config) ->
DataDir = proplists:get_value(data_dir, Config),
- T = case erlang:system_info(hipe_architecture) of
- undefined -> [beam];
- _ -> [beam,hipe]
- end,
-
- [upgrade_do(DataDir, Client, T) || Client <- T],
+ case erlang:system_info(hipe_architecture) of
+ undefined ->
+ upgrade_do(DataDir, beam, [beam]);
+
+ _ ->
+ T = [beam, hipe],
+ [upgrade_do(DataDir, Client, T) || Client <- T],
+
+ case hipe:llvm_support_available() of
+ false -> ok;
+ true ->
+ T2 = [beam, hipe_llvm],
+ [upgrade_do(DataDir, Client, T2) || Client <- T2]
+ end
+ end,
ok.
upgrade_do(DataDir, Client, T) ->
@@ -502,7 +511,7 @@ upgrade_do(DataDir, Client, T) ->
ok.
compile_load(Mod, Dir, Ver, CodeType) ->
- erlang:display({"{{{{{{{{{{{{{{{{Loading",Mod,Ver,CodeType}),
+ %%erlang:display({"{{{{{{{{{{{{{{{{Loading",Mod,Ver,CodeType}),
Version = case Ver of
undefined ->
io:format("Compiling '~p' as ~p\n", [Mod, CodeType]),
@@ -514,7 +523,8 @@ compile_load(Mod, Dir, Ver, CodeType) ->
end,
Target = case CodeType of
beam -> [];
- hipe -> [native]
+ hipe -> [native];
+ hipe_llvm -> [native,{hipe,[to_llvm]}]
end,
CompOpts = [binary, report] ++ Target ++ Version,
@@ -527,7 +537,7 @@ compile_load(Mod, Dir, Ver, CodeType) ->
T3 = erlang:now(),
io:format("Compile time ~p ms, Load time ~p ms\n",
[timer:now_diff(T2,T1) div 1000, timer:now_diff(T3,T2) div 1000]),
- erlang:display({"}}}}}}}}}}}}}}}Loaded",Mod,Ver,CodeType}),
+ %%erlang:display({"}}}}}}}}}}}}}}}Loaded",Mod,Ver,CodeType}),
ok.
dir_req(Config) when is_list(Config) ->
diff --git a/lib/kernel/test/code_SUITE_data/upgrade_client.erl b/lib/kernel/test/code_SUITE_data/upgrade_client.erl
index 98d36f6014..faa18e1410 100644
--- a/lib/kernel/test/code_SUITE_data/upgrade_client.erl
+++ b/lib/kernel/test/code_SUITE_data/upgrade_client.erl
@@ -65,7 +65,7 @@ run(Dir, Upgradee1, Upgradee2, Other1, Other2) ->
put(exp1exp2_fun, upgradee:get_exp1exp2_fun()),
?line 1 = (get(exp1exp2_fun))(),
- ?line 13 = check_tracing(Tracer),
+ ok = check_tracing(Tracer, 13),
%%
%% Load version 1 of other
@@ -89,7 +89,7 @@ run(Dir, Upgradee1, Upgradee2, Other1, Other2) ->
?line {'EXIT',{undef,_}} = proxy_call(P, other, exp2),
?line {'EXIT',{undef,_}} = proxy_call(P, other, loc2),
- ?line 5 = check_tracing(Tracer),
+ ok = check_tracing(Tracer, 5),
%%
%% Load version 2 of upgradee
@@ -150,7 +150,7 @@ run(Dir, Upgradee1, Upgradee2, Other1, Other2) ->
?line 2 = (get(exp1exp2_fun))(),
- ?line 10 = check_tracing(Tracer),
+ ok = check_tracing(Tracer, 10),
%%
%% Load version 2 of other
@@ -208,7 +208,7 @@ run(Dir, Upgradee1, Upgradee2, Other1, Other2) ->
?line {2,Env2} = (get(loc2_fun))(),
?line 2 = (get(exp1exp2_fun))(),
- ?line 10 = check_tracing(Tracer),
+ ok = check_tracing(Tracer, 10),
%%
%% Upgrade proxy to version 2
@@ -273,7 +273,7 @@ run(Dir, Upgradee1, Upgradee2, Other1, Other2) ->
?line {'EXIT',{undef,_}} = (catch (get(exp1exp2_fun))()),
- ?line 14 = check_tracing(Tracer),
+ ok = check_tracing(Tracer, 14),
unlink(P),
exit(P, die_please),
@@ -319,18 +319,24 @@ tracer_loop(Receiver) ->
tracer_loop(Receiver)
end.
-check_tracing(Tracer) ->
+check_tracing(Tracer, Expected) ->
Tracer ! {do_trace_delivered, self()},
- check_tracing_loop(0).
+ case check_tracing_loop(0,[]) of
+ {Expected,_} ->
+ ok;
+ {Got, MsgList} ->
+ io:format("Expected ~p trace msg, got ~p:\n~p\n",
+ [Expected, Got, lists:reverse(MsgList)]),
+ "Trace msg mismatch"
+ end.
-check_tracing_loop(N) ->
+check_tracing_loop(N, MsgList) ->
Self = self(),
receive
{trace, _Pid, call, {_M, _F, _Args}} = Msg ->
- io:format("Trace: ~p\n",[Msg]),
- check_tracing_loop(N+1);
+ check_tracing_loop(N+1, [Msg | MsgList]);
{trace_delivered, Self, _} ->
- N
+ {N, MsgList}
end.