[PATCH] D152251: [clang][CodeGen] Fix GPU-specific attributes being dropped by bitcode linking

Pierre van Houtryve via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 6 02:55:39 PDT 2023


Pierre-vh created this revision.
Pierre-vh added reviewers: arsenm, tra, foad.
Herald added subscribers: StephenFan, wenlei, tpr.
Herald added a project: All.
Pierre-vh requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

Device libs make use of patterns like this:

  __attribute__((target("gfx11-insts")))
  static unsigned do_intrin_stuff(void)
  {
    return __builtin_amdgcn_s_sendmsg_rtnl(0x0);
  }

For functions that are assumed to be eliminated if the currennt GPU target doesn't support them.
At O0 such functions aren't eliminated by common optimizations but often by AMDGPURemoveIncompatibleFunctions instead, which sees the "+gfx11-insts" attribute on, say, GFX9 and knows it's not valid, so it removes the function.

D142907 <https://reviews.llvm.org/D142907> accidentally made it so such attributes were dropped during bitcode linking, making it impossible for RemoveIncompatibleFunctions to catch the functions and causing ISel to catch fire eventually.

This fixes the issue and adds a new test to ensure we don't accidentally fall into this trap again.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152251

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCUDA/Inputs/ocml-sample-target-attrs.cl
  clang/test/CodeGenCUDA/link-builtin-bitcode-denormal-fp-mode.cu
  clang/test/CodeGenCUDA/link-builtin-bitcode-gpu-attrs-preserved.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152251.528763.patch
Type: text/x-patch
Size: 7056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230606/0712a92c/attachment.bin>


More information about the cfe-commits mailing list