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

checking of constant/writable arguments #178

Merged
merged 1 commit into from
Jun 24, 2022
Merged

checking of constant/writable arguments #178

merged 1 commit into from
Jun 24, 2022

Conversation

bgregoir
Copy link
Contributor

No description provided.

compiler/src/pretyping.ml Outdated Show resolved Hide resolved
@eponier
Copy link
Contributor

eponier commented Jun 22, 2022

This example is artificial, but do we want to accept such things?

fn f (reg ptr u64[1] r) -> reg u64 {
  reg u64 res;
  stack u64[1] s;

  r = s;
  r[0] = 1;
  res = r[0];

  return res;
}

export fn main () -> reg u64 {
  reg u64 res;
  stack u64[1] s;

  s[0] = 1;

  res = f(s);

  return res;
}

vbgl
vbgl previously requested changes Jun 22, 2022
Copy link
Member

@vbgl vbgl left a comment

Choose a reason for hiding this comment

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

This is not ready. The following program is now rejected:

fn zerofill(reg mut ptr u64[1] x) -> reg ptr u64[1] {
  x[0] = 0;
  return x;
}

export
fn main() -> reg u64 {
  stack u64[1] s;
  s = zerofill(s);
  reg u64 r;
  r = s[0];
  return r;
}

@eponier
Copy link
Contributor

eponier commented Jun 22, 2022

With @bgregoir, we are not sure what to do exactly, so let's postpone this a bit.

@vbgl vbgl dismissed their stale review June 22, 2022 15:34

make check works now

@vbgl
Copy link
Member

vbgl commented Jun 22, 2022

IMHO, it is OK to reject the artificial example above.

@bgregoir
Copy link
Contributor Author

I did not see your last commit and I did the same patch.
Anyway I think we try to ensure something that is verified later by the compiler without having all the information.
We can do a variation of zerofill example:

inline fn zerofill(stack u64[1] x) -> stack u64[1] {
x[0] = 0;
return x;
}

export
fn main() -> reg u64 {
stack u64[1] s;
reg const ptr u64[1] t;
t = s;
s = zerofill(t);
reg u64 r;
r = s[0];
return r;
}

compiler/src/pretyping.ml Outdated Show resolved Hide resolved
Fix printing of #inline function calls
@vbgl
Copy link
Member

vbgl commented Jun 24, 2022

Unless someone wants to implement a more precise check, I recommend to merge this PR as is.

@bgregoir
Copy link
Contributor Author

Ok with this.

@bgregoir
Copy link
Contributor Author

Apparently I can't merge it myself.

@eponier
Copy link
Contributor

eponier commented Jun 24, 2022

You have to accept it first (i.e. add a positive review).

Copy link
Contributor

@eponier eponier left a comment

Choose a reason for hiding this comment

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

@bgregoir accepts his own PR

@eponier eponier merged commit 110e0e1 into main Jun 24, 2022
@eponier eponier deleted the writable_arguments branch June 24, 2022 08:38
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.

3 participants