[PATCH] D46703: [MC] Relax .fill size requirements

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 17 03:01:39 PDT 2018


peter.smith added a comment.

Thanks for the update, typo aside they look fine to me.

If it helps here is a program that should show relaxation on a big endian arm system:

  // RUN: llvm-mc --triple=thumbv7eb-linux-gnueabihf %s -filetype=obj -o %t
  // RUN: llvm-objdump -triple=thumbv7eb-linux-gnueabihf -d %t
          .syntax unified
          .text
          .thumb
  .L1:
          beq Label
  .L2:
          .word 0
          .fill (.L2 - .L1)/4, 4, 0x12345678
          .space 1024
  Label:

llvm-objdump doesn't seem to be able to disassemble the instructions properly, but by using .word to force a .data mapping symbol it will disassemble the .fill. Big endian on an Armv7 is strange in that the object files have big-endian instructions but are reversed at link time to little-endian so I'm not surprised it doesn't handle this well.



================
Comment at: llvm/lib/MC/MCAssembler.cpp:563
     char Data[MaxChunkSize];
-    memcpy(Data, &V, 1);
-    for (unsigned I = 1; I < MaxChunkSize; ++I)
-      Data[I] = Data[0];
-
-    uint64_t Size = FragmentSize;
-    for (unsigned ChunkSize = MaxChunkSize; ChunkSize; ChunkSize /= 2) {
-      StringRef Ref(Data, ChunkSize);
-      for (uint64_t I = 0, E = Size / ChunkSize; I != E; ++I)
-        OW->writeBytes(Ref);
-      Size = Size % ChunkSize;
+    // Duplicate V into Data as byte verctor to reduce number of
+    // writes done. As such, do endian conversion here, not in OW.
----------------
Typo: verctor -> vector


Repository:
  rL LLVM

https://reviews.llvm.org/D46703





More information about the llvm-commits mailing list