Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of range jumps on PowerPC Linux #3117

Closed
vicuna opened this issue Jan 2, 2002 · 1 comment
Closed

Out of range jumps on PowerPC Linux #3117

vicuna opened this issue Jan 2, 2002 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Jan 2, 2002

Original bug ID: 770
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Related to: #7667

Bug description

Full_Name: Mark Brown
Version: 3.04
OS: Debian GNU/Linux unstable
Submission from: 62.31.64.2 (62.31.64.2)

ocaml currently fails to build on PowerPC. The failing portion of
output is:

make[3]: Entering directory `/tmp/ocaml/ocaml-3.04/camlp4/meta'
../../boot/ocamlrun ../boot/camlp4r -nolib -I ../boot pa_extend.cmo
q_MLast.cmo -o pa_r.ppo pa_r.ml
../../boot/ocamlrun ../../ocamlopt -I ../../stdlib -I ../camlp4 -I
../boot -I ../../utils -c -impl pa_r.ppo
/tmp/camlasm0.s: Assembler messages:
/tmp/camlasm0.s:26869: Error: operand out of range (54196 not between
-32768 and 32767)
/tmp/camlasm0.s:27246: Error: operand out of range (52688 not between
-32768 and 32767)

and so on. Looking at the assembler output the failures appear to be
branch instructions attempting to call into what looks like a garbage
collector:

| .L1145: bltl .L1144

...

| .L1144:
| b caml_call_gc
| .section ".text"
| .globl Pa_r_code_end
| .type Pa_r_code_end, @object

Grovelling around in asmcomp/power it appears that the only place where
a bltl is emitted is:

| | Lop(Ialloc n) ->
| if !call_gc_label = 0 then call_gc_label := new_label();
| addi {emit_gpr 31}, {emit_gpr 31}, {emit_int(-n)}\n;
| cmplw {emit_gpr 31}, {emit_gpr 30}\n;
| addi {emit_reg i.res.(0)}, {emit_gpr 31}, 4\n;
| record_frame i.live;
| bltl {emit_label !call_gc_label}\n

The compiler either needs to be smarter about how it branches into the
GC routine (perhaps inserting the hooks at a higher level) or it needs
to assume that call_gc_label will be out of the range of a conditional jump.
This patch (hopefully) takes the latter approach:

--- ocaml-3.04/asmcomp/power/emit.mlp.orig Tue Jan 1 19:40:55 2002
+++ ocaml-3.04/asmcomp/power/emit.mlp Tue Jan 1 19:40:19 2002
@@ -545,12 +545,15 @@
| _ -> "stw" in
emit_load_store storeinstr addr i.arg 1 i.arg.(0)
| Lop(Ialloc n) ->

  •   let skip_label = new_label() in
       if !call_gc_label = 0 then call_gc_label := new_label();
       `      addi    {emit_gpr 31}, {emit_gpr 31}, {emit_int(-n)}\n`;
       `      cmplw   {emit_gpr 31}, {emit_gpr 30}\n`;
       `      addi    {emit_reg i.res.(0)}, {emit_gpr 31}, 4\n`;
    
  •   `       bgt     {emit_label skip_label}\n`;
       record_frame i.live;
    
  •    `      bltl    {emit_label !call_gc_label}\n`
    
  •    `      bl      {emit_label !call_gc_label}\n`;
    
  •   `{emit_label skip_label}:\n`;
    
    | Lop(Iintop Isub) -> (* subf has swapped arguments )
    (
    Use subfc instead of subf for RS6000 compatibility. *)
    subfc {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i. arg.(0)}\n
@vicuna
Copy link
Author

vicuna commented Jan 4, 2002

Comment author: administrator

Same bug as #3086

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant