[llvm] r258141 - Simplify MCFillFragment.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 19 08:57:09 PST 2016
Author: rafael
Date: Tue Jan 19 10:57:08 2016
New Revision: 258141
URL: http://llvm.org/viewvc/llvm-project?rev=258141&view=rev
Log:
Simplify MCFillFragment.
The value size was always 1 or 0, so we don't need to store it.
In a no asserts build this takes the testcase of pr26208 from 11 to 10
seconds.
Modified:
llvm/trunk/include/llvm/MC/MCFragment.h
llvm/trunk/lib/MC/MCAssembler.cpp
llvm/trunk/lib/MC/MCFragment.cpp
llvm/trunk/lib/MC/MCMachOStreamer.cpp
llvm/trunk/lib/MC/MCObjectStreamer.cpp
llvm/trunk/lib/MC/WinCOFFStreamer.cpp
Modified: llvm/trunk/include/llvm/MC/MCFragment.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCFragment.h?rev=258141&r1=258140&r2=258141&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCFragment.h (original)
+++ llvm/trunk/include/llvm/MC/MCFragment.h Tue Jan 19 10:57:08 2016
@@ -321,36 +321,19 @@ public:
class MCFillFragment : public MCFragment {
- /// Value - Value to use for filling bytes.
- int64_t Value;
+ /// Value to use for filling bytes.
+ uint8_t Value;
- /// ValueSize - The size (in bytes) of \p Value to use when filling, or 0 if
- /// this is a virtual fill fragment.
- unsigned ValueSize;
-
- /// Size - The number of bytes to insert.
+ /// The number of bytes to insert.
uint64_t Size;
public:
- MCFillFragment(int64_t Value, unsigned ValueSize, uint64_t Size,
- MCSection *Sec = nullptr)
- : MCFragment(FT_Fill, false, 0, Sec), Value(Value), ValueSize(ValueSize),
- Size(Size) {
- assert((!ValueSize || (Size % ValueSize) == 0) &&
- "Fill size must be a multiple of the value size!");
- }
-
- /// \name Accessors
- /// @{
-
- int64_t getValue() const { return Value; }
-
- unsigned getValueSize() const { return ValueSize; }
+ MCFillFragment(uint8_t Value, uint64_t Size, MCSection *Sec = nullptr)
+ : MCFragment(FT_Fill, false, 0, Sec), Value(Value), Size(Size) {}
+ uint8_t getValue() const { return Value; }
uint64_t getSize() const { return Size; }
- /// @}
-
static bool classof(const MCFragment *F) {
return F->getKind() == MCFragment::FT_Fill;
}
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=258141&r1=258140&r2=258141&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Tue Jan 19 10:57:08 2016
@@ -489,17 +489,8 @@ static void writeFragment(const MCAssemb
++stats::EmittedFillFragments;
const MCFillFragment &FF = cast<MCFillFragment>(F);
- assert(FF.getValueSize() && "Invalid virtual align in concrete fragment!");
-
- for (uint64_t i = 0, e = FF.getSize() / FF.getValueSize(); i != e; ++i) {
- switch (FF.getValueSize()) {
- default: llvm_unreachable("Invalid size!");
- case 1: OW->write8 (uint8_t (FF.getValue())); break;
- case 2: OW->write16(uint16_t(FF.getValue())); break;
- case 4: OW->write32(uint32_t(FF.getValue())); break;
- case 8: OW->write64(uint64_t(FF.getValue())); break;
- }
- }
+ for (uint64_t I = 0, E = FF.getSize(); I != E; ++I)
+ OW->write8(FF.getValue());
break;
}
@@ -578,8 +569,7 @@ void MCAssembler::writeSectionData(const
"Invalid align in virtual section!");
break;
case MCFragment::FT_Fill:
- assert((cast<MCFillFragment>(F).getValueSize() == 0 ||
- cast<MCFillFragment>(F).getValue() == 0) &&
+ assert((cast<MCFillFragment>(F).getValue() == 0) &&
"Invalid fill in virtual section!");
break;
}
Modified: llvm/trunk/lib/MC/MCFragment.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCFragment.cpp?rev=258141&r1=258140&r2=258141&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCFragment.cpp (original)
+++ llvm/trunk/lib/MC/MCFragment.cpp Tue Jan 19 10:57:08 2016
@@ -386,8 +386,7 @@ void MCFragment::dump() {
}
case MCFragment::FT_Fill: {
const MCFillFragment *FF = cast<MCFillFragment>(this);
- OS << " Value:" << FF->getValue() << " ValueSize:" << FF->getValueSize()
- << " Size:" << FF->getSize();
+ OS << " Value:" << FF->getValue() << " Size:" << FF->getSize();
break;
}
case MCFragment::FT_Relaxable: {
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=258141&r1=258140&r2=258141&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Tue Jan 19 10:57:08 2016
@@ -414,7 +414,7 @@ void MCMachOStreamer::EmitZerofill(MCSec
if (ByteAlignment != 1)
new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, Section);
- MCFragment *F = new MCFillFragment(0, 0, Size, Section);
+ MCFragment *F = new MCFillFragment(0, Size, Section);
Symbol->setFragment(F);
// Update the maximum alignment on the zero fill section if necessary.
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=258141&r1=258140&r2=258141&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Tue Jan 19 10:57:08 2016
@@ -436,9 +436,9 @@ bool MCObjectStreamer::EmitRelocDirectiv
void MCObjectStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) {
const MCSection *Sec = getCurrentSection().first;
+ (void)Sec;
assert(Sec && "need a section");
- unsigned ItemSize = Sec->isVirtualSection() ? 0 : 1;
- insert(new MCFillFragment(FillValue, ItemSize, NumBytes));
+ insert(new MCFillFragment(FillValue, NumBytes));
}
void MCObjectStreamer::FinishImpl() {
Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=258141&r1=258140&r2=258141&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Tue Jan 19 10:57:08 2016
@@ -258,7 +258,7 @@ void MCWinCOFFStreamer::EmitLocalCommonS
ByteAlignment, Section);
MCFillFragment *Fragment = new MCFillFragment(
- /*Value=*/0, /*ValueSize=*/0, Size, Section);
+ /*Value=*/0, Size, Section);
Symbol->setFragment(Fragment);
}
More information about the llvm-commits
mailing list