[lldb][NFC] Early exit in IRExecutionUnit::GetStaticInitializers

This commit is contained in:
Raphael Isemann 2019-11-19 14:47:37 +01:00
parent b696b9dba7
commit c54d21c848
1 changed files with 27 additions and 23 deletions

View File

@ -977,33 +977,37 @@ IRExecutionUnit::FindSymbol(lldb_private::ConstString name, bool &missing_weak)
void IRExecutionUnit::GetStaticInitializers(
std::vector<lldb::addr_t> &static_initializers) {
if (llvm::GlobalVariable *global_ctors =
m_module->getNamedGlobal("llvm.global_ctors")) {
if (llvm::ConstantArray *ctor_array = llvm::dyn_cast<llvm::ConstantArray>(
global_ctors->getInitializer())) {
llvm::GlobalVariable *global_ctors =
m_module->getNamedGlobal("llvm.global_ctors");
if (!global_ctors)
return;
auto *ctor_array =
llvm::dyn_cast<llvm::ConstantArray>(global_ctors->getInitializer());
if (!ctor_array)
return;
for (llvm::Use &ctor_use : ctor_array->operands()) {
if (llvm::ConstantStruct *ctor_struct =
llvm::dyn_cast<llvm::ConstantStruct>(ctor_use)) {
lldbassert(ctor_struct->getNumOperands() ==
3); // this is standardized
if (llvm::Function *ctor_function =
llvm::dyn_cast<llvm::Function>(ctor_struct->getOperand(1))) {
auto *ctor_struct = llvm::dyn_cast<llvm::ConstantStruct>(ctor_use);
if (!ctor_struct)
continue;
// this is standardized
lldbassert(ctor_struct->getNumOperands() == 3);
auto *ctor_function =
llvm::dyn_cast<llvm::Function>(ctor_struct->getOperand(1));
if (!ctor_function)
continue;
ConstString ctor_function_name_cs(ctor_function->getName().str());
for (JittedFunction &jitted_function : m_jitted_functions) {
if (ctor_function_name_cs == jitted_function.m_name) {
if (jitted_function.m_remote_addr != LLDB_INVALID_ADDRESS) {
if (ctor_function_name_cs != jitted_function.m_name)
continue;
if (jitted_function.m_remote_addr == LLDB_INVALID_ADDRESS)
continue;
static_initializers.push_back(jitted_function.m_remote_addr);
}
break;
}
}
}
}
}
}
}
}
llvm::JITSymbol
IRExecutionUnit::MemoryManager::findSymbol(const std::string &Name) {