Repository navigation
Record trim analysis patterns in scanner - #2782
Conversation
This allows running the scanner first with warnings disabled, then "replaying" the collected patterns to produce warnings. This will enable running the scanner multiple times for a compiler-generated method.
vitek-karas
left a comment
There was a problem hiding this comment.
Did you measure perf impact? Since we're now running some of the code twice.
It's not necessarily to gate this change, but to have a feeling how bad it's going to be and if we should do something about it.
| if (operation.OpCode == OpCodes.Newobj) | ||
| AddReturnValue (methodParams[1]); |
There was a problem hiding this comment.
This check was the reason why it is not handled by the shared code. I must admit I don't know how common it is, but it's in theory possible to see a call to .ctor I think - without the "new".
In any case, if we are to make this change, I would prefer it in a separate PR.
There was a problem hiding this comment.
Thanks, I didn't really understand why we had this check. I kept it as before, by recording the instruction as part of the call pattern.
| ); | ||
| } | ||
|
|
||
| void RequireDynamicallyAccessedMembers (in DiagnosticContext diagnosticContext, in MultiValue value, ValueWithDynamicallyAccessedMembers targetValue) |
There was a problem hiding this comment.
As a separate PR - we should probably split the class into two:
- One which is the method body scanner - so HandleCall and related - derived from MethodBodyScanner
- Another one which provides all of the other functionality for MarkStep, like ProcessAttributeDataFlow and so on.
It's currently really weird since we have half of the class which always marks and produces diagnostics, and another half which does everything deferred.
There was a problem hiding this comment.
Yeah, I had the same thought - the attribute/generic logic doesn't really have anything to do with scanning the method body.
- Rename some variables - Clean up method parameter order - Remove unnecessary parameters - Inline variable only used once
I measured the wall clock time to link the shared framework on my machine (mean + standard deviation):
So looks like no significant perf impact from this measurement. |
This allows running the scanner first with warnings disabled, then "replaying" the collected patterns to produce warnings. This will enable running the scanner multiple times for a compiler-generated method. It basically works the same as the trim patterns in the analyzer. The main difference is that it also can enable or disable marking - so during the scan, it doesn't do marking or report warnings. Then once the scan is complete, it marks and produces warnings for the recorder call/assignment patterns. The exception is for the DAM type hierarchy logic which will mark and warn during the scan, because it has its own cache that prevents doing any extra work the second time around. This includes a few small changes to pass around DiagnosticContext to a few places that can produce warnings during the scan, such as resolving type names. Commit migrated from dotnet/linker@bb974a6
This allows running the scanner first with warnings disabled, then "replaying" the collected patterns to produce warnings. This will enable running the scanner multiple times for a compiler-generated method.
It basically works the same as the trim patterns in the analyzer. The main difference is that it also can enable
or disable marking - so during the scan, it doesn't do marking or report warnings. Then once the scan is complete,
it marks and produces warnings for the recorder call/assignment patterns. The exception is for the DAM type hierarchy
logic which will mark and warn during the scan, because it has its own cache that prevents doing any extra work the
second time around. (See #2777 (comment) for more context.)
This includes a few small changes to pass around
DiagnosticContextto a few places that can produce warnings during the scan, such as resolving type names.