[all-commits] [llvm/llvm-project] 8e68c1: [AMDGPU] Remove function with incompatible features

Pierre van Houtryve via All-commits all-commits at lists.llvm.org
Tue Feb 21 01:42:52 PST 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8e68c1204580d0bb57001929d3345af80b27ac01
  Author: pvanhout <pierre.vanhoutryve at amd.com>
  Date:   2023-02-21 (Tue, 21 Feb 2023)

  Changed paths:
    M llvm/include/llvm/MC/MCSubtargetInfo.h
    M llvm/lib/Target/AMDGPU/AMDGPU.h
    A llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
    M llvm/lib/Target/AMDGPU/CMakeLists.txt
    M llvm/test/CodeGen/AMDGPU/GlobalISel/dummy-target.ll
    M llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
    A llvm/test/CodeGen/AMDGPU/remove-incompatible-functions.ll

  Log Message:
  [AMDGPU] Remove function with incompatible features

Adds a new pass that removes functions
if they use features that are not supported on the current GPU.

This change is aimed at preventing crashes when building code at O0 that
uses idioms such as `if (ISA_VERSION >= N) intrinsic_a(); else intrinsic_b();`
where ISA_VERSION is not constexpr, and intrinsic_a is not selectable
on older targets.
This is a pattern that's used all over the ROCm device libs. The main
motive behind this change is to allow code using ROCm device libs
to be built at O0.

Note: the feature checking logic is done ad-hoc in the pass. There is no other
pass that needs (or will need in the foreseeable future) to do similar
feature-checking logic so I did not see a need to generalize the feature
checking logic yet. It can (and should probably) be generalized later and
moved to a TargetInfo-like class or helper file.

Reviewed By: arsenm, Joe_Nash

Differential Revision: https://reviews.llvm.org/D139000

More information about the All-commits mailing list