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
ocamlopt -g misses optimizations #5313
Comments
Comment author: meyer This is not longer happening on trunk with r11307: $ ../../bin/ocamlopt -g -dlambda -c opt.ml: |
Comment author: meyer I suspect it was fixed on trunk with #5205 @ r11085.. Could you confirm it's been fixed with the current trunk? |
Comment author: @ygrek Yes, this exact use case is fixed, thanks! But I am not sure that using -g will not prevent other optimizations cause looking at the code it seems that some optimization passes take -g option into the consideration. Actually, initially I wanted to clarify the meaning of -g and this specific example was the easiest to spot. So is it expected for -g to influence the generated code? |
Comment author: meyer Reopening, as one place in the code needs better handling of -g flag |
Original bug ID: 5313
Reporter: @ygrek
Assigned to: meyer
Status: closed (set by @xavierleroy on 2012-09-25T18:07:21Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 3.12.0
Fixed in version: 3.13.0+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #5426
Monitored by: @gasche tgazagna "Dmitry Grebeniuk" thelema @jberdine @Chris00 gerd
Bug description
$ cat opt.ml
let x = ref 0 in
for i = 1 to 10 do
x := !x + i
done
$ /opt/ocaml-3.12.1/bin/ocamlopt -dlambda -c opt.ml
(seq (let (x/1030 0) (for i/1031 1 to 10 (assign x/1030 (+ x/1030 i/1031))))
0a)
$ /opt/ocaml-3.12.1/bin/ocamlopt -g -dlambda -c opt.ml
(seq
(let (x/1030 (makemutable 0 0))
(before 17-54
(for i/1031 1 to 10
(before 38-49 (setfield_imm 0 x/1030 (+ (field 0 x/1030) i/1031))))))
0a)
When using -g int ref is allocated on the heap. This is rather surprising - I expected -g to only add debugging symbols and not prevent optimizations.
The text was updated successfully, but these errors were encountered: