[all-commits] [llvm/llvm-project] e07c05: [AMDGPU] Clear bodies of function with incompatibl...

Pierre van Houtryve via All-commits all-commits at lists.llvm.org
Wed Nov 30 03:56:07 PST 2022


  Branch: refs/heads/unsupported-attr-cleanup-fn
  Home:   https://github.com/llvm/llvm-project
  Commit: e07c05bc91ae1dfb625b7b0d93a83e5c6039fcb2
      https://github.com/llvm/llvm-project/commit/e07c05bc91ae1dfb625b7b0d93a83e5c6039fcb2
  Author: Pierre van Houtryve <pierre.vanhoutryve at amd.com>
  Date:   2022-11-30 (Wed, 30 Nov 2022)

  Changed paths:
    M llvm/lib/Target/AMDGPU/AMDGPU.h
    A llvm/lib/Target/AMDGPU/AMDGPUClearIncompatibleFunctions.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
    M llvm/lib/Target/AMDGPU/CMakeLists.txt
    M llvm/test/CodeGen/AMDGPU/GlobalISel/dummy-target.ll
    A llvm/test/CodeGen/AMDGPU/clear-incompatible-functions.ll
    M llvm/test/CodeGen/AMDGPU/llc-pipeline.ll

  Log Message:
  -----------
  [AMDGPU] Clear bodies of function with incompatible features

Adds a new passs that replaces the body of a function with trap+unreachable
if it uses 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.




More information about the All-commits mailing list