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

[CFE] Incremental compilation fails for optimized-away constants #41999

Open
annagrin opened this issue May 20, 2020 · 3 comments
Open

[CFE] Incremental compilation fails for optimized-away constants #41999

annagrin opened this issue May 20, 2020 · 3 comments
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. web-eval evaluation support on the web

Comments

@annagrin
Copy link
Contributor

annagrin commented May 20, 2020

Example

void main() {
  const int p = 1;
  print(p); // breakpoint here
}

Javascript from initial compilation

For main function only, is here to illustrate that kernel representation has variable 'p' optimized away:

main.main = function main$() {
  core.print(1);
};

Result of evaluating ‘p’ at the breakpoint above

CompilationError: Getter not found: 'p'

Suggestions

Is it possible to introduce debug mode in CFE where the information about optimized variables (such as 'p=1') is preserved so the incremental compiler can use it?

@a-siva a-siva added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label May 20, 2020
@annagrin
Copy link
Contributor Author

annagrin commented Jul 10, 2020

Added an example to expression evaluation tests in https://dart-review.googlesource.com/c/sdk/+/153941

@jensjoha @johnniwinther this is a fairly common evaluation problem I see in my examples and in flutter samples, is there a setting to work around removed constants?

@johnniwinther
Copy link
Member

We have a keepFields flag in the constant transformer that lets you preserve constant field declarations. We should add a similar flag for local constant variables. I'll look into it.

@johnniwinther
Copy link
Member

I've add keepLocals support in https://dart-review.googlesource.com/c/sdk/+/153965

@annagrin try making DevCompilerConstantsBackend.keepLocals to return true to see if this fixes this use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. web-eval evaluation support on the web
Projects
None yet
Development

No branches or pull requests

4 participants