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

llvm: Switch to trampoline-based jlcall annotations #45088

Merged
merged 1 commit into from
Jun 10, 2022
Merged

Conversation

Keno
Copy link
Member

@Keno Keno commented Apr 25, 2022

As discussed extensively in #45057, when enabling LLVM's opaque pointer
support, we get significant miscompilations in jlcall callsites, because
calls with mismatching calling conventions are considered undefined behavior.
This implements Option D) from #45057, switching our jlcall callsites to use
a julia.call trampoline intrinsic instead. The lowering for this intrinsic
is essentially the same as the CC-based lowering before, except that the
callee is now of course the first argument rather than the actual callee.
Other than that, the changes are mostly mechanical.

Fixes #45057

src/codegen.cpp Outdated
//
// ptr julia.call(ptr %fptr, ptr %f, ptr %arg1, ptr %arg2, ...)
//
// In late lowering the call then be rewritten as
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// In late lowering the call then be rewritten as
// In late lowering the call will be rewritten as

As discussed extensively in #45057, when enabling LLVM's opaque pointer
support, we get significant miscompilations in jlcall callsites, because
calls with mismatching calling conventions are considered undefined behavior.
This implements Option D) from #45057, switching our jlcall callsites to use
a `julia.call` trampoline intrinsic instead. The lowering for this intrinsic
is essentially the same as the CC-based lowering before, except that the
callee is now of course the first argument rather than the actual callee.
Other than that, the changes are mostly mechanical.

Fixes #45057
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

Remove "thunk" now from everywhere?

This LGTM. My only question is whether this will restrict optimizations in the future, since we won't be able to set function attributes on the called function target. But we will change this again later if that ever does become a real issue.

@vtjnash vtjnash merged commit 23f39f8 into master Jun 10, 2022
@vtjnash vtjnash deleted the kf/jlcalllower branch June 10, 2022 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LLVM15 does not like our calling convention scheme
4 participants