Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen causes ilverify errors - Callvirt on a value type method. #18140

Open
KevinRansom opened this issue Dec 13, 2024 · 1 comment
Open

Codegen causes ilverify errors - Callvirt on a value type method. #18140

KevinRansom opened this issue Dec 13, 2024 · 1 comment
Labels
Area-Compiler-CodeGen IlxGen, ilwrite and things at the backend Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone

Comments

@KevinRansom
Copy link
Member

The ilverifier baseline file has exemptions for :

[IL]: Error [CallVirtOnValueType]: : FSharp.Compiler.Text.RangeModule+comparer@548::System.Collections.Generic.IEquality
Comparer<FSharp.Compiler.Text.Range>.GetHashCode([FSharp.Compiler.Service]FSharp.Compiler.Text.Range)][offset
0x00000002] Callvirt on a value type method.
[IL]: Error [CallVirtOnValueType]: : FSharp.Compiler.Text.RangeModule+comparer@546::System.Collections.Generic.IEquality
Comparer<FSharp.Compiler.Text.Range>.GetHashCode([FSharp.Compiler.Service]FSharp.Compiler.Text.Range)][offset
0x00000002] Callvirt on a value type method.

We should modify our codegen to produce as few errors as possible when running

@vzarytovskii
Copy link
Member

vzarytovskii commented Dec 16, 2024

Famous last words - this one should be a really easy fix, we have one (?) place when we decide call vs callvirt, it should be a matter of adding another check (if it's the method of obj called on the valuetype).

Should also consider the following suggestion from the docs:

When calling methods of System.Object on value types, consider using the constrained prefix with the callvirt instruction. This removes the need to emit different IL depending on whether or not the value type overrides the method, avoiding a potential versioning problem. Consider using the constrained prefix when invoking interface methods on value types, since the value type method implementing the interface method can be changed using a MethodImpl. These issues are described in more detail in the Constrained opcode.

@0101 0101 added Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. Area-Compiler-CodeGen IlxGen, ilwrite and things at the backend and removed Needs-Triage labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compiler-CodeGen IlxGen, ilwrite and things at the backend Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Projects
Status: New
Development

No branches or pull requests

3 participants