Diff-able disassembly fixes (dotnet/coreclr#20863)
authorPent Ploompuu <kaalikas@gmail.com>
Tue, 27 Nov 2018 21:24:30 +0000 (23:24 +0200)
committerTomáš Rylek <trylek@microsoft.com>
Tue, 27 Nov 2018 21:24:30 +0000 (22:24 +0100)
Commit migrated from https://github.com/dotnet/coreclr/commit/3766ae3f90fa8cb9bc5ae28370b45053ce85248b

src/coreclr/src/jit/emitxarch.cpp

index f572ce1..366124c 100644 (file)
@@ -7852,16 +7852,16 @@ void emitter::emitDispAddrMode(instrDesc* id, bool noDetail)
     else
     {
         // Munge any pointers if we want diff-able disassembly
-        if (emitComp->opts.disDiffable)
+        // It's assumed to be a pointer when disp is outside of the range (-1M, +1M); top bits are not 0 or -1
+        if (!frameRef && emitComp->opts.disDiffable && (static_cast<size_t>((disp >> 20) + 1) > 1))
         {
-            ssize_t top12bits = (disp >> 20);
-            if ((top12bits != 0) && (top12bits != -1))
+            if (nsep)
             {
-                disp = 0xD1FFAB1E;
+                printf("+");
             }
+            printf("D1FFAB1EH");
         }
-
-        if (disp > 0)
+        else if (disp > 0)
         {
             if (nsep)
             {
@@ -7898,8 +7898,12 @@ void emitter::emitDispAddrMode(instrDesc* id, bool noDetail)
             {
                 printf("-%04XH", -disp);
             }
-            else if ((disp & 0x7F000000) != 0x7F000000)
+            else if (disp < -0xFFFFFF)
             {
+                if (nsep)
+                {
+                    printf("+");
+                }
                 printf("%08XH", disp);
             }
             else
@@ -8271,7 +8275,7 @@ void emitter::emitDispIns(
                 {
                     printf("%d", val);
                 }
-                else if ((val > 0) || ((val & 0x7F000000) != 0x7F000000))
+                else if ((val > 0) || (val < -0xFFFFFF))
                 {
                     printf("0x%IX", val);
                 }