[llvm-commits] [llvm] r120774 - in /llvm/trunk/lib/MC: MCAsmStreamer.cpp MCObjectStreamer.cpp MCStreamer.cpp
Rafael Espindola
rafael.espindola at gmail.com
Thu Dec 2 17:19:49 PST 2010
Author: rafael
Date: Thu Dec 2 19:19:49 2010
New Revision: 120774
URL: http://llvm.org/viewvc/llvm-project?rev=120774&view=rev
Log:
Do with uleb the same trick we now do with dwarf line/address advances. This
avoids creating leb128 fragments and speeds up the test in PR8711 to 33s.
Modified:
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/lib/MC/MCObjectStreamer.cpp
llvm/trunk/lib/MC/MCStreamer.cpp
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=120774&r1=120773&r2=120774&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Thu Dec 2 19:19:49 2010
@@ -546,10 +546,7 @@
void MCAsmStreamer::EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace) {
int64_t IntValue;
if (Value->EvaluateAsAbsolute(IntValue)) {
- SmallString<32> Tmp;
- raw_svector_ostream OSE(Tmp);
- MCObjectWriter::EncodeULEB128(IntValue, OSE);
- EmitBytes(OSE.str(), AddrSpace);
+ EmitULEB128IntValue(IntValue, AddrSpace);
return;
}
assert(MAI.hasLEB128() && "Cannot print a .uleb");
@@ -560,10 +557,7 @@
void MCAsmStreamer::EmitSLEB128Value(const MCExpr *Value, unsigned AddrSpace) {
int64_t IntValue;
if (Value->EvaluateAsAbsolute(IntValue)) {
- SmallString<32> Tmp;
- raw_svector_ostream OSE(Tmp);
- MCObjectWriter::EncodeSLEB128(IntValue, OSE);
- EmitBytes(OSE.str(), AddrSpace);
+ EmitSLEB128IntValue(IntValue, AddrSpace);
return;
}
assert(MAI.hasLEB128() && "Cannot print a .sleb");
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=120774&r1=120773&r2=120774&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Thu Dec 2 19:19:49 2010
@@ -115,11 +115,21 @@
void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value,
unsigned AddrSpace) {
+ int64_t IntValue;
+ if (Value->EvaluateAsAbsolute(IntValue, &getAssembler())) {
+ EmitULEB128IntValue(IntValue, AddrSpace);
+ return;
+ }
new MCLEBFragment(*Value, false, getCurrentSectionData());
}
void MCObjectStreamer::EmitSLEB128Value(const MCExpr *Value,
unsigned AddrSpace) {
+ int64_t IntValue;
+ if (Value->EvaluateAsAbsolute(IntValue, &getAssembler())) {
+ EmitSLEB128IntValue(IntValue, AddrSpace);
+ return;
+ }
new MCLEBFragment(*Value, true, getCurrentSectionData());
}
Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=120774&r1=120773&r2=120774&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Thu Dec 2 19:19:49 2010
@@ -52,13 +52,19 @@
/// EmitULEB128Value - Special case of EmitULEB128Value that avoids the
/// client having to pass in a MCExpr for constant integers.
void MCStreamer::EmitULEB128IntValue(uint64_t Value, unsigned AddrSpace) {
- EmitULEB128Value(MCConstantExpr::Create(Value, getContext()), AddrSpace);
+ SmallString<32> Tmp;
+ raw_svector_ostream OSE(Tmp);
+ MCObjectWriter::EncodeULEB128(Value, OSE);
+ EmitBytes(OSE.str(), AddrSpace);
}
/// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the
/// client having to pass in a MCExpr for constant integers.
void MCStreamer::EmitSLEB128IntValue(int64_t Value, unsigned AddrSpace) {
- EmitSLEB128Value(MCConstantExpr::Create(Value, getContext()), AddrSpace);
+ SmallString<32> Tmp;
+ raw_svector_ostream OSE(Tmp);
+ MCObjectWriter::EncodeSLEB128(Value, OSE);
+ EmitBytes(OSE.str(), AddrSpace);
}
void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
More information about the llvm-commits
mailing list