
This patch implements an LLVM IR pass, named kernel-info, that reports various statistics for codes compiled for GPUs. The ultimate goal of these statistics to help identify bad code patterns and ways to mitigate them. The pass operates at the LLVM IR level so that it can, in theory, support any LLVM-based compiler for programming languages supporting GPUs. It has been tested so far with LLVM IR generated by Clang for OpenMP offload codes targeting NVIDIA GPUs and AMD GPUs. By default, the pass runs at the end of LTO, and options like ``-Rpass=kernel-info`` enable its remarks. Example `opt` and `clang` command lines appear in `llvm/docs/KernelInfo.rst`. Remarks include summary statistics (e.g., total size of static allocas) and individual occurrences (e.g., source location of each alloca). Examples of its output appear in tests in `llvm/test/Analysis/KernelInfo`.
19 lines
896 B
Plaintext
19 lines
896 B
Plaintext
; Check when kernel-info is enabled in the AMD GPU target backend.
|
|
|
|
; REQUIRES: amdgpu-registered-target
|
|
|
|
; DEFINE: %{opt} = opt -disable-output %S/Inputs/test.ll \
|
|
; DEFINE: -mtriple="amdgcn-amd-amdhsa" 2>&1
|
|
; DEFINE: %{fcheck-on} = FileCheck -match-full-lines %S/Inputs/test.ll
|
|
; DEFINE: %{fcheck-off} = FileCheck -allow-empty -check-prefixes=NONE \
|
|
; DEFINE: %S/Inputs/test.ll
|
|
|
|
; By default, kernel-info is in the LTO pipeline. To see output, the LTO
|
|
; pipeline must run, -no-kernel-info-end-lto must not be specified, and remarks
|
|
; must be enabled.
|
|
; RUN: %{opt} -passes='lto<O2>' -pass-remarks=kernel-info | %{fcheck-on}
|
|
; RUN: %{opt} -passes='default<O2>' -pass-remarks=kernel-info | %{fcheck-off}
|
|
; RUN: %{opt} -passes='lto<O2>' -pass-remarks=kernel-info \
|
|
; RUN: -no-kernel-info-end-lto | %{fcheck-off}
|
|
; RUN: %{opt} -passes='lto<O2>' | %{fcheck-off}
|