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

Parameter attributes on Cfunction closures sticks #41827

Merged

Conversation

troels
Copy link
Contributor

@troels troels commented Aug 8, 2021

When CFunction closures are created an extra parameter is added to the
function signature for holding the closure.

Make sure that the parameter attributes on already existing parameters
are not shifted when adding that parameter.

Fixes #40164

src/codegen.cpp Outdated Show resolved Hide resolved
@vchuravy vchuravy requested a review from vtjnash August 8, 2021 11:32
@troels troels force-pushed the shift-parameter-attributes-when-adding-more branch 2 times, most recently from cae5325 to 4cd54af Compare August 8, 2021 11:42
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.

Seems like this will work. Seems inefficient, but valid.

@JeffBezanson
Copy link
Member

Welcome, and thanks! Great to have this fixed.

@troels troels force-pushed the shift-parameter-attributes-when-adding-more branch from 4cd54af to 983d71c Compare August 10, 2021 00:35
@troels
Copy link
Contributor Author

troels commented Aug 10, 2021

Thanks!

I did a check of the LLVM code of AttributeList and discovered I made a miss in the number of AttributeSets preceding the parameter attributes. I had mistakenly believed that only return value (Index 0) precedes parameters, but apparently function attributes do too (they are at index UNSIGNED_INT_MAX, just preceding 0).

I have done a new push with the correct code, keeping both function attributes and return value attributes in their proper place.

@troels troels force-pushed the shift-parameter-attributes-when-adding-more branch from 983d71c to 71d2916 Compare August 10, 2021 00:44
src/codegen.cpp Outdated Show resolved Hide resolved
@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label Aug 24, 2021
src/codegen.cpp Outdated Show resolved Hide resolved
@troels troels force-pushed the shift-parameter-attributes-when-adding-more branch from 70b600b to 2ef9b36 Compare August 25, 2021 10:23
When CFunction closures are created an extra argument is added to the
function signature for holding the closure.

Make sure that the parameter attributes on already existing parameters
are not shifted when adding that parameter.
@troels troels force-pushed the shift-parameter-attributes-when-adding-more branch from 2ef9b36 to d837255 Compare August 25, 2021 10:24
@KristofferC KristofferC added backport 1.6 Change should be backported to release-1.6 backport 1.7 bugfix This change fixes an existing bug labels Aug 25, 2021
@troels troels force-pushed the shift-parameter-attributes-when-adding-more branch from d837255 to 4adce69 Compare August 25, 2021 11:19
@troels troels force-pushed the shift-parameter-attributes-when-adding-more branch 2 times, most recently from 0d6ed7f to 6c6c948 Compare August 25, 2021 13:16
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.

Still LGTM to merge (and now more efficient!)

src/codegen.cpp Outdated Show resolved Hide resolved
src/codegen.cpp Outdated Show resolved Hide resolved
src/codegen.cpp Outdated Show resolved Hide resolved
@vtjnash
Copy link
Member

vtjnash commented Aug 25, 2021

Looks like this constructor requires dropping !hasAttributes ones (or use the get constructor with separate Fn, Ret, and Params attributes, which permits empty attributes)

@vtjnash vtjnash removed the merge me PR is reviewed. Merge when all tests are passing label Aug 25, 2021
@troels troels force-pushed the shift-parameter-attributes-when-adding-more branch from 6c6c948 to 6cb4806 Compare August 25, 2021 16:39
@troels troels force-pushed the shift-parameter-attributes-when-adding-more branch from 6cb4806 to ffb0e29 Compare August 25, 2021 18:01
@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label Aug 25, 2021
@vtjnash vtjnash merged commit 08f3422 into JuliaLang:master Aug 26, 2021
KristofferC pushed a commit that referenced this pull request Aug 27, 2021
When CFunction closures are created an extra argument is added to the
function signature for holding the closure.

Make sure that the parameter attributes on already existing parameters
are not shifted when adding that parameter.

(cherry picked from commit 08f3422)
KristofferC pushed a commit that referenced this pull request Aug 27, 2021
When CFunction closures are created an extra argument is added to the
function signature for holding the closure.

Make sure that the parameter attributes on already existing parameters
are not shifted when adding that parameter.

(cherry picked from commit 08f3422)
KristofferC pushed a commit that referenced this pull request Aug 31, 2021
When CFunction closures are created an extra argument is added to the
function signature for holding the closure.

Make sure that the parameter attributes on already existing parameters
are not shifted when adding that parameter.

(cherry picked from commit 08f3422)
KristofferC pushed a commit that referenced this pull request Sep 3, 2021
When CFunction closures are created an extra argument is added to the
function signature for holding the closure.

Make sure that the parameter attributes on already existing parameters
are not shifted when adding that parameter.

(cherry picked from commit 08f3422)
@DilumAluthge DilumAluthge removed the merge me PR is reviewed. Merge when all tests are passing label Sep 6, 2021
@KristofferC KristofferC removed backport 1.6 Change should be backported to release-1.6 backport 1.7 labels Sep 7, 2021
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
…#41827)

When CFunction closures are created an extra argument is added to the
function signature for holding the closure.

Make sure that the parameter attributes on already existing parameters
are not shifted when adding that parameter.
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
…#41827)

When CFunction closures are created an extra argument is added to the
function signature for holding the closure.

Make sure that the parameter attributes on already existing parameters
are not shifted when adding that parameter.
@vtjnash vtjnash mentioned this pull request Sep 6, 2022
staticfloat pushed a commit that referenced this pull request Dec 23, 2022
When CFunction closures are created an extra argument is added to the
function signature for holding the closure.

Make sure that the parameter attributes on already existing parameters
are not shifted when adding that parameter.

(cherry picked from commit 08f3422)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segfault in ccall
6 participants