[dotnet-linker] Add OptimizeGeneratedCodeSubStep into the pipeline. (#9608)

Fixes these linkall tests:

    Linker.Shared.OptimizeGeneratedCodeTest
        [FAIL] IsARM64CallingConvention :   optimized: no ldsfld instruction
        Expected: 0
        But was:  1
            at Linker.Shared.BaseOptimizeGeneratedCodeTest.IsARM64CallingConvention() in /Users/rolf/work/maccore/main/xamarin-macios/tests/linker/BaseOptimizeGeneratedCodeTest.cs:line 527
    
    [FAIL] SetupBlockPerfTest :   At least 6x speedup
        Expected: greater than 6
        But was:  1.0876440665344851d
            at Linker.Shared.BaseOptimizeGeneratedCodeTest.SetupBlockPerfTest() in /Users/rolf/work/maccore/main/xamarin-macios/tests/linker/BaseOptimizeGeneratedCodeTest.cs:line 120

And linkall is now green for .NET/Debug.
This commit is contained in:
Rolf Bjarne Kvinge 2020-09-10 08:30:45 +02:00 коммит произвёл GitHub
Родитель ae1fe7a53d
Коммит eb5206f082
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 24 добавлений и 3 удалений

Просмотреть файл

@ -395,7 +395,7 @@ namespace Xharness {
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dont link.csproj"))) { Configurations = new string [] { "Debug", "Release" } }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dont link.csproj"))) { Configurations = new string [] { "Debug", "Release" } });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dotnet", "iOS", "dont link.csproj"))) { Configurations = new string [] { "Debug", "Release" }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dotnet", "iOS", "dont link.csproj"))) { Configurations = new string [] { "Debug", "Release" }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link all", "link all.csproj"))) { Configurations = new string [] { "Debug", "Release" } }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link all", "link all.csproj"))) { Configurations = new string [] { "Debug", "Release" } });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link all", "dotnet", "iOS", "link all.csproj"))) { Configurations = new string [] { "Debug", "Release" }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true, Ignore = true }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link all", "dotnet", "iOS", "link all.csproj"))) { Configurations = new string [] { "Debug" /*, "Release" */ }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link sdk", "link sdk.csproj"))) { Configurations = new string [] { "Debug", "Release" } }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link sdk", "link sdk.csproj"))) { Configurations = new string [] { "Debug", "Release" } });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link sdk", "dotnet", "iOS", "link sdk.csproj"))) { Configurations = new string [] { "Debug" /*, "Release" */ }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link sdk", "dotnet", "iOS", "link sdk.csproj"))) { Configurations = new string [] { "Debug" /*, "Release" */ }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true });

Просмотреть файл

@ -707,6 +707,7 @@ namespace Xamarin.Bundler {
public IEnumerable<Abi> Abis { public IEnumerable<Abi> Abis {
get { return abis; } get { return abis; }
set { abis = new List<Abi> (value); }
} }
public bool IsArchEnabled (Abi arch) public bool IsArchEnabled (Abi arch)

Просмотреть файл

@ -1,6 +1,7 @@
// Compat.cs: might not be ideal but it eases code sharing with existing code during the initial implementation. // Compat.cs: might not be ideal but it eases code sharing with existing code during the initial implementation.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Mono.Cecil; using Mono.Cecil;
using Mono.Linker; using Mono.Linker;
@ -160,9 +161,14 @@ namespace Mono.Linker {
{ {
return LinkerConfiguration.GetInstance (context).Assemblies; return LinkerConfiguration.GetInstance (context).Assemblies;
} }
static ConditionalWeakTable<AnnotationStore, Dictionary<string, Dictionary<IMetadataTokenProvider, object>>> custom_annotations = new ConditionalWeakTable<AnnotationStore, Dictionary<string, Dictionary<IMetadataTokenProvider, object>>> ();
public static Dictionary<IMetadataTokenProvider, object> GetCustomAnnotations (this AnnotationStore self, string name) public static Dictionary<IMetadataTokenProvider, object> GetCustomAnnotations (this AnnotationStore self, string name)
{ {
throw new NotImplementedException (); var store = custom_annotations.GetOrCreateValue (self);
if (!store.TryGetValue (name, out var dict))
store [name] = dict = new Dictionary<IMetadataTokenProvider, object> ();
return dict;
} }
} }
} }

Просмотреть файл

