[llvm] [LLVM][DWARF] Create thread safe context for DWP DWARFContext (PR #68262)
Alexander Yermolovich via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 9 10:44:36 PDT 2023
https://github.com/ayermolo updated https://github.com/llvm/llvm-project/pull/68262
>From f8f99ff1b6885706f395756c0e61ef78de9e82a7 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich <ayermolo at meta.com>
Date: Wed, 4 Oct 2023 14:39:41 -0700
Subject: [PATCH 1/3] [LLVM][DWARF] Create thread safe context for DWP
DWARFContext
Right now DWARFContext is created is the same when input is DWO or DWP file.
Changed so that for DWP it creates a thread safe context.
---
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 1e1ab814673f423..0648ccca16cf2ae 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -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);
*Entry = S;
auto *Ctxt = S->Context.get();
return std::shared_ptr<DWARFContext>(std::move(S), Ctxt);
>From 4f28df98ffec2291ec0b79a8264217b65ef861f3 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich <ayermolo at meta.com>
Date: Mon, 9 Oct 2023 10:42:50 -0700
Subject: [PATCH 2/3] fixup! [LLVM][DWARF] Create thread safe context for DWP
DWARFContext
---
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 0648ccca16cf2ae..1284a661087b5bd 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -576,11 +576,13 @@ class ThreadUnsafeDWARFContextState : public DWARFContext::DWARFContextState {
auto S = std::make_shared<DWOFile>();
S->File = std::move(Obj.get());
StringRef FileName = S->File.getBinary()->getFileName();
+ // 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,
- FileName.find(".dwp") != StringRef::npos);
+ ThreadSafe);
*Entry = S;
auto *Ctxt = S->Context.get();
return std::shared_ptr<DWARFContext>(std::move(S), Ctxt);
>From 1e25bb6faf64822295bf253de66a8c1f6a61872c Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich <ayermolo at meta.com>
Date: Mon, 9 Oct 2023 10:43:23 -0700
Subject: [PATCH 3/3] fixup! [LLVM][DWARF] Create thread safe context for DWP
DWARFContext
---
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 1284a661087b5bd..631aa6fd00a2178 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -576,13 +576,13 @@ class ThreadUnsafeDWARFContextState : public DWARFContext::DWARFContextState {
auto S = std::make_shared<DWOFile>();
S->File = std::move(Obj.get());
StringRef FileName = S->File.getBinary()->getFileName();
- // Allow multi-threaded access if there is a .dwp file as the CU index and TU index might be accessed from multiple threads.
+ // 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);
+ WithColor::defaultWarningHandler, ThreadSafe);
*Entry = S;
auto *Ctxt = S->Context.get();
return std::shared_ptr<DWARFContext>(std::move(S), Ctxt);
More information about the llvm-commits
mailing list