forked from OSchip/llvm-project
[lldb][NFC] Early exit in IRExecutionUnit::GetStaticInitializers
This commit is contained in:
parent
b696b9dba7
commit
c54d21c848
|
@ -977,33 +977,37 @@ IRExecutionUnit::FindSymbol(lldb_private::ConstString name, bool &missing_weak)
|
||||||
|
|
||||||
void IRExecutionUnit::GetStaticInitializers(
|
void IRExecutionUnit::GetStaticInitializers(
|
||||||
std::vector<lldb::addr_t> &static_initializers) {
|
std::vector<lldb::addr_t> &static_initializers) {
|
||||||
if (llvm::GlobalVariable *global_ctors =
|
llvm::GlobalVariable *global_ctors =
|
||||||
m_module->getNamedGlobal("llvm.global_ctors")) {
|
m_module->getNamedGlobal("llvm.global_ctors");
|
||||||
if (llvm::ConstantArray *ctor_array = llvm::dyn_cast<llvm::ConstantArray>(
|
if (!global_ctors)
|
||||||
global_ctors->getInitializer())) {
|
return;
|
||||||
|
auto *ctor_array =
|
||||||
|
llvm::dyn_cast<llvm::ConstantArray>(global_ctors->getInitializer());
|
||||||
|
if (!ctor_array)
|
||||||
|
return;
|
||||||
|
|
||||||
for (llvm::Use &ctor_use : ctor_array->operands()) {
|
for (llvm::Use &ctor_use : ctor_array->operands()) {
|
||||||
if (llvm::ConstantStruct *ctor_struct =
|
auto *ctor_struct = llvm::dyn_cast<llvm::ConstantStruct>(ctor_use);
|
||||||
llvm::dyn_cast<llvm::ConstantStruct>(ctor_use)) {
|
if (!ctor_struct)
|
||||||
lldbassert(ctor_struct->getNumOperands() ==
|
continue;
|
||||||
3); // this is standardized
|
// this is standardized
|
||||||
if (llvm::Function *ctor_function =
|
lldbassert(ctor_struct->getNumOperands() == 3);
|
||||||
llvm::dyn_cast<llvm::Function>(ctor_struct->getOperand(1))) {
|
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());
|
ConstString ctor_function_name_cs(ctor_function->getName().str());
|
||||||
|
|
||||||
for (JittedFunction &jitted_function : m_jitted_functions) {
|
for (JittedFunction &jitted_function : m_jitted_functions) {
|
||||||
if (ctor_function_name_cs == jitted_function.m_name) {
|
if (ctor_function_name_cs != jitted_function.m_name)
|
||||||
if (jitted_function.m_remote_addr != LLDB_INVALID_ADDRESS) {
|
continue;
|
||||||
|
if (jitted_function.m_remote_addr == LLDB_INVALID_ADDRESS)
|
||||||
|
continue;
|
||||||
static_initializers.push_back(jitted_function.m_remote_addr);
|
static_initializers.push_back(jitted_function.m_remote_addr);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
llvm::JITSymbol
|
llvm::JITSymbol
|
||||||
IRExecutionUnit::MemoryManager::findSymbol(const std::string &Name) {
|
IRExecutionUnit::MemoryManager::findSymbol(const std::string &Name) {
|
||||||
|
|
Loading…
Reference in New Issue