Fix ocamlopt on sparc
authorStephane Glondu <steph@glondu.net>
Fri, 8 Nov 2013 15:42:19 +0000 (16:42 +0100)
committerStéphane Glondu <glondu@debian.org>
Thu, 30 Oct 2014 08:28:06 +0000 (08:28 +0000)
Bug: http://caml.inria.fr/mantis/view.php?id=6227

Gbp-Pq: Name 0012-Fix-ocamlopt-on-sparc.patch

asmcomp/interf.ml
asmcomp/sparc/emit.mlp

index 77acb78a40dee179ccd1441c3aad9c73fc4b98cf..eab8a96137ab9a7a79cf3a1fc34caabe4013b87f 100644 (file)
@@ -115,13 +115,17 @@ let build_graph fundecl =
 
   (* Add a preference from one reg to another.
      Do not add anything if the two registers conflict,
-     or if the source register already has a location. *)
+     or if the source register already has a location,
+     or if the two registers belong to different classes.
+     (The last case can occur e.g. on Sparc when passing
+      float arguments in integer registers, PR#6227.) *)
 
   let add_pref weight r1 r2 =
     if weight > 0 then begin
       let i = r1.stamp and j = r2.stamp in
       if i <> j
       && r1.loc = Unknown
+      && Proc.register_class r1 = Proc.register_class r2
       && (let p = if i < j then (i, j) else (j, i) in
           not (IntPairSet.mem p !mat))
       then r1.prefer <- (r2, weight) :: r1.prefer
index b8387cd7bdfbdca08d1af45698f2bfad3035fafa..258b2ca15f8025708222d062dea72850f2e733c0 100644 (file)
@@ -64,7 +64,7 @@ let symbol_prefix =
   if Config.system = "sunos" then "_" else ""
 
 let emit_symbol s =
-  if String.length s >= 1 & s.[0] = '.'
+  if String.length s >= 1 && s.[0] = '.'
   then emit_string s
   else begin emit_string symbol_prefix; Emitaux.emit_symbol '$' s end
 
@@ -629,8 +629,8 @@ let is_one_instr i =
           i.arg.(0).typ <> Float && i.res.(0).typ <> Float
       | Iconst_int n -> is_native_immediate n
       | Istackoffset _ -> true
-      | Iload(_, Iindexed n) -> i.res.(0).typ <> Float & is_immediate n
-      | Istore(_, Iindexed n) -> i.arg.(0).typ <> Float & is_immediate n
+      | Iload(_, Iindexed n) -> i.res.(0).typ <> Float && is_immediate n
+      | Istore(_, Iindexed n) -> i.arg.(0).typ <> Float && is_immediate n
       | Iintop(op) -> is_one_instr_op op
       | Iintop_imm(op, _) -> is_one_instr_op op
       | Iaddf | Isubf | Imulf | Idivf -> true
@@ -660,15 +660,15 @@ let rec emit_all i =
       emit_instr i.next (Some i);
       emit_all i.next.next
   | {next = {desc = Lop(Itailcall_imm s)}}
-    when s = !function_name & is_one_instr i ->
+    when s = !function_name && is_one_instr i ->
       emit_instr i.next (Some i);
       emit_all i.next.next
   | {next = {desc = Lop(Icall_ind)}}
-    when is_one_instr i & no_interference i.res i.next.arg ->
+    when is_one_instr i && no_interference i.res i.next.arg ->
       emit_instr i.next (Some i);
       emit_all i.next.next
   | {next = {desc = Lcondbranch(_, _)}}
-    when is_one_instr i & no_interference i.res i.next.arg ->
+    when is_one_instr i && no_interference i.res i.next.arg ->
       emit_instr i.next (Some i);
       emit_all i.next.next
   | _ ->