[llvm] [LLVM][DWARF] Create thread safe context for DWP DWARFContext (PR #68262)

Greg Clayton via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 9 10:05:33 PDT 2023


================
@@ -575,8 +575,12 @@ class ThreadUnsafeDWARFContextState : public DWARFContext::DWARFContextState {
 
     auto S = std::make_shared<DWOFile>();
     S->File = std::move(Obj.get());
-    S->Context = DWARFContext::create(*S->File.getBinary(),
-                                      DWARFContext::ProcessDebugRelocations::Ignore);
+    StringRef FileName = S->File.getBinary()->getFileName();
+    S->Context = DWARFContext::create(
+        *S->File.getBinary(), DWARFContext::ProcessDebugRelocations::Ignore,
+        nullptr, "", WithColor::defaultErrorHandler,
+        WithColor::defaultWarningHandler,
+        FileName.find(".dwp") != StringRef::npos);
----------------
clayborg wrote:

Add a comment stating why your are enabling threading support and make a local variable so we can add a comment:
```
// Allow multi-threaded access if there is a .dwp file as the CU index 
// and TU index might be accessed from multiple threads.
bool ThreadSafe = FileName.find(".dwp") != StringRef::npos;
S->Context = DWARFContext::create(
        *S->File.getBinary(), DWARFContext::ProcessDebugRelocations::Ignore,
        nullptr, "", WithColor::defaultErrorHandler,
        WithColor::defaultWarningHandler, ThreadSafe);
```

https://github.com/llvm/llvm-project/pull/68262


More information about the llvm-commits mailing list