[llvm] [BOLT][AArch64] Fixed indirect call instrumentation snippet (PR #141918)

Peter Waller via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 24 07:25:48 PST 2025


================
@@ -293,9 +293,12 @@ void Instrumentation::instrumentIndirectTarget(BinaryBasicBlock &BB,
                                                BinaryBasicBlock::iterator &Iter,
                                                BinaryFunction &FromFunction,
                                                uint32_t From) {
-  auto L = FromFunction.getBinaryContext().scopeLock();
-  const size_t IndCallSiteID = Summary->IndCallDescriptions.size();
-  createIndCallDescription(FromFunction, From);
+  size_t IndCallSiteID;
+  {
+    auto L = FromFunction.getBinaryContext().scopeLock();
----------------
peterwaller-arm wrote:

I see this scope lock got moved into a shorter scope; but `FromFunction.getBinaryContext` is still used below. Is there a significant advantage to reducing the scope? If no, it might be clearer/safer in the long term to having the scope of the lock span the reference to the BinaryContext (and derived objects).

Alternatively, if the lock is definitely only needed by createIndCallDescription, what if it took the lock and returned the ID, instead?

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


More information about the llvm-commits mailing list