[Lldb-commits] [lldb] c54d21c - [lldb][NFC] Early exit in IRExecutionUnit::GetStaticInitializers

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 19 06:07:51 PST 2019


Author: Raphael Isemann
Date: 2019-11-19T15:06:30+01:00
New Revision: c54d21c848d350e85cd8f95a725fc12f6fa3ab19

URL: https://github.com/llvm/llvm-project/commit/c54d21c848d350e85cd8f95a725fc12f6fa3ab19
DIFF: https://github.com/llvm/llvm-project/commit/c54d21c848d350e85cd8f95a725fc12f6fa3ab19.diff

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

Added: 
    

Modified: 
    lldb/source/Expression/IRExecutionUnit.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp
index b10628e10cc5..105f875fa1d2 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -977,30 +977,34 @@ 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())) {
-      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))) {
-            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) {
-                  static_initializers.push_back(jitted_function.m_remote_addr);
-                }
-                break;
-              }
-            }
-          }
-        }
-      }
+  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()) {
+    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)
+        continue;
+      if (jitted_function.m_remote_addr == LLDB_INVALID_ADDRESS)
+        continue;
+      static_initializers.push_back(jitted_function.m_remote_addr);
+      break;
     }
   }
 }


        


More information about the lldb-commits mailing list