[all-commits] [llvm/llvm-project] c45ccf: [BOLT] Fix runOnEachFunctionWithUniqueAllocId
Kristof Beyls via All-commits
all-commits at lists.llvm.org
Thu Apr 25 03:34:26 PDT 2024
Branch: refs/reviewable/pr90039/r1
Home: https://github.com/llvm/llvm-project
Commit: c45ccffab239ad434ebb7e5381bdaf95fd96d935
https://github.com/llvm/llvm-project/commit/c45ccffab239ad434ebb7e5381bdaf95fd96d935
Author: Kristof Beyls <kristof.beyls at arm.com>
Date: 2024-04-25 (Thu, 25 Apr 2024)
Changed paths:
M bolt/lib/Core/ParallelUtilities.cpp
Log Message:
-----------
[BOLT] Fix runOnEachFunctionWithUniqueAllocId
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.
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