dotnet / linker

389 stars 126 forks source link

Check variable type in ValidateNoReferencesToReferences instead of dataflow-tracked value and only validate on changes to locals #2983

Closed jtschuster closed 2 years ago

jtschuster commented 2 years ago

With changes in behavior with warn=5, ValidateNoReferenceToReference would sometimes fail if the local variable value was not yet added to the LocalVariableStore. This checks the type of the variable pointed to instead of looking for it's dataflow tracked value in the LocalVariableStore cache.

Also, instead of validating the local variable state on every instruction, we can limit it to places where locals is modified or passed outside of the function.