[PATCH] D114874: Support target Assemblers without a zero directive

Boris Boesler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 1 06:36:19 PST 2021


borisboesler created this revision.
borisboesler added reviewers: respindola, daltenty.
Herald added a subscriber: hiraditya.
borisboesler requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

MCAsmStreamer fails to emit fill bytes if the target's assembler does not provide a zero directive to fill a number of bytes in memory with a given value. If the directive does not exist an empty `MCStreamer::emitFill()` is called. A nested code block does emit bytes with a Data8BitsDirective, but is inside a `if (const char *ZeroDirective = MAI->getZeroDirective())` block. This should be the fall through case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114874

Files:
  llvm/lib/MC/MCAsmStreamer.cpp


Index: llvm/lib/MC/MCAsmStreamer.cpp
===================================================================
--- llvm/lib/MC/MCAsmStreamer.cpp
+++ llvm/lib/MC/MCAsmStreamer.cpp
@@ -1341,19 +1341,16 @@
       if (FillValue != 0)
         OS << ',' << (int)FillValue;
       EmitEOL();
-    } else {
-      if (!IsAbsolute)
-        report_fatal_error(
-            "Cannot emit non-absolute expression lengths of fill.");
-      for (int i = 0; i < IntNumBytes; ++i) {
-        OS << MAI->getData8bitsDirective() << (int)FillValue;
-        EmitEOL();
-      }
+      return;
     }
-    return;
   }
 
-  MCStreamer::emitFill(NumBytes, FillValue);
+  if (!IsAbsolute)
+    report_fatal_error("Cannot emit non-absolute expression lengths of fill.");
+  for (int i = 0; i < IntNumBytes; ++i) {
+    OS << MAI->getData8bitsDirective() << (int)FillValue;
+    EmitEOL();
+  }
 }
 
 void MCAsmStreamer::emitFill(const MCExpr &NumValues, int64_t Size,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114874.391002.patch
Type: text/x-patch
Size: 942 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211201/b1a7e7b8/attachment.bin>


More information about the llvm-commits mailing list