clang 20.0.0git
Public Member Functions | List of all members
clang::CodeGen::CodeGenFunction::OMPPrivateScope Class Reference

The scope used to remap some variables as private in the OpenMP loop body (or other captured region emitted without outlining), and to restore old vars back on exit. More...

#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/CodeGen/CodeGenFunction.h"

Inheritance diagram for clang::CodeGen::CodeGenFunction::OMPPrivateScope:
Inheritance graph
[legend]

Public Member Functions

 OMPPrivateScope (CodeGenFunction &CGF)
 Enter a new OpenMP private scope.
 
bool addPrivate (const VarDecl *LocalVD, Address Addr)
 Registers LocalVD variable as a private with Addr as the address of the corresponding private variable.
 
bool Privatize ()
 Privatizes local variables previously registered as private.
 
void ForceCleanup ()
 
 ~OMPPrivateScope ()
 Exit scope - all the mapped variables are restored.
 
bool isGlobalVarCaptured (const VarDecl *VD) const
 Checks if the global variable is captured in current function.
 
void restoreMap ()
 Restore all mapped variables w/o clean up.
 
- Public Member Functions inherited from clang::CodeGen::CodeGenFunction::RunCleanupsScope
 RunCleanupsScope (CodeGenFunction &CGF)
 Enter a new cleanup scope.
 
 ~RunCleanupsScope ()
 Exit this cleanup scope, emitting any accumulated cleanups.
 
bool requiresCleanups () const
 Determine whether this scope requires any cleanups.
 
void ForceCleanup (std::initializer_list< llvm::Value ** > ValuesToReload={})
 Force the emission of cleanups now, instead of waiting until this object is destroyed.
 

Additional Inherited Members

- Protected Attributes inherited from clang::CodeGen::CodeGenFunction::RunCleanupsScope
bool PerformCleanup
 
CodeGenFunctionCGF
 

Detailed Description

The scope used to remap some variables as private in the OpenMP loop body (or other captured region emitted without outlining), and to restore old vars back on exit.

Definition at line 1164 of file CodeGenFunction.h.

Constructor & Destructor Documentation

◆ OMPPrivateScope()

clang::CodeGen::CodeGenFunction::OMPPrivateScope::OMPPrivateScope ( CodeGenFunction CGF)
inlineexplicit

Enter a new OpenMP private scope.

Definition at line 1171 of file CodeGenFunction.h.

◆ ~OMPPrivateScope()

clang::CodeGen::CodeGenFunction::OMPPrivateScope::~OMPPrivateScope ( )
inline

Exit scope - all the mapped variables are restored.

Definition at line 1199 of file CodeGenFunction.h.

References ForceCleanup(), and clang::CodeGen::CodeGenFunction::RunCleanupsScope::PerformCleanup.

Member Function Documentation

◆ addPrivate()

bool clang::CodeGen::CodeGenFunction::OMPPrivateScope::addPrivate ( const VarDecl LocalVD,
Address  Addr 
)
inline

Registers LocalVD variable as a private with Addr as the address of the corresponding private variable.

PrivateGen is the address of the generated private variable.

Returns
true if the variable is registered as private, false if it has been privatized already.

Definition at line 1178 of file CodeGenFunction.h.

References clang::CodeGen::CodeGenFunction::RunCleanupsScope::CGF, clang::CodeGen::CodeGenFunction::RunCleanupsScope::PerformCleanup, and clang::CodeGen::CodeGenFunction::OMPMapVars::setVarAddr().

Referenced by clang::CodeGen::CGOpenMPRuntime::emitReduction().

◆ ForceCleanup()

void clang::CodeGen::CodeGenFunction::OMPPrivateScope::ForceCleanup ( )
inline

◆ isGlobalVarCaptured()

bool clang::CodeGen::CodeGenFunction::OMPPrivateScope::isGlobalVarCaptured ( const VarDecl VD) const
inline

Checks if the global variable is captured in current function.

Definition at line 1205 of file CodeGenFunction.h.

References clang::CodeGen::CodeGenFunction::RunCleanupsScope::CGF, clang::VarDecl::getCanonicalDecl(), and clang::VarDecl::isLocalVarDeclOrParm().

◆ Privatize()

bool clang::CodeGen::CodeGenFunction::OMPPrivateScope::Privatize ( )
inline

Privatizes local variables previously registered as private.

Registration is separate from the actual privatization to allow initializers use values of the original variables, not the private one. This is important, for example, if the private variable is a class variable initialized by a constructor that references other private variables. But at initialization original variables must be used, not private copies.

Returns
true if at least one variable was privatized, false otherwise.

Definition at line 1191 of file CodeGenFunction.h.

References clang::CodeGen::CodeGenFunction::OMPMapVars::apply(), and clang::CodeGen::CodeGenFunction::RunCleanupsScope::CGF.

Referenced by clang::CodeGen::CGOpenMPRuntime::emitReduction().

◆ restoreMap()

void clang::CodeGen::CodeGenFunction::OMPPrivateScope::restoreMap ( )
inline

Restore all mapped variables w/o clean up.

This is usefully when we want to reference the original variables but don't want the clean up because that could emit lifetime end too early, causing backend issue #56913.

Definition at line 1213 of file CodeGenFunction.h.

References clang::CodeGen::CodeGenFunction::RunCleanupsScope::CGF, and clang::CodeGen::CodeGenFunction::OMPMapVars::restore().

Referenced by ForceCleanup().


The documentation for this class was generated from the following file: