Skip to content

Commit

Permalink
Remove the new node, it's likely not needed.
Browse files Browse the repository at this point in the history
The only case where it might matter is if there's a handle access to a GVM. Then we go through this code:
https://github.com/dotnet/runtime/blob/57ae91cf6fc5672e34705b1a272cf268761d505a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeMethodHandleNode.cs#L60

That will potentially call the `GetDependenciesDueToMethodCodePresence` multiple times on the same method.

But that should not affect static cctors (since they're not GVMs) so the `GetDependenciesDueToMethodCodePresense` should only be called once per static cctor.

And even if it does happen (in the future) all it would cause is potentially generating duplicate warnings, no real functional problems.
  • Loading branch information
vitek-karas committed Mar 31, 2023
1 parent b7b28c7 commit bf53f0d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,6 @@ private void CreateNodeCaches()
return new DynamicDependencyAttributesOnEntityNode(entity);
});

_staticConstructorAnalysisNodes = new NodeCache<MethodDesc, StaticConstructorAnalysisNode>((MethodDesc method) =>
{
return new StaticConstructorAnalysisNode(method);
});

_embeddedTrimmingDescriptors = new NodeCache<EcmaModule, EmbeddedTrimmingDescriptorNode>((module) =>
{
return new EmbeddedTrimmingDescriptorNode(module);
Expand Down Expand Up @@ -732,13 +727,6 @@ public DynamicDependencyAttributesOnEntityNode DynamicDependencyAttributesOnEnti
return _dynamicDependencyAttributesOnEntities.GetOrAdd(entity);
}

private NodeCache<MethodDesc, StaticConstructorAnalysisNode> _staticConstructorAnalysisNodes;

public StaticConstructorAnalysisNode StaticConstructorAnalysis(MethodDesc staticConstructor)
{
return _staticConstructorAnalysisNodes.GetOrAdd(staticConstructor);
}

private NodeCache<EcmaModule, EmbeddedTrimmingDescriptorNode> _embeddedTrimmingDescriptors;

public EmbeddedTrimmingDescriptorNode EmbeddedTrimmingDescriptor(EcmaModule module)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using ILCompiler.Dataflow;
using ILCompiler.DependencyAnalysis;
using ILCompiler.DependencyAnalysisFramework;
using ILCompiler.Logging;
using ILCompiler.Metadata;
using ILLink.Shared;

Expand Down Expand Up @@ -564,7 +565,17 @@ protected override void GetDependenciesDueToMethodCodePresenceInternal(ref Depen
AddDataflowDependency(ref dependencies, factory, methodIL, "Method has annotated parameters");
}

StaticConstructorAnalysisNode.GetDependencies(ref dependencies, factory, method);
if (method.IsStaticConstructor)
{
if (DiagnosticUtilities.TryGetRequiresAttribute(method, DiagnosticUtilities.RequiresUnreferencedCodeAttribute, out _))
Logger.LogWarning(new MessageOrigin(method), DiagnosticId.RequiresUnreferencedCodeOnStaticConstructor, method.GetDisplayName());

if (DiagnosticUtilities.TryGetRequiresAttribute(method, DiagnosticUtilities.RequiresDynamicCodeAttribute, out _))
Logger.LogWarning(new MessageOrigin(method), DiagnosticId.RequiresDynamicCodeOnStaticConstructor, method.GetDisplayName());

if (DiagnosticUtilities.TryGetRequiresAttribute(method, DiagnosticUtilities.RequiresAssemblyFilesAttribute, out _))
Logger.LogWarning(new MessageOrigin(method), DiagnosticId.RequiresAssemblyFilesOnStaticConstructor, method.GetDisplayName());
}
}

if (method.GetTypicalMethodDefinition() is Internal.TypeSystem.Ecma.EcmaMethod ecmaMethod)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@
<Compile Include="Compiler\DependencyAnalysis\ReflectedFieldNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\ReflectedTypeNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\ReflectionInvokeSupportDependencyAlgorithm.cs" />
<Compile Include="Compiler\DependencyAnalysis\StaticConstructorAnalysisNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\StructMarshallingDataNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\Target_ARM64\ARM64TentativeMethodNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\Target_ARM\ARMTentativeMethodNode.cs" />
Expand Down

0 comments on commit bf53f0d

Please sign in to comment.