[PATCH] D146416: [MC] avoid create MCFillFragment when bytes is 0

panyuntao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 20 04:40:58 PDT 2023


yuntaopan created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
yuntaopan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In the function emitGlobalConstantFP, we may generate a
0-byte Fill Fragment, which is followed by a Data Fragment,
that will cause the next float constant to recreate a Data
Fragment and repeat,it consumes a lot of memory when the
global variable is a floating point array.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146416

Files:
  llvm/lib/MC/MCStreamer.cpp


Index: llvm/lib/MC/MCStreamer.cpp
===================================================================
--- llvm/lib/MC/MCStreamer.cpp
+++ llvm/lib/MC/MCStreamer.cpp
@@ -219,7 +219,8 @@
 /// Emit NumBytes bytes worth of the value specified by FillValue.
 /// This implements directives such as '.space'.
 void MCStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {
-  emitFill(*MCConstantExpr::create(NumBytes, getContext()), FillValue);
+  if (NumBytes != 0)
+    emitFill(*MCConstantExpr::create(NumBytes, getContext()), FillValue);
 }
 
 void llvm::MCStreamer::emitNops(int64_t NumBytes, int64_t ControlledNopLen,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146416.506542.patch
Type: text/x-patch
Size: 621 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230320/aecd1da7/attachment.bin>


More information about the llvm-commits mailing list