diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/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,