Provide a shortcut for MCObjectStreamer when emitting fills.
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 1 Oct 2012 15:14:14 +0000 (15:14 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 1 Oct 2012 15:14:14 +0000 (15:14 +0000)
Reduces runtime of i386-large-relocations.s by 10x in Release builds, even more
in Debug+Asserts builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164945 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCObjectStreamer.h
lib/MC/MCObjectStreamer.cpp

index b59b76c2be817dca592ce23cfd9908151e652d74..186907861136c1a8174e4491615567fd5f229cea 100644 (file)
@@ -81,6 +81,8 @@ public:
                                          const MCSymbol *Label);
   virtual void EmitGPRel32Value(const MCExpr *Value);
   virtual void EmitGPRel64Value(const MCExpr *Value);
+  virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue,
+                        unsigned AddrSpace);
   virtual void FinishImpl();
 
   /// @}
index 21756cd149b878ba10c449a15f844faf6269448f..4b9acf750d551b33c76fefe1154fe882c3858791 100644 (file)
@@ -270,6 +270,14 @@ void MCObjectStreamer::EmitGPRel64Value(const MCExpr *Value) {
   DF->getContents().resize(DF->getContents().size() + 8, 0);
 }
 
+void MCObjectStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue,
+                                unsigned AddrSpace) {
+  assert(AddrSpace == 0 && "Address space must be 0!");
+  // FIXME: A MCFillFragment would be more memory efficient but MCExpr has
+  //        problems evaluating expressions across multiple fragments.
+  getOrCreateDataFragment()->getContents().append(NumBytes, FillValue);
+}
+
 void MCObjectStreamer::FinishImpl() {
   // Dump out the dwarf file & directory tables and line tables.
   const MCSymbol *LineSectionSymbol = NULL;