
This restores commit d6ad4f01c3dafcab335bca66dac6e36d9eac8421, which was reverted in commit 883dbb9c86be87593a58ef10b070b3a0564c7fee, along with a fix for gcc 12.2 build errors in the original commit. Support for building, printing, and displaying CallsiteContextGraph which represents the MemProf metadata contexts. Uses CRTP to enable support for both IR (regular LTO) and summary (ThinLTO). This patch includes the support for building it in regular LTO mode (from memprof and callsite metadata), and the next patch will add the handling for building it from ThinLTO summaries. Also includes support for dumping the graph to text and to dot files. Follow-on patches will contain the support for cloning on the graph and in the IR. The graph represents the call contexts in all memprof metadata on allocation calls, with nodes for the allocations themselves, as well as for the calls in each context. The graph is initially built from the allocation memprof metadata (or summary) MIBs. It is then updated to match calls with callsite metadata onto the nodes, updating it to reflect any inlining performed on those calls. Each MIB (representing an allocation's call context with allocation behavior) is assigned a unique context id during the graph build. The edges and nodes in the graph are decorated with the context ids they carry. This is used to correctly update the graph when cloning is performed so that we can uniquify the context for a single (possibly cloned) allocation. Differential Revision: https://reviews.llvm.org/D140908
42 lines
2.0 KiB
LLVM
42 lines
2.0 KiB
LLVM
;; Test that MemProfContextDisambiguation is enabled under the expected conditions
|
|
;; and in the expected position.
|
|
|
|
;; Pass is not currently enabled by default at any opt level.
|
|
; RUN: opt -debug-pass-manager -passes='lto<O0>' -S %s \
|
|
; RUN: 2>&1 | FileCheck %s --implicit-check-not="Running pass: MemProfContextDisambiguation"
|
|
; RUN: opt -debug-pass-manager -passes='lto<O1>' -S %s \
|
|
; RUN: 2>&1 | FileCheck %s --implicit-check-not="Running pass: MemProfContextDisambiguation"
|
|
; RUN: opt -debug-pass-manager -passes='lto<O2>' -S %s \
|
|
; RUN: 2>&1 | FileCheck %s --implicit-check-not="Running pass: MemProfContextDisambiguation"
|
|
; RUN: opt -debug-pass-manager -passes='lto<O3>' -S %s \
|
|
; RUN: 2>&1 | FileCheck %s --implicit-check-not="Running pass: MemProfContextDisambiguation"
|
|
|
|
;; Pass should not run even under option at O0/O1.
|
|
; RUN: opt -debug-pass-manager -passes='lto<O0>' -S %s \
|
|
; RUN: -enable-memprof-context-disambiguation \
|
|
; RUN: 2>&1 | FileCheck %s --implicit-check-not="Running pass: MemProfContextDisambiguation"
|
|
; RUN: opt -debug-pass-manager -passes='lto<O1>' -S %s \
|
|
; RUN: -enable-memprof-context-disambiguation \
|
|
; RUN: 2>&1 | FileCheck %s --implicit-check-not="Running pass: MemProfContextDisambiguation"
|
|
|
|
;; Pass should be enabled under option at O2/O3.
|
|
; RUN: opt -debug-pass-manager -passes='lto<O2>' -S %s \
|
|
; RUN: -enable-memprof-context-disambiguation \
|
|
; RUN: 2>&1 | FileCheck %s --check-prefix=ENABLED
|
|
; RUN: opt -debug-pass-manager -passes='lto<O3>' -S %s \
|
|
; RUN: -enable-memprof-context-disambiguation \
|
|
; RUN: 2>&1 | FileCheck %s --check-prefix=ENABLED
|
|
|
|
;; When enabled, MemProfContextDisambiguation runs just after inlining.
|
|
; ENABLED: Running pass: InlinerPass
|
|
; ENABLED: Invalidating analysis: InlineAdvisorAnalysis
|
|
; ENABLED: Running pass: MemProfContextDisambiguation
|
|
|
|
define noundef ptr @_Z3barv() {
|
|
entry:
|
|
%call = call noalias noundef nonnull ptr @_Znam(i64 noundef 10)
|
|
ret ptr %call
|
|
}
|
|
|
|
declare noundef nonnull ptr @_Znam(i64 noundef)
|