summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/Dwarf2BTF.cpp280
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/Dwarf2BTF.h16
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfFile.h4
-rw-r--r--llvm/lib/MC/MCBTFContext.cpp48
-rw-r--r--llvm/lib/MC/MCDwarf2BTF.cpp17
-rw-r--r--llvm/lib/MC/MCDwarf2BTF.h11
6 files changed, 184 insertions, 192 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/Dwarf2BTF.cpp b/llvm/lib/CodeGen/AsmPrinter/Dwarf2BTF.cpp
index 8b16e389963..44484c2ae05 100644
--- a/llvm/lib/CodeGen/AsmPrinter/Dwarf2BTF.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/Dwarf2BTF.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "DwarfUnit.h"
#include "Dwarf2BTF.h"
+#include "DwarfUnit.h"
#include "llvm/MC/MCBTFContext.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSectionELF.h"
@@ -17,47 +17,47 @@ namespace llvm {
Die2BTFEntry::~Die2BTFEntry() {}
-unsigned char Die2BTFEntry::getDieKind(const DIE & Die) {
+unsigned char Die2BTFEntry::getDieKind(const DIE &Die) {
auto Tag = Die.getTag();
switch (Tag) {
- case dwarf::DW_TAG_base_type:
- if (getBaseTypeEncoding(Die) == BTF_INVALID_ENCODING)
- return BTF_KIND_UNKN;
- return BTF_KIND_INT;
- case dwarf::DW_TAG_const_type:
- return BTF_KIND_CONST;
- case dwarf::DW_TAG_pointer_type:
- return BTF_KIND_PTR;
- case dwarf::DW_TAG_restrict_type:
- return BTF_KIND_RESTRICT;
- case dwarf::DW_TAG_volatile_type:
- return BTF_KIND_VOLATILE;
- case dwarf::DW_TAG_typedef:
- return BTF_KIND_TYPEDEF;
- case dwarf::DW_TAG_structure_type:
- case dwarf::DW_TAG_class_type:
- if (Die.findAttribute(dwarf::DW_AT_declaration).getType()
- != DIEValue::isNone)
- return BTF_KIND_FWD;
- else
- return BTF_KIND_STRUCT;
- case dwarf::DW_TAG_union_type:
- if (Die.findAttribute(dwarf::DW_AT_declaration).getType()
- != DIEValue::isNone)
- return BTF_KIND_FWD;
- else
- return BTF_KIND_UNION;
- case dwarf::DW_TAG_enumeration_type:
- return BTF_KIND_ENUM;
- case dwarf::DW_TAG_array_type:
- return BTF_KIND_ARRAY;
- case dwarf::DW_TAG_subprogram:
- return BTF_KIND_FUNC;
- case dwarf::DW_TAG_subroutine_type:
- return BTF_KIND_FUNC_PROTO;
- default:
- break;
+ case dwarf::DW_TAG_base_type:
+ if (getBaseTypeEncoding(Die) == BTF_INVALID_ENCODING)
+ return BTF_KIND_UNKN;
+ return BTF_KIND_INT;
+ case dwarf::DW_TAG_const_type:
+ return BTF_KIND_CONST;
+ case dwarf::DW_TAG_pointer_type:
+ return BTF_KIND_PTR;
+ case dwarf::DW_TAG_restrict_type:
+ return BTF_KIND_RESTRICT;
+ case dwarf::DW_TAG_volatile_type:
+ return BTF_KIND_VOLATILE;
+ case dwarf::DW_TAG_typedef:
+ return BTF_KIND_TYPEDEF;
+ case dwarf::DW_TAG_structure_type:
+ case dwarf::DW_TAG_class_type:
+ if (Die.findAttribute(dwarf::DW_AT_declaration).getType() !=
+ DIEValue::isNone)
+ return BTF_KIND_FWD;
+ else
+ return BTF_KIND_STRUCT;
+ case dwarf::DW_TAG_union_type:
+ if (Die.findAttribute(dwarf::DW_AT_declaration).getType() !=
+ DIEValue::isNone)
+ return BTF_KIND_FWD;
+ else
+ return BTF_KIND_UNION;
+ case dwarf::DW_TAG_enumeration_type:
+ return BTF_KIND_ENUM;
+ case dwarf::DW_TAG_array_type:
+ return BTF_KIND_ARRAY;
+ case dwarf::DW_TAG_subprogram:
+ return BTF_KIND_FUNC;
+ case dwarf::DW_TAG_subroutine_type:
+ return BTF_KIND_FUNC_PROTO;
+ default:
+ break;
}
return BTF_KIND_UNKN;
@@ -67,27 +67,27 @@ std::unique_ptr<Die2BTFEntry> Die2BTFEntry::dieToBTFTypeEntry(const DIE &Die) {
unsigned char Kind = getDieKind(Die);
switch (Kind) {
- case BTF_KIND_INT:
- return make_unique<Die2BTFEntryInt>(Die);
- case BTF_KIND_PTR:
- case BTF_KIND_TYPEDEF:
- case BTF_KIND_VOLATILE:
- case BTF_KIND_CONST:
- case BTF_KIND_RESTRICT:
- case BTF_KIND_FWD:
- return make_unique<Die2BTFEntry>(Die);
- case BTF_KIND_ARRAY:
- return make_unique<Die2BTFEntryArray>(Die);
- case BTF_KIND_STRUCT:
- case BTF_KIND_UNION:
- return make_unique<Die2BTFEntryStruct>(Die);
- case BTF_KIND_ENUM:
- return make_unique<Die2BTFEntryEnum>(Die);
- case BTF_KIND_FUNC:
- case BTF_KIND_FUNC_PROTO:
- return make_unique<Die2BTFEntryFunc>(Die);
- default:
- break;
+ case BTF_KIND_INT:
+ return make_unique<Die2BTFEntryInt>(Die);
+ case BTF_KIND_PTR:
+ case BTF_KIND_TYPEDEF:
+ case BTF_KIND_VOLATILE:
+ case BTF_KIND_CONST:
+ case BTF_KIND_RESTRICT:
+ case BTF_KIND_FWD:
+ return make_unique<Die2BTFEntry>(Die);
+ case BTF_KIND_ARRAY:
+ return make_unique<Die2BTFEntryArray>(Die);
+ case BTF_KIND_STRUCT:
+ case BTF_KIND_UNION:
+ return make_unique<Die2BTFEntryStruct>(Die);
+ case BTF_KIND_ENUM:
+ return make_unique<Die2BTFEntryEnum>(Die);
+ case BTF_KIND_FUNC:
+ case BTF_KIND_FUNC_PROTO:
+ return make_unique<Die2BTFEntryFunc>(Die);
+ default:
+ break;
}
return nullptr;
}
@@ -96,20 +96,19 @@ bool Die2BTFEntry::shouldSkipDie(const DIE &Die) {
auto Tag = Die.getTag();
switch (Tag) {
- case dwarf::DW_TAG_const_type:
- case dwarf::DW_TAG_pointer_type:
- case dwarf::DW_TAG_restrict_type:
- case dwarf::DW_TAG_typedef:
- case dwarf::DW_TAG_volatile_type:
- {
- auto TypeV = Die.findAttribute(dwarf::DW_AT_type);
- if (TypeV.getType() == DIEValue::isNone)
- return false;
- auto &TypeDie = TypeV.getDIEEntry().getEntry();
- return Die2BTFEntry::shouldSkipDie(TypeDie);
- }
- default:
- return getDieKind(Die) == BTF_KIND_UNKN;
+ case dwarf::DW_TAG_const_type:
+ case dwarf::DW_TAG_pointer_type:
+ case dwarf::DW_TAG_restrict_type:
+ case dwarf::DW_TAG_typedef:
+ case dwarf::DW_TAG_volatile_type: {
+ auto TypeV = Die.findAttribute(dwarf::DW_AT_type);
+ if (TypeV.getType() == DIEValue::isNone)
+ return false;
+ auto &TypeDie = TypeV.getDIEEntry().getEntry();
+ return Die2BTFEntry::shouldSkipDie(TypeDie);
+ }
+ default:
+ return getDieKind(Die) == BTF_KIND_UNKN;
}
return true;
}
@@ -120,26 +119,26 @@ unsigned char Die2BTFEntry::getBaseTypeEncoding(const DIE &Die) {
return BTF_INVALID_ENCODING;
switch (V.getDIEInteger().getValue()) {
- case dwarf::DW_ATE_boolean:
- return BTF_INT_BOOL;
- case dwarf::DW_ATE_signed:
- return BTF_INT_SIGNED;
- case dwarf::DW_ATE_signed_char:
- return BTF_INT_CHAR;
- case dwarf::DW_ATE_unsigned:
- return 0;
- case dwarf::DW_ATE_unsigned_char:
- return BTF_INT_CHAR;
- case dwarf::DW_ATE_imaginary_float:
- case dwarf::DW_ATE_packed_decimal:
- case dwarf::DW_ATE_numeric_string:
- case dwarf::DW_ATE_edited:
- case dwarf::DW_ATE_signed_fixed:
- case dwarf::DW_ATE_address:
- case dwarf::DW_ATE_complex_float:
- case dwarf::DW_ATE_float:
- default:
- break;
+ case dwarf::DW_ATE_boolean:
+ return BTF_INT_BOOL;
+ case dwarf::DW_ATE_signed:
+ return BTF_INT_SIGNED;
+ case dwarf::DW_ATE_signed_char:
+ return BTF_INT_CHAR;
+ case dwarf::DW_ATE_unsigned:
+ return 0;
+ case dwarf::DW_ATE_unsigned_char:
+ return BTF_INT_CHAR;
+ case dwarf::DW_ATE_imaginary_float:
+ case dwarf::DW_ATE_packed_decimal:
+ case dwarf::DW_ATE_numeric_string:
+ case dwarf::DW_ATE_edited:
+ case dwarf::DW_ATE_signed_fixed:
+ case dwarf::DW_ATE_address:
+ case dwarf::DW_ATE_complex_float:
+ case dwarf::DW_ATE_float:
+ default:
+ break;
}
return BTF_INVALID_ENCODING;
}
@@ -148,53 +147,53 @@ Die2BTFEntry::Die2BTFEntry(const DIE &Die) : Die(Die) {
unsigned char Kind = getDieKind(Die);
switch (Kind) {
- case BTF_KIND_CONST:
- case BTF_KIND_FWD:
- case BTF_KIND_PTR:
- case BTF_KIND_RESTRICT:
- case BTF_KIND_TYPEDEF:
- case BTF_KIND_VOLATILE:
- break;
- default:
- assert("Invalid Die passed into BTFTypeEntry()");
- break;
+ case BTF_KIND_CONST:
+ case BTF_KIND_FWD:
+ case BTF_KIND_PTR:
+ case BTF_KIND_RESTRICT:
+ case BTF_KIND_TYPEDEF:
+ case BTF_KIND_VOLATILE:
+ break;
+ default:
+ assert("Invalid Die passed into BTFTypeEntry()");
+ break;
}
BTFType.info = (Kind & 0xf) << 24;
}
void Die2BTFEntry::completeData(class Dwarf2BTF &Dwarf2BTF) {
- auto TypeV = Die.findAttribute(dwarf::DW_AT_type);
- if (TypeV.getType() == DIEValue::isNone) {
- BTFType.type = 0;
- } else {
- auto &TypeDie = TypeV.getDIEEntry().getEntry();
- auto Type = Dwarf2BTF.getTypeIndex(TypeDie);
- BTFType.type = Type;
- }
+ auto TypeV = Die.findAttribute(dwarf::DW_AT_type);
+ if (TypeV.getType() == DIEValue::isNone) {
+ BTFType.type = 0;
+ } else {
+ auto &TypeDie = TypeV.getDIEEntry().getEntry();
+ auto Type = Dwarf2BTF.getTypeIndex(TypeDie);
+ BTFType.type = Type;
+ }
- unsigned char Kind = getDieKind(Die);
- if (Kind != BTF_KIND_FWD) {
- BTFType.name_off = 0;
- } else {
- auto NameV = Die.findAttribute(dwarf::DW_AT_name);
- auto Str = NameV.getDIEString().getString();
- BTFType.name_off = Dwarf2BTF.addBTFString(Str);
- }
+ unsigned char Kind = getDieKind(Die);
+ if (Kind != BTF_KIND_FWD) {
+ BTFType.name_off = 0;
+ } else {
+ auto NameV = Die.findAttribute(dwarf::DW_AT_name);
+ auto Str = NameV.getDIEString().getString();
+ BTFType.name_off = Dwarf2BTF.addBTFString(Str);
+ }
- auto typeEntry = make_unique<BTFTypeEntry>(Id, BTFType);
- Dwarf2BTF.addBTFTypeEntry(std::move(typeEntry));
+ auto typeEntry = make_unique<BTFTypeEntry>(Id, BTFType);
+ Dwarf2BTF.addBTFTypeEntry(std::move(typeEntry));
}
Die2BTFEntryInt::Die2BTFEntryInt(const DIE &Die) : Die2BTFEntry(Die) {
unsigned char Kind = getDieKind(Die);
switch (Kind) {
- case BTF_KIND_INT:
- break;
- default:
- assert("Invalid Die passed into BTFTypeEntryInt()");
- break;
+ case BTF_KIND_INT:
+ break;
+ default:
+ assert("Invalid Die passed into BTFTypeEntryInt()");
+ break;
}
// handle BTF_INT_ENCODING in IntVal
@@ -212,7 +211,7 @@ Die2BTFEntryInt::Die2BTFEntryInt(const DIE &Die) : Die2BTFEntry(Die) {
V = Die.findAttribute(dwarf::DW_AT_byte_size);
__u32 Size = V.getDIEInteger().getValue() & 0xffffffff;
-// handle BTF_INT_BITS in IntVal
+ // handle BTF_INT_BITS in IntVal
V = Die.findAttribute(dwarf::DW_AT_bit_size);
if (V.getType() == DIEValue::isInteger)
IntVal |= V.getDIEInteger().getValue() & 0xff;
@@ -225,14 +224,14 @@ Die2BTFEntryInt::Die2BTFEntryInt(const DIE &Die) : Die2BTFEntry(Die) {
}
void Die2BTFEntryInt::completeData(class Dwarf2BTF &Dwarf2BTF) {
- auto NameV = Die.findAttribute(dwarf::DW_AT_name);
- auto TypeV = Die.findAttribute(dwarf::DW_AT_type);
- auto Str = NameV.getDIEString().getString();
+ auto NameV = Die.findAttribute(dwarf::DW_AT_name);
+ auto TypeV = Die.findAttribute(dwarf::DW_AT_type);
+ auto Str = NameV.getDIEString().getString();
- BTFType.name_off = Dwarf2BTF.addBTFString(Str);
+ BTFType.name_off = Dwarf2BTF.addBTFString(Str);
- auto typeEntry = make_unique<BTFTypeEntryInt>(Id, BTFType, IntVal);
- Dwarf2BTF.addBTFTypeEntry(std::move(typeEntry));
+ auto typeEntry = make_unique<BTFTypeEntryInt>(Id, BTFType, IntVal);
+ Dwarf2BTF.addBTFTypeEntry(std::move(typeEntry));
}
Die2BTFEntryEnum::Die2BTFEntryEnum(const DIE &Die) : Die2BTFEntry(Die) {
@@ -275,8 +274,7 @@ void Die2BTFEntryEnum::completeData(class Dwarf2BTF &Dwarf2BTF) {
Dwarf2BTF.addBTFTypeEntry(std::move(typeEntry));
}
-Die2BTFEntryArray::Die2BTFEntryArray(const DIE &Die) :
- Die2BTFEntry(Die) {
+Die2BTFEntryArray::Die2BTFEntryArray(const DIE &Die) : Die2BTFEntry(Die) {
BTFType.info = (BTF_KIND_ARRAY << 24);
BTFType.size = 0;
}
@@ -289,7 +287,8 @@ void Die2BTFEntryArray::completeData(class Dwarf2BTF &Dwarf2BTF) {
Str = NameV.getDIEString().getString();
BTFType.name_off = Dwarf2BTF.addBTFString(Str);
- auto &ArrayTypeDie = Die.findAttribute(dwarf::DW_AT_type).getDIEEntry().getEntry();
+ auto &ArrayTypeDie =
+ Die.findAttribute(dwarf::DW_AT_type).getDIEEntry().getEntry();
ArrayInfo.type = Dwarf2BTF.getTypeIndex(ArrayTypeDie);
// The number of elements should count all subranges
@@ -342,7 +341,6 @@ void Die2BTFEntryStruct::completeData(class Dwarf2BTF &Dwarf2BTF) {
} else
BTFType.name_off = 0;
-
for (auto &ChildDie : Die.children()) {
if (ChildDie.getTag() != dwarf::DW_TAG_member)
continue;
@@ -456,7 +454,7 @@ void Die2BTFEntryFunc::completeData(class Dwarf2BTF &Dwarf2BTF) {
}
Dwarf2BTF::Dwarf2BTF(MCContext &Context, bool IsLittleEndian)
- : OuterCtx(Context), IsLE(IsLittleEndian) {
+ : OuterCtx(Context), IsLE(IsLittleEndian) {
BTFContext = make_unique<MCBTFContext>();
}
@@ -470,7 +468,7 @@ void Dwarf2BTF::addTypeEntry(const DIE &Die) {
auto TypeEntry = Die2BTFEntry::dieToBTFTypeEntry(Die);
if (TypeEntry != nullptr) {
TypeEntry->setId(TypeEntries.size() + 1);
- DieToIdMap[const_cast<DIE*>(&Die)] = TypeEntry->getId();
+ DieToIdMap[const_cast<DIE *>(&Die)] = TypeEntry->getId();
TypeEntries.push_back(std::move(TypeEntry));
}
}
@@ -500,4 +498,4 @@ void Dwarf2BTF::finish() {
OuterCtx.setBTFContext(std::move(BTFContext));
}
-}
+} // namespace llvm
diff --git a/llvm/lib/CodeGen/AsmPrinter/Dwarf2BTF.h b/llvm/lib/CodeGen/AsmPrinter/Dwarf2BTF.h
index 125441d37b3..a472d68ed7e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/Dwarf2BTF.h
+++ b/llvm/lib/CodeGen/AsmPrinter/Dwarf2BTF.h
@@ -26,7 +26,7 @@ class MCBTFContext;
class Die2BTFEntry {
protected:
const DIE &Die;
- size_t Id; /* type index in the BTF list, started from 1 */
+ size_t Id; /* type index in the BTF list, started from 1 */
struct btf_type BTFType;
public:
@@ -54,7 +54,7 @@ public:
// BTF_KIND_INT
class Die2BTFEntryInt : public Die2BTFEntry {
- __u32 IntVal; // encoding, offset, bits
+ __u32 IntVal; // encoding, offset, bits
public:
Die2BTFEntryInt(const DIE &Die);
@@ -99,7 +99,7 @@ public:
class Dwarf2BTF {
std::vector<std::unique_ptr<Die2BTFEntry>> TypeEntries;
- std::map<DIE*, size_t> DieToIdMap;
+ std::map<DIE *, size_t> DieToIdMap;
std::unique_ptr<MCBTFContext> BTFContext;
MCContext &OuterCtx;
bool IsLE;
@@ -110,14 +110,12 @@ public:
void addDwarfCU(DwarfUnit *TheU);
void finish();
__u32 getTypeIndex(DIE &Die) {
- DIE *DiePtr = const_cast<DIE*>(&Die);
+ DIE *DiePtr = const_cast<DIE *>(&Die);
assert((DieToIdMap.find(DiePtr) != DieToIdMap.end()) &&
"Die not added to in the BTFContext");
return DieToIdMap[DiePtr];
}
- size_t addBTFString(std::string S) {
- return BTFContext->addString(S);
- }
+ size_t addBTFString(std::string S) { return BTFContext->addString(S); }
void addBTFTypeEntry(std::unique_ptr<BTFTypeEntry> Entry);
void addBTFFuncInfo(unsigned SecNameOff, BTFFuncInfo FuncInfo) {
BTFContext->addFuncInfo(SecNameOff, FuncInfo);
@@ -126,10 +124,10 @@ public:
private:
void addTypeEntry(const DIE &Die);
bool alreadyAdded(DIE &Die) {
- return DieToIdMap.find(const_cast<DIE*>(&Die)) != DieToIdMap.end();
+ return DieToIdMap.find(const_cast<DIE *>(&Die)) != DieToIdMap.end();
}
void completeData();
};
-}
+} // namespace llvm
#endif
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
index 9aafe2613f6..114f98f725d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
@@ -137,9 +137,7 @@ public:
return ScopeVariables;
}
- DenseMap<LexicalScope *, LabelList> &getScopeLabels() {
- return ScopeLabels;
- }
+ DenseMap<LexicalScope *, LabelList> &getScopeLabels() { return ScopeLabels; }
DenseMap<const MDNode *, DIE *> &getAbstractSPDies() {
return AbstractSPDies;
diff --git a/llvm/lib/MC/MCBTFContext.cpp b/llvm/lib/MC/MCBTFContext.cpp
index d1c30dd0b88..cb121c41552 100644
--- a/llvm/lib/MC/MCBTFContext.cpp
+++ b/llvm/lib/MC/MCBTFContext.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCBTFContext.h"
+#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCObjectStreamer.h"
#include <cstdlib>
@@ -22,7 +22,7 @@ using namespace llvm;
BTFTypeEntry::~BTFTypeEntry() {}
void MCBTFContext::addTypeEntry(std::unique_ptr<BTFTypeEntry> Entry) {
- TypeEntries.push_back(std::move(Entry));
+ TypeEntries.push_back(std::move(Entry));
}
void MCBTFContext::dump(raw_ostream &OS) {
@@ -39,8 +39,7 @@ void MCBTFContext::dump(raw_ostream &OS) {
for (auto &FuncSec : FuncInfoTable) {
OS << "sec_name_off=" << FuncSec.first << "\n";
for (auto &FuncInfo : FuncSec.second) {
- OS << "\tinsn_offset=<Omitted> type_id="
- << FuncInfo.TypeId << "\n";
+ OS << "\tinsn_offset=<Omitted> type_id=" << FuncInfo.TypeId << "\n";
}
}
@@ -48,12 +47,9 @@ void MCBTFContext::dump(raw_ostream &OS) {
for (auto &LineSec : LineInfoTable) {
OS << "sec_name_off=" << LineSec.first << "\n";
for (auto &LineInfo : LineSec.second) {
- OS << "\tinsn_offset=<Omitted> file_name_off="
- << LineInfo.FileNameOff
- << " line_off=" << LineInfo.LineOff
- << " line_num=" << LineInfo.LineNum
- << " column_num=" << LineInfo.ColumnNum
- << "\n";
+ OS << "\tinsn_offset=<Omitted> file_name_off=" << LineInfo.FileNameOff
+ << " line_off=" << LineInfo.LineOff << " line_num=" << LineInfo.LineNum
+ << " column_num=" << LineInfo.ColumnNum << "\n";
}
}
}
@@ -83,7 +79,7 @@ void MCBTFContext::emitBTFSection(MCObjectStreamer *MCOS) {
MCOS->EmitIntValue(str_len, 4);
// emit type table
- for (auto &TypeEntry: TypeEntries)
+ for (auto &TypeEntry : TypeEntries)
TypeEntry->emitData(MCOS);
// emit string table
@@ -146,9 +142,8 @@ void MCBTFContext::emitAll(MCObjectStreamer *MCOS) {
emitBTFExtSection(MCOS);
}
-void BTFTypeEntry::print(raw_ostream &OS, MCBTFContext& MCBTFContext) {
- OS << "[" << Id << "] "
- << btf_kind_str[BTF_INFO_KIND(BTFType.info)]
+void BTFTypeEntry::print(raw_ostream &OS, MCBTFContext &MCBTFContext) {
+ OS << "[" << Id << "] " << btf_kind_str[BTF_INFO_KIND(BTFType.info)]
<< " name_off=" << BTFType.name_off
<< " info=" << format("0x%08lx", BTFType.info)
<< " size/type=" << BTFType.size << "\n";
@@ -160,7 +155,7 @@ void BTFTypeEntry::emitData(MCObjectStreamer *MCOS) {
MCOS->EmitIntValue(BTFType.size, 4);
}
-void BTFTypeEntryInt::print(raw_ostream &OS, MCBTFContext& MCBTFContext) {
+void BTFTypeEntryInt::print(raw_ostream &OS, MCBTFContext &MCBTFContext) {
BTFTypeEntry::print(OS, MCBTFContext);
OS << "\tdesc=" << format("0x%08lx", IntVal) << "\n";
}
@@ -170,12 +165,12 @@ void BTFTypeEntryInt::emitData(MCObjectStreamer *MCOS) {
MCOS->EmitIntValue(IntVal, 4);
}
-void BTFTypeEntryEnum::print(raw_ostream &OS, MCBTFContext& MCBTFContext) {
- BTFTypeEntry::print(OS, MCBTFContext);
+void BTFTypeEntryEnum::print(raw_ostream &OS, MCBTFContext &MCBTFContext) {
+ BTFTypeEntry::print(OS, MCBTFContext);
for (size_t i = 0; i < BTF_INFO_VLEN(BTFType.info); i++) {
auto &EnumValue = EnumValues[i];
- OS << "\tname_off=" << EnumValue.name_off
- << " value=" << EnumValue.val << "\n";
+ OS << "\tname_off=" << EnumValue.name_off << " value=" << EnumValue.val
+ << "\n";
}
}
@@ -187,7 +182,7 @@ void BTFTypeEntryEnum::emitData(MCObjectStreamer *MCOS) {
}
}
-void BTFTypeEntryArray::print(raw_ostream &OS, MCBTFContext& MCBTFContext) {
+void BTFTypeEntryArray::print(raw_ostream &OS, MCBTFContext &MCBTFContext) {
BTFTypeEntry::print(OS, MCBTFContext);
OS << "\telem_type=" << format("0x%08lx", ArrayInfo.type)
<< " index_type=" << format("0x%08lx", ArrayInfo.index_type)
@@ -201,12 +196,11 @@ void BTFTypeEntryArray::emitData(MCObjectStreamer *MCOS) {
MCOS->EmitIntValue(ArrayInfo.nelems, 4);
}
-void BTFTypeEntryStruct::print(raw_ostream &OS, MCBTFContext& MCBTFContext) {
+void BTFTypeEntryStruct::print(raw_ostream &OS, MCBTFContext &MCBTFContext) {
BTFTypeEntry::print(OS, MCBTFContext);
- for (size_t i = 0; i < BTF_INFO_VLEN(BTFType.info); i++) {
+ for (size_t i = 0; i < BTF_INFO_VLEN(BTFType.info); i++) {
auto &Member = Members[i];
- OS << "\tname_off=" << Member.name_off
- << " type=" << Member.type
+ OS << "\tname_off=" << Member.name_off << " type=" << Member.type
<< " bit_offset=" << Member.offset << "\n";
}
}
@@ -220,9 +214,9 @@ void BTFTypeEntryStruct::emitData(MCObjectStreamer *MCOS) {
}
}
-void BTFTypeEntryFunc::print(raw_ostream &OS, MCBTFContext& MCBTFContext) {
+void BTFTypeEntryFunc::print(raw_ostream &OS, MCBTFContext &MCBTFContext) {
BTFTypeEntry::print(OS, MCBTFContext);
- for (size_t i = 0; i < BTF_INFO_VLEN(BTFType.info); i++) {
+ for (size_t i = 0; i < BTF_INFO_VLEN(BTFType.info); i++) {
auto Parameter = Parameters[i];
OS << "\tparam_type=" << Parameter << "\n";
}
@@ -230,6 +224,6 @@ void BTFTypeEntryFunc::print(raw_ostream &OS, MCBTFContext& MCBTFContext) {
void BTFTypeEntryFunc::emitData(MCObjectStreamer *MCOS) {
BTFTypeEntry::emitData(MCOS);
- for (auto &Parameter: Parameters)
+ for (auto &Parameter : Parameters)
MCOS->EmitIntValue(Parameter, 4);
}
diff --git a/llvm/lib/MC/MCDwarf2BTF.cpp b/llvm/lib/MC/MCDwarf2BTF.cpp
index 08a70e6f318..9809a2153ec 100644
--- a/llvm/lib/MC/MCDwarf2BTF.cpp
+++ b/llvm/lib/MC/MCDwarf2BTF.cpp
@@ -10,11 +10,11 @@
#include "MCDwarf2BTF.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCBTFContext.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCObjectStreamer.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSectionELF.h"
-#include "llvm/MC/MCBTFContext.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/EndianStream.h"
#include <fstream>
@@ -22,7 +22,7 @@
using namespace llvm;
void MCDwarf2BTF::addFiles(MCObjectStreamer *MCOS, std::string &FileName,
- std::vector<FileContent> &Files) {
+ std::vector<FileContent> &Files) {
std::vector<std::string> Content;
std::ifstream Inputfile(FileName);
@@ -34,9 +34,10 @@ void MCDwarf2BTF::addFiles(MCObjectStreamer *MCOS, std::string &FileName,
Files.push_back(FileContent(FileName, Content));
}
-void MCDwarf2BTF::addLines(MCObjectStreamer *MCOS, StringRef &SectionName,
- std::vector<FileContent> &Files,
- const MCLineSection::MCDwarfLineEntryCollection &LineEntries) {
+void MCDwarf2BTF::addLines(
+ MCObjectStreamer *MCOS, StringRef &SectionName,
+ std::vector<FileContent> &Files,
+ const MCLineSection::MCDwarfLineEntryCollection &LineEntries) {
MCContext &Context = MCOS->getContext();
auto &BTFCxt = Context.getBTFContext();
@@ -84,9 +85,11 @@ void MCDwarf2BTF::addDwarfLineInfo(MCObjectStreamer *MCOS) {
FileName = Dirs[File.DirIndex - 1] + "/" + File.Name;
MCDwarf2BTF::addFiles(MCOS, FileName, Files);
}
- for (const auto &LineSec: CUIDTablePair.second.getMCLineSections().getMCLineEntries()) {
+ for (const auto &LineSec :
+ CUIDTablePair.second.getMCLineSections().getMCLineEntries()) {
MCSection *Section = LineSec.first;
- const MCLineSection::MCDwarfLineEntryCollection &LineEntries = LineSec.second;
+ const MCLineSection::MCDwarfLineEntryCollection &LineEntries =
+ LineSec.second;
StringRef SectionName;
if (MCSectionELF *SectionELF = dyn_cast<MCSectionELF>(Section))
diff --git a/llvm/lib/MC/MCDwarf2BTF.h b/llvm/lib/MC/MCDwarf2BTF.h
index 22d1b7741a5..69983374a09 100644
--- a/llvm/lib/MC/MCDwarf2BTF.h
+++ b/llvm/lib/MC/MCDwarf2BTF.h
@@ -18,12 +18,13 @@ using FileContent = std::pair<std::string, std::vector<std::string>>;
class MCDwarf2BTF {
public:
static void addFiles(MCObjectStreamer *MCOS, std::string &FileName,
- std::vector<FileContent> &Files);
- static void addLines(MCObjectStreamer *MCOS, StringRef &SectionName,
- std::vector<FileContent> &Files,
- const MCLineSection::MCDwarfLineEntryCollection &LineEntries);
+ std::vector<FileContent> &Files);
+ static void
+ addLines(MCObjectStreamer *MCOS, StringRef &SectionName,
+ std::vector<FileContent> &Files,
+ const MCLineSection::MCDwarfLineEntryCollection &LineEntries);
static void addDwarfLineInfo(MCObjectStreamer *MCOS);
};
-}
+} // namespace llvm
#endif
OpenPOWER on IntegriCloud