[PATCH] D139000: [AMDGPU] Clear bodies of function with incompatible features

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 30 03:55:30 PST 2022


Pierre-vh created this revision.
Pierre-vh added reviewers: arsenm, foad, Joe_Nash, b-sumner, nhaehnle, Leonc, bcahoon.
Herald added subscribers: kosarev, kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl.
Herald added a project: All.
Pierre-vh requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139000

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139000.478884.patch
Type: text/x-patch
Size: 34279 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221130/fd140b8b/attachment.bin>


More information about the llvm-commits mailing list