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

Pragma codegenDecl doesn't work inside iterators #6497

Closed
edubart opened this issue Oct 10, 2017 · 1 comment
Closed

Pragma codegenDecl doesn't work inside iterators #6497

edubart opened this issue Oct 10, 2017 · 1 comment

Comments

@edubart
Copy link
Contributor

edubart commented Oct 10, 2017

I need to use __restrict__ C keyword inside an iterator, but when inside an iterator codegenDecl does not work, test case:

iterator myitems(s : seq[int]): int =
  var data {.codegenDecl: "$# __restrict__ $#".} :ptr int = nil
  yield 1

for i in @[1].myitems:
  discard

This generates the following C code:

		NI* data;
		nimln_(2, "test2.nim");
		data = NIM_NIL;

NI* data should have been NI* __restrict__ data

Any workarounds? I want to use restrict to make GCC optimize my iterator better.

@ringabout
Copy link
Member

The issue is at transformVarSection in transf.nim.

ringabout added a commit to ringabout/Nim that referenced this issue Nov 18, 2020
narimiran pushed a commit that referenced this issue Nov 18, 2020
* fix #6497

* add testcase for #16027

(cherry picked from commit 581bcfe)
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants