mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
llvm-objdump: speed up -objc-meta-data
Running a Debug build of objdump -objc-meta-data with a large Mach-O file is currently unnecessarily slow. With some local test input, this change reduces the run time from 75-85s down to 15-20s. The two changes are: Assert on pointer equality not array equality Replace vector<pair<address, symbol>> with DenseMap<address, symbol> Additionally, use a std::unique_ptr rather than handling the memory manually. Patch by Dave Lee! llvm-svn: 291398
This commit is contained in:
parent
c49cd81d27
commit
146e18fe42
@ -2823,7 +2823,11 @@ StringRef MachORebaseEntry::typeName() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MachORebaseEntry::operator==(const MachORebaseEntry &Other) const {
|
bool MachORebaseEntry::operator==(const MachORebaseEntry &Other) const {
|
||||||
|
#ifdef EXPENSIVE_CHECKS
|
||||||
assert(Opcodes == Other.Opcodes && "compare iterators of different files");
|
assert(Opcodes == Other.Opcodes && "compare iterators of different files");
|
||||||
|
#else
|
||||||
|
assert(Opcodes.data() == Other.Opcodes.data() && "compare iterators of different files");
|
||||||
|
#endif
|
||||||
return (Ptr == Other.Ptr) &&
|
return (Ptr == Other.Ptr) &&
|
||||||
(RemainingLoopCount == Other.RemainingLoopCount) &&
|
(RemainingLoopCount == Other.RemainingLoopCount) &&
|
||||||
(Done == Other.Done);
|
(Done == Other.Done);
|
||||||
@ -3073,7 +3077,11 @@ uint32_t MachOBindEntry::flags() const { return Flags; }
|
|||||||
int MachOBindEntry::ordinal() const { return Ordinal; }
|
int MachOBindEntry::ordinal() const { return Ordinal; }
|
||||||
|
|
||||||
bool MachOBindEntry::operator==(const MachOBindEntry &Other) const {
|
bool MachOBindEntry::operator==(const MachOBindEntry &Other) const {
|
||||||
|
#ifdef EXPENSIVE_CHECKS
|
||||||
assert(Opcodes == Other.Opcodes && "compare iterators of different files");
|
assert(Opcodes == Other.Opcodes && "compare iterators of different files");
|
||||||
|
#else
|
||||||
|
assert(Opcodes.data() == Other.Opcodes.data() && "compare iterators of different files");
|
||||||
|
#endif
|
||||||
return (Ptr == Other.Ptr) &&
|
return (Ptr == Other.Ptr) &&
|
||||||
(RemainingLoopCount == Other.RemainingLoopCount) &&
|
(RemainingLoopCount == Other.RemainingLoopCount) &&
|
||||||
(Done == Other.Done);
|
(Done == Other.Done);
|
||||||
|
@ -1780,10 +1780,6 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
|||||||
llvm_unreachable("Input object can't be invalid at this point");
|
llvm_unreachable("Input object can't be invalid at this point");
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::pair<uint64_t, const char *> BindInfoEntry;
|
|
||||||
typedef std::vector<BindInfoEntry> BindTable;
|
|
||||||
typedef BindTable::iterator bind_table_iterator;
|
|
||||||
|
|
||||||
// The block of info used by the Symbolizer call backs.
|
// The block of info used by the Symbolizer call backs.
|
||||||
struct DisassembleInfo {
|
struct DisassembleInfo {
|
||||||
bool verbose;
|
bool verbose;
|
||||||
@ -1797,7 +1793,7 @@ struct DisassembleInfo {
|
|||||||
char *demangled_name;
|
char *demangled_name;
|
||||||
uint64_t adrp_addr;
|
uint64_t adrp_addr;
|
||||||
uint32_t adrp_inst;
|
uint32_t adrp_inst;
|
||||||
BindTable *bindtable;
|
std::unique_ptr<SymbolAddressMap> bindtable;
|
||||||
uint32_t depth;
|
uint32_t depth;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -5311,9 +5307,6 @@ static void printObjc2_64bit_MetaData(MachOObjectFile *O, bool verbose) {
|
|||||||
II = get_section(O, "__DATA", "__objc_imageinfo");
|
II = get_section(O, "__DATA", "__objc_imageinfo");
|
||||||
info.S = II;
|
info.S = II;
|
||||||
print_image_info64(II, &info);
|
print_image_info64(II, &info);
|
||||||
|
|
||||||
if (info.bindtable != nullptr)
|
|
||||||
delete info.bindtable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printObjc2_32bit_MetaData(MachOObjectFile *O, bool verbose) {
|
static void printObjc2_32bit_MetaData(MachOObjectFile *O, bool verbose) {
|
||||||
@ -6841,14 +6834,10 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
|
|||||||
free(SymbolizerInfo.method);
|
free(SymbolizerInfo.method);
|
||||||
if (SymbolizerInfo.demangled_name != nullptr)
|
if (SymbolizerInfo.demangled_name != nullptr)
|
||||||
free(SymbolizerInfo.demangled_name);
|
free(SymbolizerInfo.demangled_name);
|
||||||
if (SymbolizerInfo.bindtable != nullptr)
|
|
||||||
delete SymbolizerInfo.bindtable;
|
|
||||||
if (ThumbSymbolizerInfo.method != nullptr)
|
if (ThumbSymbolizerInfo.method != nullptr)
|
||||||
free(ThumbSymbolizerInfo.method);
|
free(ThumbSymbolizerInfo.method);
|
||||||
if (ThumbSymbolizerInfo.demangled_name != nullptr)
|
if (ThumbSymbolizerInfo.demangled_name != nullptr)
|
||||||
free(ThumbSymbolizerInfo.demangled_name);
|
free(ThumbSymbolizerInfo.demangled_name);
|
||||||
if (ThumbSymbolizerInfo.bindtable != nullptr)
|
|
||||||
delete ThumbSymbolizerInfo.bindtable;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9427,7 +9416,7 @@ void llvm::printMachOWeakBindTable(const object::MachOObjectFile *Obj) {
|
|||||||
static const char *get_dyld_bind_info_symbolname(uint64_t ReferenceValue,
|
static const char *get_dyld_bind_info_symbolname(uint64_t ReferenceValue,
|
||||||
struct DisassembleInfo *info) {
|
struct DisassembleInfo *info) {
|
||||||
if (info->bindtable == nullptr) {
|
if (info->bindtable == nullptr) {
|
||||||
info->bindtable = new (BindTable);
|
info->bindtable = llvm::make_unique<SymbolAddressMap>();
|
||||||
SegInfo sectionTable(info->O);
|
SegInfo sectionTable(info->O);
|
||||||
for (const llvm::object::MachOBindEntry &Entry : info->O->bindTable()) {
|
for (const llvm::object::MachOBindEntry &Entry : info->O->bindTable()) {
|
||||||
uint32_t SegIndex = Entry.segmentIndex();
|
uint32_t SegIndex = Entry.segmentIndex();
|
||||||
@ -9435,21 +9424,11 @@ static const char *get_dyld_bind_info_symbolname(uint64_t ReferenceValue,
|
|||||||
if (!sectionTable.isValidSegIndexAndOffset(SegIndex, OffsetInSeg))
|
if (!sectionTable.isValidSegIndexAndOffset(SegIndex, OffsetInSeg))
|
||||||
continue;
|
continue;
|
||||||
uint64_t Address = sectionTable.address(SegIndex, OffsetInSeg);
|
uint64_t Address = sectionTable.address(SegIndex, OffsetInSeg);
|
||||||
const char *SymbolName = nullptr;
|
|
||||||
StringRef name = Entry.symbolName();
|
StringRef name = Entry.symbolName();
|
||||||
if (!name.empty())
|
if (!name.empty())
|
||||||
SymbolName = name.data();
|
(*info->bindtable)[Address] = name;
|
||||||
info->bindtable->push_back(std::make_pair(Address, SymbolName));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (bind_table_iterator BI = info->bindtable->begin(),
|
auto name = info->bindtable->lookup(ReferenceValue);
|
||||||
BE = info->bindtable->end();
|
return !name.empty() ? name.data() : nullptr;
|
||||||
BI != BE; ++BI) {
|
|
||||||
uint64_t Address = BI->first;
|
|
||||||
if (ReferenceValue == Address) {
|
|
||||||
const char *SymbolName = BI->second;
|
|
||||||
return SymbolName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user