-
Notifications
You must be signed in to change notification settings - Fork 245
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
Warnings for uninitialized values #4530
Warnings for uninitialized values #4530
Conversation
a6e2550
to
76c1dcf
Compare
e2a46a8
to
a399f9f
Compare
af0fff0
to
5264ca5
Compare
This PR seems to not handle the case of For this case there are 3 scenarios:
|
@ArielG-NV |
I don't know the answer to this question since the behavior of
|
Possible now that considerations for the extraneous cases have been taken.
38fa750
to
cd39378
Compare
Currently the warning system does not properly handle constructors (this is the reason for the modification in ctor-ordinary-retval-legal.slang). I intend to fix this in another PR since fixing this involves modifying some other files. |
auto users = getConcernableUsers(inst); | ||
|
||
addresses.add(inst); | ||
for (auto user : users) | ||
{ | ||
if (isAliasable(user)) | ||
{ | ||
auto instAddresses = getAliasableInstructions(user); | ||
addresses.addRange(instAddresses); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question:
do we need to allocate a list here- would the following work?
auto users = getConcernableUsers(inst); | |
addresses.add(inst); | |
for (auto user : users) | |
{ | |
if (isAliasable(user)) | |
{ | |
auto instAddresses = getAliasableInstructions(user); | |
addresses.addRange(instAddresses); | |
} | |
} | |
addresses.add(inst); | |
for (auto use = inst->firstUse; use; use = use->nextUse) | |
{ | |
IRInst* user = use->getUser(); | |
// Meta instructions only use the argument type | |
if (isMetaOp(user) || !isAliasable(user)) | |
continue; | |
addresses.addRange(getAliasableInstructions(user)); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that works, thanks for the suggestion.
I was testing and it seems the following code does not warn despite using uninitialized values. Example:
|
@ArielG-NV |
👍Sounds good. Likely worth making an issue with all of the next steps. Otherwise, code looks good to me, I will let Yong review before approval. |
Addresses #3832
Changes:
slang-ir-uninitialized-out-params.*
dictated diagnostics logic for output parameters. Since this has similar behavior to checking usage of uninitialized variables, it has been refactored intoslang-ir-uninitialized-values.*
which handles both.std
functions are meta function which operate on the type of the parameter. However, in doing so, they instantiate an undefined variable of the desired type and then pass that to some compiler intrinsic. These intrinsic have their own op codes so they can be detected and ignored.What this does not implement (could be future PRs):