Skip to content

Detect labels as values C extension to enable threaded code interpretation#13239

Merged
nojb merged 1 commit intoocaml:trunkfrom
MisterDA:clang-cl-computed-gotos
Jun 17, 2024
Merged

Detect labels as values C extension to enable threaded code interpretation#13239
nojb merged 1 commit intoocaml:trunkfrom
MisterDA:clang-cl-computed-gotos

Conversation

@MisterDA
Copy link
Copy Markdown
Contributor

@MisterDA MisterDA commented Jun 14, 2024

LLVM and thus clang-cl have had support for labels as values (also called computed gotos) since 2.6~2.7 (released around 2010). All LLVM-based compilers thus support this extension too. Add a test in the configure script for this extension.

This makes ocamlc build with clang-cl blazingly faster! In GitHub Actions, I see that OCaml build time is cut by 1 to 2 minutes, and the full testsuite execution time by 3 to 4 minutes.

It could be possible to achieve similar gains with MSVC using inline assembly gotos.

@nojb
Copy link
Copy Markdown
Contributor

nojb commented Jun 14, 2024

Very nice!

It could be possible to achieve similar gains with MSVC using inline assembly gotos.

I thought inline assembly was not supported for x64; is that not the case?

@MisterDA MisterDA force-pushed the clang-cl-computed-gotos branch from d220d53 to b734e36 Compare June 14, 2024 19:42
@MisterDA
Copy link
Copy Markdown
Contributor Author

I've just force-pushed a little documentation update.

It could be possible to achieve similar gains with MSVC using inline assembly gotos.

I thought inline assembly was not supported for x64; is that not the case?

I spoke too fast, you're right. It's only supported for x86. Since we're not supporting native compilation on x86, this could be a win for OCaml on MSVC 32 bits, but it's tricky and I'd rather leave that for another hacking spree. I'm also reading that using inline assembly in a function disables the optimizer on that function. I see no other escape hatch for MSVC.

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nojb
Copy link
Copy Markdown
Contributor

nojb commented Jun 17, 2024

I'm ready to merge this on @dustanddreams's behalf. @MisterDA can you update the Changes entry? Thanks!

LLVM and thus clang-cl have had support for labels as values (also
called computed gotos) since 2.6~2.7 (released around 2010).  All
LLVM-based compilers thus support this extension too. Add a test in
the configure script for this extension.

This makes ocamlc blazingly faster.

https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
@MisterDA MisterDA force-pushed the clang-cl-computed-gotos branch from b734e36 to 193b410 Compare June 17, 2024 08:14
@MisterDA
Copy link
Copy Markdown
Contributor Author

I'm ready to merge this on @dustanddreams's behalf. @MisterDA can you update the Changes entry? Thanks!

Done!

Copy link
Copy Markdown
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (on behalf of @dustanddreams)

@nojb nojb added the merge-me label Jun 17, 2024
@nojb nojb merged commit 4cf0c57 into ocaml:trunk Jun 17, 2024
@MisterDA MisterDA deleted the clang-cl-computed-gotos branch June 17, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants