Reflector gets wrong decompiling result?
same dll and same function body, different decompiling results for Reflector, dotPeek, dnSpy(all are latest versions).
Reflector Code:
private uint e(byte[] a, ref int b) Code:
private uint e(byte[] a, ref int b) Code:
.method private hidebysig instance unsigned int32 |
Reflector has bad dataflow optimization semantics now apparently in ref arg cases
|
Nah, Reflector is the one who got it right.
Seems the others got thoroughly confused there ... int uint32 = .. |
Yup I meant other way around, Reflector right
|
"b +=4;", should appear first or last?
|
First.
Code:
IL_0000: ldarg.1 // load a Code:
IL_0008: ldarg.2 // load b on stack for later use Code:
<value: result of b+4> Then the last piece of the puzzle: Code:
IL_000d: stind.i4 //store the result of "b+4" in b Code:
<value: return value of the BitConverter call> Code:
IL_000e: ret So in conclusion the method does two things: 1) b += 4 and 2) return BitConverter(). So reflector is right and the others are wrong. You should file a bug report. A more literal decompilation would be: Code:
private uint e(byte[] a, ref int b) |
ok, I understand those IL instructions now. thanks!
Besides ECMA specification, MS also documents the instructions: https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.opcodes.ldind_i4?view=netframework-4.7.2 |
However, if the referenced value (b) is unused, in all caller contexts which invoke this function, then theoretically
Quote:
|
"b" is used as an incremental pointer/index to the buffer "a", so "b +=4;" can't be optimized out.
Later there are more parsing of the buffer data by calling the function e(a, b) many times. |
I just meant in those cases where caller never uses 'b' after the call then the assignment is optimizable (not the addition as you mention its an index):
Quote:
|
All times are GMT +8. The time now is 22:11. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX