-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
RyuJIT: dangling instructions after converting modulus to bitwise AND #4353
RyuJIT: dangling instructions after converting modulus to bitwise AND #4353
Comments
That's due to the codegen for That said, it is somewhat peculiar that this optimization is done during codegen. For codegen to be able to use |
@omariom, aside; can you please tell me how are you generating assembly code from coreclr? I built the coreclr solution and compiled my C# code and ran the compiled application with corerun.exe (all with command line interface), but couldn't figure out how to emit the asm code.. Do i need to install some other tool or is there a command-line way of doing it with the tools generated by coreclr solution? |
@jasonwilliams200OK Set COMPLUS_JitDisasm environment variable to name of the method you want to disasm. |
Thanks @omariom, I wanted to disasm Main method so I did |
@jasonwilliams200OK The disassembly should be displayed to the console. Make sure you run a debug build of coreclr, release builds do not have this feature. |
Thanks @mikedn ! It worked :) For future reference, assuming the method to disassemble is ::: Build CoreCLR (Debug) :::
git clone https://github.com/dotnet/coreclr
cd coreclr
\build.cmd :: takes quite some time!
::: /Build CoreCLR :::
SET COMPLUS_JitDisasm=MyMethod :: this is if you are in cmd
:: for powershell set env var as (notice the quotes):
:: $env:COMPLUS_JitDisasm = 'MyMethod'
cd bin\Product\Windows_NT.x64.Debug
notepad someApp.cs
:: write hello world console code in there and add a method called MyMethod
:: save and close notepad
.\csc someApp.cs
.\corerun someApp.exe
:: will spit out the disassembly for MyMethod in console, which can be piped to the file:
:: .\corerun someApp.exe > c:\temp\MyMethod.disasm.txt More info at ryujit-overview.md#dumps-and-other-tools and clr-configuration-knobs.md. @agocke, you once asked similar question on gitter. Is this what you were looking for? |
Indeed, fixing the codegen doesn't help in other cases: using System.Runtime.CompilerServices;
class Program {
[MethodImpl(MethodImplOptions.NoInlining)]
public static uint Test(uint x, uint y) {
return y + (x % 4);
}
static int Main(string[] args) {
return (int)Test((uint)args.Length, (uint)args.Length);
}
} produces
instead of
|
Reopen since dotnet/coreclr#1241 was backed out. |
Looks like after optimization a few instructions left dangling.
The text was updated successfully, but these errors were encountered: