[llvm] r215689 - Don't print comments to an object streamer :-)
Rafael Espindola
rafael.espindola at gmail.com
Thu Aug 14 20:07:13 PDT 2014
Author: rafael
Date: Thu Aug 14 22:07:13 2014
New Revision: 215689
URL: http://llvm.org/viewvc/llvm-project?rev=215689&view=rev
Log:
Don't print comments to an object streamer :-)
Modified:
llvm/trunk/lib/MC/MCDwarf.cpp
Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=215689&r1=215688&r2=215689&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Aug 14 22:07:13 2014
@@ -971,16 +971,14 @@ static unsigned getSizeForEncoding(MCStr
}
}
-static void EmitFDESymbol(MCStreamer &streamer, const MCSymbol &symbol,
- unsigned symbolEncoding, bool isEH,
- const char *comment = nullptr) {
+static void emitFDESymbol(MCObjectStreamer &streamer, const MCSymbol &symbol,
+ unsigned symbolEncoding, bool isEH) {
MCContext &context = streamer.getContext();
const MCAsmInfo *asmInfo = context.getAsmInfo();
const MCExpr *v = asmInfo->getExprForFDESymbol(&symbol,
symbolEncoding,
streamer);
unsigned size = getSizeForEncoding(streamer, symbolEncoding);
- if (streamer.isVerboseAsm() && comment) streamer.AddComment(comment);
if (asmInfo->doDwarfFDESymbolsUseAbsDiff() && isEH)
streamer.EmitAbsValue(v, size);
else
@@ -1010,8 +1008,8 @@ namespace {
void setSectionStart(const MCSymbol *Label) { SectionStart = Label; }
- /// EmitCompactUnwind - Emit the unwind information in a compact way.
- void EmitCompactUnwind(MCStreamer &streamer,
+ /// Emit the unwind information in a compact way.
+ void EmitCompactUnwind(MCObjectStreamer &streamer,
const MCDwarfFrameInfo &frame);
const MCSymbol &EmitCIE(MCObjectStreamer &streamer,
@@ -1033,65 +1031,18 @@ namespace {
} // end anonymous namespace
-static void EmitEncodingByte(MCStreamer &Streamer, unsigned Encoding,
- StringRef Prefix) {
- if (Streamer.isVerboseAsm()) {
- const char *EncStr;
- switch (Encoding) {
- default: EncStr = "<unknown encoding>"; break;
- case dwarf::DW_EH_PE_absptr: EncStr = "absptr"; break;
- case dwarf::DW_EH_PE_omit: EncStr = "omit"; break;
- case dwarf::DW_EH_PE_pcrel: EncStr = "pcrel"; break;
- case dwarf::DW_EH_PE_udata4: EncStr = "udata4"; break;
- case dwarf::DW_EH_PE_udata8: EncStr = "udata8"; break;
- case dwarf::DW_EH_PE_sdata4: EncStr = "sdata4"; break;
- case dwarf::DW_EH_PE_sdata8: EncStr = "sdata8"; break;
- case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata4:
- EncStr = "pcrel udata4";
- break;
- case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4:
- EncStr = "pcrel sdata4";
- break;
- case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8:
- EncStr = "pcrel udata8";
- break;
- case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8:
- EncStr = "screl sdata8";
- break;
- case dwarf::DW_EH_PE_indirect |dwarf::DW_EH_PE_pcrel|dwarf::DW_EH_PE_udata4:
- EncStr = "indirect pcrel udata4";
- break;
- case dwarf::DW_EH_PE_indirect |dwarf::DW_EH_PE_pcrel|dwarf::DW_EH_PE_sdata4:
- EncStr = "indirect pcrel sdata4";
- break;
- case dwarf::DW_EH_PE_indirect |dwarf::DW_EH_PE_pcrel|dwarf::DW_EH_PE_udata8:
- EncStr = "indirect pcrel udata8";
- break;
- case dwarf::DW_EH_PE_indirect |dwarf::DW_EH_PE_pcrel|dwarf::DW_EH_PE_sdata8:
- EncStr = "indirect pcrel sdata8";
- break;
- }
-
- Streamer.AddComment(Twine(Prefix) + " = " + EncStr);
- }
-
+static void emitEncodingByte(MCObjectStreamer &Streamer, unsigned Encoding) {
Streamer.EmitIntValue(Encoding, 1);
}
void FrameEmitterImpl::EmitCFIInstruction(MCObjectStreamer &Streamer,
const MCCFIInstruction &Instr) {
int dataAlignmentFactor = getDataAlignmentFactor(Streamer);
- bool VerboseAsm = Streamer.isVerboseAsm();
switch (Instr.getOperation()) {
case MCCFIInstruction::OpRegister: {
unsigned Reg1 = Instr.getRegister();
unsigned Reg2 = Instr.getRegister2();
- if (VerboseAsm) {
- Streamer.AddComment("DW_CFA_register");
- Streamer.AddComment(Twine("Reg1 ") + Twine(Reg1));
- Streamer.AddComment(Twine("Reg2 ") + Twine(Reg2));
- }
Streamer.EmitIntValue(dwarf::DW_CFA_register, 1);
Streamer.EmitULEB128IntValue(Reg1);
Streamer.EmitULEB128IntValue(Reg2);
@@ -1103,10 +1054,6 @@ void FrameEmitterImpl::EmitCFIInstructio
}
case MCCFIInstruction::OpUndefined: {
unsigned Reg = Instr.getRegister();
- if (VerboseAsm) {
- Streamer.AddComment("DW_CFA_undefined");
- Streamer.AddComment(Twine("Reg ") + Twine(Reg));
- }
Streamer.EmitIntValue(dwarf::DW_CFA_undefined, 1);
Streamer.EmitULEB128IntValue(Reg);
return;
@@ -1116,8 +1063,6 @@ void FrameEmitterImpl::EmitCFIInstructio
const bool IsRelative =
Instr.getOperation() == MCCFIInstruction::OpAdjustCfaOffset;
- if (VerboseAsm)
- Streamer.AddComment("DW_CFA_def_cfa_offset");
Streamer.EmitIntValue(dwarf::DW_CFA_def_cfa_offset, 1);
if (IsRelative)
@@ -1125,37 +1070,21 @@ void FrameEmitterImpl::EmitCFIInstructio
else
CFAOffset = -Instr.getOffset();
- if (VerboseAsm)
- Streamer.AddComment(Twine("Offset " + Twine(CFAOffset)));
Streamer.EmitULEB128IntValue(CFAOffset);
return;
}
case MCCFIInstruction::OpDefCfa: {
- if (VerboseAsm)
- Streamer.AddComment("DW_CFA_def_cfa");
Streamer.EmitIntValue(dwarf::DW_CFA_def_cfa, 1);
-
- if (VerboseAsm)
- Streamer.AddComment(Twine("Reg ") + Twine(Instr.getRegister()));
Streamer.EmitULEB128IntValue(Instr.getRegister());
-
CFAOffset = -Instr.getOffset();
-
- if (VerboseAsm)
- Streamer.AddComment(Twine("Offset " + Twine(CFAOffset)));
Streamer.EmitULEB128IntValue(CFAOffset);
return;
}
case MCCFIInstruction::OpDefCfaRegister: {
- if (VerboseAsm)
- Streamer.AddComment("DW_CFA_def_cfa_register");
Streamer.EmitIntValue(dwarf::DW_CFA_def_cfa_register, 1);
-
- if (VerboseAsm)
- Streamer.AddComment(Twine("Reg ") + Twine(Instr.getRegister()));
Streamer.EmitULEB128IntValue(Instr.getRegister());
return;
@@ -1173,63 +1102,44 @@ void FrameEmitterImpl::EmitCFIInstructio
Offset = Offset / dataAlignmentFactor;
if (Offset < 0) {
- if (VerboseAsm) Streamer.AddComment("DW_CFA_offset_extended_sf");
Streamer.EmitIntValue(dwarf::DW_CFA_offset_extended_sf, 1);
- if (VerboseAsm) Streamer.AddComment(Twine("Reg ") + Twine(Reg));
Streamer.EmitULEB128IntValue(Reg);
- if (VerboseAsm) Streamer.AddComment(Twine("Offset ") + Twine(Offset));
Streamer.EmitSLEB128IntValue(Offset);
} else if (Reg < 64) {
- if (VerboseAsm) Streamer.AddComment(Twine("DW_CFA_offset + Reg(") +
- Twine(Reg) + ")");
Streamer.EmitIntValue(dwarf::DW_CFA_offset + Reg, 1);
- if (VerboseAsm) Streamer.AddComment(Twine("Offset ") + Twine(Offset));
Streamer.EmitULEB128IntValue(Offset);
} else {
- if (VerboseAsm) Streamer.AddComment("DW_CFA_offset_extended");
Streamer.EmitIntValue(dwarf::DW_CFA_offset_extended, 1);
- if (VerboseAsm) Streamer.AddComment(Twine("Reg ") + Twine(Reg));
Streamer.EmitULEB128IntValue(Reg);
- if (VerboseAsm) Streamer.AddComment(Twine("Offset ") + Twine(Offset));
Streamer.EmitULEB128IntValue(Offset);
}
return;
}
case MCCFIInstruction::OpRememberState:
- if (VerboseAsm) Streamer.AddComment("DW_CFA_remember_state");
Streamer.EmitIntValue(dwarf::DW_CFA_remember_state, 1);
return;
case MCCFIInstruction::OpRestoreState:
- if (VerboseAsm) Streamer.AddComment("DW_CFA_restore_state");
Streamer.EmitIntValue(dwarf::DW_CFA_restore_state, 1);
return;
case MCCFIInstruction::OpSameValue: {
unsigned Reg = Instr.getRegister();
- if (VerboseAsm) Streamer.AddComment("DW_CFA_same_value");
Streamer.EmitIntValue(dwarf::DW_CFA_same_value, 1);
- if (VerboseAsm) Streamer.AddComment(Twine("Reg ") + Twine(Reg));
Streamer.EmitULEB128IntValue(Reg);
return;
}
case MCCFIInstruction::OpRestore: {
unsigned Reg = Instr.getRegister();
- if (VerboseAsm) {
- Streamer.AddComment("DW_CFA_restore");
- Streamer.AddComment(Twine("Reg ") + Twine(Reg));
- }
Streamer.EmitIntValue(dwarf::DW_CFA_restore | Reg, 1);
return;
}
case MCCFIInstruction::OpEscape:
- if (VerboseAsm) Streamer.AddComment("Escape bytes");
Streamer.EmitBytes(Instr.getValues());
return;
}
llvm_unreachable("Unhandled case in switch");
}
-/// EmitFrameMoves - Emit frame instructions to describe the layout of the
-/// frame.
+/// Emit frame instructions to describe the layout of the frame.
void FrameEmitterImpl::EmitCFIInstructions(MCObjectStreamer &streamer,
ArrayRef<MCCFIInstruction> Instrs,
MCSymbol *BaseLabel) {
@@ -1243,7 +1153,6 @@ void FrameEmitterImpl::EmitCFIInstructio
if (BaseLabel && Label) {
MCSymbol *ThisSym = Label;
if (ThisSym != BaseLabel) {
- if (streamer.isVerboseAsm()) streamer.AddComment("DW_CFA_advance_loc4");
streamer.EmitDwarfAdvanceFrameAddr(BaseLabel, ThisSym);
BaseLabel = ThisSym;
}
@@ -1253,12 +1162,11 @@ void FrameEmitterImpl::EmitCFIInstructio
}
}
-/// EmitCompactUnwind - Emit the unwind information in a compact way.
-void FrameEmitterImpl::EmitCompactUnwind(MCStreamer &Streamer,
+/// Emit the unwind information in a compact way.
+void FrameEmitterImpl::EmitCompactUnwind(MCObjectStreamer &Streamer,
const MCDwarfFrameInfo &Frame) {
MCContext &Context = Streamer.getContext();
const MCObjectFileInfo *MOFI = Context.getObjectFileInfo();
- bool VerboseAsm = Streamer.isVerboseAsm();
// range-start range-length compact-unwind-enc personality-func lsda
// _foo LfooEnd-_foo 0x00000023 0 0
@@ -1293,24 +1201,19 @@ void FrameEmitterImpl::EmitCompactUnwind
// Range Start
unsigned FDEEncoding = MOFI->getFDEEncoding();
unsigned Size = getSizeForEncoding(Streamer, FDEEncoding);
- if (VerboseAsm) Streamer.AddComment("Range Start");
Streamer.EmitSymbolValue(Frame.Begin, Size);
// Range Length
const MCExpr *Range = MakeStartMinusEndExpr(Streamer, *Frame.Begin,
*Frame.End, 0);
- if (VerboseAsm) Streamer.AddComment("Range Length");
Streamer.EmitAbsValue(Range, 4);
// Compact Encoding
Size = getSizeForEncoding(Streamer, dwarf::DW_EH_PE_udata4);
- if (VerboseAsm) Streamer.AddComment("Compact Unwind Encoding: 0x" +
- Twine::utohexstr(Encoding));
Streamer.EmitIntValue(Encoding, Size);
// Personality Function
Size = getSizeForEncoding(Streamer, dwarf::DW_EH_PE_absptr);
- if (VerboseAsm) Streamer.AddComment("Personality Function");
if (!DwarfEHFrameOnly && Frame.Personality)
Streamer.EmitSymbolValue(Frame.Personality, Size);
else
@@ -1318,7 +1221,6 @@ void FrameEmitterImpl::EmitCompactUnwind
// LSDA
Size = getSizeForEncoding(Streamer, Frame.LsdaEncoding);
- if (VerboseAsm) Streamer.AddComment("LSDA");
if (!DwarfEHFrameOnly && Frame.Lsda)
Streamer.EmitSymbolValue(Frame.Lsda, Size);
else
@@ -1335,7 +1237,6 @@ const MCSymbol &FrameEmitterImpl::EmitCI
MCContext &context = streamer.getContext();
const MCRegisterInfo *MRI = context.getRegisterInfo();
const MCObjectFileInfo *MOFI = context.getObjectFileInfo();
- bool verboseAsm = streamer.isVerboseAsm();
MCSymbol *sectionStart = context.CreateTempSymbol();
streamer.EmitLabel(sectionStart);
@@ -1346,16 +1247,13 @@ const MCSymbol &FrameEmitterImpl::EmitCI
// Length
const MCExpr *Length = MakeStartMinusEndExpr(streamer, *sectionStart,
*sectionEnd, 4);
- if (verboseAsm) streamer.AddComment("CIE Length");
streamer.EmitAbsValue(Length, 4);
// CIE ID
unsigned CIE_ID = IsEH ? 0 : -1;
- if (verboseAsm) streamer.AddComment("CIE ID Tag");
streamer.EmitIntValue(CIE_ID, 4);
// Version
- if (verboseAsm) streamer.AddComment("DW_CIE_VERSION");
// For DWARF2, we use CIE version 1
// For DWARF3+, we use CIE version 3
uint8_t CIEVersion = context.getDwarfVersion() <= 2 ? 1 : 3;
@@ -1364,7 +1262,6 @@ const MCSymbol &FrameEmitterImpl::EmitCI
// Augmentation String
SmallString<8> Augmentation;
if (IsEH) {
- if (verboseAsm) streamer.AddComment("CIE Augmentation");
Augmentation += "z";
if (personality)
Augmentation += "P";
@@ -1378,15 +1275,12 @@ const MCSymbol &FrameEmitterImpl::EmitCI
streamer.EmitIntValue(0, 1);
// Code Alignment Factor
- if (verboseAsm) streamer.AddComment("CIE Code Alignment Factor");
streamer.EmitULEB128IntValue(context.getAsmInfo()->getMinInstAlignment());
// Data Alignment Factor
- if (verboseAsm) streamer.AddComment("CIE Data Alignment Factor");
streamer.EmitSLEB128IntValue(getDataAlignmentFactor(streamer));
// Return Address Register
- if (verboseAsm) streamer.AddComment("CIE Return Address Column");
if (CIEVersion == 1) {
assert(MRI->getRARegister() <= 255 &&
"DWARF 2 encodes return_address_register in one byte");
@@ -1411,24 +1305,21 @@ const MCSymbol &FrameEmitterImpl::EmitCI
// Encoding of the FDE pointers
augmentationLength += 1;
- if (verboseAsm) streamer.AddComment("Augmentation Size");
streamer.EmitULEB128IntValue(augmentationLength);
// Augmentation Data (optional)
if (personality) {
// Personality Encoding
- EmitEncodingByte(streamer, personalityEncoding,
- "Personality Encoding");
+ emitEncodingByte(streamer, personalityEncoding);
// Personality
- if (verboseAsm) streamer.AddComment("Personality");
EmitPersonality(streamer, *personality, personalityEncoding);
}
if (lsda)
- EmitEncodingByte(streamer, lsdaEncoding, "LSDA Encoding");
+ emitEncodingByte(streamer, lsdaEncoding);
// Encoding of the FDE pointers
- EmitEncodingByte(streamer, MOFI->getFDEEncoding(), "FDE Encoding");
+ emitEncodingByte(streamer, MOFI->getFDEEncoding());
}
// Initial Instructions
@@ -1454,11 +1345,9 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCOb
MCSymbol *fdeStart = context.CreateTempSymbol();
MCSymbol *fdeEnd = context.CreateTempSymbol();
const MCObjectFileInfo *MOFI = context.getObjectFileInfo();
- bool verboseAsm = streamer.isVerboseAsm();
// Length
const MCExpr *Length = MakeStartMinusEndExpr(streamer, *fdeStart, *fdeEnd, 0);
- if (verboseAsm) streamer.AddComment("FDE Length");
streamer.EmitAbsValue(Length, 4);
streamer.EmitLabel(fdeStart);
@@ -1468,7 +1357,6 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCOb
if (IsEH) {
const MCExpr *offset = MakeStartMinusEndExpr(streamer, cieStart, *fdeStart,
0);
- if (verboseAsm) streamer.AddComment("FDE CIE Offset");
streamer.EmitAbsValue(offset, 4);
} else if (!asmInfo->doesDwarfUseRelocationsAcrossSections()) {
const MCExpr *offset = MakeStartMinusEndExpr(streamer, *SectionStart,
@@ -1482,12 +1370,11 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCOb
unsigned PCEncoding =
IsEH ? MOFI->getFDEEncoding() : (unsigned)dwarf::DW_EH_PE_absptr;
unsigned PCSize = getSizeForEncoding(streamer, PCEncoding);
- EmitFDESymbol(streamer, *frame.Begin, PCEncoding, IsEH, "FDE initial location");
+ emitFDESymbol(streamer, *frame.Begin, PCEncoding, IsEH);
// PC Range
const MCExpr *Range = MakeStartMinusEndExpr(streamer, *frame.Begin,
*frame.End, 0);
- if (verboseAsm) streamer.AddComment("FDE address range");
streamer.EmitAbsValue(Range, PCSize);
if (IsEH) {
@@ -1497,13 +1384,11 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCOb
if (frame.Lsda)
augmentationLength += getSizeForEncoding(streamer, frame.LsdaEncoding);
- if (verboseAsm) streamer.AddComment("Augmentation size");
streamer.EmitULEB128IntValue(augmentationLength);
// Augmentation Data
if (frame.Lsda)
- EmitFDESymbol(streamer, *frame.Lsda, frame.LsdaEncoding, true,
- "Language Specific Data Area");
+ emitFDESymbol(streamer, *frame.Lsda, frame.LsdaEncoding, true);
}
// Call Frame Instructions
More information about the llvm-commits
mailing list