Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions Cpp2IL.Core/ProcessingLayers/CallAnalysisProcessingLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,28 @@ private static void InjectAttribute(ApplicationAnalysisContext appContext)
AttributeInjectionUtils.AddZeroParameterAttribute(m, deduplicatedMethodConstructor);
}

m.Analyze();
var convertedIsil = appContext.InstructionSet.GetIsilFromMethod(m);

if (m.ConvertedIsil is { Count: 0 })
if (convertedIsil is { Count: 0 })
{
if ((m.MethodAttributes & MethodAttributes.Abstract) == 0)
{
AttributeInjectionUtils.AddZeroParameterAttribute(m, analysisNotSupportedConstructor);
}
m.ReleaseAnalysisData();
continue;
}

if (m.ConvertedIsil.Any(i => i.OpCode == InstructionSetIndependentOpCode.Invalid))
if (convertedIsil.Any(i => i.OpCode == InstructionSetIndependentOpCode.Invalid))
{
AttributeInjectionUtils.AddZeroParameterAttribute(m, invalidInstructionsConstructor);
}

if (m.ConvertedIsil.Any(i => i.OpCode == InstructionSetIndependentOpCode.NotImplemented))
if (convertedIsil.Any(i => i.OpCode == InstructionSetIndependentOpCode.NotImplemented))
{
AttributeInjectionUtils.AddZeroParameterAttribute(m, unimplementedInstructionsConstructor);
}

foreach (var instruction in m.ConvertedIsil)
foreach (var instruction in convertedIsil)
{
if (instruction.OpCode != InstructionSetIndependentOpCode.Call && instruction.OpCode != InstructionSetIndependentOpCode.CallNoReturn)
{
Expand Down Expand Up @@ -126,8 +125,6 @@ private static void InjectAttribute(ApplicationAnalysisContext appContext)
unknownCalls[m] = unknownCalls.GetOrDefault(m, 0) + 1;
}
}

m.ReleaseAnalysisData();
}

if(Cpp2IlApi.LowMemoryMode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@ private static void AnalyzeMethod(ApplicationAnalysisContext appContext, MethodA
if (m.UnderlyingPointer == 0)
return;

m.Analyze();
var convertedIsil = appContext.InstructionSet.GetIsilFromMethod(m);

if (m.ConvertedIsil is { Count: 0 })
if (convertedIsil is { Count: 0 })
{
m.ReleaseAnalysisData();
return;
}

foreach (var instruction in m.ConvertedIsil)
foreach (var instruction in convertedIsil)
{
if (instruction.OpCode == InstructionSetIndependentOpCode.Call)
{
Expand All @@ -80,8 +79,6 @@ private static void AnalyzeMethod(ApplicationAnalysisContext appContext, MethodA
}
}
}

m.ReleaseAnalysisData();
}

private static bool TryGetAddressFromInstruction(InstructionSetIndependentInstruction instruction, out ulong address)
Expand Down