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

2021-10-06 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal updated this revision to Diff 377502.
pdhaliwal added a comment.

Only removing optnone.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111218/new/

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,11 @@
 F->setDoesNotThrow();
   F->setDoesNotRecurse();
 
+  // TODO: should not need this once amdgcn handles function pointers properly.
+  if (CGM.getTriple().isAMDGCN()) {
+F->removeFnAttr(llvm::Attribute::OptimizeNone);
+  }
+
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, Args, Loc, Loc);
   Address ContextAddr = CGF.GetAddrOfLocalVar(CD->getContextParam());
@@ -665,8 +670,14 @@
   F->setDoesNotRecurse();
 
   // Always inline the outlined function if optimizations are enabled.
-  if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0) {
 F->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
+
+  // TODO: remove this once amdgcn handles function pointers properly.
+  if (CGM.getTriple().isAMDGCN()) {
+F->removeFnAttr(llvm::Attribute::OptimizeNone);
+  }
 
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs,


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -503,6 +503,11 @@
 F->setDoesNotThrow();
   F->setDoesNotRecurse();
 
+  // TODO: should not need this once amdgcn handles function pointers properly.
+  if (CGM.getTriple().isAMDGCN()) {
+F->removeFnAttr(llvm::Attribute::OptimizeNone);
+  }
+
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, Args, Loc, Loc);
   Address ContextAddr = CGF.GetAddrOfLocalVar(CD->getContextParam());
@@ -665,8 +670,14 @@
   F->setDoesNotRecurse();
 
   // Always inline the outlined function if optimizations are enabled.
-  if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0) {
 F->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
+
+  // TODO: remove this once amdgcn handles function pointers properly.
+  if (CGM.getTriple().isAMDGCN()) {
+F->removeFnAttr(llvm::Attribute::OptimizeNone);
+  }
 
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-10-06 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal planned changes to this revision.
pdhaliwal added a comment.

I don't have any concrete evidence but I have some doubt on presence of 
function pointers causing backend to behave improperly. Also, here removing 
optnone alone suffices to fix the issue.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111218/new/

https://reviews.llvm.org/D111218

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-10-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield edited reviewers, added: tianshilei1992, ye-luo, grokos; 
removed: ggeorgakoudis.
JonChesterfield added a comment.

Not pretty but unblocking D102107  is 
important. Could you write up your current understanding of what we're 
miscompiling for function calls as a comment to this patch? I'm guessing it's 
still attribute related but am a few days out of date.

I won't tag it as accepted because it's taking on debt in clang openmp to work 
around a bug in amdgpu middle/back end and I have a conflict of interest there. 
Hopefully an external person will accept.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111218/new/

https://reviews.llvm.org/D111218

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-10-06 Thread Pushpinder Singh via Phabricator via cfe-commits
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  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,


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,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits