[PATCH] D157459: Make DWARFContext more thread safe.

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 17 17:26:28 PDT 2023


JDevlieghere added a comment.

Can we do something like this?

  class DWARFContext {
    public:
      void foo();
      void bar();
  };
  
  template <typename T>
  class ThreadSafeDWARFContext : public T {
    public:
      void foo() {
        std::lock_guard<std::mutex> L(M);
        return T::foo();
      }
  
    private:
      std::mutex M;
  };

I think this would address everyone's concern:

- You don't pay anything when you use the non-thread safe variant. (Dave & my concern)
- Thread safety is localized in the wrapper. (Dave & Alex's concern)
- This works everywhere where a regular `DWARFContext` works. (Greg's concern)

It still doesn't solve the problem that you might be handing out other non thread safe abstractions (like the line table) but that's a bigger problem.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157459/new/

https://reviews.llvm.org/D157459



More information about the llvm-commits mailing list