[PATCH] D111218: [AMDGPU][OpenMP] Mark oulined functions always_inline

Pushpinder Singh via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 6 03:22:50 PDT 2021


pdhaliwal created this revision.
pdhaliwal added reviewers: JonChesterfield, jdoerfert, jhuber6, ggeorgakoudis.
Herald added subscribers: guansong, t-tye, tpr, dstuttard, yaxunl, kzhuravl.
pdhaliwal requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, wdng.
Herald added a project: clang.

This depends on D102107 <https://reviews.llvm.org/D102107> and unblocks the failing amdgcn runtime
tests in the latter.

>From what I understand is that amd-stg-open is working because
everything is marked inline in an internal pass which main branch
currently does not have. Marking the outlined functions as
always_inline does fix the issue, however, proper fixes to the
backend are still required. Until then, this will work. I have also
added TODO on top of the added code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111218

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===================================================================
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -503,6 +503,13 @@
     F->setDoesNotThrow();
   F->setDoesNotRecurse();
 
+  // TODO: should not need this once amdgcn handles function calls properly.
+  if (CGM.getTriple().isAMDGCN()) {
+    F->removeFnAttr(llvm::Attribute::OptimizeNone);
+    F->removeFnAttr(llvm::Attribute::NoInline);
+    F->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
+
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, Args, Loc, Loc);
   Address ContextAddr = CGF.GetAddrOfLocalVar(CD->getContextParam());
@@ -664,9 +671,14 @@
     F->setDoesNotThrow();
   F->setDoesNotRecurse();
 
-  // Always inline the outlined function if optimizations are enabled.
-  if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+  // Always inline the outlined function if optimizations are enabled or current
+  // target is amdgcn.
+  // TODO: amdgcn check should be removed once it handles function calls properly.
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0 || CGM.getTriple().isAMDGCN()) {
+    F->removeFnAttr(llvm::Attribute::NoInline);
+    F->removeFnAttr(llvm::Attribute::OptimizeNone);
     F->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
 
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111218.377491.patch
Type: text/x-patch
Size: 1431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211006/efda4b8f/attachment.bin>


More information about the cfe-commits mailing list