forked from OSchip/llvm-project
add a new DwarfPrinter::EmitEncodingByte method which handles
pretty printing encoding comments and eliminates redundancy on the client side. We now get pretty dwarf like this again: .byte 255 ## @LPStart Encoding = omit .byte 0 ## @TType Encoding = absptr .byte 0x28 ## @TType base offset .byte 3 ## Call site Encoding = udata4 .byte 0x1a ## Call site table size ... llvm-svn: 94239
This commit is contained in:
parent
1891698a9b
commit
edf96a4cc3
|
@ -703,56 +703,6 @@ void AsmPrinter::EOL(const Twine &Comment) const {
|
||||||
O << '\n';
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *DecodeDWARFEncoding(unsigned Encoding) {
|
|
||||||
switch (Encoding) {
|
|
||||||
case dwarf::DW_EH_PE_absptr:
|
|
||||||
return "absptr";
|
|
||||||
case dwarf::DW_EH_PE_omit:
|
|
||||||
return "omit";
|
|
||||||
case dwarf::DW_EH_PE_pcrel:
|
|
||||||
return "pcrel";
|
|
||||||
case dwarf::DW_EH_PE_udata4:
|
|
||||||
return "udata4";
|
|
||||||
case dwarf::DW_EH_PE_udata8:
|
|
||||||
return "udata8";
|
|
||||||
case dwarf::DW_EH_PE_sdata4:
|
|
||||||
return "sdata4";
|
|
||||||
case dwarf::DW_EH_PE_sdata8:
|
|
||||||
return "sdata8";
|
|
||||||
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata4:
|
|
||||||
return "pcrel udata4";
|
|
||||||
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4:
|
|
||||||
return "pcrel sdata4";
|
|
||||||
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8:
|
|
||||||
return "pcrel udata8";
|
|
||||||
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8:
|
|
||||||
return "pcrel sdata8";
|
|
||||||
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_udata4:
|
|
||||||
return "indirect pcrel udata4";
|
|
||||||
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_sdata4:
|
|
||||||
return "indirect pcrel sdata4";
|
|
||||||
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_udata8:
|
|
||||||
return "indirect pcrel udata8";
|
|
||||||
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_sdata8:
|
|
||||||
return "indirect pcrel sdata8";
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AsmPrinter::EOL(const Twine &Comment, unsigned Encoding) const {
|
|
||||||
if (VerboseAsm && !Comment.isTriviallyEmpty()) {
|
|
||||||
O.PadToColumn(MAI->getCommentColumn());
|
|
||||||
O << MAI->getCommentString()
|
|
||||||
<< ' '
|
|
||||||
<< Comment;
|
|
||||||
|
|
||||||
if (const char *EncStr = DecodeDWARFEncoding(Encoding))
|
|
||||||
O << " (" << EncStr << ')';
|
|
||||||
}
|
|
||||||
O << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
/// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
|
/// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
|
||||||
/// unsigned leb128 value.
|
/// unsigned leb128 value.
|
||||||
void AsmPrinter::EmitULEB128Bytes(unsigned Value) const {
|
void AsmPrinter::EmitULEB128Bytes(unsigned Value) const {
|
||||||
|
|
|
@ -185,8 +185,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
|
||||||
Asm->EmitULEB128Bytes(AugmentationSize);
|
Asm->EmitULEB128Bytes(AugmentationSize);
|
||||||
Asm->EOL("Augmentation Size");
|
Asm->EOL("Augmentation Size");
|
||||||
|
|
||||||
Asm->EmitInt8(PerEncoding);
|
EmitEncodingByte(PerEncoding, "Personality");
|
||||||
Asm->EOL("Personality", PerEncoding);
|
|
||||||
|
|
||||||
// If there is a personality, we need to indicate the function's location.
|
// If there is a personality, we need to indicate the function's location.
|
||||||
if (PersonalityRef) {
|
if (PersonalityRef) {
|
||||||
|
@ -197,11 +196,8 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
|
||||||
O << MAI->getData32bitsDirective() << *PersonalityRef;
|
O << MAI->getData32bitsDirective() << *PersonalityRef;
|
||||||
Asm->EOL("Personality");
|
Asm->EOL("Personality");
|
||||||
|
|
||||||
Asm->EmitInt8(LSDAEncoding);
|
EmitEncodingByte(LSDAEncoding, "LSDA");
|
||||||
Asm->EOL("LSDA Encoding", LSDAEncoding);
|
EmitEncodingByte(FDEEncoding, "FDE");
|
||||||
|
|
||||||
Asm->EmitInt8(FDEEncoding);
|
|
||||||
Asm->EOL("FDE Encoding", FDEEncoding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indicate locations of general callee saved registers in frame.
|
// Indicate locations of general callee saved registers in frame.
|
||||||
|
@ -784,11 +780,8 @@ void DwarfException::EmitExceptionTable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit the header.
|
// Emit the header.
|
||||||
Asm->EmitInt8(dwarf::DW_EH_PE_omit);
|
EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
|
||||||
Asm->EOL("@LPStart format", dwarf::DW_EH_PE_omit);
|
EmitEncodingByte(TTypeFormat, "@TType");
|
||||||
|
|
||||||
Asm->EmitInt8(TTypeFormat);
|
|
||||||
Asm->EOL("@TType format", TTypeFormat);
|
|
||||||
|
|
||||||
if (HaveTTData) {
|
if (HaveTTData) {
|
||||||
Asm->EmitULEB128Bytes(TyOffset);
|
Asm->EmitULEB128Bytes(TyOffset);
|
||||||
|
@ -797,8 +790,7 @@ void DwarfException::EmitExceptionTable() {
|
||||||
|
|
||||||
// SjLj Exception handling
|
// SjLj Exception handling
|
||||||
if (IsSJLJ) {
|
if (IsSJLJ) {
|
||||||
Asm->EmitInt8(dwarf::DW_EH_PE_udata4);
|
EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
|
||||||
Asm->EOL("Call site format", dwarf::DW_EH_PE_udata4);
|
|
||||||
Asm->EmitULEB128Bytes(SizeSites);
|
Asm->EmitULEB128Bytes(SizeSites);
|
||||||
Asm->EOL("Call site table length");
|
Asm->EOL("Call site table length");
|
||||||
|
|
||||||
|
@ -842,8 +834,7 @@ void DwarfException::EmitExceptionTable() {
|
||||||
// supposed to throw.
|
// supposed to throw.
|
||||||
|
|
||||||
// Emit the landing pad call site table.
|
// Emit the landing pad call site table.
|
||||||
Asm->EmitInt8(dwarf::DW_EH_PE_udata4);
|
EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
|
||||||
Asm->EOL("Call site format", dwarf::DW_EH_PE_udata4);
|
|
||||||
Asm->EmitULEB128Bytes(SizeSites);
|
Asm->EmitULEB128Bytes(SizeSites);
|
||||||
Asm->EOL("Call site table size");
|
Asm->EOL("Call site table size");
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbol.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetFrameInfo.h"
|
#include "llvm/Target/TargetFrameInfo.h"
|
||||||
|
@ -41,6 +42,50 @@ void DwarfPrinter::PrintRelDirective(bool Force32Bit, bool isInSection) const {
|
||||||
O << MAI->getData64bitsDirective();
|
O << MAI->getData64bitsDirective();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *DecodeDWARFEncoding(unsigned Encoding) {
|
||||||
|
switch (Encoding) {
|
||||||
|
case dwarf::DW_EH_PE_absptr: return "absptr";
|
||||||
|
case dwarf::DW_EH_PE_omit: return "omit";
|
||||||
|
case dwarf::DW_EH_PE_pcrel: return "pcrel";
|
||||||
|
case dwarf::DW_EH_PE_udata4: return "udata4";
|
||||||
|
case dwarf::DW_EH_PE_udata8: return "udata8";
|
||||||
|
case dwarf::DW_EH_PE_sdata4: return "sdata4";
|
||||||
|
case dwarf::DW_EH_PE_sdata8: return "sdata8";
|
||||||
|
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata4: return "pcrel udata4";
|
||||||
|
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4: return "pcrel sdata4";
|
||||||
|
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8: return "pcrel udata8";
|
||||||
|
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8: return "pcrel sdata8";
|
||||||
|
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_udata4:
|
||||||
|
return "indirect pcrel udata4";
|
||||||
|
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_sdata4:
|
||||||
|
return "indirect pcrel sdata4";
|
||||||
|
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_udata8:
|
||||||
|
return "indirect pcrel udata8";
|
||||||
|
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_sdata8:
|
||||||
|
return "indirect pcrel sdata8";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "<unknown encoding>";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an
|
||||||
|
/// encoding. If verbose assembly output is enabled, we output comments
|
||||||
|
/// describing the encoding. Desc is an optional string saying what the
|
||||||
|
/// encoding is specifying (e.g. "LSDA").
|
||||||
|
void DwarfPrinter::EmitEncodingByte(unsigned Val, const char *Desc) {
|
||||||
|
if (Asm->VerboseAsm) {
|
||||||
|
if (Desc != 0)
|
||||||
|
Asm->OutStreamer.AddComment(Twine(Desc)+" Encoding = " +
|
||||||
|
Twine(DecodeDWARFEncoding(Val)));
|
||||||
|
else
|
||||||
|
Asm->OutStreamer.AddComment(Twine("Encoding = ") +
|
||||||
|
DecodeDWARFEncoding(Val));
|
||||||
|
}
|
||||||
|
|
||||||
|
Asm->OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// PrintLabelName - Print label name in form used by Dwarf writer.
|
/// PrintLabelName - Print label name in form used by Dwarf writer.
|
||||||
///
|
///
|
||||||
void DwarfPrinter::PrintLabelName(const char *Tag, unsigned Number) const {
|
void DwarfPrinter::PrintLabelName(const char *Tag, unsigned Number) const {
|
||||||
|
|
|
@ -73,6 +73,7 @@ protected:
|
||||||
DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
|
DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
|
||||||
const char *flavor);
|
const char *flavor);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
// Accessors.
|
// Accessors.
|
||||||
//
|
//
|
||||||
|
@ -84,6 +85,12 @@ public:
|
||||||
void PrintRelDirective(bool Force32Bit = false,
|
void PrintRelDirective(bool Force32Bit = false,
|
||||||
bool isInSection = false) const;
|
bool isInSection = false) const;
|
||||||
|
|
||||||
|
/// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an
|
||||||
|
/// encoding. If verbose assembly output is enabled, we output comments
|
||||||
|
/// describing the encoding. Desc is an optional string saying what the
|
||||||
|
/// encoding is specifying (e.g. "LSDA").
|
||||||
|
void EmitEncodingByte(unsigned Val, const char *Desc = 0);
|
||||||
|
|
||||||
|
|
||||||
/// PrintLabelName - Print label name in form used by Dwarf writer.
|
/// PrintLabelName - Print label name in form used by Dwarf writer.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue