dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.06k stars 4.69k forks source link

Mono LLVMAOT fails for Sse2_r and Sse2_ro with Invalid Record #102037

Open tannergooding opened 4 months ago

tannergooding commented 4 months ago

As per the title the Sse2_r and Sse2_ro hardware intrinsics projects fail compiling with errors similar to the following:

 /__w/1/s/artifacts/bin/mono/linux.x64.Release/opt: mono_aot_dFNFkp/temp.bc: error: Invalid record (Producer: 'LLVM16.0.5' Reader: 'LLVM 16.0.5')
  AOT of image /__w/1/s/artifacts/tests/coreclr/linux.x64.Release/JIT/HardwareIntrinsics/HardwareIntrinsics_X86_r/X86_Sse2_r.dll failed.
  Mono Ahead of Time compiler - compiling assembly /__w/1/s/artifacts/tests/coreclr/linux.x64.Release/JIT/HardwareIntrinsics/HardwareIntrinsics_X86_r/X86_Sse2_r.dll

This was found in https://github.com/dotnet/runtime/pull/101886 after extending various tests to include new coverage in the form of the following (that is, the same as the existing RuneBasicScenario but using Vector.Create and Vector.ConditionalSelect as part of the scenario to ensure that embedded broadcasts and embedded masking could be validated.

public void RunBroadcastScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBroadcastScenario));

            var result = {Isa}.{Method}(
                Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr),
                {Op2VectorType}.Create<{Op2BaseType}>(Unsafe.Read<{Op2BaseType}>(_dataTable.inArray2Ptr))
            );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr, isBroadcast: true);
        }

        public void RunMaskingValueScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunMaskingValueScenario));

            var op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr);

            var result = {RetVectorType}.ConditionalSelect(
                {RetVectorType}.Equals<{RetBaseType}>(op1.As{RetBaseType}(), {RetVectorType}<{RetBaseType}>.Zero),
                {Isa}.{Method}(
                    op1,
                    Unsafe.Read<{Op2VectorType}<{Op2BaseType}>>(_dataTable.inArray2Ptr)
                ),
                {RetVectorType}.Create<{RetBaseType}>(1)
            );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr, mask: 1);
        }

        public void RunMaskingZeroScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunMaskingZeroScenario));

            var op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr);

            var result = {RetVectorType}.ConditionalSelect(
                {RetVectorType}.Equals<{RetBaseType}>(op1.As{RetBaseType}(), {RetVectorType}<{RetBaseType}>.Zero),
                {Isa}.{Method}(
                    op1,
                    Unsafe.Read<{Op2VectorType}<{Op2BaseType}>>(_dataTable.inArray2Ptr)
                ),
                {RetVectorType}<{RetBaseType}>.Zero
            );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr, mask: 0);
        }

        public void RunBroadcastAndMaskingScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBroadcastAndMaskingScenario));

            var op1 = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr);

            var result = {RetVectorType}.ConditionalSelect(
                {RetVectorType}.Equals<{RetBaseType}>(op1.As{RetBaseType}(), {RetVectorType}<{RetBaseType}>.Zero),
                {Isa}.{Method}(
                    op1,
                    {Op2VectorType}.Create<{Op2BaseType}>(Unsafe.Read<{Op2BaseType}>(_dataTable.inArray2Ptr))
                ),
                {RetVectorType}<{RetBaseType}>.Zero
            );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr, isBroadcast: true, mask: 0);
        }
dotnet-policy-service[bot] commented 4 months ago

Tagging subscribers to this area: @lambdageek, @steveisok See info in area-owners.md if you want to be subscribed.

steveisok commented 4 months ago

/cc @fanyang-mono