[PATCH] D97268: [X86] Use correct padding when in 16-bit mode

James Y Knight via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 23 15:04:06 PST 2021


jyknight added a comment.

In D97268#2582826 <https://reviews.llvm.org/D97268#2582826>, @void wrote:

> In D97268#2581555 <https://reviews.llvm.org/D97268#2581555>, @jyknight wrote:
>
>> This change also modifies (breaks!) the 32-bit NOP set, definitely shouldn't do that. (But I think all that can be reverted, in any case).
>
> Which part did it break?

It replaced the single-instruction NOPs with new sequences consisting of multiple instructions.



================
Comment at: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:1128
+        "\x8d\xb4\x00\x00",
+        // nop; lea 0w(%si),%si
+        "\x90\x8d\xb4\x00\x00",
----------------
If you want to go the complex route, and support multi-byte nops in 16bit mode:

The 5 and larger-byte strings here should be removed, as they're combinations of smaller instructions. Leave only the initial 4 elements in the Nops16Bit array. Therefore, getMaximumNopSize() should return 4 in 16bit mode.



================
Comment at: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:1138
+
+    // A nimiety of nops.
+    static const char LotsOfNops[] = "\x90\x90\x90\x90\x90\x90\x90\x90\x90"
----------------
This code is unnecessary.

Rename Nops to Nops32Bit, make both arrays have a second dimension of 11, and then you can do `char (*Nops)[11] = STI.getFeatureBits()[X86::Mode16Bit])? Nops16Bit : Nops32Bit;` -- and then the existing loop below is sufficient.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97268/new/

https://reviews.llvm.org/D97268



More information about the llvm-commits mailing list