[PATCH] D106799: [OpenMP] Always inline the OpenMP outlined function
Joseph Huber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 26 08:37:00 PDT 2021
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106799.361676.patch
Type: text/x-patch
Size: 893 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210726/d1a32b7a/attachment.bin>
More information about the cfe-commits
mailing list