WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 193487
193437
[WHLSL] Implement the return checker and the unreachable code checker
https://bugs.webkit.org/show_bug.cgi?id=193437
Summary
[WHLSL] Implement the return checker and the unreachable code checker
Myles C. Maxfield
Reported
2019-01-14 23:35:09 PST
[WHLSL] Implement the return checker
Attachments
Patch
(17.29 KB, patch)
2019-01-14 23:36 PST
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch
(24.12 KB, patch)
2019-01-14 23:54 PST
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Myles C. Maxfield
Comment 1
2019-01-14 23:36:11 PST
Created
attachment 359140
[details]
Patch
Myles C. Maxfield
Comment 2
2019-01-14 23:54:50 PST
Created
attachment 359142
[details]
Patch
Robin Morisset
Comment 3
2019-01-15 10:29:47 PST
Comment on
attachment 359142
[details]
Patch Why do we want this pass? There is nothing in the spec about requiring functions to return, and it is undecidable in general. And indeed isBoolCastFromTrue treats true differently from 2+2==4. I am strongly opposed to keeping this pass, especially as I don't think it buys us anything (is there a difference for us between a function that never terminates and one that returns in a trillion years?) The unreachable code checker is less unreasonable, but because of its design does not match at all what the spec says (for example it correctly catches {return 42; do_stuff();}, but it misses {break; do_stuff();}. Please also skip this pass for now, it is not necessary to having a testable compiler, and I will try to hack something based on the spec in its stead.
Myles C. Maxfield
Comment 4
2019-01-15 11:08:47 PST
(In reply to Robin Morisset from
comment #3
)
> Comment on
attachment 359142
[details]
> Patch > > Why do we want this pass? > There is nothing in the spec about requiring functions to return, and it is > undecidable in general. And indeed isBoolCastFromTrue treats true > differently from 2+2==4. > I am strongly opposed to keeping this pass, especially as I don't think it > buys us anything (is there a difference for us between a function that never > terminates and one that returns in a trillion years?) > > The unreachable code checker is less unreasonable, but because of its design > does not match at all what the spec says (for example it correctly catches > {return 42; do_stuff();}, but it misses {break; do_stuff();}. > Please also skip this pass for now, it is not necessary to having a testable > compiler, and I will try to hack something based on the spec in its stead.
A function that is supposed to return an int but has no return statements would break the type system, wouldn’t it?
Robin Morisset
Comment 5
2019-01-15 11:32:00 PST
(In reply to Myles C. Maxfield from
comment #4
)
> (In reply to Robin Morisset from
comment #3
) > > Comment on
attachment 359142
[details]
> > Patch > > > > Why do we want this pass? > > There is nothing in the spec about requiring functions to return, and it is > > undecidable in general. And indeed isBoolCastFromTrue treats true > > differently from 2+2==4. > > I am strongly opposed to keeping this pass, especially as I don't think it > > buys us anything (is there a difference for us between a function that never > > terminates and one that returns in a trillion years?) > > > > The unreachable code checker is less unreasonable, but because of its design > > does not match at all what the spec says (for example it correctly catches > > {return 42; do_stuff();}, but it misses {break; do_stuff();}. > > Please also skip this pass for now, it is not necessary to having a testable > > compiler, and I will try to hack something based on the spec in its stead. > > A function that is supposed to return an int but has no return statements > would break the type system, wouldn’t it?
More precisely: A non-void function that can reach the last statement of its body without hitting a return statement of the right type would break the type system. Same for a function hitting a return statement of the wrong type. A function that loops forever on the other hand is perfectly safe (in our type system), even if we claim it returns int. This pass is not testing the type of returns (I guess it is verified in some part of the type checker I have not yet reviewed), and it tries to verify a lot more than just "no reaching the end of the function body without having returned", including preventing (some) infinite loops. I won't prevent you from landing it if you really need it to get the compiler running, but I am uncomfortable with having these useless checks that do not match anything in the spec.
Myles C. Maxfield
Comment 6
2019-01-16 02:44:50 PST
*** This bug has been marked as a duplicate of
bug 193487
***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug