From 17db5ef4d319d11a842d3bd16ea0f6819cc56bb1 Mon Sep 17 00:00:00 2001 From: Vitek Karas Date: Mon, 11 Jan 2021 04:34:57 -0800 Subject: Only compute if method returns a constant when needed (#1734) This changes how the `RemoveUnreachableBlocksStep` computes if a method returns a constant or not. Previously we would go over all methods and detect those which return constants (and store only those in a dictionary). Then we would proceed with branch removal relying on this dictionary. For a hello world console app this means we ran the detection of constants on almost 50K methods. On the other hand the dictionary stored only about 1.5K records (actually constant methods). With this change the constant detection only runs on methods we need the result for later on. This means the dictionary stores records for all methods asked about (`null` value represents "We checked, and it's not constant"). For the same hello world console app we now run the detection only on ~5K methods (10x less). On the other hand we have records for all (5K -> 3x increase). So this trades CPU for memory. The purpose of this change is not the CPU/memory tradeoff, it's to prepare the constant propagation to make it possible to call it on-demand per-method from `MarkStep` which will be needed once we switch over to the current lazy-loading of assemblies. --- .../UnreachableBlock/BodiesWithSubstitutions.xml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/Mono.Linker.Tests.Cases/UnreachableBlock/BodiesWithSubstitutions.xml') diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/BodiesWithSubstitutions.xml b/test/Mono.Linker.Tests.Cases/UnreachableBlock/BodiesWithSubstitutions.xml index 23fb0d5e9..cad903687 100644 --- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/BodiesWithSubstitutions.xml +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/BodiesWithSubstitutions.xml @@ -3,6 +3,8 @@ + + -- cgit v1.2.3