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,
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