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

Polymorphic variant with no arguments aren't treated as immediate in record field assignment #7026

vicuna opened this issue Oct 19, 2015 · 2 comments


Copy link

@vicuna vicuna commented Oct 19, 2015

Original bug ID: 7026
Reporter: tianyicui
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2017-02-16T14:18:25Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: x86-64
OS: Linux
Version: 4.02.3
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: middle end (typedtree to clambda)
Monitored by: @diml @hcarty

Bug description

When a record field has a polymorphic variant type with no arguments (like [a | b]), use '<-' to assign it involves an unnecessary caml_modify call.Immediate p

Steps to reproduce

$ cat
type t =
{ mutable field : [ a | b ]

let assign t field =
t.field <- field

$ ocamlopt.opt -S

$ cat test.s
subq $8, %rsp
.cfi_adjust_cfa_offset 8
movq %rax, %rdi
movq %rbx, %rsi
call caml_modify@PLT
movq $1, %rax
addq $8, %rsp
.cfi_adjust_cfa_offset -8
.cfi_adjust_cfa_offset 8

Changing the variant into a non-polymorphic one eliminates this caml_modify.

Copy link

@vicuna vicuna commented Nov 27, 2015

Comment author: @xavierleroy

Work in progress at #288

Copy link

@vicuna vicuna commented Dec 6, 2015

Comment author: @gasche

Fixed by Simon Cruanes in #288.

@vicuna vicuna closed this as completed Feb 16, 2017
@vicuna vicuna added this to the 4.03.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants