[llvm] 4b1532a - [MC] Eagerly skip zero-sized .fill fragments

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 25 06:10:25 PDT 2023


Author: Benjamin Kramer
Date: 2023-04-25T14:59:18+02:00
New Revision: 4b1532a46f66eb71bf80458fa67b86c618803b95

URL: https://github.com/llvm/llvm-project/commit/4b1532a46f66eb71bf80458fa67b86c618803b95
DIFF: https://github.com/llvm/llvm-project/commit/4b1532a46f66eb71bf80458fa67b86c618803b95.diff

LOG: [MC] Eagerly skip zero-sized .fill fragments

This doesn't change the output in any way, but we have a bunch of
emitFill for padding. When emitting an array of floats we'd end up with

DataFragment float1
FillFragment 0
DataFragment float2
FillFragment 0
... and so on

We never actually emit anything for those fills, neither in asm nor obj
emission mode, they just consume RAM for no reason.

Added: 
    

Modified: 
    llvm/lib/MC/MCStreamer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index 4dd3163fd399d..8f29153783066 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -219,7 +219,8 @@ void MCStreamer::emitGPRel32Value(const MCExpr *Value) {
 /// 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)
+    emitFill(*MCConstantExpr::create(NumBytes, getContext()), FillValue);
 }
 
 void llvm::MCStreamer::emitNops(int64_t NumBytes, int64_t ControlledNopLen,


        


More information about the llvm-commits mailing list