jhuber6 created this revision. jhuber6 added a reviewer: jdoerfert. Herald added subscribers: guansong, yaxunl. jhuber6 requested review of this revision. Herald added subscribers: cfe-commits, sstefan1. Herald added a project: clang.
This patch adds the always inline attribute to the outlined functions generated by OpenMP regions. Because there is only a single instance of this function and it always has internal linkage it is safe to inline in every instance it is created. This could potentially lead to performance degredation due to inflated register counts in the parallel region. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D106799 Files: clang/lib/CodeGen/CGStmtOpenMP.cpp Index: clang/lib/CodeGen/CGStmtOpenMP.cpp =================================================================== --- clang/lib/CodeGen/CGStmtOpenMP.cpp +++ clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -517,6 +517,10 @@ F->setDoesNotThrow(); F->setDoesNotRecurse(); + // Always inline the outlined function if optimizations are enabled. + if (CGM.getCodeGenOpts().OptimizationLevel != 0) + F->addFnAttr(llvm::Attribute::AlwaysInline); + // Generate the function. CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs, FO.UIntPtrCastRequired ? FO.Loc : FO.S->getBeginLoc(), @@ -5303,6 +5307,8 @@ CGF.CapturedStmtInfo = &CapStmtInfo; llvm::Function *Fn = CGF.GenerateOpenMPCapturedStmtFunction(*S, Loc); Fn->setDoesNotRecurse(); + if (CGM.getCodeGenOpts().OptimizationLevel != 0) + Fn->addFnAttr(llvm::Attribute::AlwaysInline); return Fn; }
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp =================================================================== --- clang/lib/CodeGen/CGStmtOpenMP.cpp +++ clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -517,6 +517,10 @@ F->setDoesNotThrow(); F->setDoesNotRecurse(); + // Always inline the outlined function if optimizations are enabled. + if (CGM.getCodeGenOpts().OptimizationLevel != 0) + F->addFnAttr(llvm::Attribute::AlwaysInline); + // Generate the function. CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs, FO.UIntPtrCastRequired ? FO.Loc : FO.S->getBeginLoc(), @@ -5303,6 +5307,8 @@ CGF.CapturedStmtInfo = &CapStmtInfo; llvm::Function *Fn = CGF.GenerateOpenMPCapturedStmtFunction(*S, Loc); Fn->setDoesNotRecurse(); + if (CGM.getCodeGenOpts().OptimizationLevel != 0) + Fn->addFnAttr(llvm::Attribute::AlwaysInline); return Fn; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits