[all-commits] [llvm/llvm-project] 554459: [BOLT] Fix runOnEachFunctionWithUniqueAllocId (#90...
Kristof Beyls via All-commits
all-commits at lists.llvm.org
Sat May 4 00:26:57 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 554459a02f2a2064d8f3b567670a436cfda11aaf
https://github.com/llvm/llvm-project/commit/554459a02f2a2064d8f3b567670a436cfda11aaf
Author: Kristof Beyls <kristof.beyls at arm.com>
Date: 2024-05-04 (Sat, 04 May 2024)
Changed paths:
M bolt/lib/Core/ParallelUtilities.cpp
Log Message:
-----------
[BOLT] Fix runOnEachFunctionWithUniqueAllocId (#90039)
When runOnEachFunctionWithUniqueAllocId is invoked with
ForceSequential=true, then the current implementation runs the function
with AllocId==0, which is the Id for the shared, non-unique, default
AnnotationAllocator.
However, the documentation for runOnEachFunctionWithUniqueAllocId
states:
```
/// Perform the work on each BinaryFunction except those that are rejected
/// by SkipPredicate, and create a unique annotation allocator for each
/// task. This should be used whenever the work function creates annotations to
/// allow thread-safe annotation creation.
```
Therefore, even when ForceSequential==true, a unique AllocId should be
used, i.e. different from 0.
In the current upstream BOLT this is presumably not depended on, but it
is needed to reduce memory usage for analyses that use a lot of
memory/annotations. Examples are the pac-ret and stack-clash analyses
that currently have prototype implementations as described in
https://discourse.llvm.org/t/rfc-bolt-based-binary-analysis-tool-to-verify-correctness-of-security-hardening/78148
These analyses use the DataFlowAnalysis framework to sometimes store
quite a lot of information on each MCInst. They run in parallel on each
function. When the dataflow analysis is finished, the annotations on
each MCInst can be removed, hugely saving on memory consumption. The
only annotations that need to remain are those that indicate some
unexpected properties somewhere in the binary.
Fixing this bug enables implementing the deletion of the memory used by
those huge number of DataFlowAnalysis annotations (by invoking
BC.MIB->freeValuesAllocator(AllocatorId)), even when run with
--no-threads. Without this bug fixed, the invocation of
BC.MIB->freeValuesAllocator(AllocatorId) results in also the memory for
all other annotations to be deleted, as AllocatorId is 0.
---------
Co-authored-by: Maksim Panchenko <maks at meta.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list