Skip to content

Commit cf171c3

Browse files
committed
review fixes
1 parent 2e3a1ad commit cf171c3

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

backend/amd64/arch.ml

+4-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ let command_line_options =
6565

6666
open Format
6767

68+
type sym_global = Global | Local
69+
6870
type addressing_mode =
69-
Ibased of string * bool * int (* symbol + displ *)
71+
Ibased of string * sym_global * int (* symbol + displ *)
7072
| Iindexed of int (* reg + displ *)
7173
| Iindexed2 of int (* reg + reg + displ *)
7274
| Iscaled of int * int (* reg * scale + displ *)
@@ -306,7 +308,7 @@ let float_cond_and_need_swap cond =
306308
let equal_addressing_mode left right =
307309
match left, right with
308310
| Ibased (left_sym, left_glob, left_displ), Ibased (right_sym, right_glob, right_displ) ->
309-
String.equal left_sym right_sym && Bool.equal left_glob right_glob && Int.equal left_displ right_displ
311+
String.equal left_sym right_sym && left_glob = right_glob && Int.equal left_displ right_displ
310312
| Iindexed left_displ, Iindexed right_displ ->
311313
Int.equal left_displ right_displ
312314
| Iindexed2 left_displ, Iindexed2 right_displ ->

backend/amd64/emit.mlp

+9-5
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,11 @@ let res32 i n = emit_subreg reg_low_32_name DWORD i.res.(n)
321321

322322
let addressing addr typ i n =
323323
match addr with
324-
| Ibased(s, glob, ofs) ->
325-
add_used_symbol s;
326-
let s : Cmm.symbol = { sym_name = s; sym_global = if glob then Global else Local } in
327-
mem64_rip typ (emit_cmm_symbol s) ~ofs
324+
| Ibased(sym_name, sym_global, ofs) ->
325+
add_used_symbol sym_name;
326+
let sym_global : Cmm.is_global =
327+
match sym_global with Global -> Global | Local -> Local in
328+
mem64_rip typ (emit_cmm_symbol { sym_name ; sym_global }) ~ofs
328329
| Iindexed d ->
329330
mem64 typ d (arg64 i n)
330331
| Iindexed2 d ->
@@ -1249,7 +1250,7 @@ let emit_instr fallthrough i =
12491250
to control ocaml probe handlers independently from stap probe handlers.
12501251
It is placed immediately after stap semaphore, and is the same
12511252
size - hence offset 2. *)
1252-
I.mov (addressing (Ibased(semaphore_sym, true, 2)) WORD i 0) (res16 i 0);
1253+
I.mov (addressing (Ibased(semaphore_sym, Global, 2)) WORD i 0) (res16 i 0);
12531254
(* If the semaphore is 0, then the result is 0, otherwise 1. *)
12541255
I.cmp (int 0) (res16 i 0);
12551256
I.set (cond (Iunsigned Cne)) (res8 i 0);
@@ -1399,6 +1400,9 @@ let fundecl fundecl =
13991400
D.private_extern (emit_symbol fundecl.fun_name)
14001401
else
14011402
D.global (emit_symbol fundecl.fun_name);
1403+
(* Even if the function name is Local, still emit an
1404+
actual linker symbol for it. This provides symbols
1405+
for perf, gdb, and similar tools *)
14021406
D.label (emit_symbol fundecl.fun_name);
14031407
D.label (label_name (emit_symbol fundecl.fun_name));
14041408
emit_debug_info fundecl.fun_dbg;

backend/amd64/selection.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ method select_addressing _chunk exp =
245245
then (Iindexed 0, exp)
246246
else match a with
247247
| Asymbol s ->
248-
(Ibased(s.sym_name, s.sym_global = Cmm.Global, d), Ctuple [])
248+
let glob : Arch.sym_global =
249+
match s.sym_global with Global -> Global | Local -> Local in
250+
(Ibased(s.sym_name, glob, d), Ctuple [])
249251
| Alinear e ->
250252
(Iindexed d, e)
251253
| Aadd(e1, e2) ->

backend/arm64/emit.mlp

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ let emit_label lbl =
4949

5050
(* Symbols *)
5151

52+
(* CR sdolan: Support local symbol definitions & references on arm64 *)
53+
5254
let emit_symbol s =
5355
if macosx then emit_string "_";
5456
Emitaux.emit_symbol '$' s

backend/cmm_helpers.ml

+2-3
Original file line numberDiff line numberDiff line change
@@ -3614,7 +3614,6 @@ let emit_constant_closure symb fundecls clos_vars cont =
36143614
let is_last = match rem with [] -> true | _ :: _ -> false in
36153615
match f2.arity with
36163616
| { function_kind = Curried _; params_layout = [] | [_]; _ } as arity ->
3617-
(* FIXME: is sym_global correct here? *)
36183617
(Cint (infix_header pos) :: closure_symbol f2)
36193618
@ Csymbol_address
36203619
{ sym_name = f2.label; sym_global = symb.sym_global }
@@ -3690,8 +3689,8 @@ let preallocate_block cont { Clambda.symbol; exported; tag; fields } =
36903689
let emit_preallocated_blocks preallocated_blocks cont =
36913690
let symbols =
36923691
List.map
3693-
(fun ({ Clambda.symbol } : Clambda.preallocated_block) ->
3694-
global_symbol symbol)
3692+
(fun ({ Clambda.symbol; exported } : Clambda.preallocated_block) ->
3693+
{ sym_name = symbol; sym_global = (if exported then Global else Local) })
36953694
preallocated_blocks
36963695
in
36973696
let c1 = emit_gc_roots_table ~symbols cont in

0 commit comments

Comments
 (0)