[llvm] r322108 - Make one of the emitFill methods non virtual. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 9 11:29:33 PST 2018
Author: rafael
Date: Tue Jan 9 11:29:33 2018
New Revision: 322108
URL: http://llvm.org/viewvc/llvm-project?rev=322108&view=rev
Log:
Make one of the emitFill methods non virtual. NFC.
This is just preparatory work to fix PR35858.
Modified:
llvm/trunk/include/llvm/MC/MCObjectStreamer.h
llvm/trunk/include/llvm/MC/MCStreamer.h
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/lib/MC/MCObjectStreamer.cpp
llvm/trunk/lib/MC/MCStreamer.cpp
Modified: llvm/trunk/include/llvm/MC/MCObjectStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectStreamer.h?rev=322108&r1=322107&r2=322108&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectStreamer.h Tue Jan 9 11:29:33 2018
@@ -161,7 +161,6 @@ public:
bool EmitRelocDirective(const MCExpr &Offset, StringRef Name,
const MCExpr *Expr, SMLoc Loc) override;
using MCStreamer::emitFill;
- void emitFill(uint64_t NumBytes, uint8_t FillValue) override;
void emitFill(const MCExpr &NumBytes, uint64_t FillValue,
SMLoc Loc = SMLoc()) override;
void emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=322108&r1=322107&r2=322108&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Tue Jan 9 11:29:33 2018
@@ -662,7 +662,7 @@ public:
/// \brief Emit NumBytes bytes worth of the value specified by FillValue.
/// This implements directives such as '.space'.
- virtual void emitFill(uint64_t NumBytes, uint8_t FillValue);
+ void emitFill(uint64_t NumBytes, uint8_t FillValue);
/// \brief Emit \p Size bytes worth of the value specified by \p FillValue.
///
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=322108&r1=322107&r2=322108&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Tue Jan 9 11:29:33 2018
@@ -192,9 +192,6 @@ public:
void EmitGPRel32Value(const MCExpr *Value) override;
-
- void emitFill(uint64_t NumBytes, uint8_t FillValue) override;
-
void emitFill(const MCExpr &NumBytes, uint64_t FillValue,
SMLoc Loc = SMLoc()) override;
@@ -965,17 +962,12 @@ void MCAsmStreamer::EmitGPRel32Value(con
EmitEOL();
}
-/// emitFill - Emit NumBytes bytes worth of the value specified by
-/// FillValue. This implements directives such as '.space'.
-void MCAsmStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {
- if (NumBytes == 0) return;
-
- const MCExpr *E = MCConstantExpr::create(NumBytes, getContext());
- emitFill(*E, FillValue);
-}
-
void MCAsmStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue,
SMLoc Loc) {
+ int64_t IntNumBytes;
+ if (NumBytes.evaluateAsAbsolute(IntNumBytes) && IntNumBytes == 0)
+ return;
+
if (const char *ZeroDirective = MAI->getZeroDirective()) {
// FIXME: Emit location directives
OS << ZeroDirective;
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=322108&r1=322107&r2=322108&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Tue Jan 9 11:29:33 2018
@@ -577,11 +577,6 @@ bool MCObjectStreamer::EmitRelocDirectiv
return false;
}
-void MCObjectStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {
- assert(getCurrentSectionOnly() && "need a section");
- insert(new MCFillFragment(FillValue, NumBytes));
-}
-
void MCObjectStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue,
SMLoc Loc) {
MCDataFragment *DF = getOrCreateDataFragment();
@@ -593,12 +588,13 @@ void MCObjectStreamer::emitFill(const MC
return;
}
- if (IntNumBytes <= 0) {
+ if (IntNumBytes < 0) {
getContext().reportError(Loc, "invalid number of bytes");
return;
}
- emitFill(IntNumBytes, FillValue);
+ assert(getCurrentSectionOnly() && "need a section");
+ insert(new MCFillFragment(FillValue, IntNumBytes));
}
void MCObjectStreamer::emitFill(const MCExpr &NumValues, int64_t Size,
Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=322108&r1=322107&r2=322108&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Tue Jan 9 11:29:33 2018
@@ -184,8 +184,7 @@ void MCStreamer::EmitGPRel32Value(const
/// 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) {
- for (uint64_t i = 0, e = NumBytes; i != e; ++i)
- EmitIntValue(FillValue, 1);
+ emitFill(*MCConstantExpr::create(NumBytes, getContext()), FillValue);
}
void MCStreamer::emitFill(uint64_t NumValues, int64_t Size, int64_t Expr) {
More information about the llvm-commits
mailing list