Skip to content

Commit 877ef01

Browse files
committed
First Impl. Support for Non-PODs.
OmpSsRegionAnalysis: - Added 'non-pod_dsa_missing' flag to detect non-pod info (i.e OSS.INIT) without DSA OmpSsTransform: - Build a map<Value *, int> to map DSA with task_args position instead of computing it in everywhere - VLAs will be stored from largest alignment to smallest. First VLA will be aligned to 16 (hardcoded) at the end of task_args - Private VLAs will be stored in task_args. - Dtor call is added just before 'ret' instr. We assume there will be only one. Closes llvm#9, closes llvm#37, closes llvm#35
1 parent 6417664 commit 877ef01

22 files changed

+1816
-156
lines changed

clang/include/clang/AST/OmpSsClause.h

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,20 @@ class OSSPrivateClause final
370370
SourceLocation(), SourceLocation(),
371371
N) {}
372372

373+
/// Sets the list of references to private copies with initializers for
374+
/// new private variables.
375+
/// \param VL List of references.
376+
void setPrivateCopies(ArrayRef<Expr *> VL);
377+
378+
/// Gets the list of references to private copies with initializers for
379+
/// new private variables.
380+
MutableArrayRef<Expr *> getPrivateCopies() {
381+
return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
382+
}
383+
ArrayRef<const Expr *> getPrivateCopies() const {
384+
return llvm::makeArrayRef(varlist_end(), varlist_size());
385+
}
386+
373387
public:
374388
/// Creates clause with a list of variables \a VL.
375389
///
@@ -378,16 +392,33 @@ class OSSPrivateClause final
378392
/// \param LParenLoc Location of '('.
379393
/// \param EndLoc Ending location of the clause.
380394
/// \param VL List of references to the variables.
395+
/// \param PrivateVL List of references to private copies with initializers.
381396
static OSSPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
382397
SourceLocation LParenLoc,
383-
SourceLocation EndLoc, ArrayRef<Expr *> VL);
398+
SourceLocation EndLoc,
399+
ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL);
384400

385401
/// Creates an empty clause with \a N variables.
386402
///
387403
/// \param C AST context.
388404
/// \param N The number of variables.
389405
static OSSPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
390406

407+
using private_copies_iterator = MutableArrayRef<Expr *>::iterator;
408+
using private_copies_const_iterator = ArrayRef<const Expr *>::iterator;
409+
using private_copies_range = llvm::iterator_range<private_copies_iterator>;
410+
using private_copies_const_range =
411+
llvm::iterator_range<private_copies_const_iterator>;
412+
413+
private_copies_range private_copies() {
414+
return private_copies_range(getPrivateCopies().begin(),
415+
getPrivateCopies().end());
416+
}
417+
private_copies_const_range private_copies() const {
418+
return private_copies_const_range(getPrivateCopies().begin(),
419+
getPrivateCopies().end());
420+
}
421+
391422
child_range children() {
392423
return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
393424
reinterpret_cast<Stmt **>(varlist_end()));
@@ -431,6 +462,34 @@ class OSSFirstprivateClause final
431462
SourceLocation(), SourceLocation(),
432463
N) {}
433464

465+
/// Sets the list of references to private copies with initializers for
466+
/// new private variables.
467+
/// \param VL List of references.
468+
void setPrivateCopies(ArrayRef<Expr *> VL);
469+
470+
/// Gets the list of references to private copies with initializers for
471+
/// new private variables.
472+
MutableArrayRef<Expr *> getPrivateCopies() {
473+
return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
474+
}
475+
ArrayRef<const Expr *> getPrivateCopies() const {
476+
return llvm::makeArrayRef(varlist_end(), varlist_size());
477+
}
478+
479+
/// Sets the list of references to initializer variables for new
480+
/// private variables.
481+
/// \param VL List of references.
482+
void setInits(ArrayRef<Expr *> VL);
483+
484+
/// Gets the list of references to initializer variables for new
485+
/// private variables.
486+
MutableArrayRef<Expr *> getInits() {
487+
return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
488+
}
489+
ArrayRef<const Expr *> getInits() const {
490+
return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
491+
}
492+
434493
public:
435494
/// Creates clause with a list of variables \a VL.
436495
///
@@ -439,16 +498,47 @@ class OSSFirstprivateClause final
439498
/// \param LParenLoc Location of '('.
440499
/// \param EndLoc Ending location of the clause.
441500
/// \param VL List of references to the variables.
442-
static OSSFirstprivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
443-
SourceLocation LParenLoc,
444-
SourceLocation EndLoc, ArrayRef<Expr *> VL);
501+
/// \param PrivateVL List of references to private copies with initializers.
502+
/// \param InitVL List of references to auto generated variables used for
503+
/// initialization.
504+
static OSSFirstprivateClause *
505+
Create(const ASTContext &C, SourceLocation StartLoc,
506+
SourceLocation LParenLoc, SourceLocation EndLoc,
507+
ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL, ArrayRef<Expr *> InitVL);
445508

446509
/// Creates an empty clause with \a N variables.
447510
///
448511
/// \param C AST context.
449512
/// \param N The number of variables.
450513
static OSSFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
451514

