[clang] Thread Safety Analysis: Support reentrant capabilities (PR #137133)

Aaron Puchert via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 26 12:08:41 PDT 2025


================
@@ -114,31 +112,39 @@ class FactEntry : public CapabilityExpr {
   };
 
 private:
-  const FactEntryKind Kind : 8;
+  const FactEntryKind Kind : 4;
 
   /// Exclusive or shared.
-  LockKind LKind : 8;
+  const LockKind LKind : 4;
+
+  /// How it was acquired.
+  const SourceKind Source : 4;
 
-  // How it was acquired.
-  SourceKind Source : 8;
+  /// Reentrancy depth; 16 bits should be enough given that FactID is a short,
+  /// and thus we can't store more than 65536 facts anyway.
+  unsigned int ReentrancyDepth : 16;
----------------
aaronpuchert wrote:

This should probably be in `LockableFactEntry`. I don't think we want to support reentrant scoped locks, and they don't really make sense to me.

I understand that you want to pack these, but that's probably not so important: we're looking at one function at a time, and will clean up everything before we go check out the next function. The existing packing is just to make it not too wasteful. (Also, computers have byte-addressable memory, so there is no need to reserve an entire word if we only need a byte.)

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


More information about the cfe-commits mailing list