[Hide Content]diff --git a/asmcomp/comballoc.ml b/asmcomp/comballoc.ml
index 13dbcaf..a22d7df 100644
--- a/asmcomp/comballoc.ml
+++ b/asmcomp/comballoc.ml
@@ -12,7 +12,7 @@
(* $Id$ *)
-(* Combine heap allocations occurring in the same basic block *)
+(* Combine heap allocations and symbols occurring in the same basic block *)
open Mach
@@ -27,7 +27,7 @@ let allocated_size = function
No_alloc -> 0
| Pending_alloc(reg, ofs) -> ofs
-let rec combine i allocstate =
+let rec combine i allocstate symbols =
match i.desc with
Iend | Ireturn | Iexit _ | Iraise ->
(i, allocated_size allocstate)
@@ -35,17 +35,17 @@ let rec combine i allocstate =
begin match allocstate with
No_alloc ->
let (newnext, newsz) =
- combine i.next (Pending_alloc(i.res.(0), sz)) in
+ combine i.next (Pending_alloc(i.res.(0), sz)) [] in
(instr_cons (Iop(Ialloc newsz)) i.arg i.res newnext, 0)
| Pending_alloc(reg, ofs) ->
if ofs + sz < Config.max_young_wosize * Arch.size_addr then begin
let (newnext, newsz) =
- combine i.next (Pending_alloc(reg, ofs + sz)) in
+ combine i.next (Pending_alloc(reg, ofs + sz)) symbols in
(instr_cons (Iop(Iintop_imm(Iadd, ofs))) [| reg |] i.res newnext,
newsz)
end else begin
let (newnext, newsz) =
- combine i.next (Pending_alloc(i.res.(0), sz)) in
+ combine i.next (Pending_alloc(i.res.(0), sz)) [] in
(instr_cons (Iop(Ialloc newsz)) i.arg i.res newnext, ofs)
end
end
@@ -54,8 +54,19 @@ let rec combine i allocstate =
let newnext = combine_restart i.next in
(instr_cons_debug i.desc i.arg i.res i.dbg newnext,
allocated_size allocstate)
+ | Iop(Iconst_symbol s) ->
+ begin try
+ let reg = List.assoc s symbols in
+ let (newnext, sz) = combine i.next allocstate symbols in
+ (instr_cons (Iop(Imove)) [| reg |] i.res newnext, sz)
+ with
+ Not_found ->
+ let newsymbols = (s, i.res.(0)) :: symbols in
+ let (newnext, sz) = combine i.next allocstate newsymbols in
+ (instr_cons_debug i.desc i.arg i.res i.dbg newnext, sz)
+ end
| Iop op ->
- let (newnext, sz) = combine i.next allocstate in
+ let (newnext, sz) = combine i.next allocstate symbols in
(instr_cons_debug i.desc i.arg i.res i.dbg newnext, sz)
| Iifthenelse(test, ifso, ifnot) ->
let newifso = combine_restart ifso in
@@ -73,18 +84,18 @@ let rec combine i allocstate =
(instr_cons (Iloop(newbody)) i.arg i.res i.next,
allocated_size allocstate)
| Icatch(io, body, handler) ->
- let (newbody, sz) = combine body allocstate in
+ let (newbody, sz) = combine body allocstate symbols in
let newhandler = combine_restart handler in
let newnext = combine_restart i.next in
(instr_cons (Icatch(io, newbody, newhandler)) i.arg i.res newnext, sz)
| Itrywith(body, handler) ->
- let (newbody, sz) = combine body allocstate in
+ let (newbody, sz) = combine body allocstate symbols in
let newhandler = combine_restart handler in
let newnext = combine_restart i.next in
(instr_cons (Itrywith(newbody, newhandler)) i.arg i.res newnext, sz)
and combine_restart i =
- let (newi, _) = combine i No_alloc in newi
+ let (newi, _) = combine i No_alloc [] in newi
let fundecl f =
{f with fun_body = combine_restart f.fun_body}
diff --git a/asmcomp/comballoc.mli b/asmcomp/comballoc.mli
index 329e927..77ffcf6 100644
--- a/asmcomp/comballoc.mli
+++ b/asmcomp/comballoc.mli
@@ -12,6 +12,6 @@
(* $Id$ *)
-(* Combine heap allocations occurring in the same basic block *)
+(* Combine heap allocations and symbols occurring in the same basic block *)
val fundecl: Mach.fundecl -> Mach.fundecl