forked from OSchip/llvm-project
[OPENMP 4.5] Codegen support for data members in 'firstprivate' clause.
Added codegen for captured data members in non-static member functions. llvm-svn: 261089
This commit is contained in:
parent
4788179a2c
commit
417089fc7e
|
@ -1253,6 +1253,7 @@ public:
|
|||
///
|
||||
class OMPFirstprivateClause final
|
||||
: public OMPVarListClause<OMPFirstprivateClause>,
|
||||
public OMPClauseWithPreInit,
|
||||
private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
|
||||
friend TrailingObjects;
|
||||
friend OMPVarListClause;
|
||||
|
@ -1268,7 +1269,8 @@ class OMPFirstprivateClause final
|
|||
OMPFirstprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
|
||||
SourceLocation EndLoc, unsigned N)
|
||||
: OMPVarListClause<OMPFirstprivateClause>(OMPC_firstprivate, StartLoc,
|
||||
LParenLoc, EndLoc, N) {}
|
||||
LParenLoc, EndLoc, N),
|
||||
OMPClauseWithPreInit(this) {}
|
||||
|
||||
/// \brief Build an empty clause.
|
||||
///
|
||||
|
@ -1277,7 +1279,8 @@ class OMPFirstprivateClause final
|
|||
explicit OMPFirstprivateClause(unsigned N)
|
||||
: OMPVarListClause<OMPFirstprivateClause>(
|
||||
OMPC_firstprivate, SourceLocation(), SourceLocation(),
|
||||
SourceLocation(), N) {}
|
||||
SourceLocation(), N),
|
||||
OMPClauseWithPreInit(this) {}
|
||||
/// \brief Sets the list of references to private copies with initializers for
|
||||
/// new private variables.
|
||||
/// \param VL List of references.
|
||||
|
@ -1318,11 +1321,13 @@ public:
|
|||
/// \param InitVL List of references to auto generated variables used for
|
||||
/// initialization of a single array element. Used if firstprivate variable is
|
||||
/// of array type.
|
||||
/// \param PreInit Statement that must be executed before entering the OpenMP
|
||||
/// region with this clause.
|
||||
///
|
||||
static OMPFirstprivateClause *
|
||||
Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
|
||||
SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
|
||||
ArrayRef<Expr *> InitVL);
|
||||
ArrayRef<Expr *> InitVL, Stmt *PreInit);
|
||||
/// \brief Creates an empty clause with the place for \a N variables.
|
||||
///
|
||||
/// \param C AST context.
|
||||
|
|
|
@ -492,6 +492,8 @@ private:
|
|||
#include "clang/Basic/OpenMPKinds.def"
|
||||
/// \brief Process clauses with list of variables.
|
||||
template <typename T> bool VisitOMPClauseList(T *Node);
|
||||
/// Process clauses with pre-initis.
|
||||
bool VisitOMPClauseWithPreInit(OMPClauseWithPreInit *Node);
|
||||
|
||||
bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
|
||||
};
|
||||
|
@ -2497,6 +2499,13 @@ bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
|
|||
return true;
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
bool RecursiveASTVisitor<Derived>::VisitOMPClauseWithPreInit(
|
||||
OMPClauseWithPreInit *Node) {
|
||||
TRY_TO(TraverseStmt(Node->getPreInitStmt()));
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
bool RecursiveASTVisitor<Derived>::VisitOMPIfClause(OMPIfClause *C) {
|
||||
TRY_TO(TraverseStmt(C->getCondition()));
|
||||
|
@ -2548,8 +2557,8 @@ bool RecursiveASTVisitor<Derived>::VisitOMPProcBindClause(OMPProcBindClause *) {
|
|||
template <typename Derived>
|
||||
bool
|
||||
RecursiveASTVisitor<Derived>::VisitOMPScheduleClause(OMPScheduleClause *C) {
|
||||
TRY_TO(VisitOMPClauseWithPreInit(C));
|
||||
TRY_TO(TraverseStmt(C->getChunkSize()));
|
||||
TRY_TO(TraverseStmt(C->getPreInitStmt()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2637,6 +2646,7 @@ template <typename Derived>
|
|||
bool RecursiveASTVisitor<Derived>::VisitOMPFirstprivateClause(
|
||||
OMPFirstprivateClause *C) {
|
||||
TRY_TO(VisitOMPClauseList(C));
|
||||
TRY_TO(VisitOMPClauseWithPreInit(C));
|
||||
for (auto *E : C->private_copies()) {
|
||||
TRY_TO(TraverseStmt(E));
|
||||
}
|
||||
|
@ -2818,8 +2828,8 @@ bool RecursiveASTVisitor<Derived>::VisitOMPHintClause(OMPHintClause *C) {
|
|||
template <typename Derived>
|
||||
bool RecursiveASTVisitor<Derived>::VisitOMPDistScheduleClause(
|
||||
OMPDistScheduleClause *C) {
|
||||
TRY_TO(VisitOMPClauseWithPreInit(C));
|
||||
TRY_TO(TraverseStmt(C->getChunkSize()));
|
||||
TRY_TO(TraverseStmt(C->getPreInitStmt()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
|
|||
return static_cast<const OMPScheduleClause *>(C);
|
||||
case OMPC_dist_schedule:
|
||||
return static_cast<const OMPDistScheduleClause *>(C);
|
||||
case OMPC_firstprivate:
|
||||
return static_cast<const OMPFirstprivateClause *>(C);
|
||||
case OMPC_default:
|
||||
case OMPC_proc_bind:
|
||||
case OMPC_if:
|
||||
|
@ -49,7 +51,6 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
|
|||
case OMPC_simdlen:
|
||||
case OMPC_collapse:
|
||||
case OMPC_private:
|
||||
case OMPC_firstprivate:
|
||||
case OMPC_lastprivate:
|
||||
case OMPC_shared:
|
||||
case OMPC_reduction:
|
||||
|
@ -129,13 +130,14 @@ OMPFirstprivateClause *
|
|||
OMPFirstprivateClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
||||
SourceLocation LParenLoc, SourceLocation EndLoc,
|
||||
ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
|
||||
ArrayRef<Expr *> InitVL) {
|
||||
ArrayRef<Expr *> InitVL, Stmt *PreInit) {
|
||||
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
|
||||
OMPFirstprivateClause *Clause =
|
||||
new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
|
||||
Clause->setVarRefs(VL);
|
||||
Clause->setPrivateCopies(PrivateVL);
|
||||
Clause->setInits(InitVL);
|
||||
Clause->setPreInitStmt(PreInit);
|
||||
return Clause;
|
||||
}
|
||||
|
||||
|
|
|
@ -360,6 +360,7 @@ void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
|
|||
void
|
||||
OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) {
|
||||
VisitOMPClauseList(C);
|
||||
VistOMPClauseWithPreInit(C);
|
||||
for (auto *E : C->private_copies()) {
|
||||
Profiler->VisitStmt(E);
|
||||
}
|
||||
|
|
|
@ -1925,16 +1925,14 @@ void CodeGenFunction::EmitOMPSingleDirective(const OMPSingleDirective &S) {
|
|||
AssignmentOps.append(C->assignment_ops().begin(),
|
||||
C->assignment_ops().end());
|
||||
}
|
||||
bool HasFirstprivates;
|
||||
{
|
||||
OMPLexicalScope Scope(*this, S);
|
||||
// Emit code for 'single' region along with 'copyprivate' clauses
|
||||
auto &&CodeGen = [&S, &HasFirstprivates](CodeGenFunction &CGF) {
|
||||
auto &&CodeGen = [&S](CodeGenFunction &CGF) {
|
||||
CodeGenFunction::OMPPrivateScope SingleScope(CGF);
|
||||
HasFirstprivates = CGF.EmitOMPFirstprivateClause(S, SingleScope);
|
||||
(void)CGF.EmitOMPFirstprivateClause(S, SingleScope);
|
||||
CGF.EmitOMPPrivateClause(S, SingleScope);
|
||||
(void)SingleScope.Privatize();
|
||||
|
||||
CGF.EmitStmt(
|
||||
cast<CapturedStmt>(S.getAssociatedStmt())->getCapturedStmt());
|
||||
};
|
||||
|
@ -1944,8 +1942,7 @@ void CodeGenFunction::EmitOMPSingleDirective(const OMPSingleDirective &S) {
|
|||
}
|
||||
// Emit an implicit barrier at the end (to avoid data race on firstprivate
|
||||
// init or if no 'nowait' clause was specified and no 'copyprivate' clause).
|
||||
if ((!S.getSingleClause<OMPNowaitClause>() || HasFirstprivates) &&
|
||||
CopyprivateVars.empty()) {
|
||||
if (!S.getSingleClause<OMPNowaitClause>() && CopyprivateVars.empty()) {
|
||||
CGM.getOpenMPRuntime().emitBarrierCall(
|
||||
*this, S.getLocStart(),
|
||||
S.getSingleClause<OMPNowaitClause>() ? OMPD_unknown : OMPD_single);
|
||||
|
@ -2000,9 +1997,7 @@ void CodeGenFunction::EmitOMPParallelSectionsDirective(
|
|||
// Emit directive as a combined directive that consists of two implicit
|
||||
// directives: 'parallel' with 'sections' directive.
|
||||
OMPLexicalScope Scope(*this, S);
|
||||
auto &&CodeGen = [&S](CodeGenFunction &CGF) {
|
||||
CGF.EmitSections(S);
|
||||
};
|
||||
auto &&CodeGen = [&S](CodeGenFunction &CGF) { CGF.EmitSections(S); };
|
||||
emitCommonOMPParallelDirective(*this, S, OMPD_sections, CodeGen);
|
||||
}
|
||||
|
||||
|
|
|
@ -7247,6 +7247,7 @@ OMPClause *Sema::ActOnOpenMPFirstprivateClause(ArrayRef<Expr *> VarList,
|
|||
SmallVector<Expr *, 8> Vars;
|
||||
SmallVector<Expr *, 8> PrivateCopies;
|
||||
SmallVector<Expr *, 8> Inits;
|
||||
SmallVector<Decl *, 4> ExprCaptures;
|
||||
bool IsImplicitClause =
|
||||
StartLoc.isInvalid() && LParenLoc.isInvalid() && EndLoc.isInvalid();
|
||||
auto ImplicitClauseLoc = DSAStack->getConstructLoc();
|
||||
|
@ -7479,8 +7480,10 @@ OMPClause *Sema::ActOnOpenMPFirstprivateClause(ArrayRef<Expr *> VarList,
|
|||
*this, VDPrivate, RefExpr->getType().getUnqualifiedType(),
|
||||
RefExpr->getExprLoc());
|
||||
DeclRefExpr *Ref = nullptr;
|
||||
if (!VD)
|
||||
if (!VD) {
|
||||
Ref = buildCapture(*this, D->getIdentifier(), RefExpr);
|
||||
ExprCaptures.push_back(Ref->getDecl());
|
||||
}
|
||||
DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_firstprivate, Ref);
|
||||
Vars.push_back(VD ? RefExpr->IgnoreParens() : Ref);
|
||||
PrivateCopies.push_back(VDPrivateRefExpr);
|
||||
|
@ -7489,9 +7492,16 @@ OMPClause *Sema::ActOnOpenMPFirstprivateClause(ArrayRef<Expr *> VarList,
|
|||
|
||||
if (Vars.empty())
|
||||
return nullptr;
|
||||
Stmt *PreInit = nullptr;
|
||||
if (!ExprCaptures.empty()) {
|
||||
PreInit = new (Context)
|
||||
DeclStmt(DeclGroupRef::Create(Context, ExprCaptures.begin(),
|
||||
ExprCaptures.size()),
|
||||
SourceLocation(), SourceLocation());
|
||||
}
|
||||
|
||||
return OMPFirstprivateClause::Create(Context, StartLoc, LParenLoc, EndLoc,
|
||||
Vars, PrivateCopies, Inits);
|
||||
Vars, PrivateCopies, Inits, PreInit);
|
||||
}
|
||||
|
||||
OMPClause *Sema::ActOnOpenMPLastprivateClause(ArrayRef<Expr *> VarList,
|
||||
|
|
|
@ -1748,8 +1748,7 @@ public:
|
|||
OMPClauseReader(ASTStmtReader *R, ASTContext &C,
|
||||
const ASTReader::RecordData &Record, unsigned &Idx)
|
||||
: Reader(R), Context(C), Record(Record), Idx(Idx) { }
|
||||
#define OPENMP_CLAUSE(Name, Class) \
|
||||
void Visit##Class(Class *C);
|
||||
#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C);
|
||||
#include "clang/Basic/OpenMPKinds.def"
|
||||
OMPClause *readClause();
|
||||
void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
|
||||
|
@ -2002,6 +2001,7 @@ void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
|
|||
}
|
||||
|
||||
void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
|
||||
VisitOMPClauseWithPreInit(C);
|
||||
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
|
||||
unsigned NumVars = C->varlist_size();
|
||||
SmallVector<Expr *, 16> Vars;
|
||||
|
|
|
@ -1867,6 +1867,7 @@ void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) {
|
|||
|
||||
void OMPClauseWriter::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
|
||||
Record.push_back(C->varlist_size());
|
||||
VisitOMPClauseWithPreInit(C);
|
||||
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
|
||||
for (auto *VE : C->varlists()) {
|
||||
Writer->Writer.AddStmt(VE);
|
||||
|
|
|
@ -18,6 +18,59 @@ struct St {
|
|||
|
||||
volatile int g __attribute__((aligned(128))) = 1212;
|
||||
|
||||
struct SS {
|
||||
int a;
|
||||
int b : 4;
|
||||
int &c;
|
||||
SS(int &d) : a(0), b(0), c(d) {
|
||||
#pragma omp parallel firstprivate(a, b, c)
|
||||
#ifdef LAMBDA
|
||||
[&]() {
|
||||
++this->a, --b, (this)->c /= 1;
|
||||
#pragma omp parallel firstprivate(a, b, c)
|
||||
++(this)->a, --b, this->c /= 1;
|
||||
}();
|
||||
#elif defined(BLOCKS)
|
||||
^{
|
||||
++a;
|
||||
--this->b;
|
||||
(this)->c /= 1;
|
||||
#pragma omp parallel firstprivate(a, b, c)
|
||||
++(this)->a, --b, this->c /= 1;
|
||||
}();
|
||||
#else
|
||||
++this->a, --b, c /= 1;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct SST {
|
||||
T a;
|
||||
SST() : a(T()) {
|
||||
#pragma omp parallel firstprivate(a)
|
||||
#ifdef LAMBDA
|
||||
[&]() {
|
||||
[&]() {
|
||||
++this->a;
|
||||
#pragma omp parallel firstprivate(a)
|
||||
++(this)->a;
|
||||
}();
|
||||
}();
|
||||
#elif defined(BLOCKS)
|
||||
^{
|
||||
^{
|
||||
++a;
|
||||
#pragma omp parallel firstprivate(a)
|
||||
++(this)->a;
|
||||
}();
|
||||
}();
|
||||
#else
|
||||
++(this)->a;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct S {
|
||||
T f;
|
||||
|
@ -28,6 +81,9 @@ struct S {
|
|||
~S() {}
|
||||
};
|
||||
|
||||
// CHECK: [[SS_TY:%.+]] = type { i{{[0-9]+}}, i8
|
||||
// LAMBDA: [[SS_TY:%.+]] = type { i{{[0-9]+}}, i8
|
||||
// BLOCKS: [[SS_TY:%.+]] = type { i{{[0-9]+}}, i8
|
||||
// CHECK-DAG: [[S_FLOAT_TY:%.+]] = type { float }
|
||||
// CHECK-DAG: [[S_INT_TY:%.+]] = type { i{{[0-9]+}} }
|
||||
// CHECK-DAG: [[ST_TY:%.+]] = type { i{{[0-9]+}}, i{{[0-9]+}} }
|
||||
|
@ -35,6 +91,7 @@ struct S {
|
|||
template <typename T>
|
||||
T tmain() {
|
||||
S<T> test;
|
||||
SST<T> sst;
|
||||
T t_var __attribute__((aligned(128))) = T();
|
||||
T vec[] __attribute__((aligned(128))) = {1, 2};
|
||||
S<T> s_arr[] __attribute__((aligned(128))) = {1, 2};
|
||||
|
@ -51,15 +108,54 @@ T tmain() {
|
|||
|
||||
int main() {
|
||||
static int sivar;
|
||||
SS ss(sivar);
|
||||
#ifdef LAMBDA
|
||||
// LAMBDA: [[G:@.+]] = global i{{[0-9]+}} 1212,
|
||||
// LAMBDA-LABEL: @main
|
||||
// LAMBDA: call{{.*}} void [[OUTER_LAMBDA:@.+]](
|
||||
// LAMBDA: alloca [[SS_TY]],
|
||||
// LAMBDA: alloca [[CAP_TY:%.+]],
|
||||
// LAMBDA: call{{.*}} void [[OUTER_LAMBDA:@[^(]+]]([[CAP_TY]]*
|
||||
[&]() {
|
||||
// LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
|
||||
// LAMBDA: call {{.*}}void {{.+}} @__kmpc_fork_call({{.+}}, i32 2, {{.+}}* [[OMP_REGION:@.+]] to {{.+}}, i32* [[G]], {{.+}})
|
||||
#pragma omp parallel firstprivate(g, sivar)
|
||||
{
|
||||
// LAMBDA: define {{.+}} @{{.+}}([[SS_TY]]*
|
||||
// LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
|
||||
// LAMBDA: store i{{[0-9]+}} 0, i{{[0-9]+}}* %
|
||||
// LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
|
||||
// LAMBDA: store i8
|
||||
// LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
|
||||
// LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
|
||||
// LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
|
||||
// LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
|
||||
// LAMBDA: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 4, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*, i32*, i32*, i32*)* [[SS_MICROTASK:@.+]] to void
|
||||
// LAMBDA: ret
|
||||
|
||||
// LAMBDA: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32* {{.+}}, i32* {{.+}}, i32* {{.+}})
|
||||
// LAMBDA-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %
|
||||
// LAMBDA: call{{.*}} void
|
||||
// LAMBDA: ret void
|
||||
|
||||
// LAMBDA: define internal void @{{.+}}(i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32* {{.+}}, i32* {{.+}}, i32* {{.+}})
|
||||
// LAMBDA: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},
|
||||
// LAMBDA: [[B_PRIV:%.+]] = alloca i{{[0-9]+}},
|
||||
// LAMBDA: [[C_PRIV:%.+]] = alloca i{{[0-9]+}},
|
||||
// LAMBDA: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REFA:%.+]],
|
||||
// LAMBDA: store i{{[0-9]+}}* [[C_PRIV]], i{{[0-9]+}}** [[REFC:%.+]],
|
||||
// LAMBDA-NEXT: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFA]],
|
||||
// LAMBDA-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],
|
||||
// LAMBDA-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1
|
||||
// LAMBDA-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],
|
||||
// LAMBDA-NEXT: [[B_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[B_PRIV]],
|
||||
// LAMBDA-NEXT: [[DEC:%.+]] = add nsw i{{[0-9]+}} [[B_VAL]], -1
|
||||
// LAMBDA-NEXT: store i{{[0-9]+}} [[DEC]], i{{[0-9]+}}* [[B_PRIV]],
|
||||
// LAMBDA-NEXT: [[C_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFC]],
|
||||
// LAMBDA-NEXT: [[C_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[C_PRIV]],
|
||||
// LAMBDA-NEXT: [[DIV:%.+]] = sdiv i{{[0-9]+}} [[C_VAL]], 1
|
||||
// LAMBDA-NEXT: store i{{[0-9]+}} [[DIV]], i{{[0-9]+}}* [[C_PRIV]],
|
||||
// LAMBDA-NEXT: ret void
|
||||
|
||||
// LAMBDA: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i32* dereferenceable(4) %{{.+}})
|
||||
// LAMBDA: [[G_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}}, align 128
|
||||
// LAMBDA: [[SIVAR_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},
|
||||
|
@ -97,6 +193,7 @@ int main() {
|
|||
#elif defined(BLOCKS)
|
||||
// BLOCKS: [[G:@.+]] = global i{{[0-9]+}} 1212,
|
||||
// BLOCKS-LABEL: @main
|
||||
// BLOCKS: call
|
||||
// BLOCKS: call {{.*}}void {{%.+}}(i8
|
||||
^{
|
||||
// BLOCKS: define{{.*}} internal{{.*}} void {{.+}}(i8*
|
||||
|
@ -141,6 +238,41 @@ int main() {
|
|||
}
|
||||
}();
|
||||
return 0;
|
||||
// BLOCKS: define {{.+}} @{{.+}}([[SS_TY]]*
|
||||
// BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
|
||||
// BLOCKS: store i{{[0-9]+}} 0, i{{[0-9]+}}* %
|
||||
// BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
|
||||
// BLOCKS: store i8
|
||||
// BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
|
||||
// BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
|
||||
// BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
|
||||
// BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
|
||||
// BLOCKS: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 4, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*, i32*, i32*, i32*)* [[SS_MICROTASK:@.+]] to void
|
||||
// BLOCKS: ret
|
||||
|
||||
// BLOCKS: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32* {{.+}}, i32* {{.+}}, i32* {{.+}})
|
||||
// BLOCKS-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %
|
||||
// BLOCKS: call{{.*}} void
|
||||
// BLOCKS: ret void
|
||||
|
||||
// BLOCKS: define internal void @{{.+}}(i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32* {{.+}}, i32* {{.+}}, i32* {{.+}})
|
||||
// BLOCKS: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},
|
||||
// BLOCKS: [[B_PRIV:%.+]] = alloca i{{[0-9]+}},
|
||||
// BLOCKS: [[C_PRIV:%.+]] = alloca i{{[0-9]+}},
|
||||
// BLOCKS: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REFA:%.+]],
|
||||
// BLOCKS: store i{{[0-9]+}}* [[C_PRIV]], i{{[0-9]+}}** [[REFC:%.+]],
|
||||
// BLOCKS-NEXT: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFA]],
|
||||
// BLOCKS-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],
|
||||
// BLOCKS-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1
|
||||
// BLOCKS-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],
|
||||
// BLOCKS-NEXT: [[B_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[B_PRIV]],
|
||||
// BLOCKS-NEXT: [[DEC:%.+]] = add nsw i{{[0-9]+}} [[B_VAL]], -1
|
||||
// BLOCKS-NEXT: store i{{[0-9]+}} [[DEC]], i{{[0-9]+}}* [[B_PRIV]],
|
||||
// BLOCKS-NEXT: [[C_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFC]],
|
||||
// BLOCKS-NEXT: [[C_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[C_PRIV]],
|
||||
// BLOCKS-NEXT: [[DIV:%.+]] = sdiv i{{[0-9]+}} [[C_VAL]], 1
|
||||
// BLOCKS-NEXT: store i{{[0-9]+}} [[DIV]], i{{[0-9]+}}* [[C_PRIV]],
|
||||
// BLOCKS-NEXT: ret void
|
||||
#else
|
||||
S<float> test;
|
||||
int t_var = 0;
|
||||
|
@ -213,6 +345,40 @@ int main() {
|
|||
// CHECK: call {{.*}} [[S_INT_TY_DESTR:@.+]]([[S_INT_TY]]*
|
||||
// CHECK: ret
|
||||
//
|
||||
// CHECK: define {{.+}} @{{.+}}([[SS_TY]]* %
|
||||
// CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
|
||||
// CHECK: store i{{[0-9]+}} 0, i{{[0-9]+}}* %
|
||||
// CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
|
||||
// CHECK: store i8
|
||||
// CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
|
||||
// CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
|
||||
// CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
|
||||
// CHECK: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
|
||||
// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 4, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*, i32*, i32*, i32*)* [[SS_MICROTASK:@.+]] to void
|
||||
// CHECK: ret
|
||||
|
||||
// CHECK: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32* {{.+}}, i32* {{.+}}, i32* {{.+}})
|
||||
// CHECK: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},
|
||||
// CHECK: [[B_PRIV:%.+]] = alloca i{{[0-9]+}},
|
||||
// CHECK: [[C_PRIV:%.+]] = alloca i{{[0-9]+}},
|
||||
// CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[A_PRIV]]
|
||||
// CHECK: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REFA:%.+]],
|
||||
// CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[B_PRIV]]
|
||||
// CHECK: store i{{[0-9]+}} {{.+}}, i{{[0-9]+}}* [[C_PRIV]]
|
||||
// CHECK: store i{{[0-9]+}}* [[C_PRIV]], i{{[0-9]+}}** [[REFC:%.+]],
|
||||
// CHECK-NEXT: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFA]],
|
||||
// CHECK-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],
|
||||
// CHECK-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1
|
||||
// CHECK-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],
|
||||
// CHECK-NEXT: [[B_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[B_PRIV]],
|
||||
// CHECK-NEXT: [[DEC:%.+]] = add nsw i{{[0-9]+}} [[B_VAL]], -1
|
||||
// CHECK-NEXT: store i{{[0-9]+}} [[DEC]], i{{[0-9]+}}* [[B_PRIV]],
|
||||
// CHECK-NEXT: [[C_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFC]],
|
||||
// CHECK-NEXT: [[C_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[C_PRIV]],
|
||||
// CHECK-NEXT: [[DIV:%.+]] = sdiv i{{[0-9]+}} [[C_VAL]], 1
|
||||
// CHECK-NEXT: store i{{[0-9]+}} [[DIV]], i{{[0-9]+}}* [[C_PRIV]],
|
||||
// CHECK-NEXT: ret void
|
||||
|
||||
// CHECK: define internal {{.*}}void [[TMAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, i32* dereferenceable(4) %{{.+}}, [2 x [[S_INT_TY]]]* dereferenceable(8) %{{.+}}, [[S_INT_TY]]* dereferenceable(4) %{{.+}})
|
||||
// CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}}, align 128
|
||||
// CHECK: [[VEC_PRIV:%.+]] = alloca [2 x i{{[0-9]+}}], align 128
|
||||
|
|
|
@ -2141,6 +2141,13 @@ void OMPClauseEnqueue::VisitOMPPrivateClause(const OMPPrivateClause *C) {
|
|||
void OMPClauseEnqueue::VisitOMPFirstprivateClause(
|
||||
const OMPFirstprivateClause *C) {
|
||||
VisitOMPClauseList(C);
|
||||
VisitOMPClauseWithPreInit(C);
|
||||
for (const auto *E : C->private_copies()) {
|
||||
Visitor->AddStmt(E);
|
||||
}
|
||||
for (const auto *E : C->inits()) {
|
||||
Visitor->AddStmt(E);
|
||||
}
|
||||
}
|
||||
void OMPClauseEnqueue::VisitOMPLastprivateClause(
|
||||
const OMPLastprivateClause *C) {
|
||||
|
|
Loading…
Reference in New Issue