515+
using private_copies_iterator = MutableArrayRef<Expr *>::iterator;
516+
using private_copies_const_iterator = ArrayRef<const Expr *>::iterator;
517+
using private_copies_range = llvm::iterator_range<private_copies_iterator>;
518+
using private_copies_const_range =
519+
llvm::iterator_range<private_copies_const_iterator>;
520+
521+
private_copies_range private_copies() {
522+
return private_copies_range(getPrivateCopies().begin(),
523+
getPrivateCopies().end());
524+
}
525+
private_copies_const_range private_copies() const {
526+
return private_copies_const_range(getPrivateCopies().begin(),
527+
getPrivateCopies().end());
528+
}
529+
530+
using inits_iterator = MutableArrayRef<Expr *>::iterator;
531+
using inits_const_iterator = ArrayRef<const Expr *>::iterator;
532+
using inits_range = llvm::iterator_range<inits_iterator>;
533+
using inits_const_range = llvm::iterator_range<inits_const_iterator>;
534+
535+
inits_range inits() {
536+
return inits_range(getInits().begin(), getInits().end());
537+
}
538+
inits_const_range inits() const {
539+
return inits_const_range(getInits().begin(), getInits().end());
540+
}
541+
452542
child_range children() {
453543
return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
454544
reinterpret_cast<Stmt **>(varlist_end()));

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9889,8 +9889,6 @@ def err_oss_expected_addressable_lvalue_or_array_item : Error<
98899889
"expected addressable lvalue expression, array element or array section">;
98909890
def err_oss_expected_var_name_member_expr : Error<
98919891
"expected variable name%select{| or data member of current class}0">;
9892-
def err_oss_non_pod_not_supported: Error<
9893-
"Non-POD structs are not supported">;
98949892

98959893
def err_oss_not_integral : Error<
98969894
"expression must have integral or unscoped enumeration "

clang/lib/AST/OmpSsClause.cpp

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,24 @@ OSSClause::child_range OSSClause::children() {
3535
llvm_unreachable("unknown OSSClause");
3636
}
3737

38+
void OSSPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
39+
assert(VL.size() == varlist_size() &&
40+
"Number of private copies is not the same as the preallocated buffer");
41+
std::copy(VL.begin(), VL.end(), varlist_end());
42+
}
43+
3844
OSSPrivateClause *OSSPrivateClause::Create(const ASTContext &C,
3945
SourceLocation StartLoc,
4046
SourceLocation LParenLoc,
4147
SourceLocation EndLoc,
42-
ArrayRef<Expr *> VL) {
43-
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
48+
ArrayRef<Expr *> VL,
49+
ArrayRef<Expr *> PrivateVL) {
50+
// Info of item 'i' is in VL[i], PrivateVL[i]
51+
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
4452
OSSPrivateClause *Clause =
4553
new (Mem) OSSPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
4654
Clause->setVarRefs(VL);
55+
Clause->setPrivateCopies(PrivateVL);
4756
return Clause;
4857
}
4958

@@ -52,15 +61,32 @@ OSSPrivateClause *OSSPrivateClause::CreateEmpty(const ASTContext &C, unsigned N)
5261
return new (Mem) OSSPrivateClause(N);
5362
}
5463

64+
void OSSFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
65+
assert(VL.size() == varlist_size() &&
66+
"Number of private copies is not the same as the preallocated buffer");
67+
std::copy(VL.begin(), VL.end(), varlist_end());
68+
}
69+
70+
void OSSFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
71+
assert(VL.size() == varlist_size() &&
72+
"Number of inits is not the same as the preallocated buffer");
73+
std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
74+
}
75+
5576
OSSFirstprivateClause *OSSFirstprivateClause::Create(const ASTContext &C,
5677
SourceLocation StartLoc,
5778
SourceLocation LParenLoc,
5879
SourceLocation EndLoc,
59-
ArrayRef<Expr *> VL) {
60-
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
80+
ArrayRef<Expr *> VL,
81+
ArrayRef<Expr *> PrivateVL,
82+
ArrayRef<Expr *> InitVL) {
83+
// Info of item 'i' is in VL[i], PrivateVL[i] and InitVL[i]
84+
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
6185
OSSFirstprivateClause *Clause =
6286
new (Mem) OSSFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
6387
Clause->setVarRefs(VL);
88+
Clause->setPrivateCopies(PrivateVL);
89+
Clause->setInits(InitVL);
6490
return Clause;
6591
}
6692

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty,
110110
llvm::Value *ArraySize) {
111111
if (ArraySize)
112112
return Builder.CreateAlloca(Ty, ArraySize, Name);
113-
if (getLangOpts().OmpSs && CGM.getOmpSsRuntime().inTask())
113+
if (getLangOpts().OmpSs && CGM.getOmpSsRuntime().inTask() && !CGM.getOmpSsRuntime().ForceSkip)
114114
return new llvm::AllocaInst(Ty, CGM.getDataLayout().getAllocaAddrSpace(),
115115
ArraySize, Name,
116116
CGM.getOmpSsRuntime().getCurrentTask());

0 commit comments

Comments
 (0)