@ -208,6 +208,10 @@ namespace Xamarin.Linker {
Application.DeploymentTarget = DeploymentTarget; Application.DeploymentTarget = DeploymentTarget;
Application.SdkVersion = SdkVersion; Application.SdkVersion = SdkVersion;
DerivedLinkContext.Target = Target;
Target.Abis = Abis;
Application.Abis = Abis;
switch (Platform) { switch (Platform) {
case ApplePlatform.iOS: case ApplePlatform.iOS:
case ApplePlatform.TVOS: case ApplePlatform.TVOS:

Просмотреть файл

@ -55,6 +55,7 @@ namespace Xamarin {
// [assembly: LinkSafe] attributes, which means we treat them as sdk assemblies and those may have // [assembly: LinkSafe] attributes, which means we treat them as sdk assemblies and those may have
// Preserve attributes. // Preserve attributes.
prelink_substeps.Add (new ApplyPreserveAttribute ()); prelink_substeps.Add (new ApplyPreserveAttribute ());
prelink_substeps.Add (new OptimizeGeneratedCodeSubStep ());
prelink_substeps.Add (new MarkNSObjects ()); prelink_substeps.Add (new MarkNSObjects ());
prelink_substeps.Add (new PreserveSmartEnumConversionsSubStep ()); prelink_substeps.Add (new PreserveSmartEnumConversionsSubStep ());
} }

Просмотреть файл

@ -101,6 +101,9 @@
<Compile Include="..\linker\CustomSymbolWriter.cs"> <Compile Include="..\linker\CustomSymbolWriter.cs">
<Link>external\tools\linker\CustomSymbolWriter.cs</Link> <Link>external\tools\linker\CustomSymbolWriter.cs</Link>
</Compile> </Compile>
<Compile Include="..\linker\CoreOptimizeGeneratedCode.cs">
<Link>external\tools\linker\CoreOptimizeGeneratedCode.cs</Link>
</Compile>
<Compile Include="..\..\src\ObjCRuntime\Registrar.cs"> <Compile Include="..\..\src\ObjCRuntime\Registrar.cs">
<Link>external\src\ObjCRuntime\Registrar.cs</Link> <Link>external\src\ObjCRuntime\Registrar.cs</Link>
</Compile> </Compile>
@ -164,6 +167,12 @@
<Compile Include="..\..\builds\mono-ios-sdk-destdir\ios-sources\external\linker\src\linker\Linker\I18nAssemblies.cs"> <Compile Include="..\..\builds\mono-ios-sdk-destdir\ios-sources\external\linker\src\linker\Linker\I18nAssemblies.cs">
<Link>external\mono-archive\Linker\I18nAssemblies.cs</Link> <Link>external\mono-archive\Linker\I18nAssemblies.cs</Link>
</Compile> </Compile>
<Compile Include="..\..\builds\mono-ios-sdk-destdir\ios-sources\external\linker\src\linker\Linker\MethodDefinitionExtensions.cs">
<Link>mono-archive\Linker\MethodDefinitionExtensions.cs</Link>
</Compile>
<Compile Include="..\..\builds\mono-ios-sdk-destdir\ios-sources\external\linker\src\linker\Linker\TypeReferenceExtensions.cs">
<Link>mono-archive\Linker\Linker\TypeReferenceExtensions.cs</Link>
</Compile>
<Compile Include="..\..\builds\mono-ios-sdk-destdir\ios-sources\external\linker\src\tuner\Mono.Tuner\CecilRocks.cs"> <Compile Include="..\..\builds\mono-ios-sdk-destdir\ios-sources\external\linker\src\tuner\Mono.Tuner\CecilRocks.cs">
<Link>external\mono-archive\Mono.Tuner\CecilRocks.cs</Link> <Link>external\mono-archive\Mono.Tuner\CecilRocks.cs</Link>
</Compile> </Compile>

Просмотреть файл

@ -573,7 +573,7 @@ namespace Xamarin.Linker {
} }
} }
} }
#if TRACE #if false
Console.WriteLine ($"{caller.FullName}:"); Console.WriteLine ($"{caller.FullName}:");
for (int i = 0; i < reachable.Length; i++) { for (int i = 0; i < reachable.Length; i++) {
Console.WriteLine ($"{(reachable [i] ? " " : "- ")} {instructions [i]}"); Console.WriteLine ($"{(reachable [i] ? " " : "- ")} {instructions [i]